From e206c21daa7a725cca4bf96cb2c65acbbfe082eb Mon Sep 17 00:00:00 2001 From: Flugente Date: Wed, 9 Mar 2016 22:48:16 +0000 Subject: [PATCH] Unified strategic map display code for airspace, militia restrictions and disease git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8101 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- SaveLoadGame.cpp | 22 +-- Strategic/Map Screen Interface Border.cpp | 216 ++++++---------------- Strategic/Map Screen Interface Border.h | 14 +- Strategic/Map Screen Interface Map.cpp | 149 +++++++-------- Strategic/Map Screen Interface.cpp | 2 +- Strategic/Strategic Movement.cpp | 2 +- Strategic/mapscreen.cpp | 30 ++- Tactical/Disease.cpp | 62 +++---- Tactical/Disease.h | 2 +- 9 files changed, 192 insertions(+), 307 deletions(-) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index be21cfb5..a122d73f 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -250,8 +250,8 @@ typedef struct BOOLEAN fShowTownFlag; BOOLEAN fShowTeamFlag; BOOLEAN fShowMineFlag; - BOOLEAN fShowAircraftFlag; - BOOLEAN fShowMobileRestrictionsFlag; // HEADROCK HAM 4: Showing Manual Mobile Restrictions + UINT8 usMapDisplayColourMode; + BOOLEAN filler1; // Flugente: unused // is the helicopter available to player? BOOLEAN fHelicopterAvailable; @@ -496,8 +496,7 @@ typedef struct // Buggler: New global variable that tracks money earned for facility use. INT32 iTotalEarnedForFacilityOperationsToday; - // Flugente - UINT8 fShowStrategicDiseaseFlag; + UINT8 filler2; // Flugente: unused UINT8 ubFiller[265]; //This structure should be 1588 bytes @@ -8219,9 +8218,8 @@ BOOLEAN SaveGeneralInfo( HWFILE hFile ) sGeneralInfo.fShowItemsFlag = fShowItemsFlag; sGeneralInfo.fShowTownFlag = fShowTownFlag; sGeneralInfo.fShowMineFlag = fShowMineFlag; - sGeneralInfo.fShowAircraftFlag = fShowAircraftFlag; + sGeneralInfo.usMapDisplayColourMode = gusMapDisplayColourMode; sGeneralInfo.fShowTeamFlag = fShowTeamFlag; - sGeneralInfo.fShowMobileRestrictionsFlag = fShowMobileRestrictionsFlag; // HEADROCK HAM 4 sGeneralInfo.fHelicopterAvailable = fHelicopterAvailable; @@ -8442,15 +8440,13 @@ BOOLEAN SaveGeneralInfo( HWFILE hFile ) // testing for loop memcpy(sGeneralInfo.ubManualRestrictMilitia, gubManualRestrictMilitia, sizeof( UINT8 )*256); - for (int i=0;i<500;i++) + for (int i=0;i<500;++i) { sGeneralInfo.HiddenNames[i] = !zHiddenNames[i].Hidden; //legion2 } sGeneralInfo.sMercArrivalGridNo = gGameExternalOptions.iInitialMercArrivalLocation; - sGeneralInfo.fShowStrategicDiseaseFlag = fShowStrategicDiseaseFlag; - #ifdef JA2UB sGeneralInfo.sINITIALHELIGRIDNO[ 0 ] = gGameUBOptions.InitialHeliGridNo[ 0 ];//14947; sGeneralInfo.sINITIALHELIGRIDNO[ 1 ] = gGameUBOptions.InitialHeliGridNo[ 1 ];//15584;//16067; @@ -8545,9 +8541,9 @@ BOOLEAN LoadGeneralInfo( HWFILE hFile ) numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fShowTownFlag, sizeof(sGeneralInfo.fShowTownFlag), sizeof(BOOLEAN), numBytesRead); numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fShowTeamFlag, sizeof(sGeneralInfo.fShowTeamFlag), sizeof(BOOLEAN), numBytesRead); numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fShowMineFlag, sizeof(sGeneralInfo.fShowMineFlag), sizeof(BOOLEAN), numBytesRead); - numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fShowAircraftFlag, sizeof(sGeneralInfo.fShowAircraftFlag), sizeof(BOOLEAN), numBytesRead); + numBytesRead = ReadFieldByField( hFile, &sGeneralInfo.usMapDisplayColourMode, sizeof(sGeneralInfo.usMapDisplayColourMode), sizeof(UINT8), numBytesRead ); if ( guiCurrentSaveGameVersion >= NEW_GENERAL_SAVE_INFO_DATA ) - numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fShowMobileRestrictionsFlag, sizeof(sGeneralInfo.fShowMobileRestrictionsFlag), sizeof(BOOLEAN), numBytesRead); + numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.filler1, sizeof(sGeneralInfo.filler1), sizeof(BOOLEAN), numBytesRead); numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.fHelicopterAvailable, sizeof(sGeneralInfo.fHelicopterAvailable), sizeof(BOOLEAN), numBytesRead); numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.iHelicopterVehicleId, sizeof(sGeneralInfo.iHelicopterVehicleId), sizeof(INT32), numBytesRead); numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.iTotalHeliDistanceSinceRefuel, sizeof(sGeneralInfo.iTotalHeliDistanceSinceRefuel), sizeof(INT32), numBytesRead); @@ -8762,10 +8758,8 @@ BOOLEAN LoadGeneralInfo( HWFILE hFile ) fShowItemsFlag = sGeneralInfo.fShowItemsFlag; fShowTownFlag = sGeneralInfo.fShowTownFlag; fShowMineFlag = sGeneralInfo.fShowMineFlag; - fShowAircraftFlag = sGeneralInfo.fShowAircraftFlag; + gusMapDisplayColourMode = sGeneralInfo.usMapDisplayColourMode; fShowTeamFlag = sGeneralInfo.fShowTeamFlag; - fShowMobileRestrictionsFlag = sGeneralInfo.fShowMobileRestrictionsFlag; - fShowStrategicDiseaseFlag = sGeneralInfo.fShowStrategicDiseaseFlag; fHelicopterAvailable = sGeneralInfo.fHelicopterAvailable; diff --git a/Strategic/Map Screen Interface Border.cpp b/Strategic/Map Screen Interface Border.cpp index 2a440675..2e2c36aa 100644 --- a/Strategic/Map Screen Interface Border.cpp +++ b/Strategic/Map Screen Interface Border.cpp @@ -82,10 +82,11 @@ BOOLEAN fShowTownFlag = FALSE; BOOLEAN fShowMineFlag = FALSE; BOOLEAN fShowTeamFlag = FALSE; BOOLEAN fShowMilitia = FALSE; -BOOLEAN fShowAircraftFlag = FALSE; BOOLEAN fShowItemsFlag = FALSE; -BOOLEAN fShowMobileRestrictionsFlag = FALSE; // HEADROCK HAM 4 -UINT8 fShowStrategicDiseaseFlag = 0; // Flugente: disease + +// Flugente: unified several display modes +UINT8 gusMapDisplayColourMode = MAP_DISPLAY_NORMAL; + //BOOLEAN fShowVehicleFlag = FALSE; @@ -597,13 +598,7 @@ void ToggleShowTownsMode( void ) fShowMineFlag = FALSE; MapBorderButtonOff( MAP_BORDER_MINE_BTN ); } - - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + if( fShowItemsFlag == TRUE ) { fShowItemsFlag = FALSE; @@ -635,30 +630,12 @@ void ToggleShowMinesMode( void ) fShowTownFlag = FALSE; MapBorderButtonOff( MAP_BORDER_TOWN_BTN ); } - - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + if( fShowItemsFlag == TRUE ) { fShowItemsFlag = FALSE; MapBorderButtonOff( MAP_BORDER_ITEM_BTN ); } - // HEADROCK HAM 4: Mobile Militia Restrictions - if( fShowMobileRestrictionsFlag == TRUE ) - { - fShowMobileRestrictionsFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if ( fShowStrategicDiseaseFlag ) - { - fShowStrategicDiseaseFlag = MAPMODE_DISEASE; - MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); - } } fMapPanelDirty = TRUE; @@ -687,23 +664,13 @@ void ToggleShowMilitiaMode( void ) fShowTeamFlag = FALSE; MapBorderButtonOff( MAP_BORDER_TEAMS_BTN ); } - -/* - // if Airspace is ON, turn it OFF - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } -*/ - + if ( fShowItemsFlag == TRUE ) { fShowItemsFlag = FALSE; MapBorderButtonOff( MAP_BORDER_ITEM_BTN ); } - // check if player has any militia if ( DoesPlayerHaveAnyMilitia( ) == FALSE ) { @@ -759,10 +726,11 @@ void ToggleShowTeamsMode( void ) void ToggleAirspaceMode( void ) { - if( fShowAircraftFlag == TRUE ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // turn airspace OFF - fShowAircraftFlag = FALSE; + gusMapDisplayColourMode = MAP_DISPLAY_NORMAL; + MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); if( fPlotForHelicopter ) @@ -811,10 +779,10 @@ void ToggleItemsFilter( void ) // Flugente: disease void ToggleDiseaseFilter( void ) { - if ( fShowStrategicDiseaseFlag == MAPMODE_MAX - 1 ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_DISEASE ) { - // turn items OFF - fShowStrategicDiseaseFlag = MAPMODE_OFF; + gusMapDisplayColourMode = MAP_DISPLAY_NORMAL; + MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); // dirty regions @@ -832,10 +800,10 @@ void ToggleDiseaseFilter( void ) // HEADROCK HAM 4: Toggle Mobile Restrictions Button void ToggleMobileFilter( void ) { - if( fShowMobileRestrictionsFlag == TRUE ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_MOBILEMILITIARESTRICTIONS ) { - // turn items OFF - fShowMobileRestrictionsFlag = FALSE; + gusMapDisplayColourMode = MAP_DISPLAY_NORMAL; + MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); // dirty regions @@ -947,19 +915,7 @@ void TurnOnShowTeamsMode( void ) fShowMilitia = FALSE; MapBorderButtonOff( MAP_BORDER_MILITIA_BTN ); } - // HEADROCK HAM 4: Turn off Show Militia Restrictions - if (fShowMobileRestrictionsFlag == TRUE) - { - fShowMobileRestrictionsFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if ( fShowStrategicDiseaseFlag ) - { - fShowStrategicDiseaseFlag = MAPMODE_DISEASE; - MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); - } - + if( fShowItemsFlag == TRUE ) { fShowItemsFlag = FALSE; @@ -980,11 +936,13 @@ void TurnOnAirSpaceMode( void ) { // if mode already on, leave, else set and redraw - if( fShowAircraftFlag == FALSE ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { - fShowAircraftFlag = TRUE; - MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN ); + gusMapDisplayColourMode = MAP_DISPLAY_AIRSPACE; + MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN ); + MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); + MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); // Turn off towns & mines (mostly because town/mine names overlap SAM site names) if( fShowTownFlag == TRUE ) @@ -1013,18 +971,6 @@ void TurnOnAirSpaceMode( void ) MapBorderButtonOff( MAP_BORDER_MILITIA_BTN ); } */ - // HEADROCK HAM 4: Turn off Militia Restrictions - if (fShowMobileRestrictionsFlag == TRUE) - { - fShowMobileRestrictionsFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if ( fShowStrategicDiseaseFlag ) - { - fShowStrategicDiseaseFlag = MAPMODE_OFF; - MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); - } // Turn off items if( fShowItemsFlag == TRUE ) @@ -1038,7 +984,6 @@ void TurnOnAirSpaceMode( void ) AbortMovementPlottingMode( ); } - // if showing underground if ( iCurrentMapSectorZ != 0 ) { @@ -1096,25 +1041,7 @@ void TurnOnItemFilterMode( void ) fShowMilitia = FALSE; MapBorderButtonOff( MAP_BORDER_MILITIA_BTN ); } - // HEADROCK HAM 4: Turn off Militia Restrictions - if (fShowMobileRestrictionsFlag == TRUE) - { - fShowMobileRestrictionsFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if ( fShowStrategicDiseaseFlag ) - { - fShowStrategicDiseaseFlag = MAPMODE_DISEASE; - MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); - } - - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + if ( (bSelectedDestChar != -1) || fPlotForHelicopter || fPlotForMilitia ) { AbortMovementPlottingMode( ); @@ -1135,9 +1062,12 @@ void TurnOnItemFilterMode( void ) void TurnOnDiseaseFilterMode( void ) { // if mode already on, leave, else set and redraw - if ( fShowStrategicDiseaseFlag < MAPMODE_MAX - 1 ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_DISEASE ) { - ++fShowStrategicDiseaseFlag; + gusMapDisplayColourMode = MAP_DISPLAY_DISEASE; + + MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); + MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); MapBorderButtonOn( MAP_BORDER_DISEASE_BTN ); if( fShowItemsFlag == TRUE ) @@ -1145,7 +1075,7 @@ void TurnOnDiseaseFilterMode( void ) fShowItemsFlag = FALSE; MapBorderButtonOff( MAP_BORDER_ITEM_BTN ); } - + // Turn off towns, mines, teams, militia & airspace if any are on if( fShowTownFlag == TRUE ) { @@ -1170,19 +1100,7 @@ void TurnOnDiseaseFilterMode( void ) fShowMilitia = FALSE; MapBorderButtonOff( MAP_BORDER_MILITIA_BTN ); } - // HEADROCK HAM 4: Turn off Militia Restrictions - if (fShowMobileRestrictionsFlag == TRUE) - { - fShowMobileRestrictionsFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + if ( (bSelectedDestChar != -1) || fPlotForHelicopter || fPlotForMilitia ) { AbortMovementPlottingMode( ); @@ -1192,7 +1110,7 @@ void TurnOnDiseaseFilterMode( void ) CancelChangeArrivalSectorMode( ); } - if ( fShowStrategicDiseaseFlag == MAPMODE_DISEASE && !gubFact[FACT_DISEASE_VIEWED] ) + if ( !gubFact[FACT_DISEASE_VIEWED] ) { MapScreenMessage( FONT_MCOLOR_LTYELLOW, MSG_MAP_UI_POSITION_MIDDLE, zMarksMapScreenText[27] ); @@ -1211,15 +1129,18 @@ void TurnOnMobileFilterMode( void ) { // if mode already on, leave, else set and redraw - if( fShowMobileRestrictionsFlag == FALSE ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_MOBILEMILITIARESTRICTIONS ) { - fShowMobileRestrictionsFlag = TRUE; + gusMapDisplayColourMode = MAP_DISPLAY_MOBILEMILITIARESTRICTIONS; + + MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); MapBorderButtonOn( MAP_BORDER_MOBILE_BTN ); + MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); + // Also turn on Militia mode fShowMilitia = FALSE; // Fool the function so that it always turns militia ON. ToggleShowMilitiaMode(); - if( fShowMineFlag == TRUE ) { fShowMineFlag = FALSE; @@ -1231,26 +1152,14 @@ void TurnOnMobileFilterMode( void ) fShowTeamFlag = FALSE; MapBorderButtonOff( MAP_BORDER_TEAMS_BTN ); } - - if( fShowAircraftFlag == TRUE ) - { - fShowAircraftFlag = FALSE; - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + // Turn off items if( fShowItemsFlag == TRUE ) { fShowItemsFlag = FALSE; MapBorderButtonOff( MAP_BORDER_ITEM_BTN ); } - - if ( fShowStrategicDiseaseFlag ) - { - fShowStrategicDiseaseFlag = MAPMODE_OFF; - MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); - } - + if ( (bSelectedDestChar != -1) || fPlotForHelicopter || fPlotForMilitia ) { AbortMovementPlottingMode( ); @@ -1327,16 +1236,7 @@ void InitializeMapBorderButtonStates( void ) { MapBorderButtonOff( MAP_BORDER_TEAMS_BTN ); } - - if( fShowAircraftFlag ) - { - MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN ); - } - else - { - MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); - } - + if( fShowMilitia ) { MapBorderButtonOn( MAP_BORDER_MILITIA_BTN ); @@ -1346,22 +1246,25 @@ void InitializeMapBorderButtonStates( void ) MapBorderButtonOff( MAP_BORDER_MILITIA_BTN ); } - if( fShowMobileRestrictionsFlag ) - { - MapBorderButtonOn( MAP_BORDER_MOBILE_BTN ); - } - else + switch ( gusMapDisplayColourMode ) { + case MAP_DISPLAY_AIRSPACE: + MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN ); MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); - } - - if ( fShowStrategicDiseaseFlag ) - { - MapBorderButtonOn( MAP_BORDER_DISEASE_BTN ); - } - else - { MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); + break; + + case MAP_DISPLAY_MOBILEMILITIARESTRICTIONS: + MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); + MapBorderButtonOn( MAP_BORDER_MOBILE_BTN ); + MapBorderButtonOff( MAP_BORDER_DISEASE_BTN ); + break; + + case MAP_DISPLAY_DISEASE: + MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN ); + MapBorderButtonOff( MAP_BORDER_MOBILE_BTN ); + MapBorderButtonOn( MAP_BORDER_DISEASE_BTN ); + break; } } @@ -1443,14 +1346,9 @@ void InitMapScreenFlags( void ) fShowTeamFlag = TRUE; fShowMilitia = FALSE; - fShowAircraftFlag = FALSE; fShowItemsFlag = FALSE; - // HEADROCK HAM 4: Militia Restrictions - fShowMobileRestrictionsFlag = FALSE; - - // Flugente - fShowStrategicDiseaseFlag = MAPMODE_OFF; + gusMapDisplayColourMode = MAP_DISPLAY_NORMAL; } diff --git a/Strategic/Map Screen Interface Border.h b/Strategic/Map Screen Interface Border.h index bb554b4f..5ad7e63c 100644 --- a/Strategic/Map Screen Interface Border.h +++ b/Strategic/Map Screen Interface Border.h @@ -48,10 +48,18 @@ extern BOOLEAN fShowTownFlag; extern BOOLEAN fShowMineFlag; extern BOOLEAN fShowTeamFlag; extern BOOLEAN fShowMilitia; -extern BOOLEAN fShowAircraftFlag; extern BOOLEAN fShowItemsFlag; -extern BOOLEAN fShowMobileRestrictionsFlag; // HEADROCK HAM 4: Manual Mobile Militia mode -extern UINT8 fShowStrategicDiseaseFlag; // Flugente: disease + +// different types of map displays that colour sectors +enum +{ + MAP_DISPLAY_NORMAL, + MAP_DISPLAY_AIRSPACE, + MAP_DISPLAY_MOBILEMILITIARESTRICTIONS, + MAP_DISPLAY_DISEASE, +}; + +extern UINT8 gusMapDisplayColourMode; //extern BOOLEAN fShowVehicleFlag; // scroll animation diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 788d4b68..7cb29755 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -739,81 +739,53 @@ UINT32 DrawMap( void ) // LATE DESIGN CHANGE: darken sectors not yet visited, instead of those under known enemy control if(!is_networked) //hayden - dont darken anything { - // HEADROCK HAM 4: Mobile View shows all tiles as explored. - if (!fShowMobileRestrictionsFlag ) + switch ( gusMapDisplayColourMode ) { - if( GetSectorFlagStatus( cnt, cnt2, ( UINT8 ) iCurrentMapSectorZ, SF_ALREADY_VISITED ) == FALSE ) - // if ( IsTheSectorPerceivedToBeUnderEnemyControl( cnt, cnt2, ( INT8 )( iCurrentMapSectorZ ) ) ) + case MAP_DISPLAY_AIRSPACE: + if ( GetSectorFlagStatus( cnt, cnt2, (UINT8)iCurrentMapSectorZ, SF_ALREADY_VISITED ) == FALSE ) { - if( fShowAircraftFlag ) + if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) { - if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) - { - // 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, currently nobody controls the airspace - ShadeMapElem( cnt, cnt2, MAP_SHADE_MD_BLUE ); - } + // sector not visited but air controlled + ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_GREEN ); } - else if ( fShowStrategicDiseaseFlag ) + else if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_ENEMY_ACTIVE ) { - ShadeMapElem( cnt, cnt2, GetMapColour(cnt, cnt2, fShowStrategicDiseaseFlag) ); + // sector not visited and not air controlled + ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_RED ); } else { - // not visited - if (gGameSettings.fOptions[TOPTION_ALT_MAP_COLOR]) - { - // HEADROCK HAM 4: An alternate display for the map in normal mode. Unexplored sectors - // are in grey, similar to a recon map. Others are left in normal vivid color. - ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_GREY ); - } - else - { - ShadeMapElem( cnt, cnt2, MAP_SHADE_BLACK ); - } + // sector not visited, currently nobody controls the airspace + ShadeMapElem( cnt, cnt2, MAP_SHADE_MD_BLUE ); } } else { - if( fShowAircraftFlag ) + if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) { - if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_PLAYER_ACTIVE ) - { - // sector visited and air controlled - ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_GREEN); - } - 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 ); - } + // sector visited and air controlled + ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_GREEN ); } - else if ( fShowStrategicDiseaseFlag ) + else if ( StrategicMap[cnt + cnt2 * WORLD_MAP_X].usAirType == AIRSPACE_ENEMY_ACTIVE ) { - ShadeMapElem( cnt, cnt2, GetMapColour(cnt, cnt2, fShowStrategicDiseaseFlag) ); + // 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 (fShowMobileRestrictionsFlag ) - { - // HEADROCK HAM 4: Show Manual Mobile Militia Restrictions - UINT8 ubManualMobileMovementAllowed = ManualMobileMovementAllowed( SECTOR(cnt, cnt2) ); - switch ( ubManualMobileMovementAllowed ) + break; + + case MAP_DISPLAY_MOBILEMILITIARESTRICTIONS: { + // HEADROCK HAM 4: Show Manual Mobile Militia Restrictions + UINT8 ubManualMobileMovementAllowed = ManualMobileMovementAllowed( SECTOR( cnt, cnt2 ) ); + switch ( ubManualMobileMovementAllowed ) + { case 0: // Mobiles not allowed here at all. ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_GREY ); @@ -830,7 +802,31 @@ UINT32 DrawMap( void ) // Mobiles can enter ShadeMapElem( cnt, cnt2, MAP_SHADE_LT_GREEN ); break; + } } + break; + + case MAP_DISPLAY_DISEASE: + ShadeMapElem( cnt, cnt2, GetMapColour( cnt, cnt2, TRUE ) ); + break; + + case MAP_DISPLAY_NORMAL: + default: + if ( GetSectorFlagStatus( cnt, cnt2, (UINT8)iCurrentMapSectorZ, SF_ALREADY_VISITED ) == FALSE ) + { + // not visited + if ( gGameSettings.fOptions[TOPTION_ALT_MAP_COLOR] ) + { + // HEADROCK HAM 4: An alternate display for the map in normal mode. Unexplored sectors + // are in grey, similar to a recon map. Others are left in normal vivid color. + ShadeMapElem( cnt, cnt2, MAP_SHADE_DK_GREY ); + } + else + { + ShadeMapElem( cnt, cnt2, MAP_SHADE_BLACK ); + } + } + break; } } } @@ -903,7 +899,7 @@ UINT32 DrawMap( void ) DrawTownMilitiaForcesOnMap( ); } - if ( fShowAircraftFlag && !gfInChangeArrivalSectorMode ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE && !gfInChangeArrivalSectorMode ) { DrawBullseye(); } @@ -926,7 +922,7 @@ UINT32 DrawMap( void ) // do not show mercs/vehicles when airspace is ON // commented out on a trial basis! -// if( !fShowAircraftFlag ) +// if( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { if( fShowTeamFlag ) ShowTeamAndVehicles( SHOW_TEAMMATES | SHOW_VEHICLES ); @@ -952,7 +948,7 @@ UINT32 DrawMap( void ) ShowItemsOnMap(); } - if ( fShowStrategicDiseaseFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_DISEASE ) { ShowDiseaseOnMap( ); } @@ -1170,7 +1166,7 @@ INT32 ShowAssignedTeam(INT16 sMapX, INT16 sMapY, INT32 iCount) ( !PlayerIDGroupInMotion( pSoldier->ubGroupID ) ) ) { // skip mercs inside the helicopter if we're showing airspace level - they show up inside chopper icon instead - if ( !fShowAircraftFlag || ( pSoldier->bAssignment != VEHICLE ) || ( pSoldier->iVehicleId != iHelicopterVehicleId ) ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE || (pSoldier->bAssignment != VEHICLE) || (pSoldier->iVehicleId != iHelicopterVehicleId) ) { ++sNumberOfAssigned; } @@ -2005,7 +2001,7 @@ void PlotPathForHelicopter( INT16 sX, INT16 sY ) // will plot the path for the helicopter // no heli...go back - if( !fShowAircraftFlag || !fHelicopterAvailable ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE || !fHelicopterAvailable ) { return; } @@ -2941,9 +2937,9 @@ void DisplayThePotentialPathForHelicopter(INT16 sMapX, INT16 sMapY ) static INT16 sOldMapX, sOldMapY; INT32 iDifference = 0; - if( fOldShowAirCraft != fShowAircraftFlag ) + if ( fOldShowAirCraft != (gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE) ) { - fOldShowAirCraft = fShowAircraftFlag; + fOldShowAirCraft = (gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE); giPotHeliPathBaseTime = GetJA2Clock( ); sOldMapX = sMapX; @@ -4394,7 +4390,7 @@ BOOLEAN CheckForClickOverHelicopterIcon( INT16 sClickedSectorX, INT16 sClickedSe fIgnoreClick = TRUE; } - if( !fHelicopterAvailable || !fShowAircraftFlag ) + if ( !fHelicopterAvailable || gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { return( FALSE ); } @@ -6741,15 +6737,14 @@ void ShowSAMSitesOnStrategicMap( void ) HVOBJECT hHandle; INT8 ubVidObjIndex = 0; CHAR16 wString[ 40 ]; - - - if( fShowAircraftFlag ) + + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { BlitSAMGridMarkers( ); } // sam site text - for( iCounter = 0; iCounter < NUMBER_OF_SAMS; iCounter++ ) + for( iCounter = 0; iCounter < NUMBER_OF_SAMS; ++iCounter ) { // has the sam site here been found? if( !fSamSiteFound[ iCounter ] ) @@ -6773,7 +6768,7 @@ void ShowSAMSitesOnStrategicMap( void ) GetVideoObject( &hHandle, guiSAMICON); BltVideoObject( guiSAVEBUFFER, hHandle, ubVidObjIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL ); - if( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // write "SAM Site" centered underneath @@ -6825,7 +6820,7 @@ void ShowSAMSitesOnStrategicMap( void ) } // refuel site text - for( iCounter = 0; iCounter < NUMBER_OF_REFUEL_SITES; iCounter++ ) + for( iCounter = 0; iCounter < NUMBER_OF_REFUEL_SITES; ++iCounter ) { // has the refuel site here been known or found? if( !fRefuelingSiteKnown[ iCounter ] && !GetSectorFlagStatus( sRefuelSectorX[ iCounter ], sRefuelSectorY[ iCounter ], 0, SF_ALREADY_VISITED ) ) @@ -6841,7 +6836,7 @@ void ShowSAMSitesOnStrategicMap( void ) sX += 5; sY += 3; - if( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // write "Refuel Site" centered underneath @@ -6880,8 +6875,7 @@ void ShowSAMSitesOnStrategicMap( void ) { continue; } - - + SetFontDestBuffer( guiSAVEBUFFER, MapScreenRect.iLeft + 2, MapScreenRect.iTop, MapScreenRect.iRight, MapScreenRect.iBottom, FALSE ); // clip blits to mapscreen region @@ -6903,8 +6897,6 @@ void ShowSAMSitesOnStrategicMap( void ) RestoreClipRegionToFullScreen( ); } } - - return; } @@ -7071,7 +7063,6 @@ void ShowDiseaseOnMap() if ( pSectorInfo && ((pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_PLAYER) || (gubFact[FACT_DISEASE_WHODATA_ACCESS] && pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_WHO)) ) { - if ( fShowStrategicDiseaseFlag == MAPMODE_DISEASE ) // hide this information, as it might allow the player to deduct enemy positions and numbers /*{ UINT16 population = GetSectorPopulation( sMapX, sMapY ); @@ -7091,8 +7082,8 @@ void ShowDiseaseOnMap() mprintf( usXPos, usYPos, sString ); } - } - else if ( fShowStrategicDiseaseFlag == MAPMODE_SEVERITY )*/ + }*/ + { if ( pSectorInfo->fInfectionSeverity > 0 ) { diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index 55f5349b..fe59f1d0 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -6659,7 +6659,7 @@ void TurnOnSectorLocator( UINT8 ubProfileID ) { // if helicopter position is being shown, don't do this, too, cause the helicopter icon is on top and it looks // like crap. I tried moving the heli icon blit to before, but that screws up it's blitting. - if ( !fShowAircraftFlag ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { // can't use his profile, he's where his chopper is Assert( iHelicopterVehicleId != -1 ); diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index a1e1c20b..d1b5fbdf 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -3791,7 +3791,7 @@ BOOLEAN PlayersBetweenTheseSectors( INT16 sSource, INT16 sDest, INT32 *iCountEnt // if this group is aboard the helicopter and we're showing the airspace layer, don't count any mercs aboard the // chopper, because the chopper icon itself serves the function of showing the location/size of this group - if ( !fHelicopterGroup || !fShowAircraftFlag ) + if ( !fHelicopterGroup || gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { // if only showing retreat paths, ignore groups not in the battle sector // if NOT showing retreat paths, ignore groups not between sectors diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index dc6a9f26..279b0e91 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -5131,7 +5131,7 @@ UINT32 MapScreenHandle(void) fLapTop=FALSE; // reset show aircraft flag - //fShowAircraftFlag = FALSE; + //gusMapDisplayColourMode == MAP_DISPLAY_NORMAL; // reset fact we are showing white bounding box around face fShowFaceHightLight = FALSE; @@ -5641,14 +5641,14 @@ UINT32 MapScreenHandle(void) // if heli is around, show it - if( fHelicopterAvailable && ( fShowAircraftFlag || fShowTeamFlag ) && ( iCurrentMapSectorZ == 0 ) && !fShowMapInventoryPool ) + if ( fHelicopterAvailable && (gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE || fShowTeamFlag) && (iCurrentMapSectorZ == 0) && !fShowMapInventoryPool ) { // this is done on EVERY frame, I guess it beats setting entire map dirty all the time while he's moving... DisplayPositionOfHelicopter( ); } // Flugente: enemy helicopter - if ( fShowAircraftFlag && (iCurrentMapSectorZ == 0) && !fShowMapInventoryPool ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE && (iCurrentMapSectorZ == 0) && !fShowMapInventoryPool ) { DisplayPositionOfEnemyHelicopter(); } @@ -6730,7 +6730,7 @@ UINT32 HandleMapUI( ) // if we're in airspace mode - if( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // if not moving soldiers, and not yet plotting the helicopter if ( (bSelectedDestChar == -1) && !fPlotForHelicopter && !fPlotForMilitia ) @@ -9113,7 +9113,7 @@ void PollRightButtonInMapView( UINT32 *puiNewEvent ) // - ALLOW_MILITIA_MOVEMENT_THROUGH_MINOR_CITIES = TRUE && it is a Minor Cities && we have liberated that citysector // - DynamicRestrictions if set in ini (does not matter if visited or not) //if ( fShowMobileRestrictionsFlag == TRUE && gDynamicRestrictMilitia[ SECTOR( sMapX, sMapY ) ] == TRUE) - if ( fShowMobileRestrictionsFlag && gGameExternalOptions.gflimitedRoaming && + if ( gusMapDisplayColourMode == MAP_DISPLAY_MOBILEMILITIARESTRICTIONS && gGameExternalOptions.gflimitedRoaming && ( ( gGameExternalOptions.fUnrestrictVisited == TRUE && SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled ) || ( gGameExternalOptions.fAllowMilitiaMoveThroughMinorCities && GetTownIdForSector( sMapX, sMapY ) > BLANK_SECTOR && !gfMilitiaAllowedInTown[GetTownIdForSector( sMapX, sMapY )] && SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled ) || ( gGameExternalOptions.fDynamicRestrictRoaming && gDynamicRestrictMilitia[ SECTOR( sMapX, sMapY ) ] == TRUE ) @@ -11698,7 +11698,7 @@ void PlotTemporaryPaths( void ) { if ( fPlotForHelicopter ) { - Assert( fShowAircraftFlag ); + Assert( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ); // plot temp path PlotATemporaryPathForHelicopter( sMapX, sMapY); @@ -11977,7 +11977,7 @@ void CheckIfPlottingForCharacterWhileAirCraft( void ) // if the plotting modes are inconsistent, stop plotting BOOLEAN fAbort = FALSE; - if ( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { if ( (bSelectedDestChar != -1 || fPlotForMilitia) && !fPlotForHelicopter ) fAbort = TRUE; @@ -12753,7 +12753,6 @@ void RebuildWayPointsForAllSelectedCharsGroups( void ) void UpdateCursorIfInLastSector( void ) { - INT16 sMapX = 0, sMapY = 0; // check to see if we are plotting a path, if so, see if we are highlighting the last sector int he path, if so, change the cursor @@ -12761,7 +12760,7 @@ void UpdateCursorIfInLastSector( void ) { GetMouseMapXY(&sMapX, &sMapY); - if ( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // check for helicopter if ( fPlotForHelicopter ) @@ -14613,7 +14612,7 @@ void ChangeSelectedMapSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) iCurrentMapSectorZ = bMapZ; // if going underground while in airspace mode - if ( ( bMapZ > 0 ) && ( fShowAircraftFlag == TRUE ) ) + if ( (bMapZ > 0) && (gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE) ) { // turn off airspace mode ToggleAirspaceMode( ); @@ -14779,12 +14778,11 @@ void CancelOrShortenPlottedPath( void ) { INT16 sMapX, sMapY; UINT32 uiReturnValue; - - + GetMouseMapXY(&sMapX, &sMapY); // check if we are in aircraft mode - if( fShowAircraftFlag ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // check for helicopter path being plotted if( !fPlotForHelicopter ) @@ -15321,7 +15319,7 @@ void MakeMapModesSuitableForDestPlotting( INT8 bCharNumber ) if ( ( pSoldier->bAssignment == VEHICLE ) && ( pSoldier->iVehicleId == iHelicopterVehicleId ) ) { - if ( fShowAircraftFlag == FALSE ) + if ( gusMapDisplayColourMode != MAP_DISPLAY_AIRSPACE ) { // turn on airspace mode automatically ToggleAirspaceMode(); @@ -15329,7 +15327,7 @@ void MakeMapModesSuitableForDestPlotting( INT8 bCharNumber ) } else { - if ( fShowAircraftFlag == TRUE ) + if ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE ) { // turn off airspace mode automatically ToggleAirspaceMode(); @@ -15779,7 +15777,7 @@ void StartChangeSectorArrivalMode( void ) BOOLEAN CanMoveBullseyeAndClickedOnIt( INT16 sMapX, INT16 sMapY ) { // if in airspace mode, and not plotting paths - if( ( fShowAircraftFlag == TRUE ) && ( bSelectedDestChar == -1 ) && ( fPlotForHelicopter == FALSE ) ) + if ( (gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE) && (bSelectedDestChar == -1) && (fPlotForHelicopter == FALSE) ) { if (is_networked) { diff --git a/Tactical/Disease.cpp b/Tactical/Disease.cpp index d3dfa1ba..1e642be0 100644 --- a/Tactical/Disease.cpp +++ b/Tactical/Disease.cpp @@ -503,47 +503,43 @@ UINT16 GetSectorPopulation( INT16 sX, INT16 sY, BOOLEAN fWithMilitary ) } // colour for a sector on the map -INT32 GetMapColour( INT16 sX, INT16 sY, UINT8 mode ) +INT32 GetMapColour( INT16 sX, INT16 sY, BOOLEAN aDiseaseOn ) { - UINT8 sector = SECTOR( sX, sY ); - - switch ( mode ) + if ( aDiseaseOn ) { - case MAPMODE_DISEASE: + UINT16 population = GetSectorPopulation( sX, sY ); + + if ( population ) { - UINT16 population = GetSectorPopulation( sX, sY ); + UINT8 sector = SECTOR( sX, sY ); - if ( population ) + SECTORINFO *pSectorInfo = &(SectorInfo[sector]); + + // display sector information only if we know about infection there + if ( pSectorInfo && ((pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_PLAYER) || (gubFact[FACT_DISEASE_WHODATA_ACCESS] && pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_WHO)) ) { - SECTORINFO *pSectorInfo = &(SectorInfo[sector]); + FLOAT infectedpercentage = (FLOAT)pSectorInfo->usInfected / (FLOAT)(population); - // display sector information only if we know about infection there - if ( pSectorInfo && ((pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_PLAYER) || (gubFact[FACT_DISEASE_WHODATA_ACCESS] && pSectorInfo->usInfectionFlag & SECTORDISEASE_DIAGNOSED_WHO)) ) - { - FLOAT infectedpercentage = (FLOAT)pSectorInfo->usInfected / (FLOAT)(population); - - if ( infectedpercentage < 0.2f ) - return MAP_SHADE_DK_GREEN; - else if ( infectedpercentage < 0.3f ) - return MAP_SHADE_MD_GREEN; - else if ( infectedpercentage < 0.4f ) - return MAP_SHADE_LT_GREEN; - else if ( infectedpercentage < 0.5f ) - return MAP_SHADE_DK_YELLOW; - else if ( infectedpercentage < 0.6f ) - return MAP_SHADE_MD_YELLOW; - else if ( infectedpercentage < 0.7f ) - return MAP_SHADE_LT_YELLOW; - else if ( infectedpercentage < 0.8f ) - return MAP_SHADE_DK_RED; - else if ( infectedpercentage < 0.9f ) - return MAP_SHADE_MD_RED; - else - return MAP_SHADE_LT_RED; - } + if ( infectedpercentage < 0.2f ) + return MAP_SHADE_DK_GREEN; + else if ( infectedpercentage < 0.3f ) + return MAP_SHADE_MD_GREEN; + else if ( infectedpercentage < 0.4f ) + return MAP_SHADE_LT_GREEN; + else if ( infectedpercentage < 0.5f ) + return MAP_SHADE_DK_YELLOW; + else if ( infectedpercentage < 0.6f ) + return MAP_SHADE_MD_YELLOW; + else if ( infectedpercentage < 0.7f ) + return MAP_SHADE_LT_YELLOW; + else if ( infectedpercentage < 0.8f ) + return MAP_SHADE_DK_RED; + else if ( infectedpercentage < 0.9f ) + return MAP_SHADE_MD_RED; + else + return MAP_SHADE_LT_RED; } } - break; } return MAP_SHADE_DK_GREY; diff --git a/Tactical/Disease.h b/Tactical/Disease.h index f42742c4..b2d6f68d 100644 --- a/Tactical/Disease.h +++ b/Tactical/Disease.h @@ -138,7 +138,7 @@ INT16 GetAdjacentSector( UINT8 sector, UINT8 spdir ); UINT16 GetSectorPopulation( INT16 sX, INT16 sY, BOOLEAN fWithMilitary = TRUE ); // colour for a sector on the map -INT32 GetMapColour( INT16 sX, INT16 sY, UINT8 mode ); +INT32 GetMapColour( INT16 sX, INT16 sY, BOOLEAN aDiseaseOn ); // handle infection redistribution if people move from A to B (set sXB and sYB to negative values to simply remove infected people in A) void PopulationMove( INT16 sXA, INT16 sYA, INT16 sXB, INT16 sYB, UINT16 usAmount );