Files
ForeverCore/src
Karrz1 798fe774ca Core: navmesh searches from other threads wait for tile changes
A map thread loads and unloads navmesh tiles between its own path searches,
so its searches never see a half-changed tile. A thread that is not a map
thread (bot logic threads) searches while the map threads change tiles, and
Detour then reads a tile that is being added or freed.

There is now one navmesh tile lock:
- every tile or mesh change takes it exclusively: tile load and unload, mesh
  creation, map and instance unload, the dynamic tile swap and the
  handcrafted road retag. The file is read before the lock is taken, so only
  the change itself waits;
- MMAP::NavMeshReadLock takes it shared for the length of a search, counted
  per thread so nested locks are free; a tile change on a thread that holds
  one asserts instead of hanging;
- while a ScopedThreadNavMeshQuery is active, GetNavMesh and GetNavMeshQuery
  take the read lock for their own lookup, so a mesh or instance being added
  on a map thread is never read half-built.

Map threads search without the lock, as before. A thread's own queries are
dropped after any instance unload, so a long-lived thread keeps only the
queries of instances it still uses (about 350 KB each).
2026-11-15 17:29:16 +00:00
..