Skip to content

Commit eeb7b41

Browse files
committed
unify(network): Merge GameNetwork and related code
1 parent 8db49bf commit eeb7b41

File tree

23 files changed

+371
-40
lines changed

23 files changed

+371
-40
lines changed

Generals/Code/GameEngine/Include/Common/CustomMatchPreferences.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ class CustomMatchPreferences : public UserPreferences
7878
Bool getDisallowNonAsianText( void );
7979
void setDisallowNonAsianText( Bool val );
8080

81+
Bool getSuperweaponRestricted(void) const;
82+
void setSuperweaponRestricted( Bool superweaponRestricted);
83+
84+
Money getStartingCash(void) const;
85+
void setStartingCash( const Money &startingCash );
86+
87+
Bool getFactionsLimited(void) const; // Prefers to only use the original 3 sides, not USA Air Force General, GLA Toxin General, et al
88+
void setFactionsLimited( Bool factionsLimited );
89+
90+
Bool getUseStats( void ) const;
91+
void setUseStats( Bool useStats );
8192
};
8293

8394
#endif // __CUSTOMMATCHPREFERENCES_H__

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "Common/SubsystemInterface.h"
4040
#include "GameClient/Color.h"
4141
#include "Common/STLTypedefs.h"
42+
#include "Common/Money.h"
4243

4344
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
4445
struct FieldParse;
@@ -441,8 +442,8 @@ class GlobalData : public SubsystemInterface
441442
Real m_standardMinefieldDistance;
442443

443444

444-
Bool m_showMetrics; ///< whether or not to show the metrics.
445-
Int m_defaultStartingCash; ///< The amount of cash a player starts with by default.
445+
Bool m_showMetrics; ///< whether or not to show the metrics.
446+
Money m_defaultStartingCash; ///< The amount of cash a player starts with by default.
446447

447448
Bool m_debugShowGraphicalFramerate; ///< Whether or not to show the graphical framerate bar.
448449

Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define _MULTIPLAYERSETTINGS_H_
3434

3535
#include "GameClient/Color.h"
36+
#include "Common/Money.h"
3637

3738
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
3839
struct FieldParse;
@@ -69,6 +70,9 @@ class MultiplayerColorDefinition
6970
typedef std::map<Int, MultiplayerColorDefinition> MultiplayerColorList;
7071
typedef std::map<Int, MultiplayerColorDefinition>::iterator MultiplayerColorIter;
7172

73+
// A list of values to display in the starting money dropdown
74+
typedef std::vector< Money > MultiplayerStartingMoneyList;
75+
7276
//-------------------------------------------------------------------------------------------------
7377
/** Multiplayer Settings container class
7478
* Defines multiplayer settings */
@@ -91,8 +95,6 @@ class MultiplayerSettings : public SubsystemInterface
9195
MultiplayerColorDefinition * findMultiplayerColorDefinitionByName(AsciiString name);
9296
MultiplayerColorDefinition * newMultiplayerColorDefinition(AsciiString name);
9397

94-
inline Int getInitialCreditsMin( void ) { return m_initialCreditsMin; }
95-
inline Int getInitialCreditsMax( void ) { return m_initialCreditsMax; }
9698
inline Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; }
9799
inline Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; }
98100
inline Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; }
@@ -109,6 +111,17 @@ class MultiplayerSettings : public SubsystemInterface
109111
}
110112
MultiplayerColorDefinition * getColor(Int which);
111113

114+
115+
const Money & getDefaultStartingMoney() const
116+
{
117+
DEBUG_ASSERTCRASH( m_gotDefaultStartingMoney, ("You must specify a default starting money amount in multiplayer.ini") );
118+
return m_defaultStartingMoney;
119+
}
120+
121+
const MultiplayerStartingMoneyList & getStartingMoneyList() const { return m_startingMoneyList; }
122+
123+
void addStartingMoneyChoice( const Money & money, Bool isDefault );
124+
112125
private:
113126
Int m_initialCreditsMin;
114127
Int m_initialCreditsMax;
@@ -123,6 +136,9 @@ class MultiplayerSettings : public SubsystemInterface
123136
Int m_numColors;
124137
MultiplayerColorDefinition m_observerColor;
125138
MultiplayerColorDefinition m_randomColor;
139+
MultiplayerStartingMoneyList m_startingMoneyList;
140+
Money m_defaultStartingMoney;
141+
Bool m_gotDefaultStartingMoney;
126142
};
127143

