- Made the "Display - mines/bombs/tripwires" feature optional, so we can decide if we like to build an executable with/without the feature

o See: builddefines.h: #define ENABLE_DISPLAY_EXPLOSIVES
o Note: This feature is NOT the strategy performance killer

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5359 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2012-07-06 12:58:45 +00:00
parent a3dcb642ca
commit cecdc22d61
5 changed files with 580 additions and 527 deletions
+81 -62
View File
@@ -49,9 +49,10 @@ enum COVER_VALUES
MAX_COVER=3 MAX_COVER=3
}; };
// Flugente: mines display - stuff needs to be here #ifdef ENABLE_DISPLAY_EXPLOSIVES
enum MINES_VALUES // Flugente: mines display - stuff needs to be here
{ enum MINES_VALUES
{
MINES_ALL = MAX_COVER + 1, MINES_ALL = MAX_COVER + 1,
MINE_BOMB, MINE_BOMB,
MINE_WIRE, MINE_WIRE,
@@ -65,16 +66,22 @@ enum MINES_VALUES
MINES_LVL_3, MINES_LVL_3,
MINES_LVL_4, MINES_LVL_4,
MAX_MINES MAX_MINES
}; };
#endif
struct CoverCell struct CoverCell
{ {
INT32 sGridNo; INT32 sGridNo;
INT8 bCover; INT8 bCover;
BOOLEAN fInverseColor; BOOLEAN fInverseColor;
#ifdef ENABLE_DISPLAY_EXPLOSIVES
INT8 bMines; INT8 bMines;
CoverCell() : sGridNo(NOWHERE), bCover(INVALID_COVER), fInverseColor(FALSE), bMines(MINES_ALL) {} 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 { enum COVER_DRAW_MODE {
@@ -94,8 +101,9 @@ const UINT8 animArr[3] = {
#define COVER_Y_CELLS WORLD_ROWS_MAX #define COVER_Y_CELLS WORLD_ROWS_MAX
#define COVER_Z_CELLS 2 // roof or no roof #define COVER_Z_CELLS 2 // roof or no roof
// Flugente: mines display - stuff needs to be here #ifdef ENABLE_DISPLAY_EXPLOSIVES
enum MINES_DRAW_MODE { // Flugente: mines display - stuff needs to be here
enum MINES_DRAW_MODE {
MINES_DRAW_OFF, MINES_DRAW_OFF,
MINES_DRAW_DETECT_ENEMY, MINES_DRAW_DETECT_ENEMY,
MINES_DRAW_PLAYERTEAM_NETWORKS, MINES_DRAW_PLAYERTEAM_NETWORKS,
@@ -105,7 +113,8 @@ enum MINES_DRAW_MODE {
MINES_DRAW_NET_C, MINES_DRAW_NET_C,
MINES_DRAW_NET_D, MINES_DRAW_NET_D,
MINES_DRAW_MAX MINES_DRAW_MAX
}; };
#endif
//****** Local Variables ********************************************* //****** Local Variables *********************************************
@@ -116,7 +125,10 @@ CoverCell gCoverViewArea[ COVER_X_CELLS ][ COVER_Y_CELLS ][ COVER_Z_CELLS ];
DWORD guiCoverNextUpdateTime = 0; DWORD guiCoverNextUpdateTime = 0;
COVER_DRAW_MODE gubDrawMode = COVER_DRAW_OFF; 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 *********************************** //******* Local Function Prototypes ***********************************
@@ -129,7 +141,10 @@ void RemoveCoverObjectFromWorld( const INT32 sGridNo, const UINT16& usGraphic, c
void AddCoverObjectsToViewArea(); void AddCoverObjectsToViewArea();
void RemoveCoverObjectsFromViewArea(); 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 CalculateCover();
void CalculateCoverForSoldier( SOLDIERTYPE* pForSoldier, const INT32& sTargetGridNo, const BOOLEAN& fRoof, INT8& bCover ); void CalculateCoverForSoldier( SOLDIERTYPE* pForSoldier, const INT32& sTargetGridNo, const BOOLEAN& fRoof, INT8& bCover );
@@ -445,9 +460,11 @@ void CalculateCover()
return; return;
} }
#ifdef ENABLE_DISPLAY_EXPLOSIVES
// at we're here, we want to display cover, so remove the mines display // at we're here, we want to display cover, so remove the mines display
if ( gubDrawModeMine != MINES_DRAW_OFF ) if ( gubDrawModeMine != MINES_DRAW_OFF )
RemoveMinesObjectsFromViewArea(); RemoveMinesObjectsFromViewArea();
#endif
GetSoldier( &pSoldier, gusSelectedSoldier ); GetSoldier( &pSoldier, gusSelectedSoldier );
@@ -672,80 +689,81 @@ BOOLEAN IsTheRoofVisible( const INT32& sGridNo )
return( FALSE ); return( FALSE );
} }
// ----------------------------- Mines display after this ---------------------------------------- #ifdef ENABLE_DISPLAY_EXPLOSIVES
// added by Flugente // ----------------------------- 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 CalculateMines();
void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector = FALSE ); 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 ///BEGIN key binding functions
void SwitchToTrapNetworkView() void SwitchToTrapNetworkView()
{ {
if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS)
return; return;
gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network");
DisplayMines(TRUE); DisplayMines(TRUE);
} }
void SwitchToHostileTrapsView() void SwitchToHostileTrapsView()
{ {
if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY)
return; return;
gubDrawModeMine = MINES_DRAW_DETECT_ENEMY; gubDrawModeMine = MINES_DRAW_DETECT_ENEMY;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display nearby traps"); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display nearby traps");
DisplayMines(TRUE); DisplayMines(TRUE);
} }
void SwitchMineViewOff() void SwitchMineViewOff()
{ {
if (gubDrawModeMine == MINES_DRAW_OFF) if (gubDrawModeMine == MINES_DRAW_OFF)
return; return;
gubDrawModeMine = MINES_DRAW_OFF; gubDrawModeMine = MINES_DRAW_OFF;
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display");
DisplayMines(TRUE); DisplayMines(TRUE);
} }
void ToggleHostileTrapsView() void ToggleHostileTrapsView()
{ {
if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) { if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) {
SwitchMineViewOff(); SwitchMineViewOff();
} else { } else {
SwitchToHostileTrapsView(); SwitchToHostileTrapsView();
} }
} }
void ToggleTrapNetworkView() void ToggleTrapNetworkView()
{ {
SwitchMinesDrawModeForNetworks(); SwitchMinesDrawModeForNetworks();
/*if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) { /*if (gubDrawModeMine == MINES_DRAW_PLAYERTEAM_NETWORKS) {
SwitchMineViewOff(); SwitchMineViewOff();
} else { } else {
SwitchToTrapNetworkView(); SwitchToTrapNetworkView();
}*/ }*/
} }
void SwitchMinesDrawModeForNetworks() void SwitchMinesDrawModeForNetworks()
{ {
switch ( gubDrawModeMine ) switch ( gubDrawModeMine )
{ {
case MINES_DRAW_OFF: case MINES_DRAW_OFF:
@@ -801,11 +819,11 @@ void SwitchMinesDrawModeForNetworks()
SwitchMineViewOff(); SwitchMineViewOff();
break; break;
}*/ }*/
} }
///END key binding functions ///END key binding functions
TileDefines GetTileMinesIndex( const INT8& bMines ) TileDefines GetTileMinesIndex( const INT8& bMines )
{ {
switch(bMines) switch(bMines)
{ {
case MINES_ALL: case MINES_ALL:
@@ -828,10 +846,10 @@ TileDefines GetTileMinesIndex( const INT8& bMines )
default: default:
return SPECIALTILE_COVER_5; // light green, can be used to denote that you just don't know. looks just like normal green, though... 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 ) 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 :-) // 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 ) 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; return FALSE;
@@ -862,10 +880,10 @@ BOOLEAN MineTileHasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ
} }
return FALSE; return FALSE;
} }
void AddMinesObjectsToViewArea() void AddMinesObjectsToViewArea()
{ {
if (gsMineMaxCellY == -1) if (gsMineMaxCellY == -1)
{ {
return; return;
@@ -897,10 +915,10 @@ void AddMinesObjectsToViewArea()
{ {
SetRenderFlags( RENDER_FLAG_FULL ); SetRenderFlags( RENDER_FLAG_FULL );
} }
} }
void RemoveMinesObjectsFromViewArea() void RemoveMinesObjectsFromViewArea()
{ {
if (gsMineMaxCellY == -1) if (gsMineMaxCellY == -1)
{ {
return; return;
@@ -933,10 +951,10 @@ void RemoveMinesObjectsFromViewArea()
{ {
SetRenderFlags( RENDER_FLAG_FULL ); SetRenderFlags( RENDER_FLAG_FULL );
} }
} }
void DisplayMines( const BOOLEAN& forceUpdate ) void DisplayMines( const BOOLEAN& forceUpdate )
{ {
if ( gGameExternalOptions.ubCoverDisplayUpdateWait == -1 ) if ( gGameExternalOptions.ubCoverDisplayUpdateWait == -1 )
{ {
return; return;
@@ -947,10 +965,10 @@ void DisplayMines( const BOOLEAN& forceUpdate )
CalculateMines(); CalculateMines();
guiMinesNextUpdateTime = GetTickCount() + gGameExternalOptions.ubCoverDisplayUpdateWait; guiMinesNextUpdateTime = GetTickCount() + gGameExternalOptions.ubCoverDisplayUpdateWait;
} }
} }
void CalculateMines() void CalculateMines()
{ {
INT32 ubX, ubY, ubZ; INT32 ubX, ubY, ubZ;
SOLDIERTYPE* pSoldier; SOLDIERTYPE* pSoldier;
@@ -1044,11 +1062,11 @@ void CalculateMines()
} }
AddMinesObjectsToViewArea(); AddMinesObjectsToViewArea();
} }
void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLEAN fWithMineDetector ) 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 // if there is a bomb at that grid and level, and it isn't disabled
for (UINT32 uiWorldBombIndex = 0; uiWorldBombIndex < guiNumWorldBombs; ++uiWorldBombIndex) for (UINT32 uiWorldBombIndex = 0; uiWorldBombIndex < guiNumWorldBombs; ++uiWorldBombIndex)
{ {
@@ -1237,4 +1255,5 @@ void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bMines, BOOLE
} }
} }
} }
} }
#endif
+11 -9
View File
@@ -36,17 +36,19 @@ void ChangeSizeOfLOS( INT32 iNewSize );
INT8 CalcCoverForGridNoBasedOnTeamKnownEnemies( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo, INT8 bStance ); INT8 CalcCoverForGridNoBasedOnTeamKnownEnemies( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo, INT8 bStance );
//ddd for optimize oppponent turn //ddd for optimize oppponent turn
// ----------------------------- Mines display after this ---------------------------------------- #ifdef ENABLE_DISPLAY_EXPLOSIVES
// added by Flugente: display of mine, bombs and tripwire // ----------------------------- Mines display after this ----------------------------------------
void DisplayMines(const BOOLEAN& forceUpdate = FALSE); // added by Flugente: display of mine, bombs and tripwire
void DisplayMines(const BOOLEAN& forceUpdate = FALSE);
void SwitchToTrapNetworkView(); void SwitchToTrapNetworkView();
void SwitchToHostileTrapsView(); void SwitchToHostileTrapsView();
void SwitchMineViewOff(); void SwitchMineViewOff();
void ToggleTrapNetworkView(); void ToggleTrapNetworkView();
void ToggleHostileTrapsView(); void ToggleHostileTrapsView();
void SwitchMinesDrawModeForNetworks(); void SwitchMinesDrawModeForNetworks();
#endif
#endif #endif
+3
View File
@@ -655,7 +655,10 @@ UINT32 HandleTacticalUI( void )
} }
DisplayCover(); DisplayCover();
#ifdef ENABLE_DISPLAY_EXPLOSIVES
DisplayMines(); // added by Flugente DisplayMines(); // added by Flugente
#endif
if ( HandleItemPickupMenu( ) ) if ( HandleItemPickupMenu( ) )
{ {
+24
View File
@@ -1405,40 +1405,56 @@ void GetPolledKeyboardInput( UINT32 *puiNewEvent )
if( _KeyDown( DEL ) && !fDeleteDown) if( _KeyDown( DEL ) && !fDeleteDown)
{ {
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if ( _KeyDown( ALT ) ) if ( _KeyDown( ALT ) )
SwitchToHostileTrapsView(); // added by Flugente SwitchToHostileTrapsView(); // added by Flugente
else else
SwitchToEnemyView(); SwitchToEnemyView();
#else
SwitchToEnemyView();
#endif
fDeleteDown = TRUE; fDeleteDown = TRUE;
} }
if( !_KeyDown( DEL ) && fDeleteDown ) if( !_KeyDown( DEL ) && fDeleteDown )
{ {
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if ( _KeyDown( ALT ) ) if ( _KeyDown( ALT ) )
SwitchMineViewOff(); // added by Flugente SwitchMineViewOff(); // added by Flugente
else else
SwitchViewOff(); SwitchViewOff();
#else
SwitchViewOff();
#endif
fDeleteDown = FALSE; fDeleteDown = FALSE;
} }
if( _KeyDown( END ) && !fEndDown) if( _KeyDown( END ) && !fEndDown)
{ {
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if ( _KeyDown( ALT ) ) if ( _KeyDown( ALT ) )
SwitchToTrapNetworkView(); // added by Flugente SwitchToTrapNetworkView(); // added by Flugente
else else
SwitchToMercView(); SwitchToMercView();
#else
SwitchToMercView();
#endif
fEndDown = TRUE; fEndDown = TRUE;
} }
if( !_KeyDown( END ) && fEndDown ) if( !_KeyDown( END ) && fEndDown )
{ {
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if ( _KeyDown( ALT ) ) if ( _KeyDown( ALT ) )
SwitchMineViewOff(); // added by Flugente SwitchMineViewOff(); // added by Flugente
else else
SwitchViewOff(); SwitchViewOff();
#else
SwitchViewOff();
#endif
fEndDown = FALSE; fEndDown = FALSE;
@@ -2964,10 +2980,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
break; break;
case 'C': case 'C':
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if ( fAlt ) if ( fAlt )
ToggleHostileTrapsView(); // added by Flugente ToggleHostileTrapsView(); // added by Flugente
else else
ToggleEnemyView(); ToggleEnemyView();
#else
ToggleEnemyView();
#endif
break; break;
case 'd': case 'd':
if( gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT ) if( gTacticalStatus.uiFlags & TURNBASED && gTacticalStatus.uiFlags & INCOMBAT )
@@ -4358,10 +4378,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
break; break;
case 'V': case 'V':
#ifdef ENABLE_DISPLAY_EXPLOSIVES
if( fAlt ) if( fAlt )
ToggleTrapNetworkView(); // added by Flugente ToggleTrapNetworkView(); // added by Flugente
else else
ToggleMercView(); ToggleMercView();
#else
ToggleMercView();
#endif
break; break;
case 'w': case 'w':
+8 -3
View File
@@ -3,10 +3,17 @@
#include "Language Defines.h" #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). // 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 //#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 // 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 #define USE_HIGHSPEED_GAMELOOP_TIMER
// ----------------------------- // -----------------------------
// ***************************** // *****************************