Skip to content

Commit

Permalink
Fix an issue with the navigational mesh when playing unexplored maps (F…
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Nov 20, 2024
1 parent 79dce4b commit ffcb0a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/fix.6547.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- (#6547) Fix an issue with the navigational mesh on unexplored maps

The navigational mesh is used by AIs to understand the map. On unexplored maps the playable area is temporarily reduced to a very small fraction at the start of the map. This confuses the navigational mesh. We now introduce a check that if the current playable area is too small to be playable then we simply ignore it.

This should only trigger on unexplored maps.
11 changes: 10 additions & 1 deletion lua/sim/NavGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,16 @@ function PopulateCaches(tCache, dCache, daCache, pxCache, pzCache, pCache, bCach
local isSkirmish = ScenarioInfo.type == 'skirmish'

local tlx, tlz, brx, brz
if playableArea and isSkirmish then
if playableArea and isSkirmish and

-- check if the playable area is large enough. There are edge cases where maps temporarily decrease the playable
-- area size. Since we can not re-generate the navigational mesh as AIs expect the structure to remain the
-- same we just take the size of the map instead.

-- This for example applies to generated maps with the unexplored setting.
playableArea[3] - playableArea[1] > 32 and
playableArea[4] - playableArea[2] > 32
then
tlx = playableArea[1]
tlz = playableArea[2]
brx = playableArea[3]
Expand Down

0 comments on commit ffcb0a5

Please sign in to comment.