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): starting money 10k to 1m plus unlimited

Olcay Seygan5381b0f312d0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1628f84a7..eb12324bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1086,6 +1086,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- The skirmish and LAN rooms are laid out again, on one grid. Each column heading sits over its own column instead of up to 18 pixels to the right of it. The seats and the settings page underneath them start and stop at the same two edges, and Play Game stands under the map and your win record on the right-hand pair. The open tab used to be lettered in a grey that measured about 2 to 1 against the panel and read as a button that was switched off. Play Game waits at the bottom right and the button that leaves the room sits at the bottom left, as far from it as the screen allows. With all eight seats taken, "USA Super Weapon General" still fits in its box. The online room keeps its old layout.
- A GLA computer could stand one superweapon more than its towers paid for. A Scud Storm knocked down leaves a hole, and 20 seconds later a worker climbs out of it and builds the storm again for free. Those 20 seconds the storm was off the books, so a new one went down on the same four towers and then the hole put the old one back: two storms on four Stinger Sites, where every other side stopped at one. The hole now counts as the storm it is about to rebuild. Replays where a computer's superweapon went down while a storm's hole was waiting play out differently.
- Skirmish keeps starting cash and the game speed there. LAN and online keep starting cash next to peace time and the superweapon rule. Before this they were scattered around whatever space each of the three lobby screens happened to have left over.
+- Starting cash in skirmish and multiplayer now runs from 10,000 up to 1,000,000, and the 5,000 choice is gone. An Unlimited choice joins them, where nobody's money ever runs out, for the matches where the point is the armies and not the supply trucks.
- Game speed in the skirmish room is a dropdown now: x0.5, x0.75, x1, x1.5 or x2. The old slider read out a frame rate nobody plays by, and its last notch read "--" and started the match at a thousand game frames a second, which no machine can play and every machine tried to. A speed saved by the old slider comes back as the nearest of the five.
- The speed can change during a skirmish or a mission, too, from the console: `speed 150` for half again as fast, `speed` alone to ask, `speed reset` for normal. It used to live on numpad plus and minus, where the reset landed on one and a half times normal speed and the readout gave a number of frames nobody could read as a speed. Those keys are free again. Network games keep the speed the host picked.
- A Unit Limit box on the settings page caps the match at 840 units, shared out evenly: two players get 420 each, four get 210, eight get 105. Units standing and units waiting in a queue both count against your share, buildings do not, and the build buttons grey out when you reach it. A transport that rolls out full is charged for its riders while it is still in the queue, so a Troop Crawler costs nine and cannot slip eight Red Guards past the limit, and a pair of Red Guards costs two. A shift or control batch near the wall queues as many as still fit and stops there, and a button whose next order would not fit greys out. Your own count and your share sit in the top right corner next to the frame rate, so you can see the wall coming. The host ticks it; everybody else sees it ticked.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index e9f0e5840..f05a90c5c 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -1066,6 +1066,10 @@ GUI:CheatPower
"Unlimited power"
END
+GUI:StartingMoneyUnlimited
+"Unlimited"
+END
+
GUI:CheatNoCooldown
"No cooldowns"
END
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 6ce3a816a..7de534c3b 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15513,6 +15513,10 @@ GUI:CheatPower
"Sınırsız elektrik"
END
+GUI:StartingMoneyUnlimited
+"Sınırsız"
+END
+
GUI:CheatNoCooldown
"Bekleme yok"
END
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Money.h b/GeneralsMD/Code/GameEngine/Include/Common/Money.h
index 3f1a79755..a4b79da80 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Money.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Money.h
@@ -62,13 +62,35 @@ class Money : public Snapshot
public:
- inline Money() : m_money(0), m_playerIndex(0)
+ /** The lobby's "Unlimited" starting cash rides the game options as this amount, and a player who
+ starts with it holds it for the whole match: withdraw pays without taking and deposit adds
+ nothing. */
+ enum { UNLIMITED = 10000000 };
+
+ inline Money() : m_money(0), m_playerIndex(0), m_unlimited(FALSE)
+ {
+ }
+
+ /// an amount with no audio or player behind it, for lists built before either exists
+ explicit Money( UnsignedInt amount ) : m_money(amount), m_playerIndex(0), m_unlimited(FALSE)
{
}
void init()
{
m_money = 0;
+ m_unlimited = FALSE;
+ }
+
+ /// a starting cash of UNLIMITED becomes a purse that never runs out
+ void applyUnlimited()
+ {
+ m_unlimited = ( m_money == UNLIMITED );
+ }
+
+ inline Bool isUnlimited() const
+ {
+ return m_unlimited;
}
inline UnsignedInt countMoney() const
@@ -100,6 +122,7 @@ private:
UnsignedInt m_money; ///< amount of money
Int m_playerIndex; ///< what is my player index?
+ Bool m_unlimited; ///< the match's starting cash was Unlimited: m_money never moves
};
#endif // _MONEY_H_
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MultiplayerSettings.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MultiplayerSettings.cpp
index 3d3c9ddd1..2986d9e56 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MultiplayerSettings.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MultiplayerSettings.cpp
@@ -85,6 +85,12 @@ MultiplayerSettings::MultiplayerSettings()
m_randomColor;
m_gotDefaultStartingMoney = false;
+
+ // The fork's starting cash choices, whatever Multiplayer.ini (retail's 5k, 10k, 20k, 50k, or a
+ // mod's) lists; the INI still names the default.
+ static const UnsignedInt choices[] = { 10000, 25000, 50000, 100000, 500000, 1000000, Money::UNLIMITED };
+ for ( size_t i = 0; i < sizeof( choices ) / sizeof( choices[0] ); ++i )
+ m_startingMoneyList.push_back( Money( choices[i] ) );
} // end MultiplayerSettings
MultiplayerColorDefinition::MultiplayerColorDefinition()
@@ -142,7 +148,7 @@ MultiplayerColorDefinition * MultiplayerSettings::newMultiplayerColorDefinition(
void MultiplayerSettings::addStartingMoneyChoice( const Money & money, Bool isDefault )
{
- m_startingMoneyList.push_back( money );
+ // the list is the fork's own (constructor); only the default comes from the INI
if ( isDefault )
{
DEBUG_ASSERTCRASH( !m_gotDefaultStartingMoney, ("Cannot have more than one default MultiplayerStartingMoneyChoice") );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Money.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Money.cpp
index 9c3fabc58..6412a5024 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Money.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Money.cpp
@@ -68,7 +68,8 @@ UnsignedInt Money::withdraw(UnsignedInt amountToWithdraw, Bool playSound)
if (playSound)
TheAudio->addAudioEvent(&event);
- m_money -= amountToWithdraw;
+ if (!m_unlimited)
+ m_money -= amountToWithdraw;
return amountToWithdraw;
}
@@ -87,7 +88,8 @@ void Money::deposit(UnsignedInt amountToDeposit, Bool playSound)
if (playSound)
TheAudio->addAudioEvent(&event);
- m_money += amountToDeposit;
+ if (!m_unlimited)
+ m_money += amountToDeposit;
if( amountToDeposit > 0 )
{
@@ -110,19 +112,23 @@ void Money::crc( Xfer *xfer )
// ------------------------------------------------------------------------------------------------
/** Xfer method
* Version Info:
- * 1: Initial version */
+ * 1: Initial version
+ * 2: m_unlimited */
// ------------------------------------------------------------------------------------------------
void Money::xfer( Xfer *xfer )
{
// version
- XferVersion currentVersion = 1;
+ XferVersion currentVersion = 2;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
// money value
xfer->xferUnsignedInt( &m_money );
+ if( version >= 2 )
+ xfer->xferBool( &m_unlimited );
+
} // end xfer
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index 069b1cebd..a1becfd8b 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -495,7 +495,6 @@ void Player::init(const PlayerTemplate* pt)
m_nightColor = m_color;
m_money = *pt->getMoney();
- m_money.setPlayerIndex(getPlayerIndex());
m_handicap = *pt->getHandicap();
@@ -504,12 +503,15 @@ void Player::init(const PlayerTemplate* pt)
if ( TheGameInfo )
{
m_money = TheGameInfo->getStartingCash();
+ m_money.applyUnlimited();
}
else
{
m_money = TheGlobalData->m_defaultStartingCash;
}
}
+ // after the starting cash, whose copy would put every purse back on player 0's sounds and stats
+ m_money.setPlayerIndex(getPlayerIndex());
m_playerDisplayName.clear();
m_playerName.clear();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index da20be257..e135b9ddb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1620,6 +1620,7 @@ struct SpectatorStats
Int team;
Int networth; ///< cash plus the build cost of everything standing
Int cash;
+ Bool unlimited; ///< Unlimited starting cash: cash is the fixed purse, shown as the word and kept out of networth
Int income; ///< money earned per minute of match, averaged over the whole of it
Int army; ///< the build cost of everything standing that is not a structure
Int kills; ///< units and buildings destroyed
@@ -1680,7 +1681,8 @@ static std::vector< SpectatorStats > gatherSpectatorStats( const SpectatorStat &
stats.player = player;
stats.team = -1;
stats.cash = player->getMoney()->countMoney();
- stats.networth = stats.cash;
+ stats.unlimited = player->getMoney()->isUnlimited();
+ stats.networth = stats.unlimited ? 0 : stats.cash;
stats.income = frame > 0 ? (Int)( (Int64)score->getTotalMoneyEarned() * FRAMES_PER_MINUTE / frame ) : 0;
stats.army = 0;
stats.kills = score->getTotalUnitsDestroyed() + score->getTotalBuildingsDestroyed();
@@ -2504,11 +2506,17 @@ void InGameUI::update( void )
moneyPlayer = ThePlayerList->getLocalPlayer();
if( moneyPlayer)
{
- Int currentMoney = moneyPlayer->getMoney()->countMoney();
+ // -2 stands for Unlimited, apart from the -1 that a reset leaves, so switching the observed
+ // player between an unlimited purse and a counted one still rewrites the gadget
+ const Bool unlimited = moneyPlayer->getMoney()->isUnlimited();
+ Int currentMoney = unlimited ? -2 : (Int)moneyPlayer->getMoney()->countMoney();
if( m_lastMoneyDisplayed != currentMoney )
{
UnicodeString buffer;
- buffer.format( TheGameText->fetch( "GUI:ControlBarMoneyDisplay" ), currentMoney );
+ if( unlimited )
+ buffer = TheGameText->fetch( "GUI:StartingMoneyUnlimited" );
+ else
+ buffer.format( TheGameText->fetch( "GUI:ControlBarMoneyDisplay" ), currentMoney );
GadgetStaticTextSetText( moneyWin, buffer );
m_lastMoneyDisplayed = currentMoney;
@@ -8330,7 +8338,7 @@ void InGameUI::layOutBroadcast( const std::vector< SpectatorStats > &players, co
row.color = clientPlayerColor( stats.player );
row.name = broadcastNameText( "name" + seat, stats.player, BROADCAST_CARD_NAME_POINTS[ step ], BROADCAST_CARD_NAME_WIDEST );
row.side = broadcastText( "side" + seat, broadcastSide( stats.player ), BROADCAST_WORDS, detailPoints, FALSE );
- row.cash = broadcastText( "cash" + seat, broadcastNumber( "$", stats.cash ), BROADCAST_NUMBERS, detailPoints, TRUE );
+ row.cash = broadcastText( "cash" + seat, stats.unlimited ? TheGameText->fetch( "GUI:StartingMoneyUnlimited" ) : broadcastNumber( "$", stats.cash ), BROADCAST_NUMBERS, detailPoints, TRUE );
row.army = broadcastText( "army" + seat, broadcastNumber( "$", stats.army ), BROADCAST_NUMBERS, detailPoints, TRUE );
row.name->getSize( &width, &height );
if( l.compact )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
index 8da91ab18..35c0a0f9f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
@@ -405,6 +405,8 @@ void PopulateTeamComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGa
// -----------------------------------------------------------------------------
static UnicodeString formatMoneyForStartingCashComboBox( const Money & moneyAmount )
{
+ if ( moneyAmount.countMoney() == Money::UNLIMITED )
+ return TheGameText->fetch( "GUI:StartingMoneyUnlimited" );
UnicodeString rtn;
rtn.format( TheGameText->fetch( "GUI:StartingMoneyFormat" ), moneyAmount.countMoney() );
return rtn;