@@ -43,25 +43,26 @@ class CHqComms : public CRefCountable
43
43
m_CheckTimer.Reset ();
44
44
m_Stage = HQCOMMS_STAGE_QUERY;
45
45
46
- SString strUrlParams;
47
- strUrlParams += SString ( " ?ip=%s" , *g_pGame->GetConfig ()->GetServerIP () );
48
- strUrlParams += SString ( " &gport=%d" , g_pGame->GetConfig ()->GetServerPort () );
49
- strUrlParams += SString ( " &version=%s" , *CStaticFunctionDefinitions::GetVersionSortable () );
50
- strUrlParams += SString ( " &minclientautoupdate=%d" , g_pGame->GetConfig ()->GetMinClientVersionAutoUpdate () );
51
- strUrlParams += SString ( " &minclientversion=%s" , *g_pGame->GetConfig ()->GetMinClientVersion () );
52
- strUrlParams += SString ( " &badscriptrev=%d" , m_iPrevBadFileHashesRev );
53
- strUrlParams += SString ( " &maxplayers=%d" , g_pGame->GetConfig ()->GetHardMaxPlayers () );
54
- strUrlParams += SString ( " &numplayers=%d" , g_pGame->GetPlayerManager ()->Count () );
55
- strUrlParams += SString ( " &asepush=%d" , g_pGame->GetConfig ()->GetAseInternetPushEnabled () );
56
- strUrlParams += SString ( " &aselisten=%d" , g_pGame->GetConfig ()->GetAseInternetListenEnabled () );
46
+ CBitStream bitStream;
47
+ bitStream->Write ( (char )1 );
48
+ bitStream->WriteStr ( g_pGame->GetConfig ()->GetServerIP () );
49
+ bitStream->Write ( g_pGame->GetConfig ()->GetServerPort () );
50
+ bitStream->WriteStr ( CStaticFunctionDefinitions::GetVersionSortable () );
51
+ bitStream->Write ( g_pGame->GetConfig ()->GetMinClientVersionAutoUpdate () );
52
+ bitStream->WriteStr ( g_pGame->GetConfig ()->GetMinClientVersion () );
53
+ bitStream->Write ( m_iPrevBadFileHashesRev );
54
+ bitStream->Write ( g_pGame->GetConfig ()->GetHardMaxPlayers () );
55
+ bitStream->Write ( g_pGame->GetPlayerManager ()->Count () );
56
+ bitStream->Write ( g_pGame->GetConfig ()->GetAseInternetPushEnabled () ? 1 : 0 );
57
+ bitStream->Write ( g_pGame->GetConfig ()->GetAseInternetListenEnabled () ? 1 : 0 );
57
58
58
59
SString strCrashInfo;
59
60
FileLoad ( m_strCrashInfoFilename, strCrashInfo, 50000 );
60
- strUrlParams += SString ( " &crashinfosize=%d " , strCrashInfo. length () );
61
+ bitStream-> WriteStr ( strCrashInfo );
61
62
62
63
// Send request
63
64
this ->AddRef (); // Keep object alive
64
- GetDownloadManager ()->QueueFile ( m_strURL + strUrlParams , NULL , 0 , strCrashInfo, strCrashInfo. length (), true , this , StaticProgressCallback, false , 1 );
65
+ GetDownloadManager ()->QueueFile ( m_strURL, NULL , 0 , ( const char *)bitStream-> GetData (), bitStream-> GetNumberOfBytesUsed (), true , this , StaticProgressCallback, false , 1 );
65
66
}
66
67
}
67
68
@@ -85,15 +86,15 @@ class CHqComms : public CRefCountable
85
86
if ( bComplete )
86
87
{
87
88
m_Stage = HQCOMMS_STAGE_TIMER;
88
- CArgMap argMap;
89
- argMap.SetFromString ( data );
89
+ CBitStream bitStream ( data, dataLength );
90
90
91
91
// Process various parts of returned data
92
- ProcessPollInterval ( argMap );
93
- ProcessMinClientVersion ( argMap );
94
- ProcessMessage ( argMap );
95
- ProcessBadFileHashes ( argMap );
96
- ProcessCrashInfo ( argMap );
92
+ ProcessPollInterval ( bitStream );
93
+ ProcessMinClientVersion ( bitStream );
94
+ ProcessMessage ( bitStream );
95
+ ProcessBadFileHashes ( bitStream );
96
+ ProcessCrashInfo ( bitStream );
97
+ ProcessAseServers ( bitStream );
97
98
}
98
99
else
99
100
if ( iError )
@@ -103,20 +104,22 @@ class CHqComms : public CRefCountable
103
104
}
104
105
105
106
// Interval until next HQ check
106
- void ProcessPollInterval ( const CArgMap& argMap )
107
+ void ProcessPollInterval ( CBitStream& bitStream )
107
108
{
108
- int iPollInterval;
109
- argMap. Get ( " PollInterval " , iPollInterval, m_iPollInterval );
109
+ int iPollInterval = 0 ;
110
+ bitStream-> Read ( iPollInterval );
110
111
if ( iPollInterval )
111
112
m_iPollInterval = Max ( TICKS_FROM_MINUTES ( 5 ), iPollInterval );
112
113
}
113
114
114
115
// Auto update of min client check
115
- void ProcessMinClientVersion ( const CArgMap& argMap )
116
+ void ProcessMinClientVersion ( CBitStream& bitStream )
116
117
{
117
- int iForceSetting;
118
- argMap.Get ( " ForceMinClientVersion" , iForceSetting );
119
- SString strResultMinClientVersion = argMap.Get ( " AutoMinClientVersion" );
118
+ int iForceSetting = 0 ;
119
+ SString strResultMinClientVersion;
120
+
121
+ bitStream->Read ( iForceSetting );
122
+ bitStream->ReadStr ( strResultMinClientVersion );
120
123
SString strSetttingsMinClientVersion = g_pGame->GetConfig ()->GetMinClientVersion ();
121
124
if ( strResultMinClientVersion > strSetttingsMinClientVersion || iForceSetting )
122
125
{
@@ -125,11 +128,13 @@ class CHqComms : public CRefCountable
125
128
}
126
129
127
130
// Messsage for this server from HQ
128
- void ProcessMessage ( const CArgMap& argMap )
131
+ void ProcessMessage ( CBitStream& bitStream )
129
132
{
130
- int iMessageAlwaysPrint;
131
- argMap.Get ( " MessageAlwaysPrint" , iMessageAlwaysPrint );
132
- SString strMessage = argMap.Get ( " Message" );
133
+ int iMessageAlwaysPrint = 0 ;
134
+ SString strMessage;
135
+
136
+ bitStream->Read ( iMessageAlwaysPrint );
137
+ bitStream->ReadStr ( strMessage );
133
138
if ( !strMessage.empty () && ( strMessage != m_strPrevMessage || iMessageAlwaysPrint ) )
134
139
{
135
140
m_strPrevMessage = strMessage;
@@ -138,37 +143,68 @@ class CHqComms : public CRefCountable
138
143
}
139
144
140
145
// Block script hashes
141
- void ProcessBadFileHashes ( const CArgMap& argMap )
146
+ void ProcessBadFileHashes ( CBitStream& bitStream )
142
147
{
143
- int iBadFileHashesRev;
144
- argMap.Get ( " BadFileHashesRev" , iBadFileHashesRev );
148
+ int iBadFileHashesRev = 0 ;
149
+ uint uiNumHashes = 0 ;
150
+ struct SHashItem { SString strHash, strReason; };
151
+ std::vector < SHashItem > itemList;
152
+
153
+ bitStream->Read ( iBadFileHashesRev );
154
+ bitStream->Read ( uiNumHashes );
155
+ for ( uint i = 0 ; i < uiNumHashes ; i++ )
156
+ {
157
+ SString strHash, strReason;
158
+ bitStream->ReadStr ( strHash );
159
+ if ( !bitStream->ReadStr ( strReason ) )
160
+ break ;
161
+ itemList.push_back ( { strHash, strReason } );
162
+ }
163
+
145
164
if ( iBadFileHashesRev && ( iBadFileHashesRev == 1 || iBadFileHashesRev != m_iPrevBadFileHashesRev ) )
146
165
{
147
166
m_iPrevBadFileHashesRev = iBadFileHashesRev;
148
167
g_pGame->GetResourceManager ()->ClearBlockedFileReason ( " " );
149
- std::vector < SString > itemList;
150
- argMap.Get ( " BadFileHashes" ).Split ( " ," , itemList );
151
- for ( uint i = 0 ; i < itemList.size () ; i++ )
168
+ for ( auto item : itemList )
152
169
{
153
- SString strHash, strReason;
154
- itemList[i].Split ( " |" , &strHash, &strReason );
155
- g_pGame->GetResourceManager ()->AddBlockedFileReason ( strHash, strReason );
170
+ g_pGame->GetResourceManager ()->AddBlockedFileReason ( item.strHash , item.strReason );
156
171
}
157
172
g_pGame->GetResourceManager ()->SaveBlockedFileReasons ();
158
173
}
159
174
}
160
175
161
176
// Got crashinfo recpt
162
- void ProcessCrashInfo ( const CArgMap& argMap )
177
+ void ProcessCrashInfo ( CBitStream& bitStream )
163
178
{
164
- int iGotCrashInfo;
165
- argMap. Get ( " GotCrashInfo " , iGotCrashInfo );
179
+ int iGotCrashInfo = 0 ;
180
+ bitStream-> Read ( iGotCrashInfo );
166
181
if ( iGotCrashInfo )
167
182
{
168
183
FileDelete ( m_strCrashInfoFilename );
169
184
}
170
185
}
171
186
187
+ // Extra ASE servers
188
+ void ProcessAseServers ( CBitStream& bitStream )
189
+ {
190
+ uint uiNumServers = 0 ;
191
+ bitStream->Read ( uiNumServers );
192
+ for ( uint i = 0 ; i < uiNumServers ; i++ )
193
+ {
194
+ char bAcceptsPush, bDoReminders, bHideProblems;
195
+ uint uiReminderIntervalMins;
196
+ SString strDesc, strUrl;
197
+ bitStream->Read ( bAcceptsPush );
198
+ bitStream->Read ( bDoReminders );
199
+ bitStream->Read ( bHideProblems );
200
+ bitStream->Read ( uiReminderIntervalMins );
201
+ bitStream->ReadStr ( strDesc );
202
+ if ( !bitStream->ReadStr ( strUrl ) )
203
+ break ;
204
+ g_pGame->GetMasterServerAnnouncer ()->AddServer ( bAcceptsPush != 0 , bDoReminders != 0 , bHideProblems != 0 , Max ( 5U , uiReminderIntervalMins ), strDesc, strUrl );
205
+ }
206
+ }
207
+
172
208
173
209
//
174
210
// Get http downloader used for hq comms etc.
0 commit comments