Skip to content

Commit de8823f

Browse files
committed
unify(network): Merge GameNetwork and related code (#1735)
1 parent d1c5082 commit de8823f

File tree

26 files changed

+394
-27
lines changed

26 files changed

+394
-27
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ class CustomMatchPreferences : public UserPreferences
7575
Bool getDisallowNonAsianText( void );
7676
void setDisallowNonAsianText( Bool val );
7777

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

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "Common/SubsystemInterface.h"
3737
#include "GameClient/Color.h"
3838
#include "Common/STLTypedefs.h"
39+
#include "Common/Money.h"
3940

4041
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
4142
struct FieldParse;
@@ -438,8 +439,8 @@ class GlobalData : public SubsystemInterface
438439
Real m_standardMinefieldDistance;
439440

440441

441-
Bool m_showMetrics; ///< whether or not to show the metrics.
442-
Int m_defaultStartingCash; ///< The amount of cash a player starts with by default.
442+
Bool m_showMetrics; ///< whether or not to show the metrics.
443+
Money m_defaultStartingCash; ///< The amount of cash a player starts with by default.
443444

444445
Bool m_debugShowGraphicalFramerate; ///< Whether or not to show the graphical framerate bar.
445446

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#pragma once
3131

3232
#include "GameClient/Color.h"
33+
#include "Common/Money.h"
3334

3435
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
3536
struct FieldParse;
@@ -66,6 +67,9 @@ class MultiplayerColorDefinition
6667
typedef std::map<Int, MultiplayerColorDefinition> MultiplayerColorList;
6768
typedef std::map<Int, MultiplayerColorDefinition>::iterator MultiplayerColorIter;
6869

70+
// A list of values to display in the starting money dropdown
71+
typedef std::vector< Money > MultiplayerStartingMoneyList;
72+
6973
//-------------------------------------------------------------------------------------------------
7074
/** Multiplayer Settings container class
7175
* Defines multiplayer settings */
@@ -88,8 +92,6 @@ class MultiplayerSettings : public SubsystemInterface
8892
MultiplayerColorDefinition * findMultiplayerColorDefinitionByName(AsciiString name);
8993
MultiplayerColorDefinition * newMultiplayerColorDefinition(AsciiString name);
9094

91-
inline Int getInitialCreditsMin( void ) { return m_initialCreditsMin; }
92-
inline Int getInitialCreditsMax( void ) { return m_initialCreditsMax; }
9395
inline Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; }
9496
inline Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; }
9597
inline Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; }
@@ -106,6 +108,17 @@ class MultiplayerSettings : public SubsystemInterface
106108
}
107109
MultiplayerColorDefinition * getColor(Int which);
108110

111+
112+
const Money & getDefaultStartingMoney() const
113+
{
114+
DEBUG_ASSERTCRASH( m_gotDefaultStartingMoney, ("You must specify a default starting money amount in multiplayer.ini") );
115+
return m_defaultStartingMoney;
116+
}
117+
118+
const MultiplayerStartingMoneyList & getStartingMoneyList() const { return m_startingMoneyList; }
119+
120+
void addStartingMoneyChoice( const Money & money, Bool isDefault );
121+
109122
private:
110123
Int m_initialCreditsMin;
111124
Int m_initialCreditsMax;
@@ -120,6 +133,9 @@ class MultiplayerSettings : public SubsystemInterface
120133
Int m_numColors;
121134
MultiplayerColorDefinition m_observerColor;
122135
MultiplayerColorDefinition m_randomColor;
136+
MultiplayerStartingMoneyList m_startingMoneyList;
137+
Money m_defaultStartingMoney;
138+
Bool m_gotDefaultStartingMoney;
123139
};
124140

125141
// singleton

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ class SkirmishPreferences : public UserPreferences
5454
Int getPreferredColor(void); // convenience function
5555
AsciiString getPreferredMap(void); // convenience function
5656
Bool usesSystemMapDir(void); // convenience function
57+
58+
Bool getSuperweaponRestricted(void) const;
59+
void setSuperweaponRestricted( Bool superweaponRestricted);
60+
61+
Money getStartingCash(void) const;
62+
void setStartingCash( const Money &startingCash );
5763
};

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
//-----------------------------------------------------------------------------
3636
#include "Common/STLTypedefs.h"
3737

38+
class Money;
3839
typedef UnsignedInt CursorCaptureMode;
3940
typedef UnsignedInt ScreenEdgeScrollMode;
4041

