From c8a01e613f58be55c182ffb3faf342331840795c Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 11 Mar 2018 12:50:04 +0000 Subject: [PATCH] Fix: if militia groups arrive in combat alongside the player, it is possible they are interpreted as being already present, thus spawning in the sector instead of at the edges. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8545 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 18 ++++---- Tactical/Militia Control.cpp | 90 +++++++++++++++++++++++++++++++----- 2 files changed, 88 insertions(+), 20 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index 7d64c0ea..7012369a 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8545 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8545 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8545 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8545 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8545 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,16 +46,16 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8545 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8545 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8542 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8545 (Development Build)" }; #endif #endif -CHAR8 czVersionNumber[16] = { "Build 18.03.10" }; //YY.MM.DD +CHAR8 czVersionNumber[16] = { "Build 18.03.11" }; //YY.MM.DD CHAR16 zTrackingNumber[16] = { L"Z" }; // SAVE_GAME_VERSION is defined in header, change it there diff --git a/Tactical/Militia Control.cpp b/Tactical/Militia Control.cpp index 7961df14..17da8346 100644 --- a/Tactical/Militia Control.cpp +++ b/Tactical/Militia Control.cpp @@ -212,27 +212,95 @@ void PrepareMilitiaForTactical( BOOLEAN fPrepareAll) // Do we have a loaded sector? if ( gWorldSectorX == 0 && gWorldSectorY == 0 ) return; - - //for (int i=0; ibActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds(MercPtrs[i]->sGridNo)); - } - + pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; - ubGreen = MilitiaInSectorOfRank( gWorldSectorX, gWorldSectorY, GREEN_MILITIA ); - ubRegs = MilitiaInSectorOfRank( gWorldSectorX, gWorldSectorY, REGULAR_MILITIA ); - ubElites = MilitiaInSectorOfRank( gWorldSectorX, gWorldSectorY, ELITE_MILITIA ); // Prevent militia from just waiting on the border - gTacticalStatus.Team[MILITIA_TEAM].bAwareOfOpposition = (pSector->uiFlags & SF_PLAYER_KNOWS_ENEMIES_ARE_HERE) != 0; + gTacticalStatus.Team[MILITIA_TEAM].bAwareOfOpposition = ( pSector->uiFlags & SF_PLAYER_KNOWS_ENEMIES_ARE_HERE ) != 0; + ubGreen = MilitiaInSectorOfRankStationary( gWorldSectorX, gWorldSectorY, GREEN_MILITIA ); + ubRegs = MilitiaInSectorOfRankStationary( gWorldSectorX, gWorldSectorY, REGULAR_MILITIA ); + ubElites = MilitiaInSectorOfRankStationary( gWorldSectorX, gWorldSectorY, ELITE_MILITIA ); + + // Flugente: if we are entering combat, have militia groups that arrived from other sectors start at the edges. + // As the arrival time is no longer set, we try to deduct that from the previous sectors of the groups. + // If that isn't set, too bad, have them insert in the center then. + if ( fPrepareAll && !guiDirNumber && NumHostilesInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) > 0 )//(gTacticalStatus.uiFlags & INCOMBAT) ) + { + guiDirNumber = 5; + + ZeroMemory( gpAttackDirs, sizeof( gpAttackDirs ) ); + + gpAttackDirs[0][0] += ubGreen; + gpAttackDirs[0][1] += ubRegs; + gpAttackDirs[0][2] += ubElites; + + GROUP *pGroup = gpGroupList; + while ( pGroup ) + { + if ( pGroup->usGroupTeam == MILITIA_TEAM && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY ) + { + if ( pGroup->ubPrevX > 0 && pGroup->ubPrevY > 0 ) + { + if ( pGroup->ubPrevX < gWorldSectorX ) + { + gpAttackDirs[4][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[4][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[4][2] += pGroup->pEnemyGroup->ubNumElites; + gpAttackDirs[4][3] = INSERTION_CODE_WEST; + } + else if ( pGroup->ubPrevX > gWorldSectorX ) + { + gpAttackDirs[2][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[2][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[2][2] += pGroup->pEnemyGroup->ubNumElites; + gpAttackDirs[2][3] = INSERTION_CODE_EAST; + } + else if ( pGroup->ubPrevY < gWorldSectorY ) + { + gpAttackDirs[1][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[1][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[1][2] += pGroup->pEnemyGroup->ubNumElites; + gpAttackDirs[1][3] = INSERTION_CODE_NORTH; + } + else if ( pGroup->ubPrevY > gWorldSectorY ) + { + gpAttackDirs[3][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[3][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[3][2] += pGroup->pEnemyGroup->ubNumElites; + gpAttackDirs[3][3] = INSERTION_CODE_SOUTH; + } + else + { + gpAttackDirs[0][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[0][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[0][2] += pGroup->pEnemyGroup->ubNumElites; + } + } + else + { + gpAttackDirs[0][0] += pGroup->pEnemyGroup->ubNumAdmins; + gpAttackDirs[0][1] += pGroup->pEnemyGroup->ubNumTroops; + gpAttackDirs[0][2] += pGroup->pEnemyGroup->ubNumElites; + } + } + pGroup = pGroup->next; + } + } + else + { + ubGreen += MilitiaInSectorOfRankInGroups( gWorldSectorX, gWorldSectorY, GREEN_MILITIA ); + ubRegs += MilitiaInSectorOfRankInGroups( gWorldSectorX, gWorldSectorY, REGULAR_MILITIA ); + ubElites += MilitiaInSectorOfRankInGroups( gWorldSectorX, gWorldSectorY, ELITE_MILITIA ); + } + if(guiDirNumber) { if (fPrepareAll) { AddSoldierInitListMilitia( gpAttackDirs[ 0 ][0], gpAttackDirs[ 0 ][1], gpAttackDirs[ 0 ][2] ); } + // If the sector is already loaded, don't add the existing militia for( x = 1; x < guiDirNumber ; ++x ) {