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.

feat(gameengine): add the switches and counters an AI audit needs

Olcay Seygan622a6f92cead
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 2c4d30bf2..e8eaa5a17 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -115,7 +115,7 @@ public:
Bool m_useHeatEffects;
Bool m_useFpsLimit;
Bool m_useGroupPaths; ///< false = -nogrouppath: every unit solves its own path, no shared corridor
- Bool m_useCrossingCost; ///< false = -nocrosstime: the reservation map is not kept and paths ignore when other units will be where
+ Bool m_useCrossingCost; ///< false = -nocrosstime: the reservation map is still kept, but no search reads it
Bool m_dumpAssetUsage;
Int m_framesPerSecondLimit;
Int m_chipSetType; ///<See W3DShaderManager::ChipsetType for options
@@ -374,9 +374,12 @@ public:
Bool m_autoSkirmishObserver; ///< -observer: the local slot of an auto-started skirmish watches instead of playing
Bool m_headless; ///< -headless: never draw a frame, never pace the logic tick, quit when the match ends
Int m_autoSkirmishAIStateOdd; ///< -aidiff2 <name>: rung for the odd-numbered slots (0 = same as -aidiff)
+ Int m_autoSkirmishTeams; ///< -teams <n>: split the auto-skirmish slots into n allied teams (0 or 1 = free-for-all)
Int m_maxGameFrames; ///< -maxframes <n>: quit after n logic frames however the match is going (0 = no limit)
Int m_autoCameraSeconds; ///< -autocamera <n>: every n seconds, move the camera to wherever the fighting is (0 = off)
Int m_traceMoveID; ///< -tracemove [id]: log one movement line a frame for this object (0 = off, -1 = the first unit that gets blocked)
+ Real m_slowFrameMS; ///< -slowframe <ms>: a logic frame over this long logs its own breakdown (default 20)
+ Int m_aiSliceFrames; ///< -aislice <n>: a unit's AI decides once every n logic frames, staggered by id (1 = every frame, the default)
AsciiString m_netGameHosts; ///< -netgame <ip>[,<ip>...]: the slot list of a LAN game started from the command line (empty = off)
Int m_netGameLocalSlot; ///< -netslot <n>: which of those addresses this copy of the game is
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
index ba7a24694..e07cda81a 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
@@ -447,6 +447,14 @@ public:
* find out. */
static Real getLastPathfindMS( void ) { return s_lastPathfindMS; }
static Real getLastPlayerUpdateMS( void ) { return s_lastPlayerUpdateMS; }
+
+ /* Target acquisitions this logic frame. The partition manager counts every range query it is
+ asked for; this counts the ones that are a unit looking for somebody to shoot, which is the
+ difference between knowing which subsystem to work on and guessing. Zeroed with the partition
+ counters at the top of the frame. */
+ static Int getEnemyScanCountThisFrame( void ) { return s_enemyScans; }
+ static void resetEnemyScanCount( void ) { s_enemyScans = 0; }
+ static void bumpEnemyScanCount( void ) { ++s_enemyScans; }
enum
{
CAN_SEE = 1 << 0,
@@ -479,6 +487,7 @@ public:
static void parseAiDataDefinition( INI* ini );
+ static Int s_enemyScans; ///< see getEnemyScanCountThisFrame
static Real s_lastPathfindMS; ///< see getLastPathfindMS
static Real s_lastPlayerUpdateMS; ///< see getLastPlayerUpdateMS
const TAiData *getAiData() {return m_aiData;}
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
index 0298c3c55..982c5144e 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h
@@ -1328,6 +1328,15 @@ public:
virtual void init( void ); ///< initialize
virtual void reset( void ); ///< system reset
virtual void update( void ); ///< system update
+
+ /* Range queries made this logic frame, and objects looked at inside them. getClosestObjects is
+ the most expensive single function in an eight-player match; these say whether that is a few
+ huge queries or a great many small ones, which is not something a sampling profile can tell
+ you. GameLogic zeroes them at the top of its frame and the slow-frame log reads them. */
+ static Int getQueryCountThisFrame( void );
+ static Int getGatherCountThisFrame( void ); ///< of those, the ones that keep every hit in a sorted iterator
+ static Int getQueryObjectCountThisFrame( void );
+ static void resetQueryCounts( void );
// ----------------------------------------------------------------
// --------------- inherited from Snapshot interface --------------
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
index 76022fbad..fc9734d04 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
@@ -1252,6 +1252,33 @@ Int parseNoFPSLimit(char *args[], int num)
return 1;
}
+/* -nogrouppath and -nocrosstime are the control arms for the two group-movement mechanisms this
+ fork added on top of retail, in one binary. Without them the only way to measure either is two
+ exes, and two exes differ in more than the thing being measured.
+
+ -nogrouppath drops the shared corridor: every unit in a selection solves its own path and the
+ congestion cost is all that holds the column apart, which is what retail does for a formation
+ and what PathLab calls single mode. -nocrosstime keeps the reservation map but stops any
+ search reading it, so a route is priced for ground another unit's path covers and not for the
+ moment it will be there. */
+Int parseNoGroupPath(char *args[], int num)
+{
+ if (TheWritableGlobalData)
+ {
+ TheWritableGlobalData->m_useGroupPaths = FALSE;
+ }
+ return 1;
+}
+
+Int parseNoCrossingCost(char *args[], int num)
+{
+ if (TheWritableGlobalData)
+ {
+ TheWritableGlobalData->m_useCrossingCost = FALSE;
+ }
+ return 1;
+}
+
/* -headless is the unattended-run switch: no frame is ever drawn, the logic tick runs flat out
instead of being paced against wall clock, audio is silenced, and the process quits by itself
the moment the match is decided. A window and a D3D device are still created - W3D reaches into
@@ -1373,6 +1400,72 @@ Int parseTraceMove(char *args[], int num)
return 1;
}
+/* -aislice <n> lets a unit's AI decide once every n logic frames instead of every one.
+
+ This is the only lever left that reduces what the AI does rather than how fast it does it, and
+ it is off by default because what it spends is reaction time, not milliseconds: a unit acquires
+ a target and obeys an order up to n-1 frames late. Movement is not sliced - the locomotor still
+ runs every frame, so units keep driving smoothly along the route they already have; it is the
+ deciding that waits. The offset is the object id, so the units do not all think on the same
+ frame, and an id is assigned in creation order and identical on every machine, which keeps this
+ inside the CRC. */
+Int parseAISlice(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1 && args[1])
+ {
+ Int slice = atoi(args[1]);
+ if (slice < 1)
+ slice = 1;
+ if (slice > 8)
+ slice = 8; // past this a unit is visibly asleep, and it is a measuring tool anyway
+ TheWritableGlobalData->m_aiSliceFrames = slice;
+ return 2;
+ }
+ return 1;
+}
+
+/* -teams <n> splits an -autoskirmish lobby into n allied teams instead of a free-for-all.
+
+ Free-for-all and 4v4 are not the same load and not the same game. Eight players each fighting
+ seven others spread the fighting over the whole map; two sides of four put every unit on one of
+ two fronts, which is where units bunch up, where the pathfinder earns its money, and where a
+ player says the game is chugging. Slots are handed out in blocks - the first n-th of them are
+ team 0, the next team 1 - which is how the lobby numbers them, and GameLogic's own alliance
+ setup does the rest from each slot's team number. */
+Int parseTeams(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1 && args[1])
+ {
+ Int teams = atoi(args[1]);
+ if (teams < 1)
+ teams = 1; // one team is a free-for-all, same as not asking
+ if (teams > MAX_SLOTS)
+ teams = MAX_SLOTS;
+ TheWritableGlobalData->m_autoSkirmishTeams = teams;
+ return 2;
+ }
+ return 1;
+}
+
+/* -slowframe <ms> lowers the bar a logic frame has to clear before it logs its own breakdown.
+
+ The default of 20ms is a stutter hunt: it catches the frames a player would notice. Chasing a
+ subsystem's cost is a different search - the question is not "which frames were terrible" but
+ "which frames did this cost anything at all" - and for that the bar wants to be a few
+ milliseconds. Every frame over it writes a line and a flush, so a low bar on a long run is a
+ large log and a slower run; it is a measuring tool, not a setting. */
+Int parseSlowFrame(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1 && args[1])
+ {
+ const Real ms = (Real)atof(args[1]);
+ if (ms > 0.0f)
+ TheWritableGlobalData->m_slowFrameMS = ms;
+ return 2;
+ }
+ return 1;
+}
+
/* -netgame <ip>[,<ip>...] starts a LAN game against those addresses with no lobby in front of it,
and -netslot <n> says which of them this copy is. Every machine is given the same slot list in
the same order, which is all the lobby ever agreed on: the slot list, the map and the seed. A
@@ -1616,6 +1709,11 @@ static CommandLineParam params[] =
{ "-msaa", parseMSAA },
{ "-autocamera", parseAutoCamera },
{ "-tracemove", parseTraceMove },
+ { "-slowframe", parseSlowFrame },
+ { "-teams", parseTeams },
+ { "-aislice", parseAISlice },
+ { "-nogrouppath", parseNoGroupPath },
+ { "-nocrosstime", parseNoCrossingCost },
{ "-replay", parseReplay },
{ "-netgame", parseNetGame },
{ "-netslot", parseNetSlot },
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index ab8403088..e19169146 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -343,7 +343,20 @@ static void startAutoSkirmish( void )
}
slot.setColor( -1 ); // -1 is "random" to populateRandomSideAndColor
slot.setStartPos( -1 ); // and to populateRandomStartPosition
- slot.setTeamNumber( -1 ); // -1 is "no team", so everybody fights everybody
+ /* -teams splits the lobby into allied blocks: with eight players and two teams the first
+ four are team 0 and the rest team 1, the way the lobby numbers them. GameLogic's own
+ alliance pass reads the slot's team number and does the rest. Without it every slot is
+ -1, which is "no team", and everybody fights everybody. */
+ Int teamNumber = -1;
+ const Int teams = TheGlobalData->m_autoSkirmishTeams;
+ if (teams > 1 && numPlayers >= teams)
+ {
+ const Int perTeam = (numPlayers + teams - 1) / teams;
+ teamNumber = i / perTeam;
+ if (teamNumber >= teams)
+ teamNumber = teams - 1; // an uneven split puts the remainder on the last team
+ }
+ slot.setTeamNumber( teamNumber );
TheSkirmishGameInfo->setSlot( i, slot );
}
TheSkirmishGameInfo->setLocalIP( TheSkirmishGameInfo->getSlot(0)->getIP() );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 821688baa..e226ba1c8 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -630,6 +630,8 @@ GlobalData::GlobalData()
m_useDrawModuleLOD = FALSE;
m_useHeatEffects = TRUE;
m_useFpsLimit = FALSE;
+ m_useGroupPaths = TRUE;
+ m_useCrossingCost = TRUE;
m_dumpAssetUsage = FALSE;
m_framesPerSecondLimit = 0;
m_chipSetType = 0;
@@ -675,11 +677,14 @@ GlobalData::GlobalData()
m_autoSkirmishPlayers = 0; // no skirmish from the command line
m_autoSkirmishAIState = SLOT_BRUTAL_AI;
m_autoSkirmishAIStateOdd = 0; // 0 = not set: every slot plays at -aidiff
+ m_autoSkirmishTeams = 0; // 0 = not set: every slot fights every other slot
m_autoSkirmishObserver = FALSE;
m_headless = FALSE;
m_maxGameFrames = 0; // run until the match ends
m_autoCameraSeconds = 0; // the camera stays where it was put
m_traceMoveID = 0; // no movement trace
+ m_slowFrameMS = 20.0f; // a frame worth a line in the log; -slowframe lowers it for a hunt
+ m_aiSliceFrames = 1; // every unit thinks every frame, which is what the game has always done
m_netGameHosts.clear(); // no network game from the command line
m_netGameLocalSlot = 0;
m_horizontalScrollSpeedFactor = 1.0;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
index 3cd1084e7..89b4e8b80 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
@@ -356,6 +356,7 @@ void AI::reset( void )
/**
* Update the AI system
*/
+Int AI::s_enemyScans = 0;
Real AI::s_lastPathfindMS = 0.0f;
Real AI::s_lastPlayerUpdateMS = 0.0f;
@@ -677,6 +678,9 @@ Object *AI::findClosestEnemy( const Object *me, Real range, UnsignedInt qualifie
return NULL;
}
+ // counted, so the slow-frame log can say how many of the frame's range queries are this
+ bumpEnemyScanCount();
+
// only consider live, on-map enemies.
// since this gets called a ton, I made a special custom filter to
// combine several canned ones, in the name of speed (srj)
@@ -767,6 +771,23 @@ Object *AI::findClosestEnemy( const Object *me, Real range, UnsignedInt qualifie
MemoryPoolObjectHolder threatHolder(threatIter);
for (Object *theEnemy = threatIter->first(); theEnemy; theEnemy = threatIter->next())
{
+ Real dist = sqrt( ThePartitionManager->getDistanceSquared(me, theEnemy, FROM_BOUNDINGSPHERE_2D) );
+
+ /* Score it as if it were armed first, which is the best this candidate can possibly
+ do: the armed bonus is the only thing getAbleToAttackSpecificObject decides here and
+ it only ever adds. If the best it can do does not beat what we already have, the
+ expensive question never has to be asked at all.
+
+ Same answer as asking every time, and most of the asking gone. This is where an
+ eight-player match spends its partition time - the list is every enemy in vision
+ range, sorted near to far, so the first candidate sets a high bar and the far ones
+ cannot clear it. */
+ const Int armedScore = AI_threatScore( theEnemy->getTemplate()->getThreatValue(),
+ theEnemy->getTemplate()->calcCostToBuild( theEnemy->getControllingPlayer() ),
+ true, dist, distanceModifier );
+ if (armedScore <= bestScore)
+ continue;
+
Bool threatensMe = theEnemy->isAbleToAttack(); // cheap bit test, and required before the call below
if (threatensMe)
{
@@ -774,10 +795,8 @@ Object *AI::findClosestEnemy( const Object *me, Real range, UnsignedInt qualifie
threatensMe = (r == ATTACKRESULT_POSSIBLE || r == ATTACKRESULT_POSSIBLE_AFTER_MOVING);
}
- Real dist = sqrt( ThePartitionManager->getDistanceSquared(me, theEnemy, FROM_BOUNDINGSPHERE_2D) );
- Int score = AI_threatScore( theEnemy->getTemplate()->getThreatValue(),
- theEnemy->getTemplate()->calcCostToBuild( theEnemy->getControllingPlayer() ),
- threatensMe, dist, distanceModifier );
+ // the bonus is added last and nothing else in the score depends on it
+ const Int score = threatensMe ? armedScore : (armedScore - AI_THREAT_ARMED_BONUS);
if (score > bestScore)
{
bestScore = score;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
index 71701dfb2..9ab279c00 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
@@ -90,6 +90,18 @@
#include "common/mapobject.h"
#endif
+/* Range queries this logic frame, and objects looked at inside them. Zeroed by
+ PartitionManager::update, read by the slow-frame log; counts only, no clock, because this sits
+ in the innermost loop of the most called function in the game. */
+static Int thePartitionQueries = 0;
+static Int thePartitionGathers = 0;
+static Int thePartitionQueryObjects = 0;
+
+Int PartitionManager::getQueryCountThisFrame( void ) { return thePartitionQueries; }
+Int PartitionManager::getGatherCountThisFrame( void ) { return thePartitionGathers; }
+Int PartitionManager::getQueryObjectCountThisFrame( void ) { return thePartitionQueryObjects; }
+void PartitionManager::resetQueryCounts( void ) { thePartitionQueries = 0; thePartitionGathers = 0; thePartitionQueryObjects = 0; }
+
#ifdef DUMP_PERF_STATS
long s_countInClosestObjects = 0;
long s_countInClosestObjectsThisFrame = 0;
@@ -3292,6 +3304,15 @@ Object *PartitionManager::getClosestObjects(
objPos = obj->getPosition();
objToUse = obj;
}
+ /* This is the single most expensive function in an eight-player match - 9.6% of the whole game
+ in a sampling profile - and nothing said whether that was a few enormous queries or a great
+ many small ones. Two counters, read by the slow-frame log, which is the difference between
+ knowing and guessing. */
+ ++thePartitionQueries;
+ // the gathering form is the dear one: it keeps every survivor, sorted, in a pooled iterator
+ if (iterArg)
+ ++thePartitionGathers;
+
Int cellCenterX, cellCenterY;
worldToCell(objPos->x, objPos->y, &cellCenterX, &cellCenterY);
@@ -3342,9 +3363,10 @@ Object *PartitionManager::getClosestObjects(
{
PartitionData *thisMod = thisCoi->getModule();
Object *thisObj = thisMod->getObject();
+ ++thePartitionQueryObjects;
// never compare against ourself.
- if (thisObj == obj || thisObj == NULL)
+ if (thisObj == obj || thisObj == NULL)
continue;
// since an object can exist in multiple COIs, we use this to avoid processing
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
index cffdf2e5a..3f102b994 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
@@ -3893,6 +3893,8 @@ void GameLogic::update( void )
Split so the log names which one. */
Int64 tDestroy = 0, tCommandList = 0, tStores = 0, tVictory = 0;
QueryPerformanceCounter( (LARGE_INTEGER *)&tFrameStart );
+ PartitionManager::resetQueryCounts(); // counted per logic frame, reported by the slow-frame log
+ AI::resetEnemyScanCount();
Pathfinder::resetProfile();
#ifdef DEBUG_LOGGING
resetModuleProfile();
@@ -4156,7 +4158,8 @@ void GameLogic::update( void )
// how long did that take? only a frame that ran over budget is worth a line in the log
QueryPerformanceCounter( (LARGE_INTEGER *)&tFrameEnd );
{
- const Real SLOW_FRAME_MS = 20.0f; // the logic gets 1/30th of a second, 33ms, per frame
+ // the logic gets 1/30th of a second, 33ms, per frame; -slowframe lowers the bar for a hunt
+ const Real SLOW_FRAME_MS = TheGlobalData ? TheGlobalData->m_slowFrameMS : 20.0f;
const Real total = logicElapsedMS( tFrameStart, tFrameEnd );
if( total > SLOW_FRAME_MS && now > 60 && getGameMode() != GAME_SHELL && getGameMode() != GAME_NONE )
{
@@ -4170,8 +4173,11 @@ void GameLogic::update( void )
const Real stores = logicElapsedMS( tCommandList, tStores );
const Real victory = logicElapsedMS( tStores, tVictory );
const Real disabled = logicElapsedMS( tVictory, tFrameEnd );
- DEBUG_LOG(("SLOW LOGIC FRAME %d: %.1fms | scripts %.1f | objects %.1f | ai %.1f (pathfind %.1f, players %.1f) | partition %.1f | rest %.1f (destroy %.1f, cmdlist %.1f, stores %.1f, victory %.1f, disabled %.1f)\n sc: %s\n ob: %s\n pf: %s\n ai: %s\n",
- now, total, scripts, objects, ai, AI::getLastPathfindMS(), AI::getLastPlayerUpdateMS(), partition, rest,
+ DEBUG_LOG(("SLOW LOGIC FRAME %d: %.1fms | scripts %.1f | objects %.1f | ai %.1f (pathfind %.1f, players %.1f) | partition %.1f (%d queries, %d gathers, %d target scans, %d objects) | rest %.1f (destroy %.1f, cmdlist %.1f, stores %.1f, victory %.1f, disabled %.1f)\n sc: %s\n ob: %s\n pf: %s\n ai: %s\n",
+ now, total, scripts, objects, ai, AI::getLastPathfindMS(), AI::getLastPlayerUpdateMS(), partition,
+ PartitionManager::getQueryCountThisFrame(), PartitionManager::getGatherCountThisFrame(),
+ AI::getEnemyScanCountThisFrame(),
+ PartitionManager::getQueryObjectCountThisFrame(), rest,
destroy, cmdlist, stores, victory, disabled,
TheScriptEngine->getProfileReport(),
getModuleProfileReport(),
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index b28e4f722..3d5d9642b 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -6690,6 +6690,48 @@ TEST(an_option_read_before_the_parser_exists_is_read_on_word_boundaries)
CHECK( !findCommandLineValueIn( L"-logPrefix abcdef", L"-logPrefix", tiny, 0 ) );
}
+TEST(the_two_group_movement_switches_are_on_until_the_command_line_says_otherwise)
+{
+ /* Both of these were declared with a comment promising a switch and then never written, never
+ read and never initialised - so the field held whatever the allocator left there, and the
+ only way to measure either mechanism was to build a second exe. A control arm has to be in
+ the same binary as the thing it is controlling: two exes differ in more than the change. */
+ GlobalData *saved = TheWritableGlobalData;
+ TheWritableGlobalData = NEW GlobalData;
+
+ // the default is what this fork has always done: the shared corridor, and the crossing cost
+ CHECK( TheGlobalData->m_useGroupPaths );
+ CHECK( TheGlobalData->m_useCrossingCost );
+
+ char exe[] = "generals.exe";
+ char noGroupPath[] = "-nogrouppath";
+ char noCrossTime[] = "-NOCROSSTIME"; // the table matches case-insensitively
+ char *argv[] = { exe, noGroupPath, noCrossTime };
+ parseCommandLine( 3, argv );
+
+ CHECK( !TheGlobalData->m_useGroupPaths );
+ CHECK( !TheGlobalData->m_useCrossingCost );
+
+ /* -slowframe is the third of the same family: it lowers the bar a logic frame has to clear
+ before it writes its own breakdown, which is how a subsystem's cost gets hunted rather than
+ a stutter. A value that is not a positive number leaves the default alone rather than
+ silencing the log. */
+ CHECK_NEAR( TheGlobalData->m_slowFrameMS, 20.0f, 0.001f );
+ char slowFrame[] = "-slowframe";
+ char three[] = "3";
+ char *argvSlow[] = { exe, slowFrame, three };
+ parseCommandLine( 3, argvSlow );
+ CHECK_NEAR( TheGlobalData->m_slowFrameMS, 3.0f, 0.001f );
+
+ char nonsense[] = "later";
+ char *argvBad[] = { exe, slowFrame, nonsense };
+ parseCommandLine( 3, argvBad );
+ CHECK_NEAR( TheGlobalData->m_slowFrameMS, 3.0f, 0.001f );
+
+ delete TheWritableGlobalData;
+ TheWritableGlobalData = saved;
+}
+
TEST(a_netgame_slot_list_is_the_player_order_on_every_machine)
{
/* -netgame carries what the LAN lobby otherwise agrees on: who plays, at which address, in
diff --git a/ai-batch.ps1 b/ai-batch.ps1
index 148704fc7..7cf599f50 100644
--- a/ai-batch.ps1
+++ b/ai-batch.ps1
@@ -35,6 +35,10 @@ param(
[string] $Difficulty = "brutal",
# rung for the odd-numbered slots; empty means the same as -Difficulty, so a rung plays itself
[string] $Difficulty2 = "",
+ # split the slots into this many allied teams instead of a free-for-all: 2 with -Players 8 is
+ # 4v4. Free-for-all spreads the fighting over the whole map; teams put every unit on one of two
+ # fronts, which is the load a player actually complains about
+ [int] $Teams = 0,
# a match that has not been decided by here is a result in itself: the AI cannot finish
[int] $MaxFrames = 30000,
# names this batch's logs, so two batches can be compared afterwards
@@ -107,6 +111,7 @@ for ($i = 0; $i -lt $Runs; $i++) {
)
# a second rung for the odd slots, so one rung can be played against another
if ($Difficulty2) { $args += "-aidiff2"; $args += $Difficulty2 }
+ if ($Teams -gt 1) { $args += "-teams"; $args += $Teams }
if ($ExtraArgs.Count) { $args += $ExtraArgs }
$where = if ($Map) { $Map } else { "$cells cells" }
@@ -204,7 +209,7 @@ for ($i = 0; $i -lt $Runs; $i++) {
# ---------------------------------------------------------------------------------------------
Write-Host ""
-Write-Host "=== $Tag : $Runs matches, $Players players, $Difficulty$(if ($Difficulty2) { " vs " + $Difficulty2 }), $(if ($Map) { "on $Map" } else { "generated maps" }), $Exe, cap $MaxFrames frames$(if ($ExtraArgs.Count) { ", " + ($ExtraArgs -join ' ') }) ==="
+Write-Host "=== $Tag : $Runs matches, $Players players$(if ($Teams -gt 1) { " in $Teams teams" }), $Difficulty$(if ($Difficulty2) { " vs " + $Difficulty2 }), $(if ($Map) { "on $Map" } else { "generated maps" }), $Exe, cap $MaxFrames frames$(if ($ExtraArgs.Count) { ", " + ($ExtraArgs -join ' ') }) ==="
$decided = @($rows | Where-Object { $_.Why -eq "decided" })
Write-Host ("decided {0}/{1} frame-limited {2} failed {3}" -f