Skip to content

Commit 45d2a7e

Browse files
committed
unify(network): Merge GameSpy and related code
1 parent eeb7b41 commit 45d2a7e

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
@@ -114,6 +114,7 @@ class PlayerTemplate
114114
//const Image *getHiliteImage( void ) const;
115115
//const Image *getPushedImage( void ) const;
116116
const Image *getSideIconImage( void ) const;
117+
inline const AsciiString getTooltip() const { return m_tooltip; }
117118

118119
const ScienceVec& getIntrinsicSciences() const { return m_intrinsicSciences; }
119120
Int getIntrinsicSciencePurchasePoints() const { return m_intrinsicSPP; }
@@ -161,6 +162,7 @@ class PlayerTemplate
161162
AsciiString m_specialPowerShortcutWinName; ///< The name of the window we'll be using for the shortcut bar
162163
Int m_specialPowerShortcutButtonCount; ///< The number of buttons located on the shortcut bar
163164
AsciiString m_loadScreenMusic; ///< the load screen music we want to play
165+
AsciiString m_tooltip; ///< The tooltip describing this player template
164166
Bool m_observer;
165167
Bool m_playableSide;
166168

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ void RefreshGameInfoListBox( GameWindow *mainWin, GameWindow *win );
4343
void RefreshGameListBoxes( void );
4444
void ToggleGameListType( void );
4545

46+
void playerTemplateComboBoxTooltip(GameWindow *wndComboBox, WinInstanceData *instData, UnsignedInt mouse);
47+
void playerTemplateListBoxTooltip(GameWindow *wndListBox, WinInstanceData *instData, UnsignedInt mouse);
48+
4649
enum GameSortType CPP_11(: Int)
4750
{
4851
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
@@ -39,6 +39,7 @@ void CancelPatchCheckCallback( void );
3939
void StartDownloadingPatches( void );
4040
void HandleCanceledDownload( Bool resetDropDown = TRUE );
4141

42+
#if RTS_GENERALS
4243
enum OverallStatsPeriod CPP_11(: Int)
4344
{
4445
STATS_TODAY = 0,
@@ -54,9 +55,14 @@ struct OverallStats
5455
Int wins[STATS_MAX];
5556
Int losses[STATS_MAX];
5657
};
58+
#endif
5759

5860
void CheckOverallStats( void );
61+
#if RTS_GENERALS
5962
void HandleOverallStats( const OverallStats& USA, const OverallStats& China, const OverallStats& GLA );
63+
#else
64+
void HandleOverallStats( const char* szHTTPStats, unsigned len );
65+
#endif
6066

6167
void CheckNumPlayersOnline( void );
6268
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
@@ -64,7 +64,6 @@ class GameSpyInfo : public GameSpyInfoInterface
6464
virtual void setLocalPassword( AsciiString passwd ) { m_localPasswd = passwd; }
6565
virtual void setLocalBaseName( AsciiString name ) { m_localBaseName = name; }
6666
virtual AsciiString getLocalBaseName( void ){ return m_localBaseName; }
67-
6867
virtual void setCachedLocalPlayerStats( PSPlayerStats stats ) {m_cachedLocalPlayerStats = stats; }
6968
virtual PSPlayerStats getCachedLocalPlayerStats( void ){ return m_cachedLocalPlayerStats; }
7069

@@ -177,7 +176,6 @@ class GameSpyInfo : public GameSpyInfoInterface
177176
std::set<GameWindow *> m_textWindows;
178177

179178
std::set<Int> m_preorderPlayers;
180-
181179
Int m_additionalDisconnects;
182180
};
183181

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class PeerRequest
119119
UnsignedInt iniCRC;
120120
UnsignedInt gameVersion;
121121
Bool allowObservers;
122+
Bool useStats;
122123
UnsignedShort ladPort;
123124
UnsignedInt ladPassCRC;
124125
Bool restrictGameList;
@@ -331,6 +332,7 @@ class PeerResponse
331332
Bool isStaging;
332333
Bool requiresPassword;
333334
Bool allowObservers;
335+
Bool useStats;
334336
UnsignedInt version;
335337
UnsignedInt exeCRC;
336338
UnsignedInt iniCRC;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PSPlayerStats
4747
Int id;
4848
PerGeneralMap wins;
4949
PerGeneralMap losses;
50-
PerGeneralMap games;
50+
PerGeneralMap games; //first: playerTemplate #, second: #games played (see also gamesAsRandom)
5151
PerGeneralMap duration;
5252
PerGeneralMap unitsKilled;
5353
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)