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(gameclient): unstick the GLA fake-buildings page and the paused clock
Olcay Seyganf15a5e49782a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2a27cf25b..3f4e92d4e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -296,6 +296,11 @@ Around it, the whole production loop got tightened:worker by hand. Click anyway: the order goes to the nearest idle worker, and only falls back tointerrupting a busy one when every worker you own is busy. Same for the build list you get withnothing selected — it stays usable when the whole crew is out working.+- **The GLA's fake-building list is not a one-way door.** The toggle that swaps a worker's build+ list between real structures and decoys — the ones that go up in smoke on the Demolition+ general — did nothing on the build list you get with nothing selected. So a worker left on the+ decoy page stayed on it, and the only way back was to find that worker on the map and select it.+ The button works from either list now.- **Workers go back to collecting supplies** after they finish, instead of standing there.- **The times on the buttons are real seconds, not "seconds at normal speed".** Speed the game upand a 20 second barracks reads 10, because that is how long you are going to be waiting. Every@@ -343,6 +348,8 @@ Around it, the whole production loop got tightened:lost.The drawing rate really is the drawing rate now: both figures used to be counted off the sameclock, so the number in brackets was a second copy of the simulation rate and moved with it.+ Pausing stops both clocks. The real-time one used to keep running while the game stood still, so+ five minutes in the menu read as five minutes the simulation had fallen behind.**Placing buildings.** The grid you place on is drawn on the ground now instead of over the top ofeverything — it follows the slope, your units and buildings stand on it rather than under it, anddiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex c549c7a1b..071b2b190 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -844,6 +844,7 @@ protected:UnsignedInt m_hudLastSampleLogicFrame; ///< logic frame at that same sampleReal m_hudLogicHz; ///< logic frames actually simulated per real secondUnsignedInt m_hudRealClockBaseMs; ///< wall clock the two elapsed-time readouts were aligned at+ UnsignedInt m_hudLastDrawMs; ///< wall clock of the previous overlay draw, so a pause can be taken back out of it// A script time freeze stops the logic clock, and the military subtitle's counters are// logic frames, so they have to be stepped by hand while it lasts. These two turn the// wall clock into that step without drift: every update works out how many 30Hz framesdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex b07019f78..30c012966 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1059,6 +1059,7 @@ InGameUI::InGameUI()m_hudLastSampleLogicFrame = 0;m_hudLogicHz = 0.0f;m_hudRealClockBaseMs = 0;+ m_hudLastDrawMs = 0;for( Int incomeBucket = 0; incomeBucket < INCOME_SAMPLES; incomeBucket++ )m_incomeSamples[ incomeBucket ] = 0;m_incomeSampleCount = 0;@@ -5656,9 +5657,16 @@ void InGameUI::drawHudOverlay( void )// above show, totalled. The base is set the first time the overlay draws rather than at frame// zero, so switching it on mid-game does not invent an hour of lag.//+ // A pause stops the logic clock and not the wall clock, and the gap between the two readings+ // is meant to be simulation lag - time spent in the menu is not lag. So the base is walked+ // forward by every paused frame's worth of wall clock and both readouts stand still.+ //UnsignedInt gameSecs = logicFrame / LOGICFRAMES_PER_SECOND;if( m_hudRealClockBaseMs == 0 )m_hudRealClockBaseMs = nowMs - gameSecs * 1000;+ else if( TheGameLogic->isGamePaused() )+ m_hudRealClockBaseMs += nowMs - m_hudLastDrawMs;+ m_hudLastDrawMs = nowMs;UnsignedInt realSecs = (nowMs - m_hudRealClockBaseMs) / 1000;UnicodeString text;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cppindex bec3e4202..5aa9bc8a5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp@@ -1381,20 +1381,17 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )// the first one to pass the affordability check withdraws the money and every other// member then fails it. That is why clicking four upgrades on four selected barracks// stacked all four on one of them. The bar already chose the least loaded building;- // honour that choice when the id is one of the selected objects the player controls,- // and fall back to the old group-wide path otherwise. An object upgrade is bought per- // building, and the bar now sends one message per building it wants it on, so the- // group-wide path must not fire for those either - it would queue N messages on N- // buildings each.+ // honour that choice whenever the player controls the named object, and fall back to+ // the old group-wide path otherwise. An object upgrade is bought per building, and the+ // bar now sends one message per building it wants it on, so the group-wide path must+ // not fire for those either - it would queue N messages on N buildings each.+ // The named object is authorized by the ownership check below and the revalidation+ // after it, not by being in the selection: the bar also sends this from the stand-in+ // builder's bar, where nothing is selected at all - which is where the GLA worker's+ // fake-buildings toggle lives, so requiring a selection left the worker stuck on+ // whichever page it was last put on.//- Object *producer = NULL;- if( currentlySelectedGroup )- {- ObjectID producerID = msg->getArgument( 0 )->objectID;- const VecObjectID& ids = currentlySelectedGroup->getAllIDs();- if( std::find( ids.begin(), ids.end(), producerID ) != ids.end() )- producer = TheGameLogic->findObjectByID( producerID );- }+ Object *producer = TheGameLogic->findObjectByID( msg->getArgument( 0 )->objectID );if( producer && producer->getControllingPlayer() == thisPlayer ){