If airspace isn't controlled by neither side (due to damage to SAM site, lack of qualiified is currently not checked), airspace is coloured blue.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7732 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2015-02-12 20:57:27 +00:00
parent 39b45c89d8
commit 24dae202f8
7 changed files with 72 additions and 54 deletions
+22 -25
View File
@@ -1126,7 +1126,7 @@ INT32 GetCostOfPassageForHelicopter( INT16 sX, INT16 sY )
INT32 iBaseCostPerRedTile = gGameExternalOptions.usHelicopterBaseCostPerRedTile; INT32 iBaseCostPerRedTile = gGameExternalOptions.usHelicopterBaseCostPerRedTile;
// if they don't control it // 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; iCost = iBaseCostPerGreenTile;
} }
@@ -1337,7 +1337,7 @@ void HandleHeliHoverForAMinute( void )
gubHelicopterHoverTime = 0; gubHelicopterHoverTime = 0;
iTotalHeliDistanceSinceRefuel++; iTotalHeliDistanceSinceRefuel++;
if( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sX, sY ) ].fEnemyAirControlled == FALSE ) if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sX, sY )].usAirType != AIRSPACE_ENEMY_ACTIVE )
{ {
iTotalAccumulatedCostByPlayer += gGameExternalOptions.usHelicopterHoverCostOnGreenTile; iTotalAccumulatedCostByPlayer += gGameExternalOptions.usHelicopterHoverCostOnGreenTile;
} }
@@ -1567,18 +1567,15 @@ BOOLEAN IsRefuelSiteInSector( INT16 sMapX, INT16 sMapY )
void UpdateRefuelSiteAvailability( void ) void UpdateRefuelSiteAvailability( void )
{ {
INT32 iCounter = 0;
// Generally, only Drassen is initially available for refuelling // Generally, only Drassen is initially available for refuelling
// Estoni must first be captured (although player may already have it when he gets Skyrider!) // Estoni must first be captured (although player may already have it when he gets Skyrider!)
// anv: Estoni should only available after Jake-Shank quest // 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) // 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 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 ) || 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 ) ) ) ( ( iCounter == ESTONI_REFUELING_SITE ) && ( CheckFact( FACT_ESTONI_REFUELLING_POSSIBLE, 0 ) == FALSE ) ) )
{ {
// mark refueling site as unavailable // mark refueling site as unavailable
@@ -2378,9 +2375,9 @@ BOOLEAN WillAirRaidBeStopped( INT16 sSectorX, INT16 sSectorY )
UINT8 ubChance; 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 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 ); return( FALSE );
} }
@@ -2449,7 +2446,7 @@ BOOLEAN HandleSAMSiteAttackOfHelicopterInSector( INT16 sSectorX, INT16 sSectorY
UINT8 ubChance; UINT8 ubChance;
// if this sector is in friendly airspace, we're safe // 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 // no problem, friendly airspace
return( FALSE ); return( FALSE );
@@ -2741,10 +2738,10 @@ INT16 GetNumSafeSectorsInPath( void )
{ {
uiLocation = pNode->uiSectorId; uiLocation = pNode->uiSectorId;
if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) if ( StrategicMap[uiLocation].usAirType != AIRSPACE_ENEMY_ACTIVE )
{ {
uiCount++; ++uiCount;
} }
pNode = pNode->pNext; pNode = pNode->pNext;
} }
@@ -2769,10 +2766,10 @@ INT16 GetNumSafeSectorsInPath( void )
{ {
uiLocation = pNode->uiSectorId; uiLocation = pNode->uiSectorId;
if ( !StrategicMap[ uiLocation ].fEnemyAirControlled ) if ( StrategicMap[uiLocation].usAirType != AIRSPACE_ENEMY_ACTIVE )
{ {
uiCount++; ++uiCount;
} }
pNode = pNode->pNext; pNode = pNode->pNext;
} }
@@ -2823,10 +2820,10 @@ INT16 GetNumUnSafeSectorsInPath( void )
{ {
uiLocation = pNode->uiSectorId; uiLocation = pNode->uiSectorId;
if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) if ( StrategicMap[uiLocation].usAirType == AIRSPACE_ENEMY_ACTIVE )
{ {
uiCount++; ++uiCount;
} }
pNode = pNode->pNext; pNode = pNode->pNext;
} }
@@ -2850,10 +2847,10 @@ INT16 GetNumUnSafeSectorsInPath( void )
{ {
uiLocation = pNode->uiSectorId; uiLocation = pNode->uiSectorId;
if ( StrategicMap[ uiLocation ].fEnemyAirControlled ) if ( StrategicMap[uiLocation].usAirType == AIRSPACE_ENEMY_ACTIVE )
{ {
uiCount++; ++uiCount;
} }
pNode = pNode->pNext; pNode = pNode->pNext;
} }
+16 -6
View File
@@ -746,15 +746,20 @@ UINT32 DrawMap( void )
{ {
if( fShowAircraftFlag ) 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 ); 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 else
{ {
// sector not visited, controlled and air not // sector not visited, currently nobody controls the airspace
ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_RED ); ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_BLUE );
} }
} }
else if ( fShowStrategicDiseaseFlag ) else if ( fShowStrategicDiseaseFlag )
@@ -780,16 +785,21 @@ UINT32 DrawMap( void )
{ {
if( fShowAircraftFlag ) 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 // sector visited and air controlled
ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_GREEN); 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 // sector visited but not air controlled
ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_RED ); 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 ) else if ( fShowStrategicDiseaseFlag )
{ {
+1 -1
View File
@@ -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 // 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... // 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; nextCost = COST_AIRSPACE_UNSAFE;
} }
+1 -1
View File
@@ -6576,7 +6576,7 @@ UINT32 HandleMapUI( )
if( SectorInfo[ ( SECTOR( sMapX, sMapY ) ) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] != GROUNDBARRIER ) if( SectorInfo[ ( SECTOR( sMapX, sMapY ) ) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] != GROUNDBARRIER )
{ {
// if it's not enemy air controlled // 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 ]; CHAR16 sMsgString[ 128 ], sMsgSubString[ 64 ];
+9 -1
View File
@@ -5,6 +5,14 @@
#include "mapscreen.h" #include "mapscreen.h"
#include "soldier control.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{ struct strategicmapelement{
UINT8 UNUSEDuiFootEta[4]; // eta/mvt costs for feet UINT8 UNUSEDuiFootEta[4]; // eta/mvt costs for feet
@@ -13,7 +21,7 @@ struct strategicmapelement{
UINT8 uiBadVehicleSector[4]; // blocking mvt from vehicles UINT8 uiBadVehicleSector[4]; // blocking mvt from vehicles
INT8 bNameId; INT8 bNameId;
BOOLEAN fEnemyControlled; // enemy controlled or not BOOLEAN fEnemyControlled; // enemy controlled or not
BOOLEAN fEnemyAirControlled; UINT8 usAirType;
BOOLEAN UNUSEDfLostControlAtSomeTime; BOOLEAN UNUSEDfLostControlAtSomeTime;
INT8 bSAMCondition; // SAM Condition .. 0 - 100, just like an item's status INT8 bSAMCondition; // SAM Condition .. 0 - 100, just like an item's status
+22 -19
View File
@@ -5117,50 +5117,53 @@ void UpdateAirspaceControl( void )
{ {
UINT8 ubControllingSAM; UINT8 ubControllingSAM;
StrategicMapElement *pSAMStrategicMap = NULL; StrategicMapElement *pSAMStrategicMap = NULL;
BOOLEAN fEnemyControlsAir;
for ( INT32 iCounterA = 1; iCounterA < (INT32)(MAP_WORLD_X - 1); ++iCounterA ) for ( INT32 iCounterA = 1; iCounterA < (INT32)(MAP_WORLD_X - 1); ++iCounterA )
{ {
for ( INT32 iCounterB = 1; iCounterB < (INT32)(MAP_WORLD_Y - 1); ++iCounterB ) 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 // IMPORTANT: B and A are reverse here, since the table is stored transposed
ubControllingSAM = ubSAMControlledSectors[ iCounterB ][ iCounterA ]; 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 // different status depending on who controls the SAM sector, and whether the SAM is operational
if( ( pSAMStrategicMap->fEnemyControlled ) && ( pSAMStrategicMap->bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) ) if ( pSAMStrategicMap->fEnemyControlled )
{ {
if (is_networked) if ( pSAMStrategicMap->bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK )
{ StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_ACTIVE;
fEnemyControlsAir = FALSE; // disable SAM airspace restrictions...
}
else else
{ StrategicMap[CALCULATE_STRATEGIC_INDEX( iCounterA, iCounterB )].usAirType = AIRSPACE_ENEMY_INACTIVE;
fEnemyControlsAir = TRUE;
}
} }
else 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 else
{ {
// no controlling SAM site // 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 // check if currently selected arrival sector still has secure airspace
// if it's not enemy air controlled // 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! // NOPE!
CHAR16 sMsgString[ 256 ], sMsgSubString1[ 64 ], sMsgSubString2[ 64 ]; CHAR16 sMsgString[ 256 ], sMsgSubString1[ 64 ], sMsgSubString2[ 64 ];
@@ -5170,7 +5173,7 @@ void UpdateAirspaceControl( void )
// move the landing zone over to Omerta // move the landing zone over to Omerta
// HEADROCK HAM 3.5: Externalized coordinates // 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; gsMercArriveSectorX = gGameExternalOptions.ubDefaultArrivalSectorX;
gsMercArriveSectorY = gGameExternalOptions.ubDefaultArrivalSectorY; gsMercArriveSectorY = gGameExternalOptions.ubDefaultArrivalSectorY;
@@ -5181,7 +5184,7 @@ void UpdateAirspaceControl( void )
{ {
for (UINT8 ubSectorY = 1; ubSectorY <=16; ++ubSectorY) 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; gsMercArriveSectorX = ubSectorX;
gsMercArriveSectorY = ubSectorY; gsMercArriveSectorY = ubSectorY;
+1 -1
View File
@@ -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( 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 ); uiRange = StrategicPythSpacesAway( sSectorGridNo2, sSectorGridNo );