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): log peak and mean object count in unattended runs
Olcay Seygan870ab528d4d0
diff --git a/GeneralsMD/Code/Data/Cinema/wreckcheck.txt b/GeneralsMD/Code/Data/Cinema/wreckcheck.txtnew file mode 100644index 000000000..b886b7288--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/wreckcheck.txt@@ -0,0 +1,16 @@+# Scenarios/wreckcheck.txt on Twilight Flame: the tank fight east of the middle and its wreckage.+# A Battlemaster dies about frame 93, the Paladins about 201, the Crusaders about 261, so the shots+# run from the Paladins going up to the plates lying on the ground three seconds later.+#+# generals.exe -win -xres 1920 -yres 1080 -msaa 0 -turbo -quickstart -noshellmap -observer+# -multiInstance -noFPSLimit -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2+# -takeover -side 0 FactionAmerica -side 1 FactionChina -seed 7 -scenario wreckcheck+# -cinema wreckcheck -maxframes 480 -logPrefix wreckcheck_shot_++0.5 cut 1430 3780 0.8 -45 8+7.0 shot+9.0 shot+9.6 shot+11.0 shot+13.5 shot+15.0 enddiff --git a/GeneralsMD/Code/Data/Scenarios/wreckcheck.txt b/GeneralsMD/Code/Data/Scenarios/wreckcheck.txtnew file mode 100644index 000000000..73b568739--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/wreckcheck.txt@@ -0,0 +1,26 @@+# Tanks dying on open ground, for the wreckage in ObjectCreationListReforged.ini: six Crusaders and+# two Paladins against three Overlords and four Battlemasters east of Twilight Flame's middle, so+# the Crusader's 19 plates, the Paladin's, the Battlemaster's and the Overlord's scrap all land in+# one view. Two seats, everyone hostile.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionChina -seed 7 -scenario wreckcheck -maxframes 900+# -logPrefix wreckcheck_+#+# Drawn, with Cinema/wreckcheck.txt: swap -headless for -win -xres 1920 -yres 1080 -msaa 0 -turbo+# -cinema wreckcheck. The KILLXP lines in the log give the frame each tank died on.++20 spawn 0 AmericaTankCrusader 6 1380 3800 0+20 spawn 0 AmericaTankPaladin 2 1360 3740 0+20 spawn 1 ChinaTankOverlord 3 1600 3800 180+20 spawn 1 ChinaTankBattleMaster 4 1590 3740 180+40 attackmove 0 AmericaTankCrusader 1600 3800+40 attackmove 0 AmericaTankPaladin 1600 3800+40 attackmove 1 ChinaTankOverlord 1380 3800+40 attackmove 1 ChinaTankBattleMaster 1380 3800++120 tally 0 *+240 tally 0 *+360 tally 0 *+480 tally 1 *diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex 5a42d0d5c..9c0ac6578 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -1753,11 +1753,28 @@ void GameEngine_noteFrameTime( Real ms, UnsignedInt logicFrame )theFrameTimes.note( ms, logicFrame );}+/* The world's object count once a logic tick, debris and dying objects included, so a data change+ that adds objects (more wreckage, more projectiles) is argued with a number. Read-only, and only+ in an unattended run that started counting. */+static UnsignedInt theObjectPeak = 0;+static UnsignedInt theObjectPeakFrame = 0;+static double theObjectSum = 0.0;+static Int theObjectTicks = 0;+void GameEngine_noteLogicTime( Real ms, UnsignedInt logicFrame ){if( !theFrameTimesStarted )return;theLogicTimes.note( ms, logicFrame );++ const UnsignedInt objects = TheGameLogic ? TheGameLogic->getObjectCount() : 0;+ theObjectSum += objects;+ ++theObjectTicks;+ if( objects > theObjectPeak )+ {+ theObjectPeak = objects;+ theObjectPeakFrame = logicFrame;+ }}/** Start counting. Called when an unattended run actually begins, so the map load, the first@@ -1767,6 +1784,10 @@ static void startFrameTimeStats( void ){theFrameTimes.reset();theLogicTimes.reset();+ theObjectPeak = 0;+ theObjectPeakFrame = 0;+ theObjectSum = 0.0;+ theObjectTicks = 0;theFrameTimesStarted = TRUE;#ifdef DEBUG_LOGGINGmemset( &theParticleCost, 0, sizeof(theParticleCost) );@@ -1832,6 +1853,12 @@ static void reportFrameTimeStats( void )theLogicTimes.worstMS(), theLogicTimes.worstAtFrame(),theLogicTimes.countOver( 33.3f )));}++ if( theObjectTicks > 0 )+ {+ DEBUG_LOG(("HEADLESS OBJECTS: peak %u (frame %u) | mean %.0f over %d ticks\n",+ theObjectPeak, theObjectPeakFrame, theObjectSum / theObjectTicks, theObjectTicks));+ }}/** -----------------------------------------------------------------------------------------------