Skip to content

Commit 259046e

Browse files
committed
Also consider headless game for busy state
1 parent 41fc725 commit 259046e

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

GeneralsMD/Code/GameEngine/Include/Common/OSDisplay.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ enum OSDisplayOtherFlags CPP_11(: UnsignedInt)
6464
OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedInt buttonFlags, UnsignedInt otherFlags);
6565

6666
// TheSuperHackers @feature Tell the Operating System that the game is considered busy
67-
// and we would not like the display screen to shut off.
68-
void OSDisplaySetBusyState(Bool busy);
67+
// and we would not like the display screen and/or system to shut off.
68+
void OSDisplaySetBusyState(Bool busyDisplay, Bool busySystem);
6969

7070
#endif /* __OSDISPLAY_H__ */

GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ class GameLogic : public SubsystemInterface, public Snapshot
273273

274274
private:
275275

276+
void updateDisplayBusyState();
277+
276278
void pauseGameLogic(Bool paused);
277279
void pauseGameSound(Bool paused);
278280
void pauseGameMusic(Bool paused);

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,16 @@ void GameLogic::deleteLoadScreen( void )
11191119

11201120
}
11211121

1122+
// ------------------------------------------------------------------------------------------------
1123+
// ------------------------------------------------------------------------------------------------
1124+
void GameLogic::updateDisplayBusyState()
1125+
{
1126+
const Bool busySystem = isInInteractiveGame() && !isGamePaused();
1127+
const Bool busyDisplay = busySystem && !TheGlobalData->m_headless;
1128+
1129+
OSDisplaySetBusyState(busyDisplay, busySystem);
1130+
}
1131+
11221132
// ------------------------------------------------------------------------------------------------
11231133
// ------------------------------------------------------------------------------------------------
11241134
void GameLogic::setGameMode( GameMode mode )
@@ -1128,7 +1138,7 @@ void GameLogic::setGameMode( GameMode mode )
11281138

11291139
TheMouse->onGameModeChanged(prev, mode);
11301140

1131-
OSDisplaySetBusyState(isInInteractiveGame() && !isGamePaused());
1141+
updateDisplayBusyState();
11321142
}
11331143

11341144
// ------------------------------------------------------------------------------------------------
@@ -4292,7 +4302,7 @@ void GameLogic::setGamePaused( Bool paused, Bool pauseMusic, Bool pauseInput )
42924302
pauseGameMusic(paused && pauseMusic);
42934303
pauseGameInput(paused && pauseInput);
42944304

4295-
OSDisplaySetBusyState(isInInteractiveGame() && !paused);
4305+
updateDisplayBusyState();
42964306
}
42974307

42984308
// ------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32OSDisplay.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,11 @@ OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedIn
125125
}
126126

127127
//-------------------------------------------------------------------------------------------------
128-
void OSDisplaySetBusyState(Bool busy)
128+
void OSDisplaySetBusyState(Bool busyDisplay, Bool busySystem)
129129
{
130-
if (busy)
131-
{
132-
::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
133-
}
134-
else
135-
{
136-
::SetThreadExecutionState(ES_CONTINUOUS);
137-
}
130+
EXECUTION_STATE state = ES_CONTINUOUS;
131+
state |= busyDisplay ? ES_DISPLAY_REQUIRED : 0;
132+
state |= busySystem ? ES_SYSTEM_REQUIRED : 0;
133+
134+
::SetThreadExecutionState(state);
138135
}

0 commit comments

Comments
 (0)