128144
// singleton

Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class SkirmishPreferences : public UserPreferences
5757
Int getPreferredColor(void); // convenience function
5858
AsciiString getPreferredMap(void); // convenience function
5959
Bool usesSystemMapDir(void); // convenience function
60+
61+
Bool getSuperweaponRestricted(void) const;
62+
void setSuperweaponRestricted( Bool superweaponRestricted);
63+
64+
Money getStartingCash(void) const;
65+
void setStartingCash( const Money &startingCash );
6066
};
6167

6268
#endif // __SKIRMISHPREFERENCES_H__

Generals/Code/GameEngine/Include/Common/UserPreferences.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
//-----------------------------------------------------------------------------
3939
#include "Common/STLTypedefs.h"
4040

41+
class Money;
4142
typedef UnsignedInt CursorCaptureMode;
4243
typedef UnsignedInt ScreenEdgeScrollMode;
4344

@@ -166,6 +167,11 @@ class LANPreferences : public UserPreferences
166167
Bool usesSystemMapDir(void); // convenience function
167168
Int getNumRemoteIPs(void); // convenience function
168169
UnicodeString getRemoteIPEntry(Int i); // convenience function
170+
171+
Bool getSuperweaponRestricted(void) const;
172+
Money getStartingCash(void) const;
173+
void setSuperweaponRestricted( Bool superweaponRestricted);
174+
void setStartingCash( const Money & startingCash );
169175
};
170176

171177
#endif // __USERPREFERENCES_H__

Generals/Code/GameEngine/Include/GameNetwork/DisconnectManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class DisconnectManager
123123
Bool m_haveNotifiedOtherPlayersOfCurrentFrame;
124124

125125
time_t m_timeOfDisconnectScreenOn;
126-
127126
Int m_pingsSent;
128127
Int m_pingsRecieved;
129128
UnsignedInt m_pingFrame;

Generals/Code/GameEngine/Include/GameNetwork/GUIUtil.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ void ShowUnderlyingGUIElements( Bool show, const char *layoutFilename, const cha
3737
const char **gadgetsToHide, const char **perPlayerGadgetsToHide );
3838

3939
void PopulateColorComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool isObserver = FALSE);
40-
void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool allowObservers);
40+
void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool allowObservers );
4141
void PopulateTeamComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool isObserver = FALSE);
42+
void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame);
4243

4344
void EnableSlotListUpdates( Bool val );
4445
Bool AreSlotListUpdatesEnabled( void );

Generals/Code/GameEngine/Include/GameNetwork/GameInfo.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define __GAMEINFO_H__
3333

3434
#include "Common/Snapshot.h"
35+
#include "Common/Money.h"
3536
#include "GameNetwork/NetworkDefs.h"
3637
#include "GameNetwork/FirewallHelper.h"
3738

@@ -193,6 +194,13 @@ class GameInfo
193194
inline Int getMapContentsMask( void ) const; ///< Get the map contents mask
194195
void setSeed( Int seed ); ///< Set the random seed for the game
195196
inline Int getSeed( void ) const; ///< Get the game seed
197+
inline Int getUseStats( void ) const; ///< Does this game count towards gamespy stats?
198+
inline void setUseStats( Int useStats );
199+
200+
inline UnsignedShort getSuperweaponRestriction( void ) const; ///< Get any optional limits on superweapons
201+
void setSuperweaponRestriction( UnsignedShort restriction ); ///< Set the optional limits on superweapons
202+
inline const Money & getStartingCash(void) const;
203+
void setStartingCash( const Money & startingCash );
196204

197205
void setSlotPointer( Int index, GameSlot *slot ); ///< Set the slot info pointer
198206

@@ -222,6 +230,9 @@ class GameInfo
222230
Bool isPlayerPreorder(Int index);
223231
void markPlayerAsPreorder(Int index);
224232

