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): -startingcash sets an autoskirmish run's money

Olcay Seygan0cc6b9dcd34c
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 1648b675c..ca2fdebc8 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -484,6 +484,7 @@ public:
Int m_techRespawn; ///< -techrespawn <n>: the lobby's tech building respawn, in minutes, for an -autoskirmish run
Int m_supplyPileLimit; ///< -supplypilelimit <n>: the lobby's supply pile limit, in players a pile, for an -autoskirmish run
Int m_superweapons; ///< -superweapons <n>: the lobby's superweapon rule, a SUPERWEAPONS_ mode, for an -autoskirmish run
+ Int m_startingCash; ///< -startingcash <n>: the lobby's starting cash for an -autoskirmish run (0 = DefaultStartingCash)
Int m_maxGameFrames; ///< -maxframes <n>: quit after n logic frames however the match is going (0 = no limit)
Int m_screenShotFrame; ///< -screenshot <n>: save one picture when the run reaches logic frame n (0 = never)
Int m_videoStartFrame; ///< -video <from> <to> [name]: the first logic frame recorded
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
index e8a2047e9..b8419e4c0 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
@@ -2235,6 +2235,18 @@ Int parseTechRespawn(char *args[], int num)
return 1;
}
+/* -startingcash <n>: the lobby's starting cash for an -autoskirmish run, any amount rather than the
+ lobby's list, carried the same way as -incomesharing. */
+Int parseStartingCash(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1 && args[1])
+ {
+ TheWritableGlobalData->m_startingCash = atoi(args[1]);
+ return 2;
+ }
+ return 1;
+}
+
/* -supplypilelimit <players>: the lobby's supply pile limit for an -autoskirmish run, carried the
same way as -incomesharing. */
Int parseSupplyPileLimit(char *args[], int num)
@@ -2688,6 +2700,7 @@ static CommandLineParam params[] =
{ "-techrespawn", parseTechRespawn },
{ "-superweapons", parseSuperweapons },
{ "-supplypilelimit", parseSupplyPileLimit },
+ { "-startingcash", parseStartingCash },
{ "-showlanes", parseShowLanes },
{ "-uidrill", parseUIDrill },
{ "-resdrill", parseResDrill },
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index e637fc0ef..3057cec61 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -727,6 +727,12 @@ static void startAutoSkirmish( Int numPlayersWanted )
TheSkirmishGameInfo->setTechRespawn( TheGlobalData->m_techRespawn );
TheSkirmishGameInfo->setSupplyPileLimit( TheGlobalData->m_supplyPileLimit );
TheSkirmishGameInfo->setSuperweaponRestriction( (UnsignedShort)TheGlobalData->m_superweapons );
+ if (TheGlobalData->m_startingCash > 0)
+ {
+ Money cash;
+ cash.deposit( (UnsignedInt)TheGlobalData->m_startingCash, FALSE );
+ TheSkirmishGameInfo->setStartingCash( cash );
+ }
/* -seed makes the whole run repeatable: the seed drives the factions, the colours, the start
positions and every logic random draw after them, so the same command line replays the same
@@ -755,8 +761,8 @@ static void startAutoSkirmish( Int numPlayersWanted )
msg->appendIntegerArgument( 0 );
msg->appendIntegerArgument( maxFPS );
- DEBUG_LOG(("-autoskirmish: %d slots on '%s', seed %d, up to %d fps, %s%s%s\n",
- numPlayers, mapName.str(), seed, maxFPS,
+ DEBUG_LOG(("-autoskirmish: %d slots on '%s', seed %d, starting cash %u, up to %d fps, %s%s%s\n",
+ numPlayers, mapName.str(), seed, TheSkirmishGameInfo->getStartingCash().countMoney(), maxFPS,
observing ? "every slot AI, watching from the free camera" : "slot 0 is the local player",
takeover ? ", seats driverless" : "",
fixedStartPositions ? ", start positions fixed to slot order" : ""));
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 28bbaf40b..b74fec0df 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -725,6 +725,7 @@ GlobalData::GlobalData()
m_techRespawn = 0; // a destroyed tech building stays destroyed unless -techrespawn asks
m_supplyPileLimit = 0; // a supply pile takes any number of players unless -supplypilelimit asks
m_superweapons = 0; // SUPERWEAPONS_ALLOW unless -superweapons asks
+ m_startingCash = 0; // the INI's DefaultStartingCash unless -startingcash asks
m_autoSkirmishObserver = FALSE;
m_headless = FALSE;
m_turbo = FALSE;