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
fix(gameengine): three client bugs that only show up when focus goes away
Olcay Seygan80d8bb040b41
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 15414816c..30157c33a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -377,6 +377,9 @@ found and fixed — EA's own, not port damage.**- Closing a dialog while another one sits on top of it no longer leaves the game holding a pointer to the window it just freed. Every click, every keypress and the tab order all read that list, so what it caused was a crash with no pattern to it.- Ordering a group to use a special power that can kill the units casting it, the GLA rebel ambush over water being the one that does it every time, no longer walks a list of units that the ambush is deleting underneath.- A replay that never recorded which seat was yours plays instead of crashing before the map loads.+- Alt-tabbing away with an arrow key held no longer leaves the camera sliding that way when you come back. The key release goes to whatever you switched to, so the game never heard it; losing focus now ends the scroll, the middle-button pan and the ALT pitch drag along with it.+- Locking Windows mid-battle no longer eats the game. Nothing that renders runs while the screen is locked, and the particle bookkeeping had been filed under rendering, so every explosion while you were away was created and never cleared up. A hundred rocket buggies firing at the ground for a minute is enough to come back to a game that has run out of memory or simply stopped responding.+- Double-clicking a menu button opens the screen once. The button stays live while the old screen animates out, so the second click started the same transition again and the screen opened twice, one copy left drawn over whatever came next and doing nothing sensible when clicked.- Double-tapping 0 jumps the camera to that group.- The mouse wheel no longer cancels a camera move already in progress.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cppindex 009c183e7..0867f1be5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp@@ -294,6 +294,22 @@ void Shell::push( AsciiString filename, Bool shutdownImmediate )// sanityif( filename.isEmpty() )return;++ //+ // A push already waiting on the outgoing screen's shutdown animation owns this transition. The+ // button that started it stays live while that animation plays, so a second click ran the same+ // screen's shutdown a second time, and shutdownComplete then fired twice for one push: the+ // screen opened as two separate layouts, the extra copy stayed drawn over whatever came next,+ // and clicking that copy drove a layout that was no longer the top of the stack. Let a later+ // call change where we are going - that is what overwriting the name always did - but never+ // start the outgoing screen's shutdown twice.+ //+ if( m_pendingPush )+ {+ m_pendingPushName = filename;+ return;+ }+if(TheGameSpyInfo)GameSpyCloseAllOverlays();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cppindex 918f2608e..ff1f694bb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp@@ -826,9 +826,24 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessagevoid LookAtTranslator::resetModes(){+ //+ // A key or a mouse button held at the moment the window loses focus never sends its release:+ // alt-tab away with an arrow key down and the view keeps sliding that way when you come back,+ // until that key is pressed and let go once more. A drag that ends outside the window is the+ // same story with the mouse. So this has to put back everything a scroll turned on - the+ // direction flags the keyboard scroll reads, the mouse lock, the cursor - and not just clear+ // the flags that say a scroll is in progress.+ //+ for( Int i = 0; i < 4; ++i )+ scrollDir[i] = false;++ if( m_isScrolling && TheInGameUI && TheTacticalView && TheMouse )+ stopScrolling();+m_isScrolling = FALSE;m_isRotating = FALSE;m_freeRotateAngle = 0.0f;m_isPitching = FALSE;m_isChangingFOV = FALSE;+ m_scrollType = SCROLL_NONE;}\ No newline at end of filediff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppindex c7631164b..c702a2bee 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp@@ -2102,6 +2102,23 @@ AGAIN:if (TheW3DProjectedShadowManager)TheW3DProjectedShadowManager->updateRenderTargetTextures();}+ else+ {+ //+ // The particle manager's update is bookkeeping, not drawing: it ages particles, retires+ // the systems that have finished and frees them. Skipping it along with the rendering+ // meant that for as long as the device was gone the game went on creating particle+ // systems and destroyed none. Locking the Windows session is the reliable way to see+ // it - a hundred rocket buggies firing at the ground push that list into six figures in+ // under a minute, every walk of it gets slower as it grows, and what you unlock to is a+ // game that has either run out of memory or stopped responding.+ //+ // Above it runs right after updateViews on purpose (see Lorenzen's note), so the systems+ // read the client transform while it is still valid. There is no updateViews here and+ // nothing to draw the result of, so a frame's worth of stale transforms costs nothing.+ //+ TheParticleSystemManager->update();+ }Debug_Statistics::End_Statistics(); //record number of polygons rendered in RenderTargetTextures.diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cppindex 9ba662a00..bf8fb2677 100644--- a/GeneralsMD/Code/Main/WinMain.cpp+++ b/GeneralsMD/Code/Main/WinMain.cpp@@ -61,6 +61,7 @@#include "GameLogic/GameLogic.h" ///< @todo for demo, remove#include "GameClient/Mouse.h"#include "GameClient/IMEManager.h"+#include "GameClient/LookAtXlat.h"#include "Win32Device/GameClient/Win32Mouse.h"#include "Win32Device/Common/Win32GameEngine.h"#include "Common/Version.h"@@ -430,6 +431,14 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,if( TheKeyboard )TheKeyboard->resetKeys();+ //+ // ...and whatever those keys were driving. resetKeys clears the keyboard device; it+ // has no way to know that an arrow key held when focus went away left the camera+ // scrolling, and no key-up is ever coming for it.+ //+ if( TheLookAtTranslator )+ TheLookAtTranslator->resetModes();+if (TheWin32Mouse)TheWin32Mouse->lostFocus(FALSE);@@ -461,6 +470,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,{if (TheKeyboard )TheKeyboard->resetKeys();+ if( TheLookAtTranslator )+ TheLookAtTranslator->resetModes(); // see WM_SETFOCUS aboveif (TheWin32Mouse)TheWin32Mouse->lostFocus(TRUE);