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): retire particle systems on a run that never draws

Olcay Seygan95084d51fae7
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index 61a028e58..0dd17abfb 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -1463,6 +1463,14 @@ static void updateHeadlessRun( void )
why, frame,
frame - runStartFrame, wallMs / 1000.0f, logicFps,
logicFps / (Real)TheGameEngine->getFramesPerSecondLimit()));
+ //
+ // Client bookkeeping an unattended run still has to do: nothing draws, so nothing was retiring
+ // particle systems and the count climbed all run (see GameClient::update). Print it, because a
+ // number that is supposed to stay flat is only worth anything if somebody would notice it move.
+ //
+ DEBUG_LOG(("HEADLESS PARTICLES: %d systems, %d particles\n",
+ TheParticleSystemManager ? TheParticleSystemManager->getParticleSystemCount() : -1,
+ TheParticleSystemManager ? TheParticleSystemManager->getParticleCount() : -1));
/* The state of every object in the world, in one number, at the frame the run stopped. Every
movement change in PATHFINDING-PLAN.md edits GameLogic, and a change that plays beautifully
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
index 27ac32ea6..67857ed3b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
@@ -844,6 +844,22 @@ void GameClient::update( void )
TheClientDrawMS = (Real)((double)(drawEnd - drawStart) * 1000.0 / (double)freq);
#endif
}
+ else if( TheParticleSystemManager )
+ {
+ //
+ // The particle manager is updated from inside the draw, and its update is the only thing
+ // that ever retires a particle system. Skipping the draw therefore left every system the
+ // logic created standing for the rest of the run: a four-player brutal match on one seed
+ // held 1,008 of them at frame 6,000, 13,861 at 18,000 and 26,811 at 30,000, growing in a
+ // straight line and never coming down. 30,000 frames is the length of a batch match.
+ //
+ // It cannot move the simulation: ParticleSys.cpp draws on GameClientRandomValue in all
+ // thirty-three places it wants a random number and never on the logic stream, so this is
+ // the same bookkeeping a rendered run does, on a run that has no picture. The same seed
+ // ends with 138 systems instead of 26,811, and the run takes 19.1s against 18.8 and 19.0.
+ //
+ TheParticleSystemManager->update();
+ }
}
{