diff --git a/GameVersion.h b/GameVersion.h index 8f154d5b..c4f8f32d 100644 --- a/GameVersion.h +++ b/GameVersion.h @@ -21,6 +21,7 @@ extern CHAR16 zTrackingNumber[16]; // Keeps track of the saved game version. Increment the saved game version whenever // you will invalidate the saved game file +#define STRATEGIC_TEAM_GROUPS 161 // Flugente: a change to the GROUP-structure allows any team to have strategic movement groups #define PMC_WEBSITE 160 // Flugente: a new PMC allows us to hire trained militia #define DISEASE_SYSTEM 159 // Flugente: mercs can get diseases #define PRISONER_EXPANSION 158 // Flugente: more types of prisoners @@ -79,7 +80,7 @@ extern CHAR16 zTrackingNumber[16]; #define AP100_SAVEGAME_DATATYPE_CHANGE 105 // Before this, we didn't have the 100AP structure changes #define NIV_SAVEGAME_DATATYPE_CHANGE 102 // Before this, we used the old structure system -#define SAVE_GAME_VERSION PMC_WEBSITE +#define SAVE_GAME_VERSION STRATEGIC_TEAM_GROUPS //#define RUSSIANGOLD #ifdef __cplusplus diff --git a/Strategic/AI Viewer.cpp b/Strategic/AI Viewer.cpp index 1edf9509..bd75b546 100644 --- a/Strategic/AI Viewer.cpp +++ b/Strategic/AI Viewer.cpp @@ -574,7 +574,7 @@ void RenderMovingGroupsAndMercs() } - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { ubIconType = (UINT8) (( pGroup->uiTraverseTime ) ? ICON_TYPE_ASSAULT : ICON_TYPE_STOPPED); ubIconColor = ICON_COLOR_GREEN; @@ -625,7 +625,7 @@ void RenderMovingGroupsAndMercs() SetFontForeground( ubFontColor ); //Print the group size - if( pGroup->fPlayer && !pGroup->uiTraverseTime ) + if ( pGroup->usGroupTeam == OUR_TEAM && !pGroup->uiTraverseTime ) // stationary player - count all mercs there, not just the group mprintf( x+11, y+11, L"%d", PlayerMercsInSector( pGroup->ubSectorX, pGroup->ubSectorY, pGroup->ubSectorZ ) ); else @@ -731,7 +731,7 @@ void RenderInfoInSector() pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY ) { ubNumTroops += pGroup->pEnemyGroup->ubNumTroops; ubNumElites += pGroup->pEnemyGroup->ubNumElites; @@ -1570,7 +1570,7 @@ void PrintEnemyPopTable() pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fDebugGroup ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fDebugGroup ) { Assert( pGroup->pEnemyGroup != NULL ); @@ -1952,7 +1952,7 @@ void PrintDetailedEnemiesInSectorInfo( INT32 iScreenX, INT32 iScreenY, UINT8 ubS pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle ) { if ( ( pGroup->ubSectorX == ubSectorX ) && ( pGroup->ubSectorY == ubSectorY ) ) { diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 43ba9581..d86439b6 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -840,7 +840,7 @@ BOOLEAN CanCharacterDoctorButDoesntHaveMedKit( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -1143,7 +1143,7 @@ BOOLEAN BasicCanCharacterRepair( SOLDIERTYPE * pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -1254,7 +1254,7 @@ BOOLEAN CanCharacterPatient( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -1348,7 +1348,7 @@ BOOLEAN BasicCanCharacterTrainMilitia( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -1676,7 +1676,7 @@ BOOLEAN CanCharacterTrainStat( SOLDIERTYPE *pSoldier, INT8 bStat, BOOLEAN fTrain if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -1857,7 +1857,7 @@ BOOLEAN CanCharacterOnDuty( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { if( gGameExternalOptions.ubSkyriderHotLZ == 0 ) return( FALSE ); @@ -1940,7 +1940,7 @@ BOOLEAN CanCharacterPractise( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -2191,7 +2191,7 @@ BOOLEAN CanCharacterVehicle( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -5615,7 +5615,7 @@ void HandleRadioScanInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) detect_rangefactor = 1.01f - detect_rangefactor; - patrolsize = NumEnemiesInSector( sX, sY ); + patrolsize = NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ); // no or single enemies -> skip this if ( patrolsize < 2 ) @@ -5957,7 +5957,7 @@ void HandleGatheringInformationBySoldier( SOLDIERTYPE* pSoldier ) // only passable sectors matter continue; } - usPatrolSize = NumEnemiesInSector( sX, sY ); + usPatrolSize = NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ); // no enemies if ( usPatrolSize < 1 ) @@ -11333,7 +11333,7 @@ void SquadMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) pSoldier->bOldAssignment = pSoldier->bAssignment; // silversurfer: This guy was in the heli and gets out in a hostile sector. Everyone else get out of the heli and start combat! - if ( pSoldier->bOldAssignment == VEHICLE && pSoldier->iVehicleId == iHelicopterVehicleId && NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( pSoldier->bOldAssignment == VEHICLE && pSoldier->iVehicleId == iHelicopterVehicleId && NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { UINT8 ubGroupID = MoveAllInHelicopterToFootMovementGroup( iValue ); CheckConditionsForBattle( GetGroup( ubGroupID ) ); @@ -16220,10 +16220,9 @@ BOOLEAN AnyMercInGroupCantContinueMoving( GROUP *pGroup ) SOLDIERTYPE *pSoldier; BOOLEAN fMeToo = FALSE; BOOLEAN fGroupMustStop = FALSE; - - + AssertNotNIL( pGroup ); - AssertT( pGroup->fPlayer ); + AssertT( pGroup->usGroupTeam == OUR_TEAM ); pPlayer = pGroup->pPlayerList; @@ -18119,7 +18118,7 @@ BOOLEAN BasicCanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } @@ -18285,7 +18284,7 @@ BOOLEAN CanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier ) pSectorInfo = &( SectorInfo[ SECTOR(sCurrentX, sCurrentY) ] ); // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. This sector cannot generate militia anyway. iCounter++; @@ -18630,7 +18629,7 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier ) pSectorInfo = &( SectorInfo[ SECTOR(sCurrentX, sCurrentY) ] ); // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. This sector cannot generate militia anyway. iCounter++; @@ -18685,7 +18684,7 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier ) // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. This sector cannot generate militia anyway. iCounter++; @@ -18806,7 +18805,7 @@ BOOLEAN BasicCanCharacterFacility( SOLDIERTYPE *pSoldier ) if( ( iHelicopterVehicleId != -1 ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { // enemies in sector - if( NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ) > 0 ) { return( FALSE ); } diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index 449a7ba9..0f885938 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -480,7 +480,7 @@ void EliminateAllEnemies( UINT8 ubSectorX, UINT8 ubSectorY ) //Remove the mobile forces here, but only if battle is over. while( pGroup ) { - if( !pGroup->fPlayer && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY ) { ClearPreviousAIGroupAssignment( pGroup ); pDeleteGroup = pGroup; @@ -826,7 +826,7 @@ void AssociateEnemiesWithStrategicGroups() pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && pGroup->ubSectorX == gpAR->ubSectorX && pGroup->ubSectorY == gpAR->ubSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->ubSectorX == gpAR->ubSectorX && pGroup->ubSectorY == gpAR->ubSectorY ) { ubNumElitesInGroup = pGroup->pEnemyGroup->ubNumElites; ubNumTroopsInGroup = pGroup->pEnemyGroup->ubNumTroops; @@ -874,8 +874,9 @@ void AssociateEnemiesWithStrategicGroups() pGroup = gpGroupList; while( pGroup ) - { // Don't process road block. It'll be processed as static - if( pGroup->ubGroupID && !pGroup->fPlayer && IsGroupInARightSectorToReinforce( pGroup, gpAR->ubSectorX, gpAR->ubSectorY ) ) + { + // Don't process road block. It'll be processed as static + if ( pGroup->ubGroupID && pGroup->usGroupTeam != OUR_TEAM && IsGroupInARightSectorToReinforce( pGroup, gpAR->ubSectorX, gpAR->ubSectorY ) ) { ubNumElitesInGroup = pGroup->pEnemyGroup->ubNumElites; ubNumTroopsInGroup = pGroup->pEnemyGroup->ubNumTroops; @@ -2871,7 +2872,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2"); } else { //The enemy won, so repoll movement. - ResetMovementForEnemyGroupsInLocation( gpAR->ubSectorX, gpAR->ubSectorY ); + ResetMovementForNonPlayerGroupsInLocation( gpAR->ubSectorX, gpAR->ubSectorY ); } } //Physically delete the soldiers now. @@ -3607,7 +3608,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve3"); { PlayAutoResolveSample( EXPLOSION_1, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); // this is not very accurate, any enemies already dead will be counted as killed twice - gStrategicStatus.usPlayerKills += NumEnemiesInSector( gpAR->ubSectorX, gpAR->ubSectorY ); + gStrategicStatus.usPlayerKills += NumNonPlayerTeamMembersInSector( gpAR->ubSectorX, gpAR->ubSectorY, ENEMY_TEAM ); EliminateAllEnemies( gpAR->ubSectorX, gpAR->ubSectorY ); } } @@ -4166,9 +4167,9 @@ void CalculateAttackValues() pCell->usNextAttack += (UINT32)( ( i - 4 ) * 1000 ); } - if(i >= NumEnemiesInSector( gpAR->ubSectorX, gpAR->ubSectorY ) && !(pCell->uiFlags & CELL_CREATURE) ) + if ( i >= NumNonPlayerTeamMembersInSector( gpAR->ubSectorX, gpAR->ubSectorY, ENEMY_TEAM ) && !(pCell->uiFlags & CELL_CREATURE) ) { //Extra delay if it's a reinforcement - pCell->usNextAttack += REINFORCMENT_ATTACK_DELAY_PER_SOLDIER_IN_SECTOR * NumEnemiesInSector( gpAR->ubSectorX, gpAR->ubSectorY ); + pCell->usNextAttack += REINFORCMENT_ATTACK_DELAY_PER_SOLDIER_IN_SECTOR * NumNonPlayerTeamMembersInSector( gpAR->ubSectorX, gpAR->ubSectorY, ENEMY_TEAM ); } @@ -5659,7 +5660,7 @@ void CheckForSoldiersWhoRetreatedIntoMilitiaHeldSectors() for(int sX = 1; sX < ( MAP_WORLD_X - 1 ); sX++ ) { for(int sY = 1; sY < ( MAP_WORLD_Y - 1); sY++ ) { // Check if there is a sector where enemies retreated to and there are also militia present - if ((NumEnemiesInSector(sX, sY) > 0) && + if ( (NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ) > 0) && (CountAllMilitiaInSector(sX, sY) > 0) && (!gTacticalStatus.fEnemyInSector)) { unsigned mercCnt = 0; diff --git a/Strategic/Ja25 Strategic Ai.cpp b/Strategic/Ja25 Strategic Ai.cpp index 303fb3da..0681960c 100644 --- a/Strategic/Ja25 Strategic Ai.cpp +++ b/Strategic/Ja25 Strategic Ai.cpp @@ -2617,7 +2617,7 @@ void HandleSayingDontStayToLongWarningInSectorH8() } //if there are no enemies in the sector, leave - if( NumEnemiesInSector( 8, 8 ) > 0 ) + if ( NumNonPlayerTeamMembersInSector( 8, 8, ENEMY_TEAM ) > 0 ) { return; } diff --git a/Strategic/Map Screen Helicopter.cpp b/Strategic/Map Screen Helicopter.cpp index ac05921c..070b0183 100644 --- a/Strategic/Map Screen Helicopter.cpp +++ b/Strategic/Map Screen Helicopter.cpp @@ -662,9 +662,6 @@ BOOLEAN RemoveSoldierFromHelicopter( SOLDIERTYPE *pSoldier ) BOOLEAN HandleHeliEnteringSector( INT16 sX, INT16 sY ) { - UINT8 ubNumEnemies; - - // check for SAM attack upon the chopper. If it's destroyed by the attack, do nothing else here if( HandleSAMSiteAttackOfHelicopterInSector( sX, sY ) == TRUE ) { @@ -672,9 +669,8 @@ BOOLEAN HandleHeliEnteringSector( INT16 sX, INT16 sY ) return( TRUE ); } - // count how many enemies are camped there or passing through - ubNumEnemies = NumEnemiesInSector( sX, sY ); + UINT8 ubNumEnemies = NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ); // any baddies? if( ubNumEnemies > 0 ) @@ -780,7 +776,7 @@ BOOLEAN CheckIfHelicopterHasEnoughFuelToReturn( INT16 sX, INT16 sY ) HeliCharacterDialogue( pSkyRider, RETURN_TO_BASE ); // If the sector is safe - if ( NumEnemiesInSector( pVehicleList[ iHelicopterVehicleId ].sSectorX, pVehicleList[ iHelicopterVehicleId ].sSectorY ) == 0 ) + if ( NumNonPlayerTeamMembersInSector( pVehicleList[iHelicopterVehicleId].sSectorX, pVehicleList[iHelicopterVehicleId].sSectorY, ENEMY_TEAM ) == 0 ) { // kick everyone out! // anv: possibly show prompt, if option is on, and heli has any passengers @@ -1399,7 +1395,7 @@ void HandleHeliHoverTooLong( void ) HeliCharacterDialogue( pSkyRider, RETURN_TO_BASE ); // If the sector is safe - if ( NumEnemiesInSector( pVehicleList[ iHelicopterVehicleId ].sSectorX, pVehicleList[ iHelicopterVehicleId ].sSectorY ) == 0 ) + if ( NumNonPlayerTeamMembersInSector( pVehicleList[iHelicopterVehicleId].sSectorX, pVehicleList[iHelicopterVehicleId].sSectorY, ENEMY_TEAM ) == 0 ) { // anv: possibly show prompt, if option is on, and heli has any passengers if( gHelicopterSettings.fAskBeforeKickingPassengersOut == FALSE || GetNumberInVehicle( iHelicopterVehicleId ) == 0 ) diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 9869d5fc..0821fa9f 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -1808,7 +1808,7 @@ void CancelPathForGroup( GROUP *pGroup ) INT32 iVehicleId; // if it's the chopper, but player can't redirect it - if ( pGroup->fPlayer && IsGroupTheHelicopterGroup( pGroup ) && ( CanHelicopterFly( ) == FALSE ) ) + if ( pGroup->usGroupTeam == OUR_TEAM && IsGroupTheHelicopterGroup( pGroup ) && (CanHelicopterFly( ) == FALSE) ) { // explain & ignore ExplainWhySkyriderCantFly(); @@ -1816,7 +1816,7 @@ void CancelPathForGroup( GROUP *pGroup ) } // is it a non-vehicle group? - if( ( pGroup->fPlayer ) && ( pGroup->fVehicle == FALSE ) ) + if ( (pGroup->usGroupTeam == OUR_TEAM) && (pGroup->fVehicle == FALSE) ) { if( pGroup->pPlayerList ) { @@ -3031,7 +3031,7 @@ void ShowPeopleInMotion( INT16 sX, INT16 sY ) // If so, is any of the groups in the sector able to retreat in the current direction? while (curr) { - if (curr->fPlayer == TRUE && // Player group + if ( curr->usGroupTeam == OUR_TEAM && // Player group curr->ubSectorX == sX && curr->ubSectorY == sY && // Group is in the battle sector curr->ubPrevX == tXD && curr->ubPrevY == tYD) // Group came from the examined destination { @@ -3052,7 +3052,7 @@ void ShowPeopleInMotion( INT16 sX, INT16 sY ) curr = gpGroupList; while (curr) { - if (curr->fPlayer == TRUE && // Player group + if ( curr->usGroupTeam == OUR_TEAM && // Player group curr->ubSectorX == tXD && curr->ubSectorY == tYD && // Group is in the battle sector curr->ubPrevX == sX && curr->ubPrevY == sY) // Group came from the examined source { @@ -3073,7 +3073,7 @@ void ShowPeopleInMotion( INT16 sX, INT16 sY ) curr = gpGroupList; while (curr) { - if (curr->fPlayer == TRUE && // Player group + if ( curr->usGroupTeam == OUR_TEAM && // Player group curr->ubNextX == tXS && curr->ubNextY == tYS && // Heading into this sector !IsGroupTheHelicopterGroup( curr ) ) // Not a helicopter group! { @@ -3227,7 +3227,7 @@ void ShowPeopleInMotion( INT16 sX, INT16 sY ) curr = gpGroupList; while( curr ) { - if (curr->fPlayer == TRUE && // Player group + if ( curr->usGroupTeam == OUR_TEAM && // Player group curr->fBetweenSectors == TRUE && // Currently in motion SECTOR(curr->ubSectorX, curr->ubSectorY) == sSourceSector && // Heading out of this sector SECTOR(curr->ubNextX, curr->ubNextY) == sDestSector ) // Heading to the destination we're examining @@ -3339,7 +3339,7 @@ void ShowPeopleInMotion( INT16 sX, INT16 sY ) dLastTravelProgress = 10000.0f; while( curr ) { - if (curr->fPlayer == TRUE && // Player group + if ( curr->usGroupTeam == OUR_TEAM && // Player group curr->fBetweenSectors == TRUE && // Currently in motion SECTOR(curr->ubSectorX, curr->ubSectorY) == sSourceSector && // Heading out of this sector SECTOR(curr->ubNextX, curr->ubNextY) == sDestSector ) // Heading to the destination we're examining @@ -3499,8 +3499,7 @@ void ShowEnemyGroupsInMotion( INT16 sX, INT16 sY ) INT16 sTextYOffset = 0; INT32 iWidth = 0, iHeight = 0; INT32 iDeltaXForError = 0, iDeltaYForError = 0; - - + if( iCurrentMapSectorZ != 0 ) { return; @@ -3512,7 +3511,7 @@ void ShowEnemyGroupsInMotion( INT16 sX, INT16 sY ) curr = gpGroupList; while( curr->next ) { - if (!curr->fPlayer && curr->ubSectorX == sX && curr->ubSectorY == sY && curr->ubSectorZ == 0) + if ( curr->usGroupTeam != OUR_TEAM && curr->ubSectorX == sX && curr->ubSectorY == sY && curr->ubSectorZ == 0 ) { if (curr->ubNextX != sX || curr->ubNextY != sY) { @@ -6385,7 +6384,7 @@ void HandleShowingOfEnemyForcesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bS ShowMilitiaInMotion( sSectorX, sSectorY ); // get total number of badguys here - sNumberOfEnemies = NumEnemiesInSector( sSectorX, sSectorY ); + sNumberOfEnemies = NumNonPlayerTeamMembersInSector( sSectorX, sSectorY, ENEMY_TEAM ); // Flugente: tanks get a special icon, so we need to count them separately usNumTanks = NumEnemyTanksInSector( sSectorX, sSectorY ); diff --git a/Strategic/Map Screen Interface TownMine Info.cpp b/Strategic/Map Screen Interface TownMine Info.cpp index 57d30fb3..2e755f43 100644 --- a/Strategic/Map Screen Interface TownMine Info.cpp +++ b/Strategic/Map Screen Interface TownMine Info.cpp @@ -883,9 +883,10 @@ void AddCommonInfoToBox(void) AddMonoString( &hStringHandle, wString ); // how many are there, really? - ubNumEnemies = NumEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); - AssertGE(gGameExternalOptions.ubGameMaximumNumberOfEnemies, NumFreeEnemySlots()); - unsigned numEnemiesOnMap = gGameExternalOptions.ubGameMaximumNumberOfEnemies - NumFreeEnemySlots(); + ubNumEnemies = NumNonPlayerTeamMembersInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, ENEMY_TEAM ); + UINT8 enemyfreeslots = NumFreeSlots( ENEMY_TEAM ); + AssertGE( gGameExternalOptions.ubGameMaximumNumberOfEnemies, enemyfreeslots ); + unsigned numEnemiesOnMap = gGameExternalOptions.ubGameMaximumNumberOfEnemies - enemyfreeslots; switch ( WhatPlayerKnowsAboutEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ) { diff --git a/Strategic/MilitiaSquads.cpp b/Strategic/MilitiaSquads.cpp index cd80892b..62bd705b 100644 --- a/Strategic/MilitiaSquads.cpp +++ b/Strategic/MilitiaSquads.cpp @@ -102,7 +102,7 @@ BOOLEAN PlayerMercsInSector_MSE( UINT8 ubSectorX, UINT8 ubSectorY, BOOLEAN fDont pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer )// && !pGroup->fBetweenSectors) + if ( pGroup->usGroupTeam == OUR_TEAM )// && !pGroup->fBetweenSectors) { if ( ( pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && pGroup->ubSectorZ == 0 ) || ( !fDontConsiderNextSector && ( pGroup->ubNextX == ubSectorX && pGroup->ubNextY == ubSectorY && pGroup->ubSectorZ == 0 ) ) ) @@ -134,7 +134,7 @@ UINT8 GetEnemyGroupIdInSector( INT16 sMapX, INT16 sMapY ) curr = gpGroupList; while( curr ) { - if( curr->ubSectorX == sMapX && curr->ubSectorY == sMapY && !curr->fPlayer ) + if ( curr->ubSectorX == sMapX && curr->ubSectorY == sMapY && curr->usGroupTeam != OUR_TEAM ) if( !curr->ubGroupID ) return curr->ubGroupID; else @@ -865,7 +865,7 @@ UINT16 CountDirectionEnemyRating( INT16 sMapX, INT16 sMapY, UINT8 uiDir ) for( sLMY = MINIMUM_VALID_Y_COORDINATE; sLMY <= MAXIMUM_VALID_Y_COORDINATE ; ++sLMY ) { // SECTORINFO *pSectorInfo = &( SectorInfo[ uiSector ] ); - UINT8 uiSumOfEnemyTroops = NumEnemiesInSector( sLMX, sLMY ); + UINT8 uiSumOfEnemyTroops = NumNonPlayerTeamMembersInSector( sLMX, sLMY, ENEMY_TEAM ); //pSectorInfo->ubNumAdmins + pSectorInfo->ubNumTroops + pSectorInfo->ubNumElites; // there's an enemy @@ -935,7 +935,7 @@ UINT16 CountDirectionRating( INT16 sMapX, INT16 sMapY, UINT8 uiDir ) UINT16 usSourceEnemiesInFiveSectors = NumEnemiesInFiveSectors( sMapX, sMapY ); UINT16 usTargetEnemiesInFiveSectors = NumEnemiesInFiveSectors( sDMapX, sDMapY ); - UINT8 ubTargetEnemies = NumEnemiesInSector( sDMapX, sDMapY ); + UINT8 ubTargetEnemies = NumNonPlayerTeamMembersInSector( sDMapX, sDMapY, ENEMY_TEAM ); UINT16 usSourceMilitiaInFiveSectors = CountAllMilitiaInFiveSectors( sMapX, sMapY ); UINT16 usTargetMilitiaInFiveSectors = CountAllMilitiaInFiveSectors( sDMapX, sDMapY ); @@ -1030,7 +1030,7 @@ UINT16 CountDirectionRating( INT16 sMapX, INT16 sMapY, UINT8 uiDir ) } } -// ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"M %ld, E%ld,%ld %ld, Diff %ld", CountAllMilitiaInSector( sMapX, sMapY ), sDMapX, sDMapY, NumEnemiesInSector( sDMapX, sDMapY ), ((INT32)CountAllMilitiaInSector( sMapX, sMapY )) - ((INT32)NumEnemiesInSector( sDMapX, sDMapY )) ); +// ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"M %ld, E%ld,%ld %ld, Diff %ld", CountAllMilitiaInSector( sMapX, sMapY ), sDMapX, sDMapY, NumNonPlayerTeamMembersInSector( sDMapX, sDMapY, ENEMY_TEAM ), ((INT32)CountAllMilitiaInSector( sMapX, sMapY )) - ((INT32)NumNonPlayerTeamMembersInSector( sDMapX, sDMapY, ENEMY_TEAM )) ); return iRes; } @@ -1089,7 +1089,7 @@ BOOLEAN CheckStandardConditionsForDirection( INT16 sSMapX, INT16 sSMapY, INT16 s // If militia aren't set-up for battle, they can't move into an enemy sector. This prevents combat ever // being instigated by militia unless specifically requested to do so by setting all the appropriate "ready!" // flags earlier in the code. - if( !fForBattle && gfMSBattle && NumEnemiesInSector( sMapX, sMapY ) ) + if ( !fForBattle && gfMSBattle && NumNonPlayerTeamMembersInSector( sMapX, sMapY, ENEMY_TEAM ) ) { fReadyForBattle = FALSE; } @@ -1253,7 +1253,7 @@ BOOLEAN CheckStandardConditionsForDirection( INT16 sSMapX, INT16 sSMapY, INT16 s // Wilderness->Sam/Town. else { - if (!NumEnemiesInSector( sMapX, sMapY ) && // Is the sector under our control at the moment? + if ( !NumNonPlayerTeamMembersInSector( sMapX, sMapY, ENEMY_TEAM ) && // Is the sector under our control at the moment? pTargetSector->fSurfaceWasEverPlayerControlled && // Has it ever been under control? CountMilitia(pTargetSector) < gGameExternalOptions.iMaxMilitiaPerSector ) // Is there room here for more militia? { @@ -1288,7 +1288,7 @@ BOOLEAN CheckStandardConditionsForDirection( INT16 sSMapX, INT16 sSMapY, INT16 s { // This should ONLY be possible if we are explicitly training new militia groups. // Also, militia can no longer spawn directly into enemy-controlled territory. - if (fForTraining && !(NumEnemiesInSector( sMapX, sMapY ))) + if ( fForTraining && !NumNonPlayerTeamMembersInSector( sMapX, sMapY, ENEMY_TEAM ) ) { fCanSimpleMove = TRUE; } @@ -1493,7 +1493,7 @@ void MilitiaMovementOrder(UINT8 sector) if ( gfStrategicMilitiaChangesMade) ResetMilitia(); - if( NumEnemiesInSector( targetX, targetY ) ) + if ( NumNonPlayerTeamMembersInSector( targetX, targetY, ENEMY_TEAM ) ) { //Moa: handle deserters before moving in hostile territory MobileMilitiaDeserters( targetX, targetY, TRUE, TRUE ); @@ -1641,7 +1641,7 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY ) ResetMilitia(); } - if( NumEnemiesInSector( targetX, targetY ) ) + if ( NumNonPlayerTeamMembersInSector( targetX, targetY, ENEMY_TEAM ) ) { extern GROUP *gpBattleGroup; gpBattleGroup = GetGroup( GetEnemyGroupIdInSector( targetX, targetY ) ); @@ -1751,10 +1751,10 @@ void CreateMilitiaSquads(INT16 sMapX, INT16 sMapY ) // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. Generate no militia from this sector. - iCounter++; + ++iCounter; continue; } @@ -1802,7 +1802,7 @@ void CreateMilitiaSquads(INT16 sMapX, INT16 sMapY ) AddToBlockMoveList( sTMapX, sTMapY ); // Check for enemies in target sector - if( NumEnemiesInSector( sTMapX, sTMapY ) ) + if ( NumNonPlayerTeamMembersInSector( sTMapX, sTMapY, ENEMY_TEAM ) ) { // Initiave battle gfMSBattle = TRUE; @@ -1819,7 +1819,7 @@ void CreateMilitiaSquads(INT16 sMapX, INT16 sMapY ) AddToBlockMoveList( sTMapX, sTMapY ); // Check for enemies in target sector - if( NumEnemiesInSector( sTMapX, sTMapY ) ) + if ( NumNonPlayerTeamMembersInSector( sTMapX, sTMapY, ENEMY_TEAM ) ) { // Initiave battle gfMSBattle = TRUE; @@ -2309,7 +2309,7 @@ BOOLEAN IsSectorRoamingAllowed( UINT32 uiSector ) // HEADROCK HAM 4: Take player restrictions into account if ( gubManualRestrictMilitia[ uiSector ] == MANUAL_MOBILE_NO_ENTER ) { - if ( !NumEnemiesInSector( SECTORX(uiSector), SECTORY(uiSector) ) ) + if ( !NumNonPlayerTeamMembersInSector( SECTORX( uiSector ), SECTORY( uiSector ), ENEMY_TEAM ) ) { // The player has disallowed movement into this sector, manually. As the condition above // dictates, this only takes effect if there are no enemies in the target sector. Otherwise, diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index 3b2ab6b2..750122bc 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -219,7 +219,7 @@ void ValidateAndCorrectInBattleCounters( GROUP *pLocGroup ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { if( pGroup->ubSectorX == pLocGroup->ubSectorX && pGroup->ubSectorY == pLocGroup->ubSectorY ) { @@ -373,7 +373,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) gubPBSectorZ = gpBattleGroup->ubSectorZ; // get number of enemies thought to be here - SectorInfo[ SECTOR( gubPBSectorX, gubPBSectorY ) ].bLastKnownEnemies = NumEnemiesInSector( gubPBSectorX, gubPBSectorY ); + SectorInfo[SECTOR( gubPBSectorX, gubPBSectorY )].bLastKnownEnemies = NumNonPlayerTeamMembersInSector( gubPBSectorX, gubPBSectorY, ENEMY_TEAM ); fMapPanelDirty = TRUE; } else if( gfPersistantPBI ) @@ -408,7 +408,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) gubExplicitEnemyEncounterCode = ENTERING_ENEMY_SECTOR_CODE; } } - else if (pBattleGroup && !pBattleGroup->fPlayer && CountAllMilitiaInSector( pBattleGroup->ubSectorX, pBattleGroup->ubSectorY ) > 0) + else if ( pBattleGroup && pBattleGroup->usGroupTeam != OUR_TEAM && CountAllMilitiaInSector( pBattleGroup->ubSectorX, pBattleGroup->ubSectorY ) > 0 ) { gubEnemyEncounterCode = ENEMY_ENCOUNTER_CODE; } @@ -572,7 +572,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) { //creature's attacking! gubEnemyEncounterCode = CREATURE_ATTACK_CODE; } - else if( gpBattleGroup->fPlayer ) + else if ( gpBattleGroup->usGroupTeam == OUR_TEAM ) { if( gubEnemyEncounterCode != BLOODCAT_AMBUSH_CODE && gubEnemyEncounterCode != ENTERING_BLOODCAT_LAIR_CODE ) { @@ -1256,7 +1256,7 @@ void RenderPreBattleInterface() else { // know exactly how many - i = NumEnemiesInSector( gubPBSectorX, gubPBSectorY ); + i = NumNonPlayerTeamMembersInSector( gubPBSectorX, gubPBSectorY, ENEMY_TEAM ); swprintf( str, L"%d", i ); SectorInfo[ SECTOR( gubPBSectorX, gubPBSectorY ) ].bLastKnownEnemies = (INT8)i; } @@ -1419,7 +1419,7 @@ void AutoResolveBattleCallback( GUI_BUTTON *btn, INT32 reason ) return; } PlayJA2Sample( EXPLOSION_1, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); - gStrategicStatus.usPlayerKills += NumEnemiesInSector( gubPBSectorX, gubPBSectorY ); + gStrategicStatus.usPlayerKills += NumNonPlayerTeamMembersInSector( gubPBSectorX, gubPBSectorY, ENEMY_TEAM ); EliminateAllEnemies( gubPBSectorX, gubPBSectorY ); SetMusicMode( MUSIC_TACTICAL_VICTORY ); btn->uiFlags &= ~BUTTON_CLICKED_ON; @@ -1455,7 +1455,7 @@ void GoToSectorCallback( GUI_BUTTON *btn, INT32 reason ) return; } PlayJA2Sample( EXPLOSION_1, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); - gStrategicStatus.usPlayerKills += NumEnemiesInSector( gubPBSectorX, gubPBSectorY ); + gStrategicStatus.usPlayerKills += NumNonPlayerTeamMembersInSector( gubPBSectorX, gubPBSectorY, ENEMY_TEAM ); EliminateAllEnemies( gubPBSectorX, gubPBSectorY ); SetMusicMode( MUSIC_TACTICAL_VICTORY ); btn->uiFlags &= ~BUTTON_CLICKED_ON; @@ -1469,7 +1469,7 @@ void GoToSectorCallback( GUI_BUTTON *btn, INT32 reason ) SetMusicMode( MUSIC_TACTICAL_NOTHING ); return; } - if( gfPersistantPBI && gpBattleGroup && gpBattleGroup->fPlayer && + if ( gfPersistantPBI && gpBattleGroup && gpBattleGroup->usGroupTeam == OUR_TEAM && gubEnemyEncounterCode != ENEMY_AMBUSH_CODE && gubEnemyEncounterCode != CREATURE_ATTACK_CODE && gubEnemyEncounterCode != BLOODCAT_AMBUSH_CODE ) @@ -1541,7 +1541,7 @@ void RetreatMercsCallback( GUI_BUTTON *btn, INT32 reason ) //Warp time by 5 minutes so that player can't just go back into the sector he left. //WarpGameTime( 300, WARPTIME_NO_PROCESSING_OF_EVENTS ); - ResetMovementForEnemyGroupsInLocation( gubPBSectorX, gubPBSectorY ); + ResetMovementForNonPlayerGroupsInLocation( gubPBSectorX, gubPBSectorY ); btn->uiFlags &= ~BUTTON_CLICKED_ON; DrawButton( btn->IDNum ); @@ -1728,7 +1728,7 @@ SOLDIERTYPE* UninvolvedSoldier( INT32 index ) pGroup = gpGroupList; while( pGroup && !fFound ) { - if ( pGroup->fPlayer && !PlayerGroupInvolvedInThisCombat( pGroup ) ) + if ( pGroup->usGroupTeam == OUR_TEAM && !PlayerGroupInvolvedInThisCombat( pGroup ) ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -2056,7 +2056,7 @@ BOOLEAN PlayerGroupInvolvedInThisCombat( GROUP *pGroup ) // player group, non-empty, not between sectors, in the right sector, isn't a group of in transit, dead, or POW mercs, // and either not the helicopter group, or the heli is on the ground - if( pGroup->fPlayer && pGroup->ubGroupSize && + if ( pGroup->usGroupTeam == OUR_TEAM && pGroup->ubGroupSize && !pGroup->fBetweenSectors && !GroupHasInTransitDeadOrPOWMercs( pGroup ) && ( !IsGroupTheHelicopterGroup( pGroup ) || !fHelicopterIsAirBorne ) ) diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index 1ff784f4..cc6a01a1 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -177,7 +177,7 @@ UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { ubNumHostiles += pGroup->ubGroupSize; } @@ -221,7 +221,7 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { ubNumEnemies += pGroup->ubGroupSize; } @@ -232,7 +232,8 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) return ubNumEnemies; } -UINT8 NumEnemiesInSector( INT16 sSectorX, INT16 sSectorY ) +// returns how many members of a team are in a sector - not intended for OUR_TEAM! +UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam ) { SECTORINFO *pSector; GROUP *pGroup; @@ -254,20 +255,29 @@ UINT8 NumEnemiesInSector( INT16 sSectorX, INT16 sSectorY ) AssertLE( sSectorY, MAXIMUM_VALID_Y_COORDINATE ); pSector = &SectorInfo[ SECTOR( sSectorX, sSectorY ) ]; - ubNumTroops = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumTanks); + + if ( ubTeam == ENEMY_TEAM ) + { + ubNumTroops = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumTanks); - if (is_networked) - ubNumTroops += numenemyLAN((UINT8)sSectorX,(UINT8)sSectorY ); //hayden + if ( is_networked ) + ubNumTroops += numenemyLAN((UINT8)sSectorX,(UINT8)sSectorY ); //hayden + } + else if ( ubTeam == MILITIA_TEAM ) + { + ubNumTroops = (UINT8)(pSector->ubNumberOfCivsAtLevel[0] + pSector->ubNumberOfCivsAtLevel[1] + pSector->ubNumberOfCivsAtLevel[2]); + } pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam == ubTeam && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { ubNumTroops += pGroup->ubGroupSize; } pGroup = pGroup->next; } + return ubNumTroops; } @@ -302,7 +312,7 @@ UINT16 NumEnemyTanksInSector( INT16 sSectorX, INT16 sSectorY ) pGroup = gpGroupList; while ( pGroup ) { - if ( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { ubNum += pGroup->pEnemyGroup->ubNumTanks; } @@ -353,7 +363,7 @@ UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { ubNumTroops += pGroup->ubGroupSize; } @@ -383,7 +393,7 @@ void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pu pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { *pubNumTroops += pGroup->pEnemyGroup->ubNumTroops; *pubNumElites += pGroup->pEnemyGroup->ubNumElites; @@ -417,7 +427,7 @@ void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSe pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { *pubNumTroops += pGroup->pEnemyGroup->ubNumTroops; *pubNumElites += pGroup->pEnemyGroup->ubNumElites; @@ -496,7 +506,7 @@ void EndTacticalBattleForEnemy() pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY ) { pGroup->pEnemyGroup->ubTroopsInBattle = 0; pGroup->pEnemyGroup->ubElitesInBattle = 0; @@ -527,18 +537,17 @@ void EndTacticalBattleForEnemy() } } -UINT8 NumFreeEnemySlots() +UINT8 NumFreeSlots( UINT8 ubTeam ) { UINT8 ubNumFreeSlots = 0; - INT32 i; - SOLDIERTYPE *pSoldier; + //Count the number of free enemy slots. It is possible to have multiple groups exceed the maximum. - for( i = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; i <= gTacticalStatus.Team[ ENEMY_TEAM].bLastID; i++ ) + for ( INT32 i = gTacticalStatus.Team[ubTeam].bFirstID; i <= gTacticalStatus.Team[ubTeam].bLastID; ++i ) { - pSoldier = &Menptr[ i ]; - if( !pSoldier->bActive ) - ubNumFreeSlots++; + if ( !Menptr[i].bActive ) + ++ubNumFreeSlots; } + return ubNumFreeSlots; } @@ -563,7 +572,7 @@ BOOLEAN PrepareEnemyForSectorBattle() return PrepareEnemyForUndergroundBattle(); // Add the invading group - if (gpBattleGroup && !gpBattleGroup->fPlayer ) + if ( gpBattleGroup && gpBattleGroup->usGroupTeam != OUR_TEAM ) { //The enemy has instigated the battle which means they are the ones entering the conflict. //The player was actually in the sector first, and the enemy doesn't use reinforced placements @@ -602,7 +611,7 @@ BOOLEAN PrepareEnemyForSectorBattle() pGroup = gpGroupList; while( pGroup ) { - if( pGroup != gpBattleGroup && !pGroup->fPlayer && !pGroup->fVehicle && + if ( pGroup != gpBattleGroup && pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gpBattleGroup->ubSectorX && pGroup->ubSectorY == gpBattleGroup->ubSectorY && !pGroup->pEnemyGroup->ubAdminsInBattle && @@ -638,7 +647,7 @@ BOOLEAN PrepareEnemyForSectorBattle() if (mapMaximumNumberOfEnemies > gGameExternalOptions.ubGameMaximumNumberOfEnemies) mapMaximumNumberOfEnemies = gGameExternalOptions.ubGameMaximumNumberOfEnemies; - gfPendingEnemies = (NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) > mapMaximumNumberOfEnemies ); + gfPendingEnemies = (NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) > mapMaximumNumberOfEnemies); pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; @@ -741,7 +750,7 @@ BOOLEAN PrepareEnemyForSectorBattle() #endif //Search for movement groups that happen to be in the sector. - sNumSlots = NumFreeEnemySlots(); + sNumSlots = NumFreeSlots( ENEMY_TEAM ); if (sNumSlots > (int)mapMaximumNumberOfEnemies) sNumSlots = mapMaximumNumberOfEnemies; @@ -771,7 +780,7 @@ BOOLEAN PrepareEnemyForSectorBattle() pGroup; pGroup = pGroup->next) { - if( !pGroup->fPlayer && !pGroup->fVehicle && + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) { //Process enemy group in sector. if( sNumSlots > 0 ) @@ -834,7 +843,7 @@ BOOLEAN PrepareEnemyForSectorBattle() //no provisions for profile troop leader or retreat groups yet. } - if( pGroup->fPlayer && !pGroup->fVehicle && !pGroup->fBetweenSectors && + if ( pGroup->usGroupTeam == OUR_TEAM && !pGroup->fVehicle && !pGroup->fBetweenSectors && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) { //TEMP: The player path needs to get destroyed, otherwise, it'll be impossible to move the // group after the battle is resolved. @@ -865,7 +874,7 @@ BOOLEAN PrepareEnemyForSectorBattle() pGroup = gpGroupList; while( pGroup && sNumSlots > 0 ) { - if( !pGroup->fPlayer && !pGroup->fVehicle && + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) { ubNumAdmins = pGroup->pEnemyGroup->ubAdminsInBattle; @@ -1123,7 +1132,7 @@ void ProcessQueenCmdImplicationsOfDeath( SOLDIERTYPE *pSoldier ) #endif return; } - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { #ifdef JA2BETAVERSION CHAR16 str[256]; @@ -1470,7 +1479,7 @@ void ProcessQueenCmdImplicationsOfDeath( SOLDIERTYPE *pSoldier ) if( !pSoldier->bSectorZ ) { pSector = &SectorInfo[ SECTOR( pSoldier->sSectorX, pSoldier->sSectorY ) ]; - iNumEnemiesInSector = NumEnemiesInSector( pSoldier->sSectorX, pSoldier->sSectorY ); + iNumEnemiesInSector = NumNonPlayerTeamMembersInSector( pSoldier->sSectorX, pSoldier->sSectorY, ENEMY_TEAM ); if( iNumEnemiesInSector ) { if( pSector->bLastKnownEnemies >= 0 ) @@ -1520,9 +1529,10 @@ void AddPossiblePendingEnemiesToBattle() } if( ( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) && !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) ) - || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return; + || !NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ) + return; - ubSlots = NumFreeEnemySlots(); + ubSlots = NumFreeSlots( ENEMY_TEAM ); if(gGameExternalOptions.sMinDelayEnemyReinforcements)//dnl ch68 080913 { if(gTacticalStatus.Team[ENEMY_TEAM].bAwareOfOpposition == TRUE) @@ -1557,8 +1567,10 @@ void AddPossiblePendingEnemiesToBattle() guiReinforceTurn = guiArrived = 0; //SendFmtMsg("Enemy reinforcements: guiTurnCnt=%d guiReinforceTurn=%d guiArrived=%d", guiTurnCnt, guiReinforceTurn, guiArrived); } + if( !ubSlots ) - { //no available slots to add enemies to. Try again later... + { + //no available slots to add enemies to. Try again later... return; } @@ -1641,13 +1653,13 @@ void AddPossiblePendingEnemiesToBattle() if( ubStrategicInsertionCode == 255 ) { - if( NumEnemiesInSector( gWorldSectorX + 1, gWorldSectorY ) ) + if ( NumNonPlayerTeamMembersInSector( gWorldSectorX + 1, gWorldSectorY, ENEMY_TEAM ) ) ubStrategicInsertionCode = INSERTION_CODE_EAST; - else if( NumEnemiesInSector( gWorldSectorX - 1, gWorldSectorY ) ) + else if ( NumNonPlayerTeamMembersInSector( gWorldSectorX - 1, gWorldSectorY, ENEMY_TEAM ) ) ubStrategicInsertionCode = INSERTION_CODE_WEST; - else if( NumEnemiesInSector( gWorldSectorX, gWorldSectorY + 1 ) ) + else if ( NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY + 1, ENEMY_TEAM ) ) ubStrategicInsertionCode = INSERTION_CODE_SOUTH; - else if( NumEnemiesInSector( gWorldSectorX, gWorldSectorY - 1 ) ) + else if ( NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY - 1, ENEMY_TEAM ) ) ubStrategicInsertionCode = INSERTION_CODE_NORTH; #ifdef JA2UB else if( gsGridNoForMapEdgePointInfo != -1 ) @@ -1684,13 +1696,13 @@ void AddPossiblePendingEnemiesToBattle() // Figure out which groups are in the sector, so we can have reinforcements arrive at random for (ubNumGroupsInSector = 0, pGroup = gpGroupList; pGroup; pGroup = pGroup->next) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) ubNumGroupsInSector++; } pGroupInSectorList = (GROUP**) MemAlloc( ubNumGroupsInSector * sizeof( GROUP*)); for (ubNumGroupsInSector = 0, pGroup = gpGroupList; pGroup; pGroup = pGroup->next) { - if( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) { pGroupInSectorList[ ubNumGroupsInSector++] = pGroup; } @@ -2296,7 +2308,7 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier ) // Are there enemies in ALMA? ( I13 ) - iNumEnemiesInSector = NumEnemiesInSector( gModSettings.ubInitialPOWSectorX, gModSettings.ubInitialPOWSectorY ); //(13, 9) + iNumEnemiesInSector = NumNonPlayerTeamMembersInSector( gModSettings.ubInitialPOWSectorX, gModSettings.ubInitialPOWSectorY, ENEMY_TEAM ); //(13, 9) // IF there are no enemies, and we need to do alma, skip! if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED && iNumEnemiesInSector == 0 ) @@ -2533,13 +2545,17 @@ BOOLEAN PlayerSectorDefended( UINT8 ubSectorID ) if( pSector->ubNumberOfCivsAtLevel[ GREEN_MILITIA ] + pSector->ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] + pSector->ubNumberOfCivsAtLevel[ ELITE_MILITIA ] ) - { //militia in sector + { + //militia in sector return TRUE; } - if( FindMovementGroupInSector( (UINT8)SECTORX( ubSectorID ), (UINT8)SECTORY( ubSectorID ), TRUE ) ) - { //player in sector + + if ( FindMovementGroupInSector( (UINT8)SECTORX( ubSectorID ), (UINT8)SECTORY( ubSectorID ), OUR_TEAM ) || FindMovementGroupInSector( (UINT8)SECTORX( ubSectorID ), (UINT8)SECTORY( ubSectorID ), MILITIA_TEAM ) ) + { + // player/militia in sector return TRUE; } + return FALSE; } @@ -2613,7 +2629,7 @@ BOOLEAN CheckPendingEnemies() return TRUE; for (GROUP *pGroup = gpGroupList; pGroup; pGroup = pGroup->next) { - if( !pGroup->fPlayer + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY diff --git a/Strategic/Queen Command.h b/Strategic/Queen Command.h index 8626bc3b..d6080e94 100644 --- a/Strategic/Queen Command.h +++ b/Strategic/Queen Command.h @@ -12,14 +12,16 @@ extern BOOLEAN gfPendingEnemies; -UINT8 NumFreeEnemySlots(); +UINT8 NumFreeSlots( UINT8 ubTeam ); //Counts enemies and crepitus, but not bloodcats. UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); -UINT8 NumEnemiesInSector( INT16 sSectorX, INT16 sSectorY ); +// returns how many members of a team are in a sector - not intended for OUR_TEAM! +UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam ); + UINT16 NumEnemyTanksInSector( INT16 sSectorX, INT16 sSectorY ); UINT8 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY ); UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY ); diff --git a/Strategic/Reinforcement.cpp b/Strategic/Reinforcement.cpp index 07fa2c1d..f5cb953c 100644 --- a/Strategic/Reinforcement.cpp +++ b/Strategic/Reinforcement.cpp @@ -235,7 +235,7 @@ GROUP* GetEnemyGroupInSector( INT16 sMapX, INT16 sMapY ) curr = gpGroupList; while( curr ) { - if( curr->ubSectorX == sMapX && curr->ubSectorY == sMapY && !curr->fPlayer && curr->ubGroupID ) + if ( curr->ubSectorX == sMapX && curr->ubSectorY == sMapY && curr->usGroupTeam != OUR_TEAM && curr->ubGroupID ) return curr; curr = curr->next; } @@ -284,7 +284,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) { ubIndex = Random(ubDirNumber); - if( NumEnemiesInSector( SECTORX( pusMoveDir[ ubIndex ][ 0 ] ), SECTORY( pusMoveDir[ ubIndex ][ 0 ] ) ) > gubReinforcementMinEnemyStaticGroupSize ) + if ( NumNonPlayerTeamMembersInSector( SECTORX( pusMoveDir[ubIndex][0] ), SECTORY( pusMoveDir[ubIndex][0] ), ENEMY_TEAM ) > gubReinforcementMinEnemyStaticGroupSize ) { pSector = &SectorInfo[ pusMoveDir[ ubIndex ][ 0 ] ]; @@ -412,10 +412,10 @@ void AddPossiblePendingMilitiaToBattle() } // if( !PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) || !CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ) - // || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) return; + // || !NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ) return; if( (PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, 0 ) == 0) || !(gTacticalStatus.uiFlags & WANT_MILITIA_REINFORCEMENTS) - || (NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) == 0) + || (NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) == 0) ) return; //gGameExternalOptions.guiMaxMilitiaSquadSize - CountAllMilitiaInSector( gWorldSectorX, gWorldSectorY ); diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index c553560b..1ec6f6c2 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -727,7 +727,7 @@ void ValidatePendingGroups() if( ubGroupID ) { pGroup = GetGroup( ubGroupID ); - if( !pGroup || pGroup->fPlayer ) + if( !pGroup || pGroup->usGroupTeam == OUR_TEAM ) { iErrorsForInvalidPendingGroup++; gPatrolGroup[ i ].ubPendingGroupID = 0; @@ -740,7 +740,7 @@ void ValidatePendingGroups() if( ubGroupID ) { pGroup = GetGroup( ubGroupID ); - if( !pGroup || pGroup->fPlayer ) + if ( !pGroup || pGroup->usGroupTeam == OUR_TEAM ) { iErrorsForInvalidPendingGroup++; gGarrisonGroup[ i ].ubPendingGroupID = 0; @@ -824,7 +824,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Strategic2"); } if( !pGroup->ubNextX || !pGroup->ubNextY ) { - if( !pGroup->fPlayer && pGroup->pEnemyGroup->ubIntention != STAGING + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->pEnemyGroup->ubIntention != STAGING && pGroup->pEnemyGroup->ubIntention != REINFORCEMENTS ) { #ifdef JA2BETAVERSION @@ -874,7 +874,7 @@ void RemovePlayersFromAllMismatchGroups( SOLDIERTYPE *pSoldier ) pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -938,7 +938,7 @@ void ValidatePlayersAreInOneGroupOnly() pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -976,7 +976,7 @@ void ValidatePlayersAreInOneGroupOnly() pOtherGroup = NULL; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -1023,7 +1023,7 @@ void ValidatePlayersAreInOneGroupOnly() pOtherGroup = NULL; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -2208,7 +2208,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Strategic5"); { return FALSE; } - Assert( !pGroup->fPlayer ); + Assert( pGroup->usGroupTeam != OUR_TEAM ); if( pGroup->pEnemyGroup->ubIntention == PURSUIT ) { //Lost the player group that he was going to attack. Return to original position. SetThisSectorAsEnemyControlled( pGroup->ubSectorX, pGroup->ubSectorY, 0, TRUE ); @@ -2412,9 +2412,9 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) UINT8 ubNumEnemies; UINT8 ubSectorID; if( !gfQueenAIAwake ) - { //The queen isn't aware the player's presence yet, so she is oblivious to any situations. + {//The queen isn't aware the player's presence yet, so she is oblivious to any situations. - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam == ENEMY_TEAM ) { //Exception case! //In the beginning of the game, a group is sent to A9 after the first battle. If you leave A9, when they arrive, @@ -2441,8 +2441,10 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return FALSE; } } - if( !pGroup->fPlayer ) - { //The enemy group has arrived at a new sector and now controls it. + + if ( pGroup->usGroupTeam == ENEMY_TEAM ) + { + //The enemy group has arrived at a new sector and now controls it. //Look in each of the four directions, and the alertness rating will //determine the chance to detect any players that may exist in that sector. pEnemyGroup = pGroup; @@ -2451,9 +2453,10 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return EvaluateGroupSituation( pEnemyGroup ); } ubSectorID = (UINT8)SECTOR( pEnemyGroup->ubSectorX, pEnemyGroup->ubSectorY ); + if( pEnemyGroup && pEnemyGroup->ubSectorY > 1 && EnemyPermittedToAttackSector( &pEnemyGroup, (UINT8)(ubSectorID - 16) ) ) { - pPlayerGroup = FindMovementGroupInSector( pEnemyGroup->ubSectorX, (UINT8)(pEnemyGroup->ubSectorY-1), TRUE ); + pPlayerGroup = FindMovementGroupInSector( pEnemyGroup->ubSectorX, (UINT8)(pEnemyGroup->ubSectorY - 1), OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { return HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2468,9 +2471,10 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return HandleEmptySectorNoticedByPatrolGroup( pEnemyGroup, (UINT8)(ubSectorID-16) ); } } + if( pEnemyGroup && pEnemyGroup->ubSectorX > 1 && EnemyPermittedToAttackSector( &pEnemyGroup, (UINT8)(ubSectorID - 1) ) ) { - pPlayerGroup = FindMovementGroupInSector( (UINT8)(pEnemyGroup->ubSectorX-1), pEnemyGroup->ubSectorY, TRUE ); + pPlayerGroup = FindMovementGroupInSector( (UINT8)(pEnemyGroup->ubSectorX - 1), pEnemyGroup->ubSectorY, OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { return HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2485,9 +2489,10 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return HandleEmptySectorNoticedByPatrolGroup( pEnemyGroup, (UINT8)(ubSectorID-1) ); } } + if( pEnemyGroup && pEnemyGroup->ubSectorY < 16 && EnemyPermittedToAttackSector( &pEnemyGroup, (UINT8)(ubSectorID + 16) ) ) { - pPlayerGroup = FindMovementGroupInSector( pEnemyGroup->ubSectorX, (UINT8)(pEnemyGroup->ubSectorY+1), TRUE ); + pPlayerGroup = FindMovementGroupInSector( pEnemyGroup->ubSectorX, (UINT8)(pEnemyGroup->ubSectorY + 1), OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { return HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2502,9 +2507,10 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return HandleEmptySectorNoticedByPatrolGroup( pEnemyGroup, (UINT8)(ubSectorID+16) ); } } + if( pEnemyGroup && pEnemyGroup->ubSectorX < 16 && EnemyPermittedToAttackSector( &pEnemyGroup, (UINT8)(ubSectorID + 1) ) ) { - pPlayerGroup = FindMovementGroupInSector( (UINT8)(pEnemyGroup->ubSectorX+1), pEnemyGroup->ubSectorY, TRUE ); + pPlayerGroup = FindMovementGroupInSector( (UINT8)(pEnemyGroup->ubSectorX + 1), pEnemyGroup->ubSectorY, OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { return HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2519,13 +2525,16 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) return HandleEmptySectorNoticedByPatrolGroup( pEnemyGroup, (UINT8)(ubSectorID+1) ); } } + if( !pEnemyGroup ) - { //group deleted. + { + //group deleted. return TRUE; } } - else - { //The player group has arrived at a new sector and now controls it. + else if ( pGroup->usGroupTeam == OUR_TEAM || pGroup->usGroupTeam == MILITIA_TEAM ) + { + //The player group has arrived at a new sector and now controls it. //Look in each of the four directions, and the enemy alertness rating will //determine if the enemy notices that the player is here. //Additionally, there are also stationary enemy groups that may also notice the @@ -2540,7 +2549,7 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) // WDS BAD BUG FIX - 12/25/2008 - some of the +1/-1 in the following were goofed up if( pPlayerGroup->ubSectorY > 1 ) { - pEnemyGroup = FindMovementGroupInSector( pPlayerGroup->ubSectorX, (UINT8)(pPlayerGroup->ubSectorY-1), FALSE ); + pEnemyGroup = FindMovementGroupInSector( pPlayerGroup->ubSectorX, (UINT8)(pPlayerGroup->ubSectorY - 1), ENEMY_TEAM ); if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2556,7 +2565,7 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) } if( pPlayerGroup->ubSectorX < 16 ) { - pEnemyGroup = FindMovementGroupInSector( (UINT8)(pPlayerGroup->ubSectorX+1), pPlayerGroup->ubSectorY, FALSE ); + pEnemyGroup = FindMovementGroupInSector( (UINT8)(pPlayerGroup->ubSectorX + 1), pPlayerGroup->ubSectorY, ENEMY_TEAM ); if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2572,7 +2581,7 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) } if( pPlayerGroup->ubSectorY < 16 ) { - pEnemyGroup = FindMovementGroupInSector( pPlayerGroup->ubSectorX, (UINT8)(pPlayerGroup->ubSectorY+1), FALSE ); + pEnemyGroup = FindMovementGroupInSector( pPlayerGroup->ubSectorX, (UINT8)(pPlayerGroup->ubSectorY + 1), ENEMY_TEAM ); if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2588,7 +2597,7 @@ BOOLEAN StrategicAILookForAdjacentGroups( GROUP *pGroup ) } if( pPlayerGroup->ubSectorX > 1 ) { - pEnemyGroup = FindMovementGroupInSector( (UINT8)(pPlayerGroup->ubSectorX-1), pPlayerGroup->ubSectorY, FALSE ); + pEnemyGroup = FindMovementGroupInSector( (UINT8)(pPlayerGroup->ubSectorX-1), pPlayerGroup->ubSectorY, ENEMY_TEAM ); if( pEnemyGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByPatrolGroup( pPlayerGroup, pEnemyGroup ); @@ -2668,7 +2677,7 @@ void CheckEnemyControlledSector( UINT8 ubSectorID ) if( ubSectorY > 1 && EnemyPermittedToAttackSector( NULL, (UINT8)(ubSectorID - 16) ) ) { /* - pPlayerGroup = FindMovementGroupInSector( ubSectorX, (UINT8)(ubSectorY-1), TRUE ); + pPlayerGroup = FindMovementGroupInSector( ubSectorX, (UINT8)(ubSectorY-1), OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByGarrison( pPlayerGroup, ubSectorID ); @@ -2685,7 +2694,7 @@ void CheckEnemyControlledSector( UINT8 ubSectorID ) if( ubSectorX < 16 && EnemyPermittedToAttackSector( NULL, (UINT8)(ubSectorID + 1) ) ) { /* - pPlayerGroup = FindMovementGroupInSector( (UINT8)(ubSectorX+1), ubSectorY, TRUE ); + pPlayerGroup = FindMovementGroupInSector( (UINT8)(ubSectorX+1), ubSectorY, OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByGarrison( pPlayerGroup, ubSectorID ); @@ -2702,7 +2711,7 @@ void CheckEnemyControlledSector( UINT8 ubSectorID ) if( ubSectorY < 16 && EnemyPermittedToAttackSector( NULL, (UINT8)(ubSectorID + 16) ) ) { /* - pPlayerGroup = FindMovementGroupInSector( ubSectorX, (UINT8)(ubSectorY+1), TRUE ); + pPlayerGroup = FindMovementGroupInSector( ubSectorX, (UINT8)(ubSectorY+1), OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByGarrison( pPlayerGroup, ubSectorID ); @@ -2719,7 +2728,7 @@ void CheckEnemyControlledSector( UINT8 ubSectorID ) if( ubSectorX > 1 && EnemyPermittedToAttackSector( NULL, (UINT8)(ubSectorID - 1) ) ) { /* - pPlayerGroup = FindMovementGroupInSector( (UINT8)(ubSectorX-1), ubSectorY, TRUE ); + pPlayerGroup = FindMovementGroupInSector( (UINT8)(ubSectorX-1), ubSectorY, OUR_TEAM ); if( pPlayerGroup && AttemptToNoticeAdjacentGroupSucceeds() ) { HandlePlayerGroupNoticedByGarrison( pPlayerGroup, ubSectorID ); @@ -3842,7 +3851,7 @@ BOOLEAN LoadStrategicAI( HWFILE hFile ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && pGroup->ubGroupSize >= 16 ) + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->ubGroupSize >= 16 ) { //accident in patrol groups being too large UINT8 ubGetRidOfXTroops = pGroup->ubGroupSize - 10; if( gbWorldSectorZ || pGroup->ubSectorX != gWorldSectorX || pGroup->ubSectorY != gWorldSectorY ) @@ -4112,7 +4121,7 @@ BOOLEAN LoadStrategicAI( HWFILE hFile ) while( pGroup ) { pNext = pGroup->next; - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { if( pGroup->ubSectorX == gModSettings.ubSAISpawnSectorX && pGroup->ubSectorY == gModSettings.ubSAISpawnSectorY && !pGroup->ubPrevX && !pGroup->ubPrevY ) { @@ -4141,7 +4150,7 @@ BOOLEAN LoadStrategicAI( HWFILE hFile ) while( pGroup ) { next = pGroup->next; //store the next node as pGroup could be deleted! - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { if( !pGroup->fBetweenSectors ) { @@ -5087,7 +5096,7 @@ void ExecuteStrategicAIAction( UINT16 usActionCode, INT16 sSectorX, INT16 sSecto //enemies will simply check it out, then leave. if( pSector->ubGarrisonID != NO_GARRISON ) { //sector has a garrison - if( !NumEnemiesInSector( (INT16)SECTORX( ubSectorID ), (INT16)SECTORY( ubSectorID ) ) ) + if ( !NumNonPlayerTeamMembersInSector( (INT16)SECTORX( ubSectorID ), (INT16)SECTORY( ubSectorID ), ENEMY_TEAM ) ) { //no enemies are here if( gArmyComp[ !gGarrisonGroup[ pSector->ubGarrisonID ].ubComposition ].bPriority ) { //the garrison is important @@ -6308,7 +6317,7 @@ void UpgradeAdminsToTroops() pGroup = gpGroupList; while( pGroup ) { - if( pGroup->ubGroupSize && !pGroup->fPlayer && !pGroup->fVehicle) + if ( pGroup->ubGroupSize && pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle ) { Assert ( pGroup->pEnemyGroup ); @@ -6603,9 +6612,9 @@ BOOLEAN PermittedToFillPatrolGroup( INT32 iPatrolID ) void RepollSAIGroup( GROUP *pGroup ) { INT32 i; - Assert( !pGroup->fPlayer ); + Assert( pGroup->usGroupTeam != OUR_TEAM ); - Ensure_RepairedGarrisonGroup( &gGarrisonGroup, &giGarrisonArraySize ); /* added NULL fix, 2007-03-03, Sgt. Kolja */ + Ensure_RepairedGarrisonGroup( &gGarrisonGroup, &giGarrisonArraySize ); /* added NULL fix, 2007-03-03, Sgt. Kolja */ if( GroupAtFinalDestination( pGroup ) ) { EvaluateGroupSituation( pGroup ); @@ -6701,7 +6710,7 @@ void CalcNumTroopsBasedOnComposition( UINT8 *pubNumTroops, UINT8 *pubNumElites, void ConvertGroupTroopsToComposition( GROUP *pGroup, INT32 iCompositionID ) { Assert( pGroup ); - Assert( !pGroup->fPlayer ); + Assert( pGroup->usGroupTeam != OUR_TEAM ); CalcNumTroopsBasedOnComposition( &pGroup->pEnemyGroup->ubNumTroops, &pGroup->pEnemyGroup->ubNumElites, pGroup->ubGroupSize, iCompositionID ); pGroup->pEnemyGroup->ubNumAdmins = 0; pGroup->ubGroupSize = pGroup->pEnemyGroup->ubNumTroops + pGroup->pEnemyGroup->ubNumElites; @@ -6843,8 +6852,9 @@ UINT8 RedirectEnemyGroupsMovingThroughSector( UINT8 ubSectorX, UINT8 ubSectorY ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer && pGroup->ubMoveType == ONE_WAY ) - { //check the waypoint list + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->ubMoveType == ONE_WAY ) + { + //check the waypoint list if( GroupWillMoveThroughSector( pGroup, ubSectorX, ubSectorY ) ) { //extract the group's destination. diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 639c56e2..254c361a 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -175,7 +175,7 @@ UINT8 CreateNewPlayerGroupDepartingFromSector( UINT8 ubSectorX, UINT8 ubSectorY pNew->ubSectorX = pNew->ubNextX = ubSectorX; pNew->ubSectorY = pNew->ubNextY = ubSectorY; pNew->ubOriginalSector = (UINT8)SECTOR( ubSectorX, ubSectorY ); - pNew->fPlayer = TRUE; + pNew->usGroupTeam = OUR_TEAM; pNew->ubMoveType = ONE_WAY; pNew->ubNextWaypointID = 0; pNew->ubFatigueLevel = 100; @@ -206,7 +206,7 @@ UINT8 CreateNewVehicleGroupDepartingFromSector( UINT8 ubSectorX, UINT8 ubSectorY pNew->ubFatigueLevel = 100; pNew->ubRestAtFatigueLevel = 0; pNew->fVehicle = TRUE; - pNew->fPlayer = TRUE; + pNew->usGroupTeam = OUR_TEAM; pNew->pPlayerList = NULL; pNew->ubCreatedSectorID = pNew->ubOriginalSector; pNew->ubSectorIDOfLastReassignment = 255; @@ -226,7 +226,7 @@ BOOLEAN AddPlayerToGroup( UINT8 ubGroupID, SOLDIERTYPE *pSoldier ) Assert( pGroup ); pPlayer = (PLAYERGROUP*)MemAlloc( sizeof( PLAYERGROUP ) ); Assert( pPlayer ); - AssertMsg( pGroup->fPlayer, "Attempting AddPlayerToGroup() on an ENEMY group!"); + AssertMsg( pGroup->usGroupTeam == OUR_TEAM, "Attempting AddPlayerToGroup() on an ENEMY group!" ); pPlayer->pSoldier = pSoldier; pPlayer->ubProfileID = pSoldier->ubProfile; pPlayer->ubID = pSoldier->ubID; @@ -289,7 +289,7 @@ BOOLEAN RemoveAllPlayersFromPGroup( GROUP *pGroup ) { PLAYERGROUP *curr; - AssertMsg( pGroup->fPlayer, "Attempting RemovePlayerFromGroup() on an ENEMY group!"); + AssertMsg( pGroup->usGroupTeam == OUR_TEAM, "Attempting RemovePlayerFromGroup() on an ENEMY group!" ); curr = pGroup->pPlayerList; while( curr ) @@ -320,7 +320,7 @@ BOOLEAN RemoveAllPlayersFromPGroup( GROUP *pGroup ) BOOLEAN RemovePlayerFromPGroup( GROUP *pGroup, SOLDIERTYPE *pSoldier ) { PLAYERGROUP *prev, *curr; - AssertMsg( pGroup->fPlayer, "Attempting RemovePlayerFromGroup() on an ENEMY group!" ); + AssertMsg( pGroup->usGroupTeam == OUR_TEAM, "Attempting RemovePlayerFromGroup() on an ENEMY group!" ); curr = pGroup->pPlayerList; @@ -430,7 +430,7 @@ BOOLEAN GroupReversingDirectionsBetweenSectors( GROUP *pGroup, UINT8 ubSectorX, pGroup->ubSectorX = pGroup->ubPrevX; pGroup->ubSectorY = pGroup->ubPrevY; - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { // ARM: because we've changed the group's ubSectoryX and ubSectorY, we must now also go and change the sSectorX and // sSectorY of all the soldiers in this group so that they stay in synch. Otherwise pathing and movement problems @@ -451,7 +451,7 @@ BOOLEAN GroupReversingDirectionsBetweenSectors( GROUP *pGroup, UINT8 ubSectorX, //Post the replacement event to move back to the previous sector! AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( ( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY ) > GetWorldTotalMin( ) ) { @@ -551,7 +551,7 @@ BOOLEAN AddWaypointToPGroup( GROUP* pGroup, UINT8 ubSectorX, UINT8 ubSectorY ) / { if( GroupReversingDirectionsBetweenSectors( pGroup, ubSectorX, ubSectorY, TRUE ) ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { // because we reversed, we must add the new current sector back at the head of everyone's mercpath AddSectorToFrontOfMercPathForAllSoldiersInGroup( pGroup, pGroup->ubSectorX, pGroup->ubSectorY ); @@ -640,7 +640,7 @@ BOOLEAN AddWaypointToPGroup( GROUP* pGroup, UINT8 ubSectorX, UINT8 ubSectorY ) / } } - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { PLAYERGROUP *curr; //Also, nuke any previous "tactical traversal" information. @@ -731,7 +731,7 @@ GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmin pNew->ubSectorX = (UINT8)SECTORX( uiSector ); pNew->ubSectorY = (UINT8)SECTORY( uiSector ); pNew->ubOriginalSector = (UINT8)uiSector; - pNew->fPlayer = FALSE; + pNew->usGroupTeam = ENEMY_TEAM; pNew->ubMoveType = CIRCULAR; pNew->ubNextWaypointID = 0; pNew->ubFatigueLevel = 100; @@ -979,7 +979,7 @@ void PrepareForPreBattleInterface( GROUP *pPlayerDialogGroup, GROUP *pInitiating SetMusicMode( MUSIC_TACTICAL_ENEMYPRESENT ); if( gfTacticalTraversal && pInitiatingBattleGroup == gpTacticalTraversalGroup || - pInitiatingBattleGroup && !pInitiatingBattleGroup->fPlayer && + pInitiatingBattleGroup && pInitiatingBattleGroup->usGroupTeam != OUR_TEAM && pInitiatingBattleGroup->ubSectorX == gWorldSectorX && pInitiatingBattleGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ ) { // At least say quote.... @@ -1058,12 +1058,15 @@ BOOLEAN CheckConditionsForBattle( GROUP *pGroup ) BOOLEAN fBloodCatAmbush = FALSE; if( gfWorldLoaded ) - { //look for people arriving in the currently loaded sector. This handles reinforcements. - curr = FindMovementGroupInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, TRUE ); + { + //look for people arriving in the currently loaded sector. This handles reinforcements. + curr = FindMovementGroupInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, OUR_TEAM ); + if( !gbWorldSectorZ && PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, gbWorldSectorZ ) && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && curr ) - { //Reinforcements have arrived! + { + //Reinforcements have arrived! #ifdef JA2BETAVERSION if( guiCurrentScreen == AIVIEWER_SCREEN ) { @@ -1088,7 +1091,7 @@ BOOLEAN CheckConditionsForBattle( GROUP *pGroup ) curr = gpGroupList; while( curr ) { - if( curr->fPlayer && curr->ubGroupSize ) + if ( curr->usGroupTeam == OUR_TEAM && curr->ubGroupSize ) { if( !curr->fBetweenSectors ) { @@ -1134,11 +1137,11 @@ BOOLEAN CheckConditionsForBattle( GROUP *pGroup ) curr = curr->next; } - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayerDialogGroup = pGroup; - if( NumEnemiesInSector( pGroup->ubSectorX, pGroup->ubSectorY ) && + if ( NumNonPlayerTeamMembersInSector( pGroup->ubSectorX, pGroup->ubSectorY, ENEMY_TEAM ) && (!IsGroupTheHelicopterGroup( pGroup ) || (gGameSettings.fOptions[ TOPTION_SILENT_SKYRIDER ] == FALSE))) { fBattlePending = TRUE; @@ -1276,7 +1279,7 @@ void TriggerPrebattleInterface( UINT8 ubResult ) void DeployGroupToSector( GROUP *pGroup ) { Assert( pGroup ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { //Update the sector positions of the players... return; @@ -1384,7 +1387,7 @@ BOOLEAN AttemptToMergeSeparatedGroups( GROUP *pGroup, BOOLEAN fDecrementTraversa return FALSE; #if 0 //First, make sure that we have a player group that isn't empty - if( !pGroup->fPlayer || !pGroup->ubGroupSize ) + if( pGroup->usGroupTeam != OUR_TEAM || !pGroup->ubGroupSize ) return FALSE; //If our group doesn't have any traversals left to be allowed to merge, then no chance. if( !pGroup->pPlayerList->pSoldier->ubNumTraversalsAllowedToMerge ) @@ -1417,7 +1420,7 @@ BOOLEAN AttemptToMergeSeparatedGroups( GROUP *pGroup, BOOLEAN fDecrementTraversa { //This group is looking for another group to merge with. while( curr ) { - if( curr != pGroup && curr->fPlayer && curr->ubGroupSize ) + if( curr != pGroup && curr->usGroupTeam == OUR_TEAM && curr->ubGroupSize ) { //We have a player group with members if( curr->pPlayerList->pSoldier->ubNumTraversalsAllowedToMerge ) { //This group is allowed to merge @@ -1473,10 +1476,11 @@ BOOLEAN AttemptToMergeSeparatedGroups( GROUP *pGroup, BOOLEAN fDecrementTraversa } } else if( pGroup->ubGroupSize < NUMBER_OF_SOLDIERS_PER_SQUAD ) - { //Search for other groups looking to join our group. + { + //Search for other groups looking to join our group. while( curr ) { - if( curr != pGroup && curr->fPlayer && curr->ubGroupSize ) + if( curr != pGroup && curr->usGroupTeam == OUR_TEAM && curr->ubGroupSize ) { //We have a player group with members if( curr->pPlayerList->pSoldier->ubNumTraversalsAllowedToMerge ) { //This group is allowed to merge @@ -1540,7 +1544,7 @@ void AwardExperienceForTravelling( GROUP * pGroup ) UINT32 uiPoints; UINT32 uiCarriedPercent; - if ( !pGroup || !pGroup->fPlayer ) + if ( !pGroup || pGroup->usGroupTeam != OUR_TEAM ) { return; } @@ -1674,7 +1678,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe return; } - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { //Set the fact we have visited the sector curr = pGroup->pPlayerList; @@ -1721,7 +1725,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe //Check for exception cases which if( gTacticalStatus.bBoxingState != NOT_BOXING ) { - if( !pGroup->fPlayer && pGroup->ubNextX == 5 && pGroup->ubNextY == 4 && pGroup->ubSectorZ == 0 ) + if ( pGroup->usGroupTeam != OUR_TEAM && pGroup->ubNextX == 5 && pGroup->ubNextY == 4 && pGroup->ubSectorZ == 0 ) { fExceptionQueue = TRUE; } @@ -1730,7 +1734,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe //First check if the group arriving is going to queue another battle. //NOTE: We can't have more than one battle ongoing at a time. if( fExceptionQueue || fCheckForBattle && gTacticalStatus.fEnemyInSector && - FindMovementGroupInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, TRUE ) && + FindMovementGroupInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, OUR_TEAM ) && (pGroup->ubNextX != gWorldSectorX || pGroup->ubNextY != gWorldSectorY || gbWorldSectorZ > 0 ) || #ifdef JA2UB //Ja25: NO meanwhiles @@ -1764,7 +1768,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe if( !AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ) ) AssertMsg( 0, "Failed to add movement event." ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY > GetWorldTotalMin( ) ) { @@ -1776,7 +1780,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe } // Flugente: disease - if ( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { PopulationMove( pGroup->ubSectorX, pGroup->ubSectorY, pGroup->ubNextX, pGroup->ubNextY, pGroup->ubGroupSize ); } @@ -1789,11 +1793,11 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe pGroup->ubNextX = 0; pGroup->ubNextY = 0; - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( pGroup->ubSectorZ == 0 ) { - SectorInfo[ SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ) ].bLastKnownEnemies = NumEnemiesInSector( pGroup->ubSectorX, pGroup->ubSectorY ); + SectorInfo[SECTOR( pGroup->ubSectorX, pGroup->ubSectorY )].bLastKnownEnemies = NumNonPlayerTeamMembersInSector( pGroup->ubSectorX, pGroup->ubSectorY, ENEMY_TEAM ); } // award life 'experience' for travelling, based on travel time! @@ -1835,7 +1839,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe fMapScreenBottomDirty = TRUE; // if a player group - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { // if this is the last sector along player group's movement path (no more waypoints) if ( GroupAtFinalDestination( pGroup ) ) @@ -2115,7 +2119,7 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe #ifdef JA2UB /* //if the enemy group is at its final destination - if( !pGroup->fPlayer && GroupAtFinalDestination( pGroup ) ) + if( pGroup->usGroupTeam != OUR_TEAM && GroupAtFinalDestination( pGroup ) ) { // Check to see if this is an AI sector INT16 sJa25SaiSectorValue = GetJA25SectorID( pGroup->ubSectorX, pGroup->ubSectorY, pGroup->ubSectorZ ); @@ -2165,7 +2169,7 @@ void HandleNonCombatGroupArrival( GROUP *pGroup, BOOLEAN fMainGroup, BOOLEAN fNe } #endif - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { //The group will always exist after the AI was processed. @@ -2271,7 +2275,7 @@ void PrepareGroupsForSimultaneousArrival() while( pGroup ) { //For all of the groups that haven't arrived yet, determine which one is going to take the longest. if( pGroup != gpPendingSimultaneousGroup - && pGroup->fPlayer + && pGroup->usGroupTeam == OUR_TEAM && pGroup->fBetweenSectors && pGroup->ubNextX == gpPendingSimultaneousGroup->ubSectorX && pGroup->ubNextY == gpPendingSimultaneousGroup->ubSectorY && @@ -2295,7 +2299,7 @@ void PrepareGroupsForSimultaneousArrival() SetGroupArrivalTime( pGroup, uiLatestArrivalTime ); AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY > GetWorldTotalMin( ) ) { @@ -2338,7 +2342,7 @@ void PrepareGroupsForSimultaneousArrival() AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY > GetWorldTotalMin( ) ) { @@ -2373,7 +2377,7 @@ BOOLEAN PossibleToCoordinateSimultaneousGroupArrivals( GROUP *pFirstGroup ) pGroup = gpGroupList; while( pGroup ) { - if( pGroup != pFirstGroup && pGroup->fPlayer && pGroup->fBetweenSectors && + if ( pGroup != pFirstGroup && pGroup->usGroupTeam == OUR_TEAM && pGroup->fBetweenSectors && pGroup->ubNextX == pFirstGroup->ubSectorX && pGroup->ubNextY == pFirstGroup->ubSectorY && !(pGroup->uiFlags & GROUPFLAG_SIMULTANEOUSARRIVAL_CHECKED) && !IsGroupTheHelicopterGroup( pGroup ) ) @@ -2454,7 +2458,7 @@ void DelayEnemyGroupsIfPathsCross( GROUP *pPlayerGroup ) pGroup = gpGroupList; while( pGroup ) { - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { //then check to see if this group will arrive in next sector before the player group. if( pGroup->uiArrivalTime < pPlayerGroup->uiArrivalTime ) @@ -2581,7 +2585,7 @@ void InitiateGroupMovementToNextSector( GROUP *pGroup ) if ( !pGroup->ubSectorZ ) { BOOLEAN fCalcRegularTime = TRUE; - if ( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { //Determine if the enemy group is "sleeping". If so, then simply delay their arrival time by the amount of time //they are going to be sleeping for. @@ -2611,7 +2615,7 @@ void InitiateGroupMovementToNextSector( GROUP *pGroup ) if ( pGroup->uiTraverseTime == 0xffffffff ) { AssertMsg( 0, String( "Group %d (%s) attempting illegal move from %c%d to %c%d (%s).", - pGroup->ubGroupID, (pGroup->fPlayer) ? "Player" : "AI", + pGroup->ubGroupID, (pGroup->usGroupTeam == OUR_TEAM) ? "Player" : "AI", pGroup->ubSectorY + 'A' - 1, pGroup->ubSectorX, pGroup->ubNextY + 'A' - 1, pGroup->ubNextX, gszTerrain[SectorInfo[ubSector].ubTraversability[ubDirection]] ) ); } @@ -2675,7 +2679,7 @@ void InitiateGroupMovementToNextSector( GROUP *pGroup ) AssertMsg( 0, "Failed to add movement event." ); //For the case of player groups, we need to update the information of the soldiers. - if ( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { PLAYERGROUP *curr; @@ -2803,7 +2807,7 @@ void RemovePGroup( GROUP *pGroup ) DeleteStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->ubGroupID ); //Determine what type of group we have (because it requires different methods) - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { //Remove player group PLAYERGROUP *pPlayer; while( pGroup->pPlayerList ) @@ -3084,7 +3088,7 @@ INT32 FindTravelTimeBetweenWaypoints( WAYPOINT * pSource, WAYPOINT * pDest, GROU if( iThisCostInTime == 0xffffffff ) { AssertMsg( 0, String("Group %d (%s) attempting illegal move from sector %d, dir %d (%s).", - pGroup->ubGroupID, ( pGroup->fPlayer ) ? "Player" : "AI", + pGroup->ubGroupID, (pGroup->usGroupTeam == OUR_TEAM) ? "Player" : "AI", ubCurrentSector, ubDirection, gszTerrain[SectorInfo[ubCurrentSector].ubTraversability[ubDirection]] ) ); } @@ -3164,7 +3168,7 @@ INT32 GetSectorMvtTimeForGroup( UINT8 ubSector, UINT8 ubDirection, GROUP *pGroup if( iTraverseTime < iBestTraverseTime ) iBestTraverseTime = iTraverseTime; - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { curr = pGroup->pPlayerList; while( curr ) @@ -3248,7 +3252,7 @@ INT32 GetSectorMvtTimeForGroup( UINT8 ubSector, UINT8 ubDirection, GROUP *pGroup /////////////////////////////////////////////////////////////////////////////// // SANDRO - STOMP traits - ranger reduces time needed for travelling around - if( pGroup->fPlayer && !fAir && gGameOptions.fNewTraitSystem) + if ( pGroup->usGroupTeam == OUR_TEAM && !fAir && gGameOptions.fNewTraitSystem ) { // see if we have any ranger here UINT8 ubRangerHere = 0; @@ -3302,7 +3306,7 @@ INT32 GetSectorMvtTimeForGroup( UINT8 ubSector, UINT8 ubDirection, GROUP *pGroup } } } - else if ( !pGroup->fPlayer ) + else if ( pGroup->usGroupTeam == ENEMY_TEAM ) { // Flugente: enemy generals can speed up the AI decision process (justification: the generals are the ones planning the military operations, so if theay are around, the army is more efficient) FLOAT dEnemyGeneralsSpeedupFactor = 1.0f; @@ -3329,7 +3333,7 @@ UINT8 PlayerMercsInSector( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ ) pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer && !pGroup->fBetweenSectors) + if ( pGroup->usGroupTeam == OUR_TEAM && !pGroup->fBetweenSectors ) { if ( pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && pGroup->ubSectorZ == ubSectorZ ) { @@ -3359,7 +3363,7 @@ UINT8 PlayerGroupsInSector( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ ) pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer && !pGroup->fBetweenSectors) + if ( pGroup->usGroupTeam == OUR_TEAM && !pGroup->fBetweenSectors ) { if ( pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && pGroup->ubSectorZ == ubSectorZ ) { @@ -3442,8 +3446,9 @@ void HandleArrivalOfReinforcements( GROUP *pGroup ) INT32 iNumEnemiesInSector; INT32 cnt; - if( pGroup->fPlayer ) - { //We don't have to worry about filling up the player slots, because it is impossible + if ( pGroup->usGroupTeam == OUR_TEAM ) + { + //We don't have to worry about filling up the player slots, because it is impossible //to have more players in the game than the number of slots available for the player. PLAYERGROUP *pPlayer; UINT8 ubStrategicInsertionCode; @@ -3490,9 +3495,10 @@ void HandleArrivalOfReinforcements( GROUP *pGroup ) ResetNumSquadleadersInArmyGroup(); // added by SANDRO AddPossiblePendingEnemiesToBattle(); } + //Update the known number of enemies in the sector. pSector = &SectorInfo[ SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ) ]; - iNumEnemiesInSector = NumEnemiesInSector( pGroup->ubSectorX, pGroup->ubSectorY ); + iNumEnemiesInSector = NumNonPlayerTeamMembersInSector( pGroup->ubSectorX, pGroup->ubSectorY, ENEMY_TEAM ); if( iNumEnemiesInSector ) { if( pSector->bLastKnownEnemies >= 0 ) @@ -3539,7 +3545,7 @@ BOOLEAN PlayersBetweenTheseSectors( INT16 sSource, INT16 sDest, INT32 *iCountEnt while( curr ) { // if player group - if( curr->fPlayer == TRUE ) + if ( curr->usGroupTeam == OUR_TEAM ) { fHelicopterGroup = IsGroupTheHelicopterGroup( curr ); @@ -3618,7 +3624,7 @@ void MoveAllGroupsInCurrentSectorToSector( UINT8 ubSectorX, UINT8 ubSectorY, UIN pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && + if ( pGroup->usGroupTeam == OUR_TEAM && pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && pGroup->ubSectorZ == gbWorldSectorZ && !pGroup->fBetweenSectors ) { //This player group is in the currently loaded sector... pGroup->ubSectorX = ubSectorX; @@ -3697,7 +3703,7 @@ void SetGroupPosition( UINT8 ubNextX, UINT8 ubNextY, UINT8 ubPrevX, UINT8 ubPrev AddWaypointToPGroup( pGroup, pGroup->ubNextX, pGroup->ubNextY ); //now, if player group set all grunts in the group to be between secotrs - if( pGroup->fPlayer == TRUE ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -3749,7 +3755,7 @@ BOOLEAN SaveStrategicMovementGroupsToSaveGameFile( HWFILE hFile ) // // If its a player group - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { //if there is a player list, add it if( pGroup->ubGroupSize ) @@ -3784,7 +3790,8 @@ BOOLEAN SaveStrategicMovementGroupsToSaveGameFile( HWFILE hFile ) return( TRUE ); } - +#include "SaveLoadGame.h" +#include "GameVersion.h" BOOLEAN LoadStrategicMovementGroupsFromSavedGameFile( HWFILE hFile ) { @@ -3813,9 +3820,9 @@ BOOLEAN LoadStrategicMovementGroupsFromSavedGameFile( HWFILE hFile ) } pGroup = gpGroupList; - + //loop through all the nodes and add them to the LL - for( cnt=0; cnt< uiNumberOfGroups; cnt++ ) + for( cnt=0; cnt< uiNumberOfGroups; ++cnt ) { //allocate memory for the node pTemp = (GROUP *) MemAlloc( sizeof( GROUP )); @@ -3831,11 +3838,28 @@ BOOLEAN LoadStrategicMovementGroupsFromSavedGameFile( HWFILE hFile ) return( FALSE ); } + // Flugente: Up to now, GROUPs were either player-controlled (fPlayer = TRUE) or enemy-controlled (fPlayer = FALSE). + // As a result, no other team could have any travelling groups (militia, civilians, creatures...) + // I've changed this - instead of BOOLEAN fPlayer; there now is UINT8 usGroupTeam; + // This doesn't mess with the struct size, as BOOLEAN has the same size as UINT8 here. + // However, + if ( guiCurrentSaveGameVersion < STRATEGIC_TEAM_GROUPS ) + { + // TODO + if ( pTemp->usGroupTeam == 0 ) + pTemp->usGroupTeam = ENEMY_TEAM; + else if ( pTemp->usGroupTeam == 1 ) + pTemp->usGroupTeam = OUR_TEAM; + //this shouldn't be happening... + else + Assert( 0 ); + } + // // Add either the pointer or the linked list. // - if( pTemp->fPlayer ) + if ( pTemp->usGroupTeam == OUR_TEAM ) { //if there is a player list, add it if( pTemp->ubGroupSize ) @@ -3878,7 +3902,7 @@ BOOLEAN LoadStrategicMovementGroupsFromSavedGameFile( HWFILE hFile ) pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { if( pGroup->ubGroupSize ) { @@ -4097,7 +4121,7 @@ void CheckMembersOfMvtGroupAndComplainAboutBleeding( SOLDIERTYPE *pSoldier ) } // player controlled group? - if( pGroup->fPlayer == FALSE ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { return; } @@ -4271,8 +4295,9 @@ void CalculateGroupRetreatSector( GROUP *pGroup ) return; } - if( pGroup->fPlayer ) - { //update the previous sector for the mercs + if ( pGroup->usGroupTeam == OUR_TEAM ) + { + //update the previous sector for the mercs PLAYERGROUP *pPlayer; pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -4327,7 +4352,7 @@ void RetreatGroupToPreviousSector( GROUP *pGroup ) if( pGroup->uiTraverseTime == 0xffffffff ) { AssertMsg( 0, String("Group %d (%s) attempting illegal move from %c%d to %c%d (%s).", - pGroup->ubGroupID, ( pGroup->fPlayer ) ? "Player" : "AI", + pGroup->ubGroupID, (pGroup->usGroupTeam == OUR_TEAM) ? "Player" : "AI", pGroup->ubSectorY+'A', pGroup->ubSectorX, pGroup->ubNextY+'A', pGroup->ubNextX, gszTerrain[SectorInfo[ubSector].ubTraversability[ubDirection]] ) ); } @@ -4355,7 +4380,7 @@ void RetreatGroupToPreviousSector( GROUP *pGroup ) AssertMsg( 0, "Failed to add movement event." ); //For the case of player groups, we need to update the information of the soldiers. - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { PLAYERGROUP *curr; curr = pGroup->pPlayerList; @@ -4377,26 +4402,29 @@ void RetreatGroupToPreviousSector( GROUP *pGroup ) } } -GROUP* FindMovementGroupInSector( UINT8 ubSectorX, UINT8 ubSectorY, BOOLEAN fPlayer ) +GROUP* FindMovementGroupInSector( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubTeam ) { GROUP *pGroup; pGroup = gpGroupList; while( pGroup ) { - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == ubTeam && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && !pGroup->ubSectorZ ) { - // NOTE: These checks must always match the INVOLVED group checks in PBI!!! - if( fPlayer && pGroup->ubGroupSize && !pGroup->fBetweenSectors && - pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && !pGroup->ubSectorZ && - !GroupHasInTransitDeadOrPOWMercs( pGroup ) && - ( !IsGroupTheHelicopterGroup( pGroup ) || !fHelicopterIsAirBorne ) ) + // special checks for player groups + if ( ubTeam == OUR_TEAM ) { - return pGroup; + // NOTE: These checks must always match the INVOLVED group checks in PBI!!! + if ( pGroup->ubGroupSize && !pGroup->fBetweenSectors && + !GroupHasInTransitDeadOrPOWMercs( pGroup ) && + (!IsGroupTheHelicopterGroup( pGroup ) || !fHelicopterIsAirBorne) ) + { + return pGroup; + } } + else + return pGroup; } - else if( !fPlayer && pGroup->ubSectorX == ubSectorX && pGroup->ubSectorY == ubSectorY && !pGroup->ubSectorZ ) - return pGroup; - + pGroup = pGroup->next; } return NULL; @@ -4449,8 +4477,8 @@ WAYPOINT *GetFinalWaypoint( GROUP *pGroup ) //The sector supplied resets ALL enemy groups in the sector specified. See comments in -//ResetMovementForEnemyGroup() for more details on what the resetting does. -void ResetMovementForEnemyGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ) +//ResetMovementForNonPlayerGroup() for more details on what the resetting does. +void ResetMovementForNonPlayerGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ) { GROUP *pGroup, *next; INT16 sSectorX, sSectorY, sSectorZ; @@ -4460,11 +4488,11 @@ void ResetMovementForEnemyGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ) while( pGroup ) { next = pGroup->next; - if( !pGroup->fPlayer ) + if ( pGroup->usGroupTeam != OUR_TEAM ) { if( pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { - ResetMovementForEnemyGroup( pGroup ); + ResetMovementForNonPlayerGroup( pGroup ); } } pGroup = next; @@ -4477,13 +4505,14 @@ void ResetMovementForEnemyGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ) //then after this function is called, then that group would be 0% of the way from //sector A10 to A11. In no way does this function effect the strategic path for //the group. -void ResetMovementForEnemyGroup( GROUP *pGroup ) +void ResetMovementForNonPlayerGroup( GROUP *pGroup ) { //Validate that the group is an enemy group and that it is moving. - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { return; } + if( !pGroup->fBetweenSectors || !pGroup->ubNextX || !pGroup->ubNextY ) { //Reset the group's assignment by moving it to the group's original sector as it's pending group. @@ -4527,7 +4556,7 @@ void UpdatePersistantGroupsFromOldSave( UINT32 uiSavedGameVersion ) // create mvt groups pGroup = GetGroup( (UINT8)cnt ); - if( pGroup != NULL && pGroup->fPlayer ) + if ( pGroup != NULL && pGroup->usGroupTeam == OUR_TEAM ) { pGroup->fPersistant = TRUE; } @@ -4826,7 +4855,7 @@ void RandomizePatrolGroupLocation( GROUP *pGroup ) //return; //disabled for now - Assert( !pGroup->fPlayer ); + Assert( pGroup->usGroupTeam != OUR_TEAM ); Assert( pGroup->ubMoveType == ENDTOEND_FORWARDS ); Assert( pGroup->pEnemyGroup->ubIntention == PATROL ); @@ -5012,7 +5041,7 @@ BOOLEAN TestForBloodcatAmbush( GROUP *pGroup ) // An ambush is occuring? if( !fAlreadyAmbushed && PlacementType != BLOODCAT_PLACEMENT_STATIC && pSector->bBloodCats > 0 && - !pGroup->fVehicle && !NumEnemiesInSector( pGroup->ubSectorX, pGroup->ubSectorY ) ) + !pGroup->fVehicle && !NumNonPlayerTeamMembersInSector( pGroup->ubSectorX, pGroup->ubSectorY, ENEMY_TEAM ) ) { /////////////////////////////////////////////////////////////////////////////////////////// // SANDRO - STOMP traits - Scouting prevents the ambush of bloodcats @@ -5206,7 +5235,7 @@ void PlayerGroupArrivedSafelyInSector( GROUP *pGroup, BOOLEAN fCheckForNPCs ) Assert( pGroup ); - Assert( pGroup->fPlayer ); + Assert( pGroup->usGroupTeam == OUR_TEAM ); // if we haven't already checked for NPCs, and the group isn't empty @@ -5257,7 +5286,7 @@ BOOLEAN HandlePlayerGroupEnteringSectorToCheckForNPCsOfNote( GROUP *pGroup ) Assert( pGroup ); - Assert( pGroup->fPlayer ); + Assert( pGroup->usGroupTeam == OUR_TEAM ); // nobody in the group (perfectly legal with the chopper) if ( pGroup->pPlayerList == NULL ) @@ -5514,7 +5543,7 @@ BOOLEAN ValidateGroups( GROUP *pGroup ) ValidatePlayersAreInOneGroupOnly(); #endif - if( !pGroup->fPlayer && !pGroup->ubGroupSize ) + if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->ubGroupSize ) { isValid = FALSE; @@ -5585,7 +5614,7 @@ GROUP* CreateNewEnemyGroupDepartingFromSectorUsingZLevel( UINT32 uiSector, UINT8 pNew->ubSectorY = (UINT8)SECTORY( uiSector ); pNew->ubSectorZ = ubSectorZ; pNew->ubOriginalSector = (UINT8)uiSector; - pNew->fPlayer = FALSE; + pNew->usGroupTeam = ENEMY_TEAM; pNew->ubMoveType = CIRCULAR; pNew->ubNextWaypointID = 0; pNew->ubFatigueLevel = 100; diff --git a/Strategic/Strategic Movement.h b/Strategic/Strategic Movement.h index 98c9cecc..2ad441c5 100644 --- a/Strategic/Strategic Movement.h +++ b/Strategic/Strategic Movement.h @@ -95,7 +95,7 @@ typedef struct ENEMYGROUP typedef struct GROUP { BOOLEAN fDebugGroup; //for testing purposes -- handled differently in certain cases. - BOOLEAN fPlayer; //set if this is a player controlled group. + UINT8 usGroupTeam; // the team that controls this group - 0 for OUR_TEAM, 1 for ENEMY_TEAM.. BOOLEAN fVehicle; //vehicle controlled group? BOOLEAN fPersistant; //This flag when set prevents the group from being automatically deleted when it becomes empty. UINT8 ubGroupID; //the unique ID of the group (used for hooking into events and SOLDIERTYPE) @@ -266,7 +266,7 @@ BOOLEAN AttemptToMergeSeparatedGroups( GROUP *pGroup, BOOLEAN fDecrementTraversa //blindly determines where to move the group. void RetreatGroupToPreviousSector( GROUP *pGroup ); -GROUP* FindMovementGroupInSector( UINT8 ubSectorX, UINT8 ubSectorY, BOOLEAN fPlayer ); +GROUP* FindMovementGroupInSector( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubTeam ); BOOLEAN GroupAtFinalDestination( GROUP *pGroup ); @@ -280,8 +280,8 @@ void RemoveGroupFromList( GROUP *pGroup ); WAYPOINT *GetFinalWaypoint( GROUP *pGroup ); -void ResetMovementForEnemyGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ); -void ResetMovementForEnemyGroup( GROUP *pGroup ); +void ResetMovementForNonPlayerGroupsInLocation( UINT8 ubSectorX, UINT8 ubSectorY ); +void ResetMovementForNonPlayerGroup( GROUP *pGroup ); //Determines if any particular group WILL be moving through a given sector given it's current //position in the route and TREATS the pGroup->ubMoveType as ONE_WAY EVEN IF IT ISN'T. If the diff --git a/Strategic/Strategic Pathing.cpp b/Strategic/Strategic Pathing.cpp index c5040c12..d0db7b29 100644 --- a/Strategic/Strategic Pathing.cpp +++ b/Strategic/Strategic Pathing.cpp @@ -210,7 +210,7 @@ INT32 FindStratPath(INT16 sStart, INT16 sDestination, INT16 sMvtGroupNumber, BOO // for player groups only! pGroup = GetGroup( ( UINT8 )sMvtGroupNumber ); - if ( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { // if player is holding down SHIFT key, find the shortest route instead of the quickest route! if ( _KeyDown( SHIFT ) ) @@ -1569,7 +1569,7 @@ void RebuildWayPointsForGroupPath( PathStPtr pHeadOfPath, INT16 sMvtGroup ) RemoveGroupWaypoints( ( UINT8 )sMvtGroup ); - if( pGroup->fPlayer ) + if ( pGroup->usGroupTeam == OUR_TEAM ) { #ifdef BETA_VERSION VerifyAllMercsInGroupAreOnSameSquad( pGroup ); @@ -1592,7 +1592,7 @@ void RebuildWayPointsForGroupPath( PathStPtr pHeadOfPath, INT16 sMvtGroup ) { // and it's a player group, and it's between sectors // NOTE: AI groups never reverse direction between sectors, Kris cheats & teleports them back to their current sector! - if( pGroup->fPlayer && pGroup->fBetweenSectors ) + if ( pGroup->usGroupTeam == OUR_TEAM && pGroup->fBetweenSectors ) { // send the group right back to its current sector by reversing directions GroupReversingDirectionsBetweenSectors( pGroup, pGroup->ubSectorX, pGroup->ubSectorY, FALSE ); @@ -1916,7 +1916,7 @@ PathStPtr GetGroupMercPathPtr( GROUP *pGroup ) Assert( pGroup ); // must be a player group! - Assert( pGroup->fPlayer ); + Assert( pGroup->usGroupTeam == OUR_TEAM ); if( pGroup->fVehicle ) { diff --git a/Strategic/Town Militia.cpp b/Strategic/Town Militia.cpp index 8381d00f..666e1687 100644 --- a/Strategic/Town Militia.cpp +++ b/Strategic/Town Militia.cpp @@ -924,7 +924,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3"); pSectorInfo = &( SectorInfo[ SECTOR(sCurrentX, sCurrentY) ] ); // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. This sector cannot generate militia anyway. iCounter++; @@ -981,7 +981,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3"); // if sector has enemies or hasn't already been taken at least once, then if ( !SectorInfo[ SECTOR(sCurrentX, sCurrentY) ].fSurfaceWasEverPlayerControlled || - NumEnemiesInSector( sCurrentX, sCurrentY ) > 0 ) + NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) { // skip the rest. This sector cannot generate militia anyway. iCounter++; diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 4d739c42..e0f4a60a 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -15228,7 +15228,7 @@ void HandleNewDestConfirmation( INT16 sMapX, INT16 sMapY ) if( fPlotForHelicopter ) { // if there are no enemies in destination sector, or we don't know - if ( ( NumEnemiesInSector( sMapX, sMapY ) == 0 ) || + if ( (NumNonPlayerTeamMembersInSector( sMapX, sMapY, ENEMY_TEAM ) == 0) || ( WhatPlayerKnowsAboutEnemiesInSector( sMapX, sMapY ) == KNOWS_NOTHING ) ) { // no problem diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index 200c9757..0d67aa5f 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -1890,7 +1890,7 @@ UINT8 GetTownSectorsUnderControl( INT8 bTownId ) if( ( StrategicMap[ usSector ].bNameId == bTownId ) && ( StrategicMap[ usSector ].fEnemyControlled == FALSE ) && - ( NumEnemiesInSector( ( INT16 )iCounterA, ( INT16 )iCounterB ) == 0 ) ) + (NumNonPlayerTeamMembersInSector( (INT16)iCounterA, (INT16)iCounterB, ENEMY_TEAM ) == 0) ) { ++ubSectorsControlled; } @@ -4006,7 +4006,7 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 pValidSoldier->ubNumTraversalsAllowedToMerge = 2; pGroup = GetGroup( ubPrevGroupID ); Assert( pGroup ); - Assert( pGroup->fPlayer ); + Assert( pGroup->usGroupTeam == OUR_TEAM ); Assert( pGroup->ubGroupSize ); pPlayer = pGroup->pPlayerList; while( pPlayer ) @@ -4085,8 +4085,9 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 } // Give guy(s) orders to walk off sector... - if( pGroup->fPlayer ) - { //For player groups, update the soldier information + if ( pGroup->usGroupTeam == OUR_TEAM ) + { + //For player groups, update the soldier information PLAYERGROUP *curr; INT32 sGridNo; UINT8 ubNum = 0; @@ -4120,33 +4121,33 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 } curr->pSoldier->EVENT_GetNewSoldierPath( sGridNo, WALKING ); - } else { - // Here, get closest location for exit grid.... - sGridNo = FindGridNoFromSweetSpotCloseToExitGrid( curr->pSoldier, sAdditionalData, 10, &ubDirection ); + // Here, get closest location for exit grid.... + sGridNo = FindGridNoFromSweetSpotCloseToExitGrid( curr->pSoldier, sAdditionalData, 10, &ubDirection ); - if (!TileIsOutOfBounds(sGridNo)) - { - // Save wait code - this will make buddy walk off screen into oblivion - // curr->pSoldier->ubWaitActionToDo = 2; - } - else - { - AssertMsg( 0, String( "Failed to get good exit location for adjacentmove" ) ); - } + if (!TileIsOutOfBounds(sGridNo)) + { + // Save wait code - this will make buddy walk off screen into oblivion + // curr->pSoldier->ubWaitActionToDo = 2; + } + else + { + AssertMsg( 0, String( "Failed to get good exit location for adjacentmove" ) ); + } - // Don't worry about walk off screen, just stay at gridno... - curr->pSoldier->ubWaitActionToDo = 1; + // Don't worry about walk off screen, just stay at gridno... + curr->pSoldier->ubWaitActionToDo = 1; - // Set buddy go! - gfPlotPathToExitGrid = TRUE; - curr->pSoldier->EVENT_GetNewSoldierPath( sGridNo, WALKING ); - gfPlotPathToExitGrid = FALSE; + // Set buddy go! + gfPlotPathToExitGrid = TRUE; + curr->pSoldier->EVENT_GetNewSoldierPath( sGridNo, WALKING ); + gfPlotPathToExitGrid = FALSE; } - ubNum++; + + ++ubNum; } else { @@ -4519,7 +4520,7 @@ void AllMercsHaveWalkedOffSector( ) //of the tactical placement gui to get into better position. Additionally, if there are any //enemies in this sector that are part of a movement group, reset that movement group so that they //are "in" the sector rather than 75% of the way to the next sector if that is the case. - ResetMovementForEnemyGroupsInLocation( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY ); + ResetMovementForNonPlayerGroupsInLocation( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY ); if( guiAdjacentTraverseTime > 5 ) { @@ -4612,7 +4613,7 @@ void DoneFadeOutAdjacentSector( ) } // OK, give our guys new orders... - if( gpAdjacentGroup->fPlayer ) + if ( gpAdjacentGroup->usGroupTeam == OUR_TEAM ) { //For player groups, update the soldier information PLAYERGROUP *curr; diff --git a/Tactical/Disease.cpp b/Tactical/Disease.cpp index 8510c56c..9d1174ab 100644 --- a/Tactical/Disease.cpp +++ b/Tactical/Disease.cpp @@ -361,7 +361,7 @@ void HandleDisease() } // the bulk of doctoring will come from the military - doctors += NumEnemiesInSector( sX, sY ) * GetMilitaryPopulationDoctorRate( ); + doctors += NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ) * GetMilitaryPopulationDoctorRate( ); UINT32 doctorpower = doctors * GetPopulationDoctorPoints( ); @@ -479,8 +479,7 @@ UINT16 GetSectorPopulation( INT16 sX, INT16 sY, BOOLEAN fWithMilitary ) if ( fWithMilitary ) { // add number of enemies... - UINT16 sNumberOfEnemies = NumEnemiesInSector( sX, sY ); - population += sNumberOfEnemies; + population += NumNonPlayerTeamMembersInSector( sX, sY, ENEMY_TEAM ); } return population; diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 95291810..b7cc0723 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -4460,7 +4460,7 @@ void MilitiaChangesSides( ) { if (pSoldier->bActive && pSoldier->bInSector && pSoldier->stats.bLife) { - if ( (gWorldSectorX ==0 && gWorldSectorY == 0) || !NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) + if ( (gWorldSectorX == 0 && gWorldSectorY == 0) || !NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ) MakeCivHostile( pSoldier, 2 ); RecalculateOppCntsDueToNoLongerNeutral( pSoldier ); } @@ -7070,7 +7070,7 @@ BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated ) { if( !gbWorldSectorZ ) { - SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY) ].bLastKnownEnemies = NumEnemiesInSector( gWorldSectorX, gWorldSectorY ); + SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )].bLastKnownEnemies = NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ); } // Flugente: note number of wounded for campaign stats @@ -10906,7 +10906,7 @@ BOOLEAN GetRandomEnemyTownSector(INT8 bTownId, UINT16& aSector) { usSector = CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB ); - if ( StrategicMap[usSector].bNameId == bTownId && NumEnemiesInSector( iCounterA, iCounterB ) > 0 && !SectorHasVIP( iCounterA, iCounterB ) ) + if ( StrategicMap[usSector].bNameId == bTownId && NumNonPlayerTeamMembersInSector( iCounterA, iCounterB, ENEMY_TEAM ) > 0 && !SectorHasVIP( iCounterA, iCounterB ) ) { possiblesectors.push_back( usSector ); } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index dfc90192..d177b3e8 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -17914,7 +17914,7 @@ BOOLEAN SOLDIERTYPE::OrderArtilleryStrike( UINT32 usSectorNr, INT32 sTargetGridN GROUP *pGroup = gpGroupList; while ( pGroup ) { - if ( !pGroup->fPlayer && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) + if ( pGroup->usGroupTeam == bTeam && !pGroup->fVehicle && pGroup->ubSectorX == sSectorX && pGroup->ubSectorY == sSectorY ) { nummortars += pGroup->ubGroupSize; numshells += gSkillTraitValues.usVOMortarPointsTroop * pGroup->ubGroupSize;