From 38cb0f8ffca71de6a55519b2b17d7e0d3e3273a6 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Sun, 15 Feb 2015 13:36:58 +0000 Subject: [PATCH] fix: on map screen number of enemy troops in a sector was displayed incorrectly if there was one player unit besides the sector and another unit was diagonal to it and ALLOW_DETECTION_IN_DIAGONAL_SECTORS was FALSE. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7740 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Town Militia.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Strategic/Town Militia.cpp b/Strategic/Town Militia.cpp index 93767a7b9..c7697d1c4 100644 --- a/Strategic/Town Militia.cpp +++ b/Strategic/Town Militia.cpp @@ -1288,13 +1288,14 @@ BOOLEAN CanSomeoneNearbyScoutThisSector( INT16 sSectorX, INT16 sSectorY, BOOLEAN INT16 sSectorValue = 0, sSector = 0; INT16 sCounterA = 0, sCounterB = 0; UINT8 ubScoutingRange = 1; + BOOLEAN bScout = FALSE; // get the sector value sSector = sSectorX + sSectorY * MAP_WORLD_X; - for( sCounterA = sSectorX - ubScoutingRange; sCounterA <= sSectorX + ubScoutingRange; ++sCounterA ) + for( sCounterA = sSectorX - ubScoutingRange; (sCounterA <= sSectorX + ubScoutingRange && !bScout); ++sCounterA ) { - for( sCounterB = sSectorY - ubScoutingRange; sCounterB <= sSectorY + ubScoutingRange; ++sCounterB ) + for( sCounterB = sSectorY - ubScoutingRange; (sCounterB <= sSectorY + ubScoutingRange && !bScout); ++sCounterB ) { // skip out of bounds sectors if ( ( sCounterA < 1 ) || ( sCounterA > 16 ) || ( sCounterB < 1 ) || ( sCounterB > 16 ) ) @@ -1304,6 +1305,11 @@ BOOLEAN CanSomeoneNearbyScoutThisSector( INT16 sSectorX, INT16 sSectorY, BOOLEAN sSectorValue = SECTOR( sCounterA, sCounterB ); + // check if any sort of militia here + if ( NumNonPlayerTeamMembersInSector( sCounterA, sCounterB, MILITIA_TEAM ) ) + { + return( TRUE ); + } // SANDRO - STOMP traits - Scouting check if (fScoutTraitCheck && gGameOptions.fNewTraitSystem && ScoutIsPresentInSquad( sCounterA, sCounterB )) { @@ -1314,23 +1320,17 @@ BOOLEAN CanSomeoneNearbyScoutThisSector( INT16 sSectorX, INT16 sSectorY, BOOLEAN (sCounterA + 1 == sSectorX && sCounterB + 1 == sSectorY) || (sCounterA + 1 == sSectorX && sCounterB - 1 == sSectorY))) { - return( FALSE ); + continue; } else - return( TRUE ); - } - else - { - // check if any sort of militia here - if ( NumNonPlayerTeamMembersInSector( sCounterA, sCounterB, MILITIA_TEAM ) ) { - return( TRUE ); + bScout = TRUE; } } } } - return( FALSE ); + return( bScout ); } BOOLEAN IsTownFullMilitia( INT8 bTownId, INT8 iMilitiaType )