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(gameengine): run a clear-game tick's client calls at once

Olcay Seyganfdece53e592c
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h b/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h
index a03d91b5c..09c15b92d 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h
@@ -188,7 +188,7 @@ namespace LogicThread
* systems) wait in one queue, in the order the tick asked for them, and runTick runs them on the
* main thread after the drawables' deferred work, so every drawable they attach to has its render
* objects. Keyed on isInGameLogicUpdate past the map load, like the drawables, so -logicthread 0
- * and 1 run one path. */
+ * and 1 run one path. A tick clearing the game runs its calls at once, as a map load does. */
Bool defersEffects( void );
/** Inside a tick, queue `call` for after it; anywhere else, run it now. */
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp
index 495cd93a1..0fec12d7d 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp
@@ -520,7 +520,11 @@ void LogicThread::runTick( void )
//-------------------------------------------------------------------------------------------------
Bool LogicThread::defersEffects( void )
{
- return TheGameLogic != NULL && TheGameLogic->isInGameLogicUpdate() && !TheGameLogic->isLoadingMap();
+ /* Nor while the game is cleared. That tick runs on the main thread (tickNeedsMainThread), and
+ GameEngine::reset discards the queue: the closers clearGameData and the resets call were lost
+ with it, which left the victory banner and a script's popup message over the shell. */
+ return TheGameLogic != NULL && TheGameLogic->isInGameLogicUpdate() && !TheGameLogic->isLoadingMap()
+ && !TheGameLogic->isClearingGameData();
}
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp
index ac0e4c6a0..945a44729 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp
@@ -203,18 +203,12 @@ void ScriptActions::closeWindows( Bool suppressNewWindows )
m_suppressNewWindows = suppressNewWindows;
// the window is the client's: after the tick, in order with the one doVictory opens
- auto close = []{
+ LogicThread::callAfterTick( []{
if (m_messageWindow) {
TheWindowManager->winDestroy(m_messageWindow);
m_messageWindow = NULL;
}
- };
- // except while the game is cleared: that tick runs on the main thread and GameEngine::reset
- // discards what it queued, which left the victory banner over the shell
- if (TheGameLogic->isClearingGameData())
- close();
- else
- LogicThread::callAfterTick( close );
+ } );
}
//-------------------------------------------------------------------------------------------------