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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): let the menus render uncapped too
Olcay Seyganb1d4a3eec4e5
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.hindex 2742711db..f39d7d1b8 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h@@ -175,6 +175,8 @@ private:AnimateWindowList m_winList; ///< A list of AnimationWindows that we don't care if their finished animatingAnimateWindowList m_winMustFinishList; ///< A list of AnimationWindows that we do care aboutBool m_needsUpdate; ///< If we're done animating all our monitored windows, then this will be false+ UnsignedInt m_lastStepMs; ///< wall clock of the last animation step (menus render uncapped now)+ Real m_stepAccumMs; ///< milliseconds banked toward the next stepBool m_reverse; ///< Are we in a reverse state?ProcessAnimateWindowSlideFromRight *m_slideFromRight; ///< Holds the process in which the windows slide from the rightProcessAnimateWindowSlideFromRightFast *m_slideFromRightFast;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex c34cc48ce..df09a3d05 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -907,25 +907,11 @@ void GameEngine::execute( void )} // perf{- // In a real game rendering runs uncapped - game speed stays constant because- // the logic tick is paced by wall clock inside update(). The menus/shell keep- // the original coupled cadence: their window animations step once per loop- // iteration and were tuned for m_maxFPS, and capping here also keeps the- // present queue short so the cursor stays responsive.- // Unconditional in menus - the window animations move a fixed step per loop- // iteration, so an uncapped menu makes them finish instantly after their- // wall-clock start delay ("wait, then pop") whatever m_useFpsLimit says.- Bool inMenus = !TheGameLogic->isInGame() || TheGameLogic->isInShellGame();- if (inMenus && m_maxFPS > 0)- {- DWORD limit = (DWORD)(1000.0f/m_maxFPS)-1;- DWORD now = timeGetTime();- while ((now - prevLoopTime) < limit)- {- ::Sleep(1);- now = timeGetTime();- }- }+ // Rendering runs uncapped everywhere now, menus included. Game speed stays+ // constant because the logic tick is paced by wall clock inside update(), and the+ // menus no longer need a capped loop either: AnimateWindowManager::update paces+ // its own stepping off the wall clock, so the window animations keep the cadence+ // they were tuned for however fast the loop runs.prevLoopTime = timeGetTime();#if defined(_DEBUG) || defined(_INTERNAL)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cppindex 9f49b758c..754c48f5c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp@@ -132,6 +132,8 @@ AnimateWindowManager::AnimateWindowManager( void )m_winList.clear();m_needsUpdate = FALSE;m_reverse = FALSE;+ m_lastStepMs = 0;+ m_stepAccumMs = 0.0f;m_winMustFinishList.clear();}AnimateWindowManager::~AnimateWindowManager( void )@@ -166,6 +168,8 @@ void AnimateWindowManager::init( void )clearWinList(m_winMustFinishList);m_needsUpdate = FALSE;m_reverse = FALSE;+ m_lastStepMs = 0;+ m_stepAccumMs = 0.0f;}void AnimateWindowManager::reset( void )@@ -175,11 +179,35 @@ void AnimateWindowManager::reset( void )clearWinList(m_winMustFinishList);m_needsUpdate = FALSE;m_reverse = FALSE;+ m_lastStepMs = 0;+ m_stepAccumMs = 0.0f;}void AnimateWindowManager::update( void ){-+ //+ // Every animation below advances a fixed step per call, and they were tuned back when the+ // menus were held to a capped frame rate. Rendering is uncapped now, so pace the stepping off+ // the wall clock at that same rate instead - otherwise a menu animation covers its whole+ // travel in a handful of milliseconds and appears to snap into place.+ //+ const Real WINDOW_ANIM_STEPS_PER_SEC = 30.0f;+ const Real msPerStep = 1000.0f / WINDOW_ANIM_STEPS_PER_SEC;++ UnsignedInt nowMs = timeGetTime();+ if (m_lastStepMs == 0)+ m_lastStepMs = nowMs;++ Real elapsedMs = (Real)(nowMs - m_lastStepMs);+ m_lastStepMs = nowMs;+ if (elapsedMs > msPerStep)+ elapsedMs = msPerStep; // never burst several steps after a stall++ m_stepAccumMs += elapsedMs;+ if (m_stepAccumMs < msPerStep)+ return;+ m_stepAccumMs -= msPerStep;+ProcessAnimateWindow *processAnim = NULL;// if we need to update the windows that need to finish, update that list