@@ -43,25 +43,26 @@ class CHqComms : public CRefCountable
4343 m_CheckTimer.Reset ();
4444 m_Stage = HQCOMMS_STAGE_QUERY;
4545
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 );
5758
5859 SString strCrashInfo;
5960 FileLoad ( m_strCrashInfoFilename, strCrashInfo, 50000 );
60- strUrlParams += SString ( " &crashinfosize=%d " , strCrashInfo. length () );
61+ bitStream-> WriteStr ( strCrashInfo );
6162
6263 // Send request
6364 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 );
6566 }
6667 }
6768
@@ -85,15 +86,15 @@ class CHqComms : public CRefCountable
8586 if ( bComplete )
8687 {
8788 m_Stage = HQCOMMS_STAGE_TIMER;
88- CArgMap argMap;
89- argMap.SetFromString ( data );
89+ CBitStream bitStream ( data, dataLength );
9090
9191 // 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 );
9798 }
9899 else
99100 if ( iError )
@@ -103,20 +104,22 @@ class CHqComms : public CRefCountable
103104 }
104105
105106 // Interval until next HQ check
106- void ProcessPollInterval ( const CArgMap& argMap )
107+ void ProcessPollInterval ( CBitStream& bitStream )
107108 {
108- int iPollInterval;
109- argMap. Get ( " PollInterval " , iPollInterval, m_iPollInterval );
109+ int iPollInterval = 0 ;
110+ bitStream-> Read ( iPollInterval );
110111 if ( iPollInterval )
111112 m_iPollInterval = Max ( TICKS_FROM_MINUTES ( 5 ), iPollInterval );
112113 }
113114
114115 // Auto update of min client check
115- void ProcessMinClientVersion ( const CArgMap& argMap )
116+ void ProcessMinClientVersion ( CBitStream& bitStream )
116117 {
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 );
120123 SString strSetttingsMinClientVersion = g_pGame->GetConfig ()->GetMinClientVersion ();
121124 if ( strResultMinClientVersion > strSetttingsMinClientVersion || iForceSetting )
122125 {
@@ -125,11 +128,13 @@ class CHqComms : public CRefCountable
125128 }
126129
127130 // Messsage for this server from HQ
128- void ProcessMessage ( const CArgMap& argMap )
131+ void ProcessMessage ( CBitStream& bitStream )
129132 {
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 );
133138 if ( !strMessage.empty () && ( strMessage != m_strPrevMessage || iMessageAlwaysPrint ) )
134139 {
135140 m_strPrevMessage = strMessage;
@@ -138,37 +143,68 @@ class CHqComms : public CRefCountable
138143 }
139144
140145 // Block script hashes
141- void ProcessBadFileHashes ( const CArgMap& argMap )
146+ void ProcessBadFileHashes ( CBitStream& bitStream )
142147 {
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+
145164 if ( iBadFileHashesRev && ( iBadFileHashesRev == 1 || iBadFileHashesRev != m_iPrevBadFileHashesRev ) )
146165 {
147166 m_iPrevBadFileHashesRev = iBadFileHashesRev;
148167 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 )
152169 {
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 );
156171 }
157172 g_pGame->GetResourceManager ()->SaveBlockedFileReasons ();
158173 }
159174 }
160175
161176 // Got crashinfo recpt
162- void ProcessCrashInfo ( const CArgMap& argMap )
177+ void ProcessCrashInfo ( CBitStream& bitStream )
163178 {
164- int iGotCrashInfo;
165- argMap. Get ( " GotCrashInfo " , iGotCrashInfo );
179+ int iGotCrashInfo = 0 ;
180+ bitStream-> Read ( iGotCrashInfo );
166181 if ( iGotCrashInfo )
167182 {
168183 FileDelete ( m_strCrashInfoFilename );
169184 }
170185 }
171186
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+
172208
173209 //
174210 // Get http downloader used for hq comms etc.
0 commit comments