diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 1d5cee55..c8bec277 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -632,8 +632,6 @@ BOOLEAN ValidTrainingPartnerInSameSectorOnAssignmentFound( SOLDIERTYPE *pSoldier extern void AddSectorForSoldierToListOfSectorsThatCompletedMilitiaTraining( SOLDIERTYPE *pSoldier ); -extern BOOLEAN SectorIsImpassable( INT16 sSector ); - extern BOOLEAN CanChangeSleepStatusForCharSlot( INT8 bCharNumber ); // only 2 trainers are allowed per sector, so this function counts the # in a guy's sector diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index e41abfa2..17dbfceb 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -2285,7 +2285,7 @@ void RetreatAllInvolvedMilitiaGroups() // if we haven't found a good direction yet, we have to pick the best adjacent sector we can find if ( !found ) { - INT32 besttime = 1000000; + INT32 besttime = 0xffffffff; UINT8 usDirection = NORTH_STRATEGIC_MOVE; for ( UINT8 i = 0; i < 4; ++i ) { @@ -2316,6 +2316,9 @@ void RetreatAllInvolvedMilitiaGroups() if ( loopX < 1 || loopX >= MAP_WORLD_X - 1 || loopY < 1 || loopY >= MAP_WORLD_Y - 1 ) continue; + if ( SectorIsImpassable( SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ), usDirection ) ) + continue; + // don't retreat into an occupied sector! if ( NumNonPlayerTeamMembersInSector( loopX, loopY, ENEMY_TEAM ) > 0 ) continue; diff --git a/Strategic/Strategic Movement Costs.cpp b/Strategic/Strategic Movement Costs.cpp index bd57a819..ff6c280e 100644 --- a/Strategic/Strategic Movement Costs.cpp +++ b/Strategic/Strategic Movement Costs.cpp @@ -694,11 +694,11 @@ UINT8 GetTraversability( INT16 sStartSector, INT16 sEndSector ) return( SectorInfo[ sStartSector ].ubTraversability[ ubDirection ] ); } -BOOLEAN SectorIsImpassable( INT16 sSector ) +BOOLEAN SectorIsImpassable( INT16 sSector, UINT8 aDirection ) { - // returns true if the sector is impassable in all directions - return( SectorInfo[ sSector ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == GROUNDBARRIER || - SectorInfo[ sSector ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == EDGEOFWORLD ); + // returns true if the sector is impassable in direction + return( SectorInfo[ sSector ].ubTraversability[aDirection] == GROUNDBARRIER || + SectorInfo[ sSector ].ubTraversability[aDirection] == EDGEOFWORLD ); } UINT8 gubEncryptionArray3[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_ARRAY_SIZE ] = diff --git a/Strategic/Strategic Movement.h b/Strategic/Strategic Movement.h index d946d894..76f99764 100644 --- a/Strategic/Strategic Movement.h +++ b/Strategic/Strategic Movement.h @@ -319,7 +319,7 @@ void RandomizePatrolGroupLocation( GROUP *pGroup ); BOOLEAN InitStrategicMovementCosts(); -BOOLEAN SectorIsImpassable( INT16 sSector ); +BOOLEAN SectorIsImpassable( INT16 sSector, UINT8 aDirection = THROUGH_STRATEGIC_MOVE ); void PlaceGroupInSector( UINT8 ubGroupID, INT16 sPrevX, INT16 sPrevY, INT16 sNextX, INT16 sNextY, INT8 bZ, BOOLEAN fCheckForBattle );