Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): keep the main menu asleep between campaign missions

Olcay Seygan540df4e830a6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d44bc7ff6..33dbb5147 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -414,6 +414,7 @@ found and fixed — EA's own, not port damage.**
## Twenty-two-year-old bugs, found by testing
+- Pressing Continue after a campaign mission goes straight to the next one. The main menu used to wake up behind the score screen on the way out, show its buttons and start loading its own background battle, so the menu sat on screen over the next mission's load.
- A civilian car no longer drives into your base in the first minute of every game. A map's civilians are owned by a computer player like any other, and the scouting pass looks for anything of that player's that can drive - so it was picking a parked car out of the scenery and sending it to a start position. A side with no faction and no build list has nothing to learn from the map and does not scout.
- A rifleman pulled off an oil derrick mid-capture left it flashing and chiming for the rest of the match, and the derrick changed hands anyway with nobody standing on it. Walking away now stops the capture, whether you or the computer gave the order.
- Every countdown on screen was a second too long. Rounding up a whole number of seconds gave a whole number plus one, so a ten second build said eleven - production queues, buildings going up, superweapons, all of it.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
index cba555e5b..c89d3fb35 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
@@ -133,6 +133,7 @@ public:
void push( AsciiString filename, Bool shutdownImmediate = FALSE ); ///< load new screen on top, optionally doing an immediate shutdown
void pop( void ); ///< pop top layout
void popImmediate( void ); ///< pop now, don't wait for shutdown
+ void popImmediateIntoGame( void ); ///< pop now for a game about to load, leaving the screen underneath asleep
void showShell( Bool runInit = TRUE ); ///< init the top of stack
void hideShell( void ); ///< shutdown the top of stack
WindowLayout *top( void ); ///< return top layout
@@ -166,6 +167,7 @@ protected:
void doPush( AsciiString layoutFile ); ///< workhorse for push action
void doPop( Bool impendingPush ); ///< workhorse for pop action
+ Bool shutdownTopForImmediatePop( void ); ///< run the top screen's shutdown ahead of an immediate pop, FALSE on an empty stack
enum { MAX_SHELL_STACK = 16 }; ///< max simultaneous shell screens
WindowLayout *m_screenStack[ MAX_SHELL_STACK ]; ///< the screen layout stack
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp
index 5b1b05ac7..6c9cf8e31 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp
@@ -198,7 +198,7 @@ void populateSideInfo( UnicodeString side,ScoreGather *sg, Int pos, Color color)
void startNextCampaignGame(void)
{
- TheShell->popImmediate();
+ TheShell->popImmediateIntoGame();
TheShell->hideShell();
TheWritableGlobalData->m_pendingFile = TheCampaignManager->getCurrentMap();
if (TheCampaignManager->getCurrentCampaign() && TheCampaignManager->getCurrentCampaign()->isChallengeCampaign())
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
index 4767d0f6e..ae93f30d4 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
@@ -414,12 +414,42 @@ void Shell::pop( void )
* the stack */
//-------------------------------------------------------------------------------------------------
void Shell::popImmediate( void )
+{
+ if( !shutdownTopForImmediatePop() )
+ return;
+
+ // pop the screen of the stack
+ doPop( FALSE );
+
+ if (TheIMEManager)
+ TheIMEManager->detatch();
+
+} // end popImmediate
+
+//-------------------------------------------------------------------------------------------------
+/** The immediate pop for a game that is about to load. popImmediate runs the init of whatever the
+ * pop uncovers, and between two campaign missions that is the main menu: its init shows the
+ * buttons, brings the layout forward and queues the shell map as a new game ahead of the next
+ * mission, so the menu came up over the load. Here the uncovered screen is left as it was, and
+ * showShell wakes it when the game ends and the shell comes back. */
+//-------------------------------------------------------------------------------------------------
+void Shell::popImmediateIntoGame( void )
+{
+ if( !shutdownTopForImmediatePop() )
+ return;
+
+ doPop( TRUE );
+
+} // end popImmediateIntoGame
+
+//-------------------------------------------------------------------------------------------------
+Bool Shell::shutdownTopForImmediatePop( void )
{
WindowLayout *screen = top();
// sanity
if( screen == NULL )
- return;
+ return FALSE;
#ifdef DEBUG_LOGGING
DEBUG_LOG(("Shell:popImmediate() - stack was\n"));
@@ -435,14 +465,9 @@ void Shell::popImmediate( void )
// run the shutdown
Bool immediatePop = TRUE;
screen->runShutdown( &immediatePop );
+ return TRUE;
- // pop the screen of the stack
- doPop( FALSE );
-
- if (TheIMEManager)
- TheIMEManager->detatch();
-
-} // end popImmediate
+} // end shutdownTopForImmediatePop
//-------------------------------------------------------------------------------------------------
/** Run the initialize function for the top of the stack just as though it was pushed