Skip to content

Commit 59e5d9b

Browse files
committed
unify(network): Merge GameSpy and related code (#1735)
1 parent de8823f commit 59e5d9b

File tree

30 files changed

+481
-113
lines changed

30 files changed

+481
-113
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class PlayerTemplate
111111
//const Image *getHiliteImage( void ) const;
112112
//const Image *getPushedImage( void ) const;
113113
const Image *getSideIconImage( void ) const;
114+
inline const AsciiString getTooltip() const { return m_tooltip; }
114115

115116
const ScienceVec& getIntrinsicSciences() const { return m_intrinsicSciences; }
116117
Int getIntrinsicSciencePurchasePoints() const { return m_intrinsicSPP; }
@@ -158,6 +159,7 @@ class PlayerTemplate
158159
AsciiString m_specialPowerShortcutWinName; ///< The name of the window we'll be using for the shortcut bar
159160
Int m_specialPowerShortcutButtonCount; ///< The number of buttons located on the shortcut bar
160161
AsciiString m_loadScreenMusic; ///< the load screen music we want to play
162+
AsciiString m_tooltip; ///< The tooltip describing this player template
161163
Bool m_observer;
162164
Bool m_playableSide;
163165

Generals/Code/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void RefreshGameInfoListBox( GameWindow *mainWin, GameWindow *win );
4040
void RefreshGameListBoxes( void );
4141
void ToggleGameListType( void );
4242

43+
void playerTemplateComboBoxTooltip(GameWindow *wndComboBox, WinInstanceData *instData, UnsignedInt mouse);
44+
void playerTemplateListBoxTooltip(GameWindow *wndListBox, WinInstanceData *instData, UnsignedInt mouse);
45+
4346
enum GameSortType CPP_11(: Int)
4447
{
4548
GAMESORT_ALPHA_ASCENDING = 0,

Generals/Code/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void CancelPatchCheckCallback( void );
3636
void StartDownloadingPatches( void );
3737
void HandleCanceledDownload( Bool resetDropDown = TRUE );
3838

39+
#if RTS_GENERALS
3940
enum OverallStatsPeriod CPP_11(: Int)
4041
{
4142
STATS_TODAY = 0,
@@ -51,9 +52,14 @@ struct OverallStats
5152
Int wins[STATS_MAX];
5253
Int losses[STATS_MAX];
5354
};
55+
#endif
5456

5557
void CheckOverallStats( void );
58+
#if RTS_GENERALS
5659
void HandleOverallStats( const OverallStats& USA, const OverallStats& China, const OverallStats& GLA );
60+
#else
61+
void HandleOverallStats( const char* szHTTPStats, unsigned len );
62+
#endif
5763

5864
void CheckNumPlayersOnline( void );
5965
void HandleNumPlayersOnline( Int numPlayersOnline );

Generals/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class GameSpyInfo : public GameSpyInfoInterface
6161
virtual void setLocalPassword( AsciiString passwd ) { m_localPasswd = passwd; }
6262
virtual void setLocalBaseName( AsciiString name ) { m_localBaseName = name; }
6363
virtual AsciiString getLocalBaseName( void ){ return m_localBaseName; }
64-
6564
virtual void setCachedLocalPlayerStats( PSPlayerStats stats ) {m_cachedLocalPlayerStats = stats; }
6665
virtual PSPlayerStats getCachedLocalPlayerStats( void ){ return m_cachedLocalPlayerStats; }
6766

@@ -174,6 +173,5 @@ class GameSpyInfo : public GameSpyInfoInterface
174173
std::set<GameWindow *> m_textWindows;
175174

176175
std::set<Int> m_preorderPlayers;
177-
178176
Int m_additionalDisconnects;
179177
};

Generals/Code/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class PeerRequest
116116
UnsignedInt iniCRC;
117117
UnsignedInt gameVersion;
118118
Bool allowObservers;
119+
Bool useStats;
119120
UnsignedShort ladPort;
120121
UnsignedInt ladPassCRC;
121122
Bool restrictGameList;
@@ -328,6 +329,7 @@ class PeerResponse
328329
Bool isStaging;
329330
Bool requiresPassword;
330331
Bool allowObservers;
332+
Bool useStats;
331333
UnsignedInt version;
332334
UnsignedInt exeCRC;
333335
UnsignedInt iniCRC;

Generals/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class PSPlayerStats
4444
Int id;
4545
PerGeneralMap wins;
4646
PerGeneralMap losses;
47-
PerGeneralMap games;
47+
PerGeneralMap games; //first: playerTemplate #, second: #games played (see also gamesAsRandom)
4848
PerGeneralMap duration;
4949
PerGeneralMap unitsKilled;
5050
PerGeneralMap unitsLost;

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupHostGame.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,17 @@ void createGame( void )
542542
req.password = passwd.str();
543543
CustomMatchPreferences customPref;
544544
Bool aO = GadgetCheckBoxIsChecked(checkBoxAllowObservers);
545+
Bool limitArmies = FALSE;
546+
Bool useStats = TRUE;
545547
customPref.setAllowsObserver(aO);
548+
customPref.setFactionsLimited( limitArmies );
549+
customPref.setUseStats( useStats );
546550
customPref.write();
547551
req.stagingRoomCreation.allowObservers = aO;
552+
req.stagingRoomCreation.useStats = useStats;
548553
TheGameSpyGame->setAllowObservers(aO);
554+
TheGameSpyGame->setOldFactionsOnly( limitArmies );
555+
TheGameSpyGame->setUseStats( useStats );
549556
req.stagingRoomCreation.exeCRC = TheGlobalData->m_exeCRC;
550557
req.stagingRoomCreation.iniCRC = TheGlobalData->m_iniCRC;
551558
req.stagingRoomCreation.gameVersion = TheGameSpyInfo->getInternalIP();

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData)
11731173
room.setExeCRC(resp.stagingRoom.exeCRC);
11741174
room.setIniCRC(resp.stagingRoom.iniCRC);
11751175
room.setAllowObservers(resp.stagingRoom.allowObservers);
1176+
room.setUseStats(resp.stagingRoom.useStats);
11761177
room.setPingString(resp.stagingServerPingString.c_str());
11771178
room.setLadderIP(resp.stagingServerLadderIP.c_str());
11781179
room.setLadderPort(resp.stagingRoom.ladderPort);

Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ Color GameSpyColor[GSCOLOR_MAX] =
8989
GameMakeColor(128,128,0,255), // GSCOLOR_GAME
9090
GameMakeColor(128,128,128,255), // GSCOLOR_GAME_FULL
9191
GameMakeColor(128,128,128,255), // GSCOLOR_GAME_CRCMISMATCH
92+
#if RTS_GENERALS
9293
GameMakeColor(255, 0, 0,255), // GSCOLOR_PLAYER_NORMAL
94+
#else
95+
GameMakeColor(255,255,255,255), // GSCOLOR_PLAYER_NORMAL
96+
#endif
9397
GameMakeColor(255, 0,255,255), // GSCOLOR_PLAYER_OWNER
9498
GameMakeColor(255, 0,128,255), // GSCOLOR_PLAYER_BUDDY
9599
GameMakeColor(255, 0, 0,255), // GSCOLOR_PLAYER_SELF
96100
GameMakeColor(128,128,128,255), // GSCOLOR_PLAYER_IGNORED
101+
#if RTS_GENERALS
97102
GameMakeColor(255,0,0,255), // GSCOLOR_CHAT_NORMAL
103+
#else
104+
GameMakeColor(255,255,255,255), // GSCOLOR_CHAT_NORMAL
105+
#endif
98106
GameMakeColor(255,128,0,255), // GSCOLOR_CHAT_EMOTE,
99107
GameMakeColor(255,255,0,255), // GSCOLOR_CHAT_OWNER,
100108
GameMakeColor(128,255,0,255), // GSCOLOR_CHAT_OWNER_EMOTE,
@@ -114,6 +122,8 @@ Color GameSpyColor[GSCOLOR_MAX] =
114122

