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(w3ddevice): step the police car light on the logic clock
Olcay Seygand298b9bb5ee1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5a2f29508..bb4c722d5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -383,6 +383,7 @@ found and fixed — EA's own, not port damage.**- A mission script that waits for a line of speech to finish waits the same length of time on every machine. It used to ask the sound hardware how long the file was, so a player whose sound card was not working, or was turned off, got the answer zero and walked straight through waits that everyone else sat out. That is a different game on two screens, and a replay that stops matching the machine that recorded it. The length now comes out of the file itself: measured on one line of speech, a silent machine said 0 milliseconds and a machine with sound said 3,285. Both say 3,285 now.- Laying a foundation costs less the further up the map you build. Flattening the ground under a new building scanned every row of the map from the bottom edge up to the building, threw all of them away bar the ones actually under it, and did that once per column. It works out the rows it needs now. The ground comes out identical, down to the last unit of height.- EVA announcements that were queued behind another one no longer go quiet. A request waits its turn and expires if its turn never comes, and the sum that worked out when that was could wrap round to zero, retiring the announcement on the frame it was asked for.+- Police car lights flash at their own speed instead of your monitor's. On a fast screen with the frame cap off they were cycling five and a half times too quickly.- Ten more places that wrote terrain, roads, bridges, trees, foundations and scorch marks into a buffer the graphics card had refused to hand over. Every one of them wrote to address zero instead, and a graphics device pulled out from under the game is all it takes; the frame is simply skipped now.- Tank tracks no longer crash the game. The renderer has to borrow the buffer it writes them into, and when that request failed, which is what a graphics device pulled out from under the game does, the tracks were written to address zero anyway. Two more of the same shape went with it: the screenshot path and the texture size lookup both used a pointer that the failing call had never filled in. Three of those texture lookups also leaked the surface they asked about, once per procedural texture, for the life of the process.- 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.diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.hindex 27fdea725..048d140df 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h@@ -61,6 +61,7 @@ protected:W3DDynamicLight *m_light; ///< light for the POLICECARReal m_curFrame;+ UnsignedInt m_lastAnimFrame; ///< logic frame the light last stepped on; see doDrawModule};diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cppindex 39bb6c1aa..28e9e3573 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp@@ -33,6 +33,7 @@#include "Common/Thing.h"#include "Common/Xfer.h"#include "GameClient/Drawable.h"+#include "GameClient/GameClient.h"#include "W3DDevice/GameClient/Module/W3DPoliceCarDraw.h"#include "W3DDevice/GameClient/W3DDisplay.h"#include "common/RandomValue.h"@@ -76,6 +77,7 @@ W3DPoliceCarDraw::W3DPoliceCarDraw( Thing *thing, const ModuleData* moduleData ){m_light = NULL;m_curFrame = GameClientRandomValueReal(0, 10 );+ m_lastAnimFrame = 0;}@@ -109,12 +111,22 @@ void W3DPoliceCarDraw::doDrawModule(const Matrix3D* transformMtx)return;HAnimClass *anim = policeCarRenderObj->Peek_Animation();- if (anim)- {+ if (anim)+ {Real frames = anim->Get_Num_Frames();- m_curFrame += animAmt;- if (m_curFrame > frames-1) {- m_curFrame = 0;+ //+ // animAmt is a quarter of an animation frame per LOGIC frame, but doDrawModule runs once+ // per RENDER frame: uncapped, the light span through its cycle at (fps/30) times speed.+ // Step it on the logic clock, the same way the tree sway does.+ //+ const UnsignedInt now = TheGameClient ? TheGameClient->getFrame() : 0;+ if (now != m_lastAnimFrame)+ {+ m_lastAnimFrame = now;+ m_curFrame += animAmt;+ if (m_curFrame > frames-1) {+ m_curFrame = 0;+ }}policeCarRenderObj->Set_Animation(anim, m_curFrame);}