File tree Expand file tree Collapse file tree 6 files changed +19
-21
lines changed
GeneralsMD/Code/GameEngine Expand file tree Collapse file tree 6 files changed +19
-21
lines changed Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ class GlobalData : public SubsystemInterface
406406 Bool m_useCameraInReplay;
407407
408408 // TheSuperHackers @feature L3-M 21/08/2025 toggle the money per minute display; 'no' shows only the original current money
409- Bool m_moneyPerMinute ;
409+ Bool m_showMoneyPerMinute ;
410410
411411 // TheSuperHackers @feature Mauller 21/06/2025 allow the system time and game time font size to be set, a size of zero disables them
412412 Int m_systemTimeFontSize;
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ class OptionPreferences : public UserPreferences
128128 Bool getFPSLimitEnabled (void );
129129 Bool getNoDynamicLODEnabled (void );
130130 Bool getBuildingOcclusionEnabled (void );
131- Bool getMoneyPerMinute (void );
131+ Bool getShowMoneyPerMinute (void );
132132 Int getParticleCap (void );
133133
134134 Int getCampaignDifficulty (void );
Original file line number Diff line number Diff line change @@ -934,7 +934,7 @@ GlobalData::GlobalData()
934934 m_saveCameraInReplay = FALSE ;
935935 m_useCameraInReplay = FALSE ;
936936
937- m_moneyPerMinute = TRUE ;
937+ m_showMoneyPerMinute = FALSE ;
938938
939939 m_systemTimeFontSize = 8 ;
940940 m_gameTimeFontSize = 8 ;
@@ -1205,7 +1205,7 @@ void GlobalData::parseGameDataDefinition( INI* ini )
12051205
12061206 TheWritableGlobalData->m_systemTimeFontSize = optionPref.getSystemTimeFontSize ();
12071207 TheWritableGlobalData->m_gameTimeFontSize = optionPref.getGameTimeFontSize ();
1208- TheWritableGlobalData->m_moneyPerMinute = optionPref.getMoneyPerMinute ();
1208+ TheWritableGlobalData->m_showMoneyPerMinute = optionPref.getShowMoneyPerMinute ();
12091209
12101210 Int val=optionPref.getGammaValue ();
12111211 // generate a value between 0.6 and 2.0.
Original file line number Diff line number Diff line change 4444
4545#include " PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
4646#include " Common/Money.h"
47+ #include < numeric>
4748
4849#include " Common/AudioSettings.h"
4950#include " Common/GameAudio.h"
@@ -109,7 +110,7 @@ void Money::setStartingCash(UnsignedInt amount)
109110 m_money = amount;
110111 m_currentBucket = 0 ;
111112 m_lastBucketFrame = 0 ;
112- for (UnsignedInt i = 0 ; i < 60 ; ++i)
113+ for (UnsignedInt i = 0 ; i < ARRAY_SIZE (m_incomeBuckets) ; ++i)
113114 m_incomeBuckets[i] = 0 ;
114115}
115116
@@ -124,22 +125,17 @@ void Money::updateIncomeBucket()
124125 {
125126 if (diff > 60 )
126127 diff = 60 ;
128+ m_currentBucket = (m_currentBucket + diff) % ARRAY_SIZE (m_incomeBuckets);
127129 for (UnsignedInt i = 0 ; i < diff; ++i)
128- {
129- m_currentBucket = (m_currentBucket + 1 ) % 60 ;
130130 m_incomeBuckets[m_currentBucket] = 0 ;
131- }
132131 }
133132 m_lastBucketFrame = frame;
134133}
135134
136135// ------------------------------------------------------------------------------------------------
137136UnsignedInt Money::getCashPerMinute () const
138137{
139- UnsignedInt sum = 0 ;
140- for (UnsignedInt i = 0 ; i < 60 ; ++i)
141- sum += m_incomeBuckets[i];
142- return sum;
138+ return std::accumulate (m_incomeBuckets, m_incomeBuckets + ARRAY_SIZE (m_incomeBuckets), 0u );
143139}
144140
145141void Money::triggerAudioEvent (const AudioEventRTS& audioEvent)
Original file line number Diff line number Diff line change @@ -828,11 +828,11 @@ Int OptionPreferences::getGameTimeFontSize(void)
828828 return fontSize;
829829}
830830
831- Bool OptionPreferences::getMoneyPerMinute (void )
831+ Bool OptionPreferences::getShowMoneyPerMinute (void )
832832{
833- OptionPreferences::const_iterator it = find (" MoneyPerMinute " );
833+ OptionPreferences::const_iterator it = find (" ShowMoneyPerMinute " );
834834 if (it == end ())
835- return TheGlobalData->m_moneyPerMinute ;
835+ return TheGlobalData->m_showMoneyPerMinute ;
836836
837837 if (stricmp (it->second .str (), " yes" ) == 0 )
838838 {
@@ -1370,10 +1370,10 @@ static void saveOptions( void )
13701370 // -------------------------------------------------------------------------------------------------
13711371 // Set Money Per Minute
13721372 {
1373- Bool showIncome = pref->getMoneyPerMinute ();
1373+ Bool showIncome = pref->getShowMoneyPerMinute ();
13741374 AsciiString prefString;
13751375 prefString = showIncome ? " yes" : " no" ;
1376- (*pref)[" MoneyPerMinute " ] = prefString;
1376+ (*pref)[" ShowMoneyPerMinute " ] = prefString;
13771377 }
13781378
13791379 // -------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -1854,7 +1854,7 @@ void InGameUI::update( void )
18541854 if ( moneyPlayer)
18551855 {
18561856 Money *money = moneyPlayer->getMoney ();
1857- Bool showIncome = TheGlobalData->m_moneyPerMinute ;
1857+ Bool showIncome = TheGlobalData->m_showMoneyPerMinute ;
18581858 if (!showIncome)
18591859 {
18601860 Int currentMoney = money->countMoney ();
@@ -1879,22 +1879,24 @@ void InGameUI::update( void )
18791879 UnicodeString buffer;
18801880 UnicodeString moneyStr;
18811881 UnicodeString incomeStr;
1882+
18821883 if (currentMoney >= 100000 )
18831884 {
1884- moneyStr.format (L" %dK " , currentMoney / 1000 );
1885+ moneyStr.format (L" %dk " , currentMoney / 1000 );
18851886 }
18861887 else
18871888 {
18881889 moneyStr.format (L" %d" , currentMoney);
18891890 }
1891+
18901892 if (cashPerMin >= 10000 )
18911893 {
1892- incomeStr.format (L" %dK " , cashPerMin / 1000 );
1894+ incomeStr.format (L" %dk " , cashPerMin / 1000 );
18931895 }
18941896 else if (cashPerMin >= 1000 )
18951897 {
18961898 UnsignedInt k = cashPerMin / 100 ;
1897- incomeStr.format (L" %d.%dK " , k / 10 , k % 10 );
1899+ incomeStr.format (L" %d.%dk " , k / 10 , k % 10 );
18981900 }
18991901 else
19001902 {
You can’t perform that action at this time.
0 commit comments