115123
Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *playerListbox )
116124
{
125+
static UnicodeString s_prevMsg = UnicodeString::TheEmptyString; //stop spam before it happens
126+
117127
RoomType roomType = StagingRoom;
118128
if (getCurrentGroupRoom())
119129
roomType = GroupRoom;
@@ -126,11 +136,14 @@ Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *pl
126136
if (!message.isEmpty())
127137
{
128138
if (!playerListbox)
129-
{
130-
// Public message
131-
req.message.isAction = isAction;
132-
req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;
133-
TheGameSpyPeerMessageQueue->addRequest(req);
139+
{ // Public message
140+
if( isAction || message.compare(s_prevMsg) != 0 ) //don't send duplicate messages
141+
{
142+
req.message.isAction = isAction;
143+
req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;
144+
TheGameSpyPeerMessageQueue->addRequest(req);
145+
s_prevMsg = message;
146+
}
134147
return false;
135148
}
136149

@@ -140,11 +153,14 @@ Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *pl
140153
GadgetListBoxGetSelected(playerListbox, (Int *)&selections);
141154

142155
if (selections[0] == -1)
143-
{
144-
// Public message
145-
req.message.isAction = isAction;
146-
req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;
147-
TheGameSpyPeerMessageQueue->addRequest(req);
156+
{ // Public message
157+
if( isAction || message.compare(s_prevMsg) != 0 ) //don't send duplicate messages
158+
{
159+
req.message.isAction = isAction;
160+
req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;
161+
TheGameSpyPeerMessageQueue->addRequest(req);
162+
s_prevMsg = message;
163+
}
148164
return false;
149165
}
150166
else
@@ -180,10 +196,11 @@ Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *pl
180196
req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEPLAYER;
181197
TheGameSpyPeerMessageQueue->addRequest(req);
182198
}
183-
199+
s_prevMsg = message;
184200
return true;
185201
}
186202
}
203+
s_prevMsg = message;
187204
return false;
188205
}
189206

Generals/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ m_qmChannel(0)
336336
// German2 is missing some maps because of content. But, we need the m_qmMaps
337337
// to contain same number of strings as the Retail version so that the
338338
// QM Bot thinks that they have the same number of maps.
339-
#if 1
339+
#if RTS_GENERALS
340340
m_qmMaps.push_back(mapName);
341341
#else
342342
const MapMetaData *md = TheMapCache->findMap(mapName);

0 commit comments

Comments
 (0)