diff --git a/Tactical/DisplayCover.cpp b/Tactical/DisplayCover.cpp index 995f55b6..92a55cb8 100644 --- a/Tactical/DisplayCover.cpp +++ b/Tactical/DisplayCover.cpp @@ -49,32 +49,39 @@ enum COVER_VALUES MAX_COVER=3 }; -// Flugente: mines display - stuff needs to be here -enum MINES_VALUES -{ - MINES_ALL = MAX_COVER + 1, - MINE_BOMB, - MINE_WIRE, - MINE_BOMB_AND_WIRE, - MINES_NET_1, - MINES_NET_2, - MINES_NET_3, - MINES_NET_4, - MINES_LVL_1, - MINES_LVL_2, - MINES_LVL_3, - MINES_LVL_4, - MAX_MINES -}; +#ifdef ENABLE_DISPLAY_EXPLOSIVES + // Flugente: mines display - stuff needs to be here + enum MINES_VALUES + { + MINES_ALL = MAX_COVER + 1, + MINE_BOMB, + MINE_WIRE, + MINE_BOMB_AND_WIRE, + MINES_NET_1, + MINES_NET_2, + MINES_NET_3, + MINES_NET_4, + MINES_LVL_1, + MINES_LVL_2, + MINES_LVL_3, + MINES_LVL_4, + MAX_MINES + }; +#endif struct CoverCell { INT32 sGridNo; INT8 bCover; BOOLEAN fInverseColor; + +#ifdef ENABLE_DISPLAY_EXPLOSIVES INT8 bMines; CoverCell() : sGridNo(NOWHERE), bCover(INVALID_COVER), fInverseColor(FALSE), bMines(MINES_ALL) {} +#else + CoverCell() : sGridNo(NOWHERE), bCover(INVALID_COVER), fInverseColor(FALSE) {} +#endif }; enum COVER_DRAW_MODE { @@ -94,18 +101,20 @@ const UINT8 animArr[3] = { #define COVER_Y_CELLS WORLD_ROWS_MAX #define COVER_Z_CELLS 2 // roof or no roof -// Flugente: mines display - stuff needs to be here -enum MINES_DRAW_MODE { - MINES_DRAW_OFF, - MINES_DRAW_DETECT_ENEMY, - MINES_DRAW_PLAYERTEAM_NETWORKS, - MINES_DRAW_NETWORKCOLOURING, - MINES_DRAW_NET_A, - MINES_DRAW_NET_B, - MINES_DRAW_NET_C, - MINES_DRAW_NET_D, - MINES_DRAW_MAX -}; +#ifdef ENABLE_DISPLAY_EXPLOSIVES + // Flugente: mines display - stuff needs to be here + enum MINES_DRAW_MODE { + MINES_DRAW_OFF, + MINES_DRAW_DETECT_ENEMY, + MINES_DRAW_PLAYERTEAM_NETWORKS, + MINES_DRAW_NETWORKCOLOURING, + MINES_DRAW_NET_A, + MINES_DRAW_NET_B, + MINES_DRAW_NET_C, + MINES_DRAW_NET_D, + MINES_DRAW_MAX + }; +#endif //****** Local Variables ********************************************* @@ -116,7 +125,10 @@ CoverCell gCoverViewArea[ COVER_X_CELLS ][ COVER_Y_CELLS ][ COVER_Z_CELLS ]; DWORD guiCoverNextUpdateTime = 0; COVER_DRAW_MODE gubDrawMode = COVER_DRAW_OFF; -MINES_DRAW_MODE gubDrawModeMine = MINES_DRAW_OFF; // Flugente: mines display + +#ifdef ENABLE_DISPLAY_EXPLOSIVES + MINES_DRAW_MODE gubDrawModeMine = MINES_DRAW_OFF; // Flugente: mines display +#endif //******* Local Function Prototypes *********************************** @@ -129,7 +141,10 @@ void RemoveCoverObjectFromWorld( const INT32 sGridNo, const UINT16& usGraphic, c void AddCoverObjectsToViewArea(); void RemoveCoverObjectsFromViewArea(); -void RemoveMinesObjectsFromViewArea(); // added by Flugente, has to be declared here + +#ifdef ENABLE_DISPLAY_EXPLOSIVES + void RemoveMinesObjectsFromViewArea(); // added by Flugente, has to be declared here +#endif void CalculateCover(); void CalculateCoverForSoldier( SOLDIERTYPE* pForSoldier, const INT32& sTargetGridNo, const BOOLEAN& fRoof, INT8& bCover ); @@ -445,9 +460,11 @@ void CalculateCover() return; } +#ifdef ENABLE_DISPLAY_EXPLOSIVES // at we're here, we want to display cover, so remove the mines display if ( gubDrawModeMine != MINES_DRAW_OFF ) RemoveMinesObjectsFromViewArea(); +#endif GetSoldier( &pSoldier, gusSelectedSoldier ); @@ -672,569 +689,571 @@ BOOLEAN IsTheRoofVisible( const INT32& sGridNo ) return( FALSE ); } -// ----------------------------- Mines display after this ---------------------------------------- -// added by Flugente +#ifdef ENABLE_DISPLAY_EXPLOSIVES + // ----------------------------- Mines display after this ---------------------------------------- + // added by Flugente -//****** Local Variables ********************************************* + //****** Local Variables ********************************************* -INT16 gsMineMinCellX, gsMineMinCellY, gsMineMaxCellX, gsMineMaxCellY = -1; + INT16 gsMineMinCellX, gsMineMinCellY, gsMineMaxCellX, gsMineMaxCellY = -1; -DWORD guiMinesNextUpdateTime = 0; + DWORD guiMinesNextUpdateTime = 0; -//******* Local Function Prototypes *********************************** + //******* Local Function Prototypes *********************************** -TileDefines GetTileMinesIndex( const INT8& bMines ); + TileDefines GetTileMinesIndex( const INT8& bMines ); -void AddMinesObjectsToViewArea(); + void AddMinesObjectsToViewArea(); -void CalculateMines(); -void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector = FALSE ); + void CalculateMines(); + void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector = FALSE ); -BOOLEAN MineTileHasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ); + BOOLEAN MineTileHasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ); -//******* Functions ************************************************** + //******* Functions ************************************************** -///BEGIN key binding functions -void SwitchToTrapNetworkView() -{ - if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) - return; - - gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); - DisplayMines(TRUE); -} - -void SwitchToHostileTrapsView() -{ - if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) - return; - - gubDrawModeMine = MINES_DRAW_DETECT_ENEMY; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display nearby traps"); - DisplayMines(TRUE); -} - -void SwitchMineViewOff() -{ - if (gubDrawModeMine == MINES_DRAW_OFF) - return; - - gubDrawModeMine = MINES_DRAW_OFF; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); - DisplayMines(TRUE); -} - -void ToggleHostileTrapsView() -{ - if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) { - SwitchMineViewOff(); - } else { - SwitchToHostileTrapsView(); - } -} - -void ToggleTrapNetworkView() -{ - SwitchMinesDrawModeForNetworks(); - /*if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) { - SwitchMineViewOff(); - } else { - SwitchToTrapNetworkView(); - }*/ -} - -void SwitchMinesDrawModeForNetworks() -{ - switch ( gubDrawModeMine ) + ///BEGIN key binding functions + void SwitchToTrapNetworkView() { - case MINES_DRAW_OFF: - case MINES_DRAW_DETECT_ENEMY: - gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); - DisplayMines(TRUE); - break; + if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) + return; - case MINES_DRAW_PLAYERTEAM_NETWORKS: - gubDrawModeMine = MINES_DRAW_NETWORKCOLOURING; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network colouring"); - DisplayMines(TRUE); - break; - case MINES_DRAW_NETWORKCOLOURING: - gubDrawModeMine = MINES_DRAW_NET_A; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network A"); - DisplayMines(TRUE); - break; - case MINES_DRAW_NET_A: - gubDrawModeMine = MINES_DRAW_NET_B; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network B"); - DisplayMines(TRUE); - break; - case MINES_DRAW_NET_B: - gubDrawModeMine = MINES_DRAW_NET_C; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network C"); - DisplayMines(TRUE); - break; - case MINES_DRAW_NET_C: - gubDrawModeMine = MINES_DRAW_NET_D; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network D"); - DisplayMines(TRUE); - break; - case MINES_DRAW_NET_D: - case MINES_DRAW_MAX: - default: - gubDrawModeMine = MINES_DRAW_OFF; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); - DisplayMines(TRUE); - break; + gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); + DisplayMines(TRUE); } - /*switch(gubDrawModeMine) + void SwitchToHostileTrapsView() { - case MINES_DRAW_OFF: - SwitchToTrapNetworkView(); - break; - case MINES_DRAW_PLAYERTEAM_NETWORKS: - SwitchToHostileTrapsView(); - break; - default: - SwitchMineViewOff(); - break; - }*/ -} -///END key binding functions + if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) + return; -TileDefines GetTileMinesIndex( const INT8& bMines ) -{ - switch(bMines) - { - case MINES_ALL: - case MINE_BOMB: - case MINES_NET_1: - case MINES_LVL_4: - return SPECIALTILE_COVER_1; // red - case MINE_BOMB_AND_WIRE: - case MINES_NET_2: - case MINES_LVL_3: - return SPECIALTILE_COVER_2; // orange - case MINE_WIRE: - case MINES_NET_3: - case MINES_LVL_2: - return SPECIALTILE_COVER_3; // yellow - case MINES_NET_4: - case MINES_LVL_1: - return SPECIALTILE_COVER_4; // green - case MAX_MINES: - default: - return SPECIALTILE_COVER_5; // light green, can be used to denote that you just don't know. looks just like normal green, though... + gubDrawModeMine = MINES_DRAW_DETECT_ENEMY; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display nearby traps"); + DisplayMines(TRUE); } -} -BOOLEAN MineTileHasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ) -{ - // no search for adjacent tiles wehn looking at a specific network (we have only 4 colours, need them all :-) - if ( gubDrawModeMine == MINES_DRAW_NETWORKCOLOURING || gubDrawModeMine == MINES_DRAW_NET_A || gubDrawModeMine == MINES_DRAW_NET_B || gubDrawModeMine == MINES_DRAW_NET_C || gubDrawModeMine == MINES_DRAW_NET_D ) - return FALSE; - - INT32 ubTX, ubTY; - - for ( ubTX = ubX-1; ubTX <= ubX+1; ++ubTX ) + void SwitchMineViewOff() { - if ( ubTX < 0 || ubTX > WORLD_COLS ) + if (gubDrawModeMine == MINES_DRAW_OFF) + return; + + gubDrawModeMine = MINES_DRAW_OFF; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); + DisplayMines(TRUE); + } + + void ToggleHostileTrapsView() + { + if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) { + SwitchMineViewOff(); + } else { + SwitchToHostileTrapsView(); + } + } + + void ToggleTrapNetworkView() + { + SwitchMinesDrawModeForNetworks(); + /*if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) { + SwitchMineViewOff(); + } else { + SwitchToTrapNetworkView(); + }*/ + } + + void SwitchMinesDrawModeForNetworks() + { + switch ( gubDrawModeMine ) { - continue; + case MINES_DRAW_OFF: + case MINES_DRAW_DETECT_ENEMY: + gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); + DisplayMines(TRUE); + break; + + case MINES_DRAW_PLAYERTEAM_NETWORKS: + gubDrawModeMine = MINES_DRAW_NETWORKCOLOURING; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network colouring"); + DisplayMines(TRUE); + break; + case MINES_DRAW_NETWORKCOLOURING: + gubDrawModeMine = MINES_DRAW_NET_A; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network A"); + DisplayMines(TRUE); + break; + case MINES_DRAW_NET_A: + gubDrawModeMine = MINES_DRAW_NET_B; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network B"); + DisplayMines(TRUE); + break; + case MINES_DRAW_NET_B: + gubDrawModeMine = MINES_DRAW_NET_C; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network C"); + DisplayMines(TRUE); + break; + case MINES_DRAW_NET_C: + gubDrawModeMine = MINES_DRAW_NET_D; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network D"); + DisplayMines(TRUE); + break; + case MINES_DRAW_NET_D: + case MINES_DRAW_MAX: + default: + gubDrawModeMine = MINES_DRAW_OFF; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); + DisplayMines(TRUE); + break; } - for ( ubTY = ubY-1; ubTY <= ubY+1; ++ubTY ) + /*switch(gubDrawModeMine) { - if ( ubTY < 0 || ubTY > WORLD_ROWS ) + case MINES_DRAW_OFF: + SwitchToTrapNetworkView(); + break; + case MINES_DRAW_PLAYERTEAM_NETWORKS: + SwitchToHostileTrapsView(); + break; + default: + SwitchMineViewOff(); + break; + }*/ + } + ///END key binding functions + + TileDefines GetTileMinesIndex( const INT8& bMines ) + { + switch(bMines) + { + case MINES_ALL: + case MINE_BOMB: + case MINES_NET_1: + case MINES_LVL_4: + return SPECIALTILE_COVER_1; // red + case MINE_BOMB_AND_WIRE: + case MINES_NET_2: + case MINES_LVL_3: + return SPECIALTILE_COVER_2; // orange + case MINE_WIRE: + case MINES_NET_3: + case MINES_LVL_2: + return SPECIALTILE_COVER_3; // yellow + case MINES_NET_4: + case MINES_LVL_1: + return SPECIALTILE_COVER_4; // green + case MAX_MINES: + default: + return SPECIALTILE_COVER_5; // light green, can be used to denote that you just don't know. looks just like normal green, though... + } + } + + BOOLEAN MineTileHasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ) + { + // no search for adjacent tiles wehn looking at a specific network (we have only 4 colours, need them all :-) + if ( gubDrawModeMine == MINES_DRAW_NETWORKCOLOURING || gubDrawModeMine == MINES_DRAW_NET_A || gubDrawModeMine == MINES_DRAW_NET_B || gubDrawModeMine == MINES_DRAW_NET_C || gubDrawModeMine == MINES_DRAW_NET_D ) + return FALSE; + + INT32 ubTX, ubTY; + + for ( ubTX = ubX-1; ubTX <= ubX+1; ++ubTX ) + { + if ( ubTX < 0 || ubTX > WORLD_COLS ) { continue; } - INT8& bMines = gCoverViewArea[ ubTX ][ ubTY ][ ubZ ].bMines; - - if ( bMines > MINES_ALL && bMines < MAX_MINES ) + for ( ubTY = ubY-1; ubTY <= ubY+1; ++ubTY ) { - return TRUE; - } - } - } - - return FALSE; -} - -void AddMinesObjectsToViewArea() -{ - if (gsMineMaxCellY == -1) - { - return; - } - INT32 ubX, ubY, ubZ; - BOOLEAN fChanged = FALSE; - - for ( ubX=gsMineMinCellX; ubX<=gsMineMaxCellX; ++ubX ) - { - for ( ubY=gsMineMinCellY; ubY<=gsMineMaxCellY; ++ubY ) - { - for ( ubZ=0; ubZ guiMinesNextUpdateTime ) ) - { - CalculateMines(); - guiMinesNextUpdateTime = GetTickCount() + gGameExternalOptions.ubCoverDisplayUpdateWait; - } -} - -void CalculateMines() -{ - INT32 ubX, ubY, ubZ; - SOLDIERTYPE* pSoldier; - - RemoveMinesObjectsFromViewArea(); - - if( gubDrawModeMine == MINES_DRAW_OFF ) - { - return; - } - - if( gusSelectedSoldier == NOBODY ) - { - return; - } - - // at we're here, we want to display mines, so remove the cover display - if ( gubDrawMode != COVER_DRAW_OFF ) - RemoveCoverObjectsFromViewArea(); - - GetSoldier( &pSoldier, gusSelectedSoldier ); - - // if we want to detect hostile mines and we have an metal detector in our hands, allow seeking - BOOLEAN fWithMineDetector = FALSE; - if ( pSoldier && gubDrawModeMine == MINES_DRAW_DETECT_ENEMY ) - { - if ( FindMetalDetectorInHand(pSoldier) ) - fWithMineDetector = TRUE; - - // TODO: perhaps even consume batteries one day... - } - - // if we are looking for mines via mine detector, but don't have one equipped, return, we won't detect anything - if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && !fWithMineDetector ) - { - return; - } - - const INT32& sSelectedSoldierGridNo = MercPtrs[ gusSelectedSoldier ]->sGridNo; - - INT16 usTmp; - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMineMinCellX, &usTmp ); - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMineMaxCellX, &usTmp ); - - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMineMinCellY ); - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMineMaxCellY ); - for ( ubX=gsMineMinCellX; ubX<=gsMineMaxCellX; ++ubX ) - { - for ( ubY=gsMineMinCellY; ubY<=gsMineMaxCellY; ++ubY ) - { - for ( ubZ=0; ubZ WORLD_ROWS ) { continue; } - if ( !NewOKDestination( pSoldier, sGridNo, false, (INT8) ubZ ) ) - { - continue; - } + INT8& bMines = gCoverViewArea[ ubTX ][ ubTY ][ ubZ ].bMines; - // do not show stuff on roofs if ground is shown - if ( ubZ == I_ROOF_LEVEL && !IsTheRoofVisible( sGridNo ) ) + if ( bMines > MINES_ALL && bMines < MAX_MINES ) { - continue; + return TRUE; } - - // do not show stuff on ground if roof is shown - if ( ubZ == I_GROUND_LEVEL && IsTheRoofVisible( sGridNo ) ) - { - continue; - } - - bMines = MAX_MINES; - - // if we are looking for hostile mines, but the tile is out of our' detectors range, skip looking for mines - if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && fWithMineDetector ) - { - if ( PythSpacesAway(sSelectedSoldierGridNo, sGridNo) > 4 ) - continue; - } - - DetermineMineDisplayInTile( sGridNo, ubZ, bMines, fWithMineDetector ); } } + + return FALSE; } - AddMinesObjectsToViewArea(); -} - - -void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector ) -{ - // if there is a bomb at that grid and level, and it isn't disabled - for (UINT32 uiWorldBombIndex = 0; uiWorldBombIndex < guiNumWorldBombs; ++uiWorldBombIndex) + void AddMinesObjectsToViewArea() { - if (gWorldBombs[uiWorldBombIndex].fExists && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].sGridNo == sGridNo && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].ubLevel == bLevel ) + if (gsMineMaxCellY == -1) { - OBJECTTYPE* pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].object ); - if (!((*pObj).fFlags & OBJECT_DISABLED_BOMB)) + return; + } + INT32 ubX, ubY, ubZ; + BOOLEAN fChanged = FALSE; + + for ( ubX=gsMineMinCellX; ubX<=gsMineMaxCellX; ++ubX ) + { + for ( ubY=gsMineMinCellY; ubY<=gsMineMaxCellY; ++ubY ) { - // we are looking for hostile mines and have got an detector equipped - if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && fWithMineDetector ) + for ( ubZ=0; ubZdata.misc.ubBombOwner > 1 ) + INT32& sGridNo = gCoverViewArea[ ubX ][ ubY ][ ubZ ].sGridNo; + INT8& bMines = gCoverViewArea[ ubX ][ ubY ][ ubZ ].bMines; + + if ( bMines != MINES_ALL && ( bMines != MAX_MINES || MineTileHasAdjTile( ubX, ubY, ubZ ) ) ) { - switch ( gubDrawModeMine ) + TileDefines tile = GetTileMinesIndex( bMines ); + AddCoverObjectToWorld( sGridNo, tile, (BOOLEAN) ubZ ); + fChanged = TRUE; + } + } + } + } + + // Re-render the scene! + if ( fChanged ) + { + SetRenderFlags( RENDER_FLAG_FULL ); + } + } + + void RemoveMinesObjectsFromViewArea() + { + if (gsMineMaxCellY == -1) + { + return; + } + INT32 ubX, ubY, ubZ; + BOOLEAN fChanged = FALSE; + + for ( ubX=gsMineMinCellX; ubX<=gsMineMaxCellX; ++ubX ) + { + for ( ubY=gsMineMinCellY; ubY<=gsMineMaxCellY; ++ubY ) + { + for ( ubZ=0; ubZ guiMinesNextUpdateTime ) ) + { + CalculateMines(); + guiMinesNextUpdateTime = GetTickCount() + gGameExternalOptions.ubCoverDisplayUpdateWait; + } + } + + void CalculateMines() + { + INT32 ubX, ubY, ubZ; + SOLDIERTYPE* pSoldier; + + RemoveMinesObjectsFromViewArea(); + + if( gubDrawModeMine == MINES_DRAW_OFF ) + { + return; + } + + if( gusSelectedSoldier == NOBODY ) + { + return; + } + + // at we're here, we want to display mines, so remove the cover display + if ( gubDrawMode != COVER_DRAW_OFF ) + RemoveCoverObjectsFromViewArea(); + + GetSoldier( &pSoldier, gusSelectedSoldier ); + + // if we want to detect hostile mines and we have an metal detector in our hands, allow seeking + BOOLEAN fWithMineDetector = FALSE; + if ( pSoldier && gubDrawModeMine == MINES_DRAW_DETECT_ENEMY ) + { + if ( FindMetalDetectorInHand(pSoldier) ) + fWithMineDetector = TRUE; + + // TODO: perhaps even consume batteries one day... + } + + // if we are looking for mines via mine detector, but don't have one equipped, return, we won't detect anything + if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && !fWithMineDetector ) + { + return; + } + + const INT32& sSelectedSoldierGridNo = MercPtrs[ gusSelectedSoldier ]->sGridNo; + + INT16 usTmp; + GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMineMinCellX, &usTmp ); + GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMineMaxCellX, &usTmp ); + + GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMineMinCellY ); + GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMineMaxCellY ); + for ( ubX=gsMineMinCellX; ubX<=gsMineMaxCellX; ++ubX ) + { + for ( ubY=gsMineMinCellY; ubY<=gsMineMaxCellY; ++ubY ) + { + for ( ubZ=0; ubZ 4 ) + continue; + } + + DetermineMineDisplayInTile( sGridNo, ubZ, bMines, fWithMineDetector ); + } + } + } + + AddMinesObjectsToViewArea(); + } + + + void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector ) + { + // if there is a bomb at that grid and level, and it isn't disabled + for (UINT32 uiWorldBombIndex = 0; uiWorldBombIndex < guiNumWorldBombs; ++uiWorldBombIndex) + { + if (gWorldBombs[uiWorldBombIndex].fExists && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].sGridNo == sGridNo && gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].ubLevel == bLevel ) + { + OBJECTTYPE* pObj = &( gWorldItems[ gWorldBombs[uiWorldBombIndex].iItemIndex ].object ); + if (!((*pObj).fFlags & OBJECT_DISABLED_BOMB)) + { + // we are looking for hostile mines and have got an detector equipped + if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && fWithMineDetector ) + { + // display all mines + bMines = MINE_BOMB; + } + else + { + // look for mines from our own team + if ( (*pObj)[0]->data.misc.ubBombOwner > 1 ) { - case MINES_DRAW_PLAYERTEAM_NETWORKS: - { - if ( Item[pObj->usItem].tripwire == 1 ) + switch ( gubDrawModeMine ) + { + case MINES_DRAW_PLAYERTEAM_NETWORKS: { - // if we're already marked as MINE_BOMB, switch to MINE_BOMB_AND_WIRE - if ( bMines == MINE_BOMB ) - bMines = MINE_BOMB_AND_WIRE; - else if ( bMines == MINE_BOMB_AND_WIRE ) - ; + if ( Item[pObj->usItem].tripwire == 1 ) + { + // if we're already marked as MINE_BOMB, switch to MINE_BOMB_AND_WIRE + if ( bMines == MINE_BOMB ) + bMines = MINE_BOMB_AND_WIRE; + else if ( bMines == MINE_BOMB_AND_WIRE ) + ; + else + { + // check if the tripwire has a gun attached + BOOLEAN fgunfound = FALSE; + attachmentList::iterator iterend = (*pObj)[0]->attachments.end(); + for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter) + { + if ( iter->exists() && Item[iter->usItem].usItemClass == IC_GUN ) + { + fgunfound = TRUE; + break; + } + } + + if ( fgunfound ) + bMines = MINE_BOMB_AND_WIRE; + else + bMines = MINE_WIRE; + } + } else { - // check if the tripwire has a gun attached - BOOLEAN fgunfound = FALSE; - attachmentList::iterator iterend = (*pObj)[0]->attachments.end(); - for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != iterend; ++iter) - { - if ( iter->exists() && Item[iter->usItem].usItemClass == IC_GUN ) - { - fgunfound = TRUE; - break; - } - } - - if ( fgunfound ) + // if we're already marked as MINE_WIRE, switch to MINE_BOMB_AND_WIRE + if ( bMines == MINE_WIRE ) bMines = MINE_BOMB_AND_WIRE; else - bMines = MINE_WIRE; + bMines = MINE_BOMB; } } - else + break; + + case MINES_DRAW_NETWORKCOLOURING: { - // if we're already marked as MINE_WIRE, switch to MINE_BOMB_AND_WIRE - if ( bMines == MINE_WIRE ) - bMines = MINE_BOMB_AND_WIRE; - else - bMines = MINE_BOMB; - } - } - break; - - case MINES_DRAW_NETWORKCOLOURING: - { - if ( Item[pObj->usItem].tripwire == 1 ) - { - // determine if wire is of the network we're searching for - // determine this tripwire's flag - UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - - // correct network? - if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_1 | PLAYER_NET_1_LVL_2 | PLAYER_NET_1_LVL_3 | PLAYER_NET_1_LVL_4 ) ) != 0 ) - bMines = MINES_NET_1; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_1 | PLAYER_NET_2_LVL_2 | PLAYER_NET_2_LVL_3 | PLAYER_NET_2_LVL_4 ) ) != 0 ) - bMines = MINES_NET_2; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_1 | PLAYER_NET_3_LVL_2 | PLAYER_NET_3_LVL_3 | PLAYER_NET_3_LVL_4 ) ) != 0 ) - bMines = MINES_NET_3; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_1 | PLAYER_NET_4_LVL_2 | PLAYER_NET_4_LVL_3 | PLAYER_NET_4_LVL_4 ) ) != 0 ) - bMines = MINES_NET_4; - } - } - break; - - case MINES_DRAW_NET_A: - { - if ( Item[pObj->usItem].tripwire == 1 ) - { - // determine if wire is of the network we're searching for - // determine this tripwire's flag - UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - - // correct network? - if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_1 | PLAYER_NET_1_LVL_2 | PLAYER_NET_1_LVL_3 | PLAYER_NET_1_LVL_4 ) ) != 0 ) + if ( Item[pObj->usItem].tripwire == 1 ) { - bMines = MINES_LVL_1; + // determine if wire is of the network we're searching for + // determine this tripwire's flag + UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_2 ) ) != 0 ) - bMines = MINES_LVL_2; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_3 ) ) != 0 ) - bMines = MINES_LVL_3; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_4 ) ) != 0 ) - bMines = MINES_LVL_4; + // correct network? + if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_1 | PLAYER_NET_1_LVL_2 | PLAYER_NET_1_LVL_3 | PLAYER_NET_1_LVL_4 ) ) != 0 ) + bMines = MINES_NET_1; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_1 | PLAYER_NET_2_LVL_2 | PLAYER_NET_2_LVL_3 | PLAYER_NET_2_LVL_4 ) ) != 0 ) + bMines = MINES_NET_2; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_1 | PLAYER_NET_3_LVL_2 | PLAYER_NET_3_LVL_3 | PLAYER_NET_3_LVL_4 ) ) != 0 ) + bMines = MINES_NET_3; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_1 | PLAYER_NET_4_LVL_2 | PLAYER_NET_4_LVL_3 | PLAYER_NET_4_LVL_4 ) ) != 0 ) + bMines = MINES_NET_4; } } - } - break; + break; - case MINES_DRAW_NET_B: - { - if ( Item[pObj->usItem].tripwire == 1 ) + case MINES_DRAW_NET_A: { - // determine if wire is of the network we're searching for - // determine this tripwire's flag - UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - - // correct network? - if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_1 | PLAYER_NET_2_LVL_2 | PLAYER_NET_2_LVL_3 | PLAYER_NET_2_LVL_4 ) ) != 0 ) + if ( Item[pObj->usItem].tripwire == 1 ) { - bMines = MINES_LVL_1; + // determine if wire is of the network we're searching for + // determine this tripwire's flag + UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_2 ) ) != 0 ) - bMines = MINES_LVL_2; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_3 ) ) != 0 ) - bMines = MINES_LVL_3; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_4 ) ) != 0 ) - bMines = MINES_LVL_4; + // correct network? + if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_1 | PLAYER_NET_1_LVL_2 | PLAYER_NET_1_LVL_3 | PLAYER_NET_1_LVL_4 ) ) != 0 ) + { + bMines = MINES_LVL_1; + + if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_2 ) ) != 0 ) + bMines = MINES_LVL_2; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_3 ) ) != 0 ) + bMines = MINES_LVL_3; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_1_LVL_4 ) ) != 0 ) + bMines = MINES_LVL_4; + } } } - } - break; + break; - case MINES_DRAW_NET_C: - { - if ( Item[pObj->usItem].tripwire == 1 ) + case MINES_DRAW_NET_B: { - // determine if wire is of the network we're searching for - // determine this tripwire's flag - UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - - // correct network? - if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_1 | PLAYER_NET_3_LVL_2 | PLAYER_NET_3_LVL_3 | PLAYER_NET_3_LVL_4 ) ) != 0 ) + if ( Item[pObj->usItem].tripwire == 1 ) { - bMines = MINES_LVL_1; + // determine if wire is of the network we're searching for + // determine this tripwire's flag + UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_2 ) ) != 0 ) - bMines = MINES_LVL_2; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_3 ) ) != 0 ) - bMines = MINES_LVL_3; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_4 ) ) != 0 ) - bMines = MINES_LVL_4; + // correct network? + if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_1 | PLAYER_NET_2_LVL_2 | PLAYER_NET_2_LVL_3 | PLAYER_NET_2_LVL_4 ) ) != 0 ) + { + bMines = MINES_LVL_1; + + if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_2 ) ) != 0 ) + bMines = MINES_LVL_2; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_3 ) ) != 0 ) + bMines = MINES_LVL_3; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_2_LVL_4 ) ) != 0 ) + bMines = MINES_LVL_4; + } } } - } - break; + break; - case MINES_DRAW_NET_D: - { - if ( Item[pObj->usItem].tripwire == 1 ) + case MINES_DRAW_NET_C: { - // determine if wire is of the network we're searching for - // determine this tripwire's flag - UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - - // correct network? - if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_1 | PLAYER_NET_4_LVL_2 | PLAYER_NET_4_LVL_3 | PLAYER_NET_4_LVL_4 ) ) != 0 ) + if ( Item[pObj->usItem].tripwire == 1 ) { - bMines = MINES_LVL_1; + // determine if wire is of the network we're searching for + // determine this tripwire's flag + UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; - if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_2 ) ) != 0 ) - bMines = MINES_LVL_2; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_3 ) ) != 0 ) - bMines = MINES_LVL_3; - else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_4 ) ) != 0 ) - bMines = MINES_LVL_4; + // correct network? + if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_1 | PLAYER_NET_3_LVL_2 | PLAYER_NET_3_LVL_3 | PLAYER_NET_3_LVL_4 ) ) != 0 ) + { + bMines = MINES_LVL_1; + + if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_2 ) ) != 0 ) + bMines = MINES_LVL_2; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_3 ) ) != 0 ) + bMines = MINES_LVL_3; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_3_LVL_4 ) ) != 0 ) + bMines = MINES_LVL_4; + } } } - } - break; + break; - case MINES_DRAW_DETECT_ENEMY: - case MINES_DRAW_MAX: - default: - break; + case MINES_DRAW_NET_D: + { + if ( Item[pObj->usItem].tripwire == 1 ) + { + // determine if wire is of the network we're searching for + // determine this tripwire's flag + UINT32 ubWireNetworkFlag = (*pObj)[0]->data.ubWireNetworkFlag; + + // correct network? + if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_1 | PLAYER_NET_4_LVL_2 | PLAYER_NET_4_LVL_3 | PLAYER_NET_4_LVL_4 ) ) != 0 ) + { + bMines = MINES_LVL_1; + + if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_2 ) ) != 0 ) + bMines = MINES_LVL_2; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_3 ) ) != 0 ) + bMines = MINES_LVL_3; + else if ( (ubWireNetworkFlag & ( PLAYER_NET_4_LVL_4 ) ) != 0 ) + bMines = MINES_LVL_4; + } + } + } + break; + + case MINES_DRAW_DETECT_ENEMY: + case MINES_DRAW_MAX: + default: + break; + } } } } } } } -} +#endif diff --git a/Tactical/DisplayCover.h b/Tactical/DisplayCover.h index e5d5cd3e..a4cf15bf 100644 --- a/Tactical/DisplayCover.h +++ b/Tactical/DisplayCover.h @@ -36,17 +36,19 @@ void ChangeSizeOfLOS( INT32 iNewSize ); INT8 CalcCoverForGridNoBasedOnTeamKnownEnemies( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo, INT8 bStance ); //ddd for optimize oppponent turn -// ----------------------------- Mines display after this ---------------------------------------- -// added by Flugente: display of mine, bombs and tripwire -void DisplayMines(const BOOLEAN& forceUpdate = FALSE); +#ifdef ENABLE_DISPLAY_EXPLOSIVES + // ----------------------------- Mines display after this ---------------------------------------- + // added by Flugente: display of mine, bombs and tripwire + void DisplayMines(const BOOLEAN& forceUpdate = FALSE); -void SwitchToTrapNetworkView(); -void SwitchToHostileTrapsView(); -void SwitchMineViewOff(); + void SwitchToTrapNetworkView(); + void SwitchToHostileTrapsView(); + void SwitchMineViewOff(); -void ToggleTrapNetworkView(); -void ToggleHostileTrapsView(); + void ToggleTrapNetworkView(); + void ToggleHostileTrapsView(); -void SwitchMinesDrawModeForNetworks(); + void SwitchMinesDrawModeForNetworks(); +#endif #endif diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index b006602f..4a552e68 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -655,7 +655,10 @@ UINT32 HandleTacticalUI( void ) } DisplayCover(); + +#ifdef ENABLE_DISPLAY_EXPLOSIVES DisplayMines(); // added by Flugente +#endif if ( HandleItemPickupMenu( ) ) { diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 410a697a..18aa83f2 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -1405,40 +1405,56 @@ void GetPolledKeyboardInput( UINT32 *puiNewEvent ) if( _KeyDown( DEL ) && !fDeleteDown) { +#ifdef ENABLE_DISPLAY_EXPLOSIVES if ( _KeyDown( ALT ) ) SwitchToHostileTrapsView(); // added by Flugente else SwitchToEnemyView(); +#else + SwitchToEnemyView(); +#endif fDeleteDown = TRUE; } if( !_KeyDown( DEL ) && fDeleteDown ) { +#ifdef ENABLE_DISPLAY_EXPLOSIVES if ( _KeyDown( ALT ) ) SwitchMineViewOff(); // added by Flugente else SwitchViewOff(); +#else + SwitchViewOff(); +#endif fDeleteDown = FALSE; } if( _KeyDown( END ) && !fEndDown) { +#ifdef ENABLE_DISPLAY_EXPLOSIVES if ( _KeyDown( ALT ) ) SwitchToTrapNetworkView(); // added by Flugente else SwitchToMercView(); +#else + SwitchToMercView(); +#endif fEndDown = TRUE; } if( !_KeyDown( END ) && fEndDown ) { +#ifdef ENABLE_DISPLAY_EXPLOSIVES if ( _KeyDown( ALT ) ) SwitchMineViewOff(); // added by Flugente else SwitchViewOff(); +#else + SwitchViewOff(); +#endif fEndDown = FALSE; @@ -2964,10 +2980,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) break; case 'C': +#ifdef ENABLE_DISPLAY_EXPLOSIVES if ( fAlt ) ToggleHostileTrapsView(); // added by Flugente else ToggleEnemyView(); +#else + ToggleEnemyView(); +#endif break; case 'd': if( gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT ) @@ -4358,10 +4378,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) break; case 'V': +#ifdef ENABLE_DISPLAY_EXPLOSIVES if( fAlt ) ToggleTrapNetworkView(); // added by Flugente else ToggleMercView(); +#else + ToggleMercView(); +#endif break; case 'w': diff --git a/builddefines.h b/builddefines.h index 01c2d7f7..6ee51cc2 100644 --- a/builddefines.h +++ b/builddefines.h @@ -3,10 +3,17 @@ #include "Language Defines.h" +// ----------------------------- +// ***************************** +// WANNE: Enable this define to show explosives display (Feature was added in Revision: 5210) +#define ENABLE_DISPLAY_EXPLOSIVES +// ----------------------------- +// ***************************** + // ----------------------------- // ***************************** // WANNE: Enable this define, to build an executable where you can enable/disable zombies in tactical (ingame option screen). -// It seems, that executables compiled with this zombie option turned on, causes slowdown in tactical. +// It seems (and is confirmed), that executables compiled with this zombie option turned on, causes slowdown in tactical. //#define ENABLE_ZOMBIES // ----------------------------- // ***************************** @@ -14,8 +21,6 @@ // ----------------------------- // ***************************** // WANNE: Enable this define, to build the gameloop with the highspeed timer. To use the highspeed timer, you also have to set the HIGHSPEED_TIMER = TRUE in ja2.ini -// CAUTION: A lot of games reported, when the exe is compiled with the highspeed timer on, the game runs very slowly in strategy map screen when doing repair, .. -// This is the reason, why I made a compilation define, where we can turn on/off the highspeed timer. #define USE_HIGHSPEED_GAMELOOP_TIMER // ----------------------------- // *****************************