TrinityCore's PathGenerator uses a shared dtNavMeshQuery which is NOT
thread-safe — calling it from bot worker threads causes ACCESS_VIOLATION
crashes in dtNavMeshQuery::getPathToNode.
ThreadSafePathfinder creates per-thread dtNavMeshQuery instances using
thread_local storage. Each thread gets its own query with independent
node pool and open list, sharing the read-only dtNavMesh. This is safe
because dtNavMesh is read-only after tile loading.
API: ThreadSafePathfinder::IsReachable(mapId, start, dest)
- Returns true if navmesh path exists from start to dest
- Creates query on first use per thread per map
- 64-poly path check (enough for reachability, not full pathfinding)
Re-enabled navmesh reachability check in SearchForQuestGivers using
the thread-safe pathfinder instead of PathGenerator.
Added GetBotPosition(), GetBotDistanceTo(), GetBotDistance2dTo() to
SpatialGridQueryHelpers for thread-safe position reads.
Converted position reads in:
- PositionManager: 15 GetPosition/GetExactDist calls
- CombatStateAnalyzer: 4 GetPositionX/Y/Z calls
Combat distance calculations now use the spatial grid position which
is updated every 100ms from the main thread, eliminating stale position
data that caused bots to walk through walls and air.
Signed-off-by: luis <[email protected]>