diff --git a/Strategic/Map Screen Helicopter.cpp b/Strategic/Map Screen Helicopter.cpp index 070b0183..2f34b566 100644 --- a/Strategic/Map Screen Helicopter.cpp +++ b/Strategic/Map Screen Helicopter.cpp @@ -1126,7 +1126,7 @@ INT32 GetCostOfPassageForHelicopter( INT16 sX, INT16 sY ) INT32 iBaseCostPerRedTile = gGameExternalOptions.usHelicopterBaseCostPerRedTile; // if they don't control it - if( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sX, sY ) ].fEnemyAirControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sX, sY )].usAirType != AIRSPACE_ENEMY_ACTIVE ) { iCost = iBaseCostPerGreenTile; } @@ -1337,7 +1337,7 @@ void HandleHeliHoverForAMinute( void ) gubHelicopterHoverTime = 0; iTotalHeliDistanceSinceRefuel++; - if( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sX, sY ) ].fEnemyAirControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sX, sY )].usAirType != AIRSPACE_ENEMY_ACTIVE ) { iTotalAccumulatedCostByPlayer += gGameExternalOptions.usHelicopterHoverCostOnGreenTile; } @@ -1567,18 +1567,15 @@ BOOLEAN IsRefuelSiteInSector( INT16 sMapX, INT16 sMapY ) void UpdateRefuelSiteAvailability( void ) { - INT32 iCounter = 0; - // Generally, only Drassen is initially available for refuelling // Estoni must first be captured (although player may already have it when he gets Skyrider!) // anv: Estoni should only available after Jake-Shank quest // site availability should not be dependent on SAM zones, or weird things will happen after controlling Estoni (like inability to land in base if it's in SAM zone) - for( iCounter = 0; iCounter < NUMBER_OF_REFUEL_SITES; iCounter++ ) + for ( INT32 iCounter = 0; iCounter < NUMBER_OF_REFUEL_SITES; ++iCounter ) { // if enemy controlled sector (ground OR air, don't want to fly into enemy air territory) if( ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sRefuelSectorX[ iCounter ], sRefuelSectorY[ iCounter ] ) ].fEnemyControlled == TRUE ) || - //( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sRefuelSectorX[ iCounter ], sRefuelSectorY[ iCounter ] ) ].fEnemyAirControlled == TRUE ) || ( ( iCounter == ESTONI_REFUELING_SITE ) && ( CheckFact( FACT_ESTONI_REFUELLING_POSSIBLE, 0 ) == FALSE ) ) ) { // mark refueling site as unavailable @@ -2378,9 +2375,9 @@ BOOLEAN WillAirRaidBeStopped( INT16 sSectorX, INT16 sSectorY ) UINT8 ubChance; - DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("WillAirRaidBeStopped: enemy air controlled = %d",StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].fEnemyAirControlled)); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "WillAirRaidBeStopped: enemy air controlled = %d", StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].usAirType ) ); // if enemy controls this SAM site, then it can't stop an air raid - if( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].fEnemyAirControlled == TRUE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].usAirType != AIRSPACE_PLAYER_ACTIVE ) { return( FALSE ); } @@ -2449,7 +2446,7 @@ BOOLEAN HandleSAMSiteAttackOfHelicopterInSector( INT16 sSectorX, INT16 sSectorY UINT8 ubChance; // if this sector is in friendly airspace, we're safe - if( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].fEnemyAirControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].usAirType != AIRSPACE_ENEMY_ACTIVE ) { // no problem, friendly airspace return( FALSE ); @@ -2741,10 +2738,10 @@ INT16 GetNumSafeSectorsInPath( void ) { uiLocation = pNode->uiSectorId; - if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[uiLocation].usAirType != AIRSPACE_ENEMY_ACTIVE ) + { + ++uiCount; + } pNode = pNode->pNext; } @@ -2769,10 +2766,10 @@ INT16 GetNumSafeSectorsInPath( void ) { uiLocation = pNode->uiSectorId; - if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[uiLocation].usAirType != AIRSPACE_ENEMY_ACTIVE ) + { + ++uiCount; + } pNode = pNode->pNext; } @@ -2823,10 +2820,10 @@ INT16 GetNumUnSafeSectorsInPath( void ) { uiLocation = pNode->uiSectorId; - if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[uiLocation].usAirType == AIRSPACE_ENEMY_ACTIVE ) + { + ++uiCount; + } pNode = pNode->pNext; } @@ -2850,10 +2847,10 @@ INT16 GetNumUnSafeSectorsInPath( void ) { uiLocation = pNode->uiSectorId; - if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) - { - uiCount++; - } + if ( StrategicMap[uiLocation].usAirType == AIRSPACE_ENEMY_ACTIVE ) + { + ++uiCount; + } pNode = pNode->pNext; } diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 45170357..ce1d1b53 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -746,15 +746,20 @@ UINT32 DrawMap( void ) { if( fShowAircraftFlag ) { - if( !StrategicMap[ cnt + cnt2 * WORLD_MAP_X ].fEnemyAirControlled ) + if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) { - // sector not visited, not air controlled + // sector not visited but air controlled ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_GREEN ); } + else if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_ENEMY_ACTIVE ) + { + // sector not visited and not air controlled + ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_RED ); + } else { - // sector not visited, controlled and air not - ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_RED ); + // sector not visited, currently nobody controls the airspace + ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_BLUE ); } } else if ( fShowStrategicDiseaseFlag ) @@ -780,16 +785,21 @@ UINT32 DrawMap( void ) { if( fShowAircraftFlag ) { - if( !StrategicMap[ cnt + cnt2 * WORLD_MAP_X ].fEnemyAirControlled ) + if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) { // sector visited and air controlled ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_GREEN); } - else + else if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_ENEMY_ACTIVE ) { // sector visited but not air controlled ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_RED ); } + else + { + // sector visited, currently nobody controls the airspace + ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_BLUE ); + } } else if ( fShowStrategicDiseaseFlag ) { diff --git a/Strategic/Strategic Pathing.cpp b/Strategic/Strategic Pathing.cpp index 822bdf26..afb5afeb 100644 --- a/Strategic/Strategic Pathing.cpp +++ b/Strategic/Strategic Pathing.cpp @@ -335,7 +335,7 @@ INT32 FindStratPath(INT16 sStart, INT16 sDestination, INT16 sMvtGroupNumber, BOO { // is a heli, its pathing is determined not by time (it's always the same) but by total cost // Skyrider will avoid uncontrolled airspace as much as possible... - if ( StrategicMap[ curLoc ].fEnemyAirControlled == TRUE ) + if ( StrategicMap[curLoc].usAirType == AIRSPACE_ENEMY_ACTIVE ) { nextCost = COST_AIRSPACE_UNSAFE; } diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index a9552cac..393b9312 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -6576,7 +6576,7 @@ UINT32 HandleMapUI( ) if( SectorInfo[ ( SECTOR( sMapX, sMapY ) ) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] != GROUNDBARRIER ) { // if it's not enemy air controlled - if ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sMapX, sMapY ) ].fEnemyAirControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sMapX, sMapY )].usAirType != AIRSPACE_ENEMY_ACTIVE ) { CHAR16 sMsgString[ 128 ], sMsgSubString[ 64 ]; diff --git a/Strategic/strategic.h b/Strategic/strategic.h index 84d17e3d..1bd029e4 100644 --- a/Strategic/strategic.h +++ b/Strategic/strategic.h @@ -5,6 +5,14 @@ #include "mapscreen.h" #include "soldier control.h" +// different states for airspace control +enum +{ + AIRSPACE_PLAYER_ACTIVE, // controlled by player and active + AIRSPACE_ENEMY_ACTIVE, // controlled by enemy and active + AIRSPACE_PLAYER_INACTIVE, // controlled by player but not active + AIRSPACE_ENEMY_INACTIVE, // controlled by enemy but not active +}; struct strategicmapelement{ UINT8 UNUSEDuiFootEta[4]; // eta/mvt costs for feet @@ -13,7 +21,7 @@ struct strategicmapelement{ UINT8 uiBadVehicleSector[4]; // blocking mvt from vehicles INT8 bNameId; BOOLEAN fEnemyControlled; // enemy controlled or not - BOOLEAN fEnemyAirControlled; + UINT8 usAirType; BOOLEAN UNUSEDfLostControlAtSomeTime; INT8 bSAMCondition; // SAM Condition .. 0 - 100, just like an item's status diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index b718cc38..4f03d099 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -5117,50 +5117,53 @@ void UpdateAirspaceControl( void ) { UINT8 ubControllingSAM; StrategicMapElement *pSAMStrategicMap = NULL; - BOOLEAN fEnemyControlsAir; for ( INT32 iCounterA = 1; iCounterA < (INT32)(MAP_WORLD_X - 1); ++iCounterA ) { for ( INT32 iCounterB = 1; iCounterB < (INT32)(MAP_WORLD_Y - 1); ++iCounterB ) { + // if networked, disable SAM airspace restrictions... + if ( is_networked ) + { + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_INACTIVE; + continue; + } + // IMPORTANT: B and A are reverse here, since the table is stored transposed ubControllingSAM = ubSAMControlledSectors[ iCounterB ][ iCounterA ]; - if ( ( ubControllingSAM >= 1 ) && ( ubControllingSAM <= NUMBER_OF_SAMS ) ) + if ( ubControllingSAM >= 1 && ubControllingSAM <= NUMBER_OF_SAMS ) { - pSAMStrategicMap = &( StrategicMap[ SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[ ubControllingSAM - 1 ] ) ] ); + pSAMStrategicMap = &( StrategicMap[ SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[ubControllingSAM - 1] ) ] ); - // if the enemies own the controlling SAM site, and it's in working condition - if( ( pSAMStrategicMap->fEnemyControlled ) && ( pSAMStrategicMap->bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) ) + // different status depending on who controls the SAM sector, and whether the SAM is operational + if ( pSAMStrategicMap->fEnemyControlled ) { - if (is_networked) - { - fEnemyControlsAir = FALSE; // disable SAM airspace restrictions... - } + if ( pSAMStrategicMap->bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_ACTIVE; else - { - fEnemyControlsAir = TRUE; - } + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_INACTIVE; } else { - fEnemyControlsAir = FALSE; + if ( pSAMStrategicMap->bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_PLAYER_ACTIVE; + else + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_PLAYER_INACTIVE; } } else { // no controlling SAM site - fEnemyControlsAir = FALSE; + StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_INACTIVE; } - - StrategicMap[ CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB ) ].fEnemyAirControlled = fEnemyControlsAir; } } // check if currently selected arrival sector still has secure airspace // if it's not enemy air controlled - if ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( gsMercArriveSectorX, gsMercArriveSectorY ) ].fEnemyAirControlled == TRUE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( gsMercArriveSectorX, gsMercArriveSectorY )].usAirType == AIRSPACE_ENEMY_ACTIVE ) { // NOPE! CHAR16 sMsgString[ 256 ], sMsgSubString1[ 64 ], sMsgSubString2[ 64 ]; @@ -5170,7 +5173,7 @@ void UpdateAirspaceControl( void ) // move the landing zone over to Omerta // HEADROCK HAM 3.5: Externalized coordinates - if ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( gGameExternalOptions.ubDefaultArrivalSectorX, gGameExternalOptions.ubDefaultArrivalSectorY ) ].fEnemyAirControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( gGameExternalOptions.ubDefaultArrivalSectorX, gGameExternalOptions.ubDefaultArrivalSectorY )].usAirType != AIRSPACE_ENEMY_ACTIVE ) { gsMercArriveSectorX = gGameExternalOptions.ubDefaultArrivalSectorX; gsMercArriveSectorY = gGameExternalOptions.ubDefaultArrivalSectorY; @@ -5181,7 +5184,7 @@ void UpdateAirspaceControl( void ) { for (UINT8 ubSectorY = 1; ubSectorY <=16; ++ubSectorY) { - if ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( ubSectorX, ubSectorY ) ].fEnemyAirControlled == FALSE && !sBadSectorsList[ ubSectorX ][ ubSectorY ] ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( ubSectorX, ubSectorY )].usAirType != AIRSPACE_ENEMY_ACTIVE && !sBadSectorsList[ubSectorX][ubSectorY] ) { gsMercArriveSectorX = ubSectorX; gsMercArriveSectorY = ubSectorY; diff --git a/Tactical/Merc Hiring.cpp b/Tactical/Merc Hiring.cpp index 11096573..5a403df9 100644 --- a/Tactical/Merc Hiring.cpp +++ b/Tactical/Merc Hiring.cpp @@ -872,7 +872,7 @@ void CheckForValidArrivalSector( ) if( sSectorGridNo2 >=1 && sSectorGridNo2 < ( ( MAP_WORLD_X - 1 ) * ( MAP_WORLD_X - 1 ) ) && sSectorGridNo2 >= leftmost && sSectorGridNo2 < ( leftmost + MAP_WORLD_X ) ) { - if ( !StrategicMap[ sSectorGridNo2 ].fEnemyControlled && !StrategicMap[ sSectorGridNo2 ].fEnemyAirControlled ) + if ( !StrategicMap[ sSectorGridNo2 ].fEnemyControlled && !StrategicMap[ sSectorGridNo2 ].usAirType != AIRSPACE_ENEMY_ACTIVE ) { uiRange = StrategicPythSpacesAway( sSectorGridNo2, sSectorGridNo );