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.

test(gameengine): scenarios that put hundreds of angry mobs on one map

Olcay Seygan67489805e64e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30143475e..fb1543d28 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -845,7 +845,7 @@ found and fixed — EA's own, not port damage.**
- The four together, on the same four battles: the average logic frame is a fifth shorter, the worst frame of a match went from 38.6 milliseconds to 16.0, frames over a sixtieth of a second went from 2 to none at all, and the number of frames costing more than 3 milliseconds fell from 14,105 to 3,360. In an eight-player 4v4 the average frame is a tenth shorter and the worst one went from 26.7 milliseconds to 17.9.
- Putting a building on uneven ground froze the picture for a sixteenth of a second. Levelling the dirt under a foundation asked the game to re-light every blade of grass on the map - sixty-one milliseconds, measured, for a patch a few paces wide. It now redoes the patch. Over a seven-minute four-way battle that took the worst frame of the match from 82 milliseconds down to 19, and left nothing at all above a thirtieth of a second.
-- The rest of the same mob. A mob is a leader and ten rioters, and a rioter only reconsiders where it is standing once every sixteen frames - but it was woken on all sixteen anyway, just to be sent back to sleep, and every mob on the map is eleven of those. EA left a note in the code asking for exactly this and never came back to it. The rioters sleep properly now, and one whose mob is dead stops being woken at all. Eight mobs on the field is eighty rioters: where all eighty were woken every frame, five are.
+- The rest of the same mob. A mob is a leader and ten rioters, and a rioter only reconsiders where it is standing once every sixteen frames - but it was woken on all sixteen anyway, just to be sent back to sleep, and every mob on the map is eleven of those. EA left a note in the code asking for exactly this and never came back to it. The rioters sleep properly now, and one whose mob is dead stops being woken at all. Eight mobs on the field is eighty rioters: where all eighty were woken every frame, five are. Measured against the number in the complaint rather than a comfortable one: a hundred mobs is 1,100 men and costs 4.3 milliseconds of a 33 millisecond frame, two hundred and fifty is 2,750 men and 7.1, four hundred is 4,400 men and 12.6, and not one frame of any of those three ran over budget. Four hundred mobs is past anything a match will produce; what the rioters cost there is a fifth of a millisecond.
## Sound, video, and getting it to start at all
diff --git a/GeneralsMD/Code/Data/Scenarios/mob100.txt b/GeneralsMD/Code/Data/Scenarios/mob100.txt
new file mode 100644
index 000000000..945a82de7
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/mob100.txt
@@ -0,0 +1,25 @@
+# A hundred angry mobs, marched back and forth for the whole match.
+#
+# The point of this one is the number in the goal: hundreds of mobs on the field without the logic
+# frame giving way. A hundred nexuses is 1100 objects, and the marching is what matters - a mob
+# standing still costs almost nothing, while a mob whose members keep falling behind is the case
+# that fires the catch-up path and its pathfinder requests.
+#
+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
+# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover
+# -side 0 FactionGLA -side 1 FactionAmerica -seed 1 -maxframes 6000
+# -scenario mob100 -logPrefix mob100_
+#
+# See mobstress.txt for the line grammar.
+
+30 spawn 0 GLAInfantryAngryMobNexus 100 760 920 40
+
+600 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+1200 move 0 GLAInfantryAngryMobNexus 760 920
+1800 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+2400 move 0 GLAInfantryAngryMobNexus 760 920
+3000 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+3600 move 0 GLAInfantryAngryMobNexus 760 920
+4200 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+4800 move 0 GLAInfantryAngryMobNexus 760 920
+5400 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
diff --git a/GeneralsMD/Code/Data/Scenarios/mob250.txt b/GeneralsMD/Code/Data/Scenarios/mob250.txt
new file mode 100644
index 000000000..1e3931d8a
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/mob250.txt
@@ -0,0 +1,24 @@
+# Two hundred and fifty angry mobs, marched back and forth for the whole match.
+#
+# 250 nexuses is 2750 objects, which is the far end of "hundreds of mobs" and well past anything a
+# real match produces. The marching is the point: a mob standing still costs almost nothing, and
+# the case worth measuring is the one where members keep falling behind their nexus.
+#
+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
+# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover
+# -side 0 FactionGLA -side 1 FactionAmerica -seed 1 -maxframes 6000
+# -scenario mob250 -logPrefix mob250_
+#
+# See mobstress.txt for the line grammar.
+
+30 spawn 0 GLAInfantryAngryMobNexus 250 760 920 35
+
+600 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+1200 move 0 GLAInfantryAngryMobNexus 760 920
+1800 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+2400 move 0 GLAInfantryAngryMobNexus 760 920
+3000 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+3600 move 0 GLAInfantryAngryMobNexus 760 920
+4200 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+4800 move 0 GLAInfantryAngryMobNexus 760 920
+5400 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
diff --git a/GeneralsMD/Code/Data/Scenarios/mob400.txt b/GeneralsMD/Code/Data/Scenarios/mob400.txt
new file mode 100644
index 000000000..4362faed9
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/mob400.txt
@@ -0,0 +1,21 @@
+# Four hundred angry mobs. 4400 objects, which is past anything a match will ever produce and is
+# here to find where the logic frame actually gives way rather than to describe a real game.
+#
+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
+# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover
+# -side 0 FactionGLA -side 1 FactionAmerica -seed 1 -maxframes 6000
+# -scenario mob400 -logPrefix mob400_
+#
+# See mobstress.txt for the line grammar.
+
+30 spawn 0 GLAInfantryAngryMobNexus 400 760 920 30
+
+600 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+1200 move 0 GLAInfantryAngryMobNexus 760 920
+1800 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+2400 move 0 GLAInfantryAngryMobNexus 760 920
+3000 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+3600 move 0 GLAInfantryAngryMobNexus 760 920
+4200 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+4800 move 0 GLAInfantryAngryMobNexus 760 920
+5400 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
diff --git a/GeneralsMD/Code/Data/Scenarios/mobstress.txt b/GeneralsMD/Code/Data/Scenarios/mobstress.txt
index 8cfed9e92..72dff338d 100644
--- a/GeneralsMD/Code/Data/Scenarios/mobstress.txt
+++ b/GeneralsMD/Code/Data/Scenarios/mobstress.txt
@@ -26,8 +26,10 @@
# Coordinates are world positions, the same ones -camera takes, so UI-MAP.md's verified camera
# positions are the cheapest place to find ground that exists.
#
-# Each nexus brings ten members with it, so eight of these is 88 objects.
+# Each nexus brings ten members with it, so forty of these is 440 objects. Eight was tried first
+# and was far too light to measure anything: the whole match sat under a millisecond a frame and
+# the only slow module in it was the one-off birth on frame 30.
-30 spawn 0 GLAInfantryAngryMobNexus 8 760 920 60
-600 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
-1800 move 0 GLAInfantryAngryMobNexus 760 920
+30 spawn 0 GLAInfantryAngryMobNexus 40 760 920 45
+600 attackmove 0 GLAInfantryAngryMobNexus 1400 1400
+1800 move 0 GLAInfantryAngryMobNexus 760 920