From abe7117231822a1ab8c685edac5937a1cbc9d6a7 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Sun, 2 Aug 2015 13:59:07 +0000 Subject: [PATCH] Fix (by navaroe): The game could try to place more soldiers on the map than the map had slots which would cause the game to crash. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7955 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Queen Command.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index e02c2397e..d87f6ca0c 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -656,6 +656,7 @@ BOOLEAN PrepareEnemyForSectorBattle() if (mapMaximumNumberOfEnemies > gGameExternalOptions.ubGameMaximumNumberOfEnemies) mapMaximumNumberOfEnemies = gGameExternalOptions.ubGameMaximumNumberOfEnemies; + //are there more enemies in the sector then we can actually place on map? gfPendingNonPlayerTeam[ENEMY_TEAM] = (NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) > mapMaximumNumberOfEnemies); pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; @@ -881,7 +882,7 @@ BOOLEAN PrepareEnemyForSectorBattle() //sNumSlots = mapMaximumNumberOfEnemies - totalCountOfStationaryEnemies; // Flugente: at this point, soldiers have already been placed, thus enough slots for them exist - sNumSlots = max( mapMaximumNumberOfEnemies, NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ); + sNumSlots = min( mapMaximumNumberOfEnemies, NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ); pGroup = gpGroupList; while( pGroup && sNumSlots > 0 )