@@ -164,4 +165,9 @@ class LANPreferences : public UserPreferences
164165
Bool usesSystemMapDir(void); // convenience function
165166
Int getNumRemoteIPs(void); // convenience function
166167
UnicodeString getRemoteIPEntry(Int i); // convenience function
168+
169+
Bool getSuperweaponRestricted(void) const;
170+
Money getStartingCash(void) const;
171+
void setSuperweaponRestricted( Bool superweaponRestricted);
172+
void setStartingCash( const Money & startingCash );
167173
};

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

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

121121
time_t m_timeOfDisconnectScreenOn;
122-
123122
Int m_pingsSent;
124123
Int m_pingsRecieved;
125124
UnsignedInt m_pingFrame;

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

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

3636
void PopulateColorComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool isObserver = FALSE);
37-
void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool allowObservers);
37+
void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool allowObservers );
3838
void PopulateTeamComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool isObserver = FALSE);
39+
void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame);
3940

4041
void EnableSlotListUpdates( Bool val );
4142
Bool AreSlotListUpdatesEnabled( void );

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#pragma once
3030

3131
#include "Common/Snapshot.h"
32+
#include "Common/Money.h"
3233
#include "GameNetwork/NetworkDefs.h"
3334
#include "GameNetwork/FirewallHelper.h"
3435

@@ -190,6 +191,13 @@ class GameInfo
190191
inline Int getMapContentsMask( void ) const; ///< Get the map contents mask
191192
void setSeed( Int seed ); ///< Set the random seed for the game
192193
inline Int getSeed( void ) const; ///< Get the game seed
194+
inline Int getUseStats( void ) const; ///< Does this game count towards gamespy stats?
195+
inline void setUseStats( Int useStats );
196+
197+
inline UnsignedShort getSuperweaponRestriction( void ) const; ///< Get any optional limits on superweapons
198+
void setSuperweaponRestriction( UnsignedShort restriction ); ///< Set the optional limits on superweapons
199+
inline const Money & getStartingCash(void) const;
200+
void setStartingCash( const Money & startingCash );
193201

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

@@ -219,6 +227,9 @@ class GameInfo
219227
Bool isPlayerPreorder(Int index);
220228
void markPlayerAsPreorder(Int index);
221229

230+
inline Bool oldFactionsOnly(void) const;
231+
inline void setOldFactionsOnly( Bool oldFactionsOnly );
232+
222233
protected:
223234
Int m_preorderMask;
224235
Int m_crcInterval;
@@ -236,6 +247,10 @@ class GameInfo
236247
UnsignedInt m_mapSize;
237248
Int m_mapMask;
238249
Int m_seed;
250+
Int m_useStats;
251+
Money m_startingCash;
252+
UnsignedShort m_superweaponRestriction;
253+
Bool m_oldFactionsOnly; // Only USA, China, GLA -- not USA Air Force General, GLA Toxic General, et al
239254
};
240255

241256
extern GameInfo *TheGameInfo;
@@ -251,6 +266,12 @@ Bool GameInfo::isInGame( void ) const { return m_inGame; }
251266
void GameInfo::setInGame( void ) { m_inGame = true; }
252267
Bool GameInfo::isGameInProgress( void ) const { return m_inProgress; }
253268
void GameInfo::setGameInProgress( Bool inProgress ) { m_inProgress = inProgress; }
269+
Int GameInfo::getUseStats( void ) const { return m_useStats; }
270+
void GameInfo::setUseStats( Int useStats ) { m_useStats = useStats; }
271+
const Money&GameInfo::getStartingCash( void ) const { return m_startingCash; }
272+
UnsignedShort GameInfo::getSuperweaponRestriction( void ) const { return m_superweaponRestriction; }
273+
Bool GameInfo::oldFactionsOnly(void) const { return m_oldFactionsOnly; }
274+
void GameInfo::setOldFactionsOnly( Bool oldFactionsOnly ) { m_oldFactionsOnly = oldFactionsOnly; }
254275

255276
AsciiString GameInfoToAsciiString( const GameInfo *game );
256277
Bool ParseAsciiStringToGameInfo( GameInfo *game, AsciiString options );
@@ -281,3 +302,4 @@ class SkirmishGameInfo : public GameInfo, public Snapshot
281302
};
282303

283304
extern SkirmishGameInfo *TheSkirmishGameInfo;
305+
extern SkirmishGameInfo *TheChallengeGameInfo;

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+
// TheSuperHackers @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)