233+
inline Bool oldFactionsOnly(void) const;
234+
inline void setOldFactionsOnly( Bool oldFactionsOnly );
235+
225236
protected:
226237
Int m_preorderMask;
227238
Int m_crcInterval;
@@ -239,6 +250,10 @@ class GameInfo
239250
UnsignedInt m_mapSize;
240251
Int m_mapMask;
241252
Int m_seed;
253+
Int m_useStats;
254+
Money m_startingCash;
255+
UnsignedShort m_superweaponRestriction;
256+
Bool m_oldFactionsOnly; // Only USA, China, GLA -- not USA Air Force General, GLA Toxic General, et al
242257
};
243258

244259
extern GameInfo *TheGameInfo;
@@ -254,6 +269,12 @@ Bool GameInfo::isInGame( void ) const { return m_inGame; }
254269
void GameInfo::setInGame( void ) { m_inGame = true; }
255270
Bool GameInfo::isGameInProgress( void ) const { return m_inProgress; }
256271
void GameInfo::setGameInProgress( Bool inProgress ) { m_inProgress = inProgress; }
272+
Int GameInfo::getUseStats( void ) const { return m_useStats; }
273+
void GameInfo::setUseStats( Int useStats ) { m_useStats = useStats; }
274+
const Money&GameInfo::getStartingCash( void ) const { return m_startingCash; }
275+
UnsignedShort GameInfo::getSuperweaponRestriction( void ) const { return m_superweaponRestriction; }
276+
Bool GameInfo::oldFactionsOnly(void) const { return m_oldFactionsOnly; }
277+
void GameInfo::setOldFactionsOnly( Bool oldFactionsOnly ) { m_oldFactionsOnly = oldFactionsOnly; }
257278

258279
AsciiString GameInfoToAsciiString( const GameInfo *game );
259280
Bool ParseAsciiStringToGameInfo( GameInfo *game, AsciiString options );
@@ -284,5 +305,6 @@ class SkirmishGameInfo : public GameInfo, public Snapshot
284305
};
285306

286307
extern SkirmishGameInfo *TheSkirmishGameInfo;
308+
extern SkirmishGameInfo *TheChallengeGameInfo;
287309

288310
#endif // __GAMEINFO_H__

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ GlobalData* GlobalData::m_theOriginal = NULL;
464464
{ "ObjectPlacementShadows", INI::parseBool, NULL, offsetof( GlobalData, m_objectPlacementShadows ) },
465465

466466
{ "StandardPublicBone", INI::parseAsciiStringVectorAppend, NULL, offsetof(GlobalData, m_standardPublicBones) },
467-
{ "ShowMetrics", INI::parseBool, NULL, offsetof( GlobalData, m_showMetrics ) },
468-
{ "DefaultStartingCash", INI::parseUnsignedInt, NULL, offsetof( GlobalData, m_defaultStartingCash ) },
467+
{ "ShowMetrics", INI::parseBool, NULL, offsetof( GlobalData, m_showMetrics ) },
468+
{ "DefaultStartingCash", Money::parseMoneyAmount, NULL, offsetof( GlobalData, m_defaultStartingCash ) },
469469

470470
// NOTE: m_doubleClickTimeMS is still in use, but we disallow setting it from the GameData.ini file. It is now set in the constructor according to the windows parameter.
471471
// { "DoubleClickTimeMS", INI::parseUnsignedInt, NULL, offsetof( GlobalData, m_doubleClickTimeMS ) },

Generals/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
#include "GameLogic/Module/BattlePlanUpdate.h"
9999
#include "GameLogic/VictoryConditions.h"
100100

101+
#include "GameNetwork/GameInfo.h"
101102

102103

103104
//Grey for neutral.
@@ -429,7 +430,16 @@ void Player::init(const PlayerTemplate* pt)
429430

430431
if( m_money.countMoney() == 0 )
431432
{
432-
m_money.deposit( TheGlobalData->m_defaultStartingCash, FALSE );
433+
// TheSuperHacker @bugfix Now correctly deposits the money and fixes its audio and academy issues.
434+
// Note that copying the entire Money class instead would also copy the player index inside of it.
435+
if ( TheGameInfo )
436+
{
437+
m_money.deposit( TheGameInfo->getStartingCash().countMoney(), FALSE );
438+
}
439+
else
440+
{
441+
m_money.deposit( TheGlobalData->m_defaultStartingCash.countMoney(), FALSE );
442+
}
433443
}
434444

435445
m_playerDisplayName.clear();

0 commit comments

Comments
 (0)