@@ -191,7 +191,7 @@ public function Ping( )
191191 $ this ->Socket ->Write ( self :: A2S_PING );
192192 $ this ->Socket ->Read ( );
193193
194- return $ this ->Buffer ->GetByte ( ) == self :: S2A_PING ;
194+ return $ this ->Buffer ->GetByte ( ) === self :: S2A_PING ;
195195 }
196196
197197 /**
@@ -213,13 +213,13 @@ public function GetInfo( )
213213
214214 $ Type = $ this ->Buffer ->GetByte ( );
215215
216- if ( $ Type == 0 )
216+ if ( $ Type === 0 )
217217 {
218218 return false ;
219219 }
220220
221221 // Old GoldSource protocol, HLTV still uses it
222- if ( $ Type == self :: S2A_INFO_OLD && $ this ->Socket ->Engine == self :: GOLDSOURCE )
222+ if ( $ Type === self :: S2A_INFO_OLD && $ this ->Socket ->Engine = == self :: GOLDSOURCE )
223223 {
224224 /**
225225 * If we try to read data again, and we get the result with type S2A_INFO (0x49)
@@ -237,8 +237,8 @@ public function GetInfo( )
237237 $ Server [ 'Protocol ' ] = $ this ->Buffer ->GetByte ( );
238238 $ Server [ 'Dedicated ' ] = Chr ( $ this ->Buffer ->GetByte ( ) );
239239 $ Server [ 'Os ' ] = Chr ( $ this ->Buffer ->GetByte ( ) );
240- $ Server [ 'Password ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
241- $ Server [ 'IsMod ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
240+ $ Server [ 'Password ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
241+ $ Server [ 'IsMod ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
242242
243243 if ( $ Server [ 'IsMod ' ] )
244244 {
@@ -247,11 +247,11 @@ public function GetInfo( )
247247 $ this ->Buffer ->Get ( 1 ); // NULL byte
248248 $ Mod [ 'Version ' ] = $ this ->Buffer ->GetLong ( );
249249 $ Mod [ 'Size ' ] = $ this ->Buffer ->GetLong ( );
250- $ Mod [ 'ServerSide ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
251- $ Mod [ 'CustomDLL ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
250+ $ Mod [ 'ServerSide ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
251+ $ Mod [ 'CustomDLL ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
252252 }
253253
254- $ Server [ 'Secure ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
254+ $ Server [ 'Secure ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
255255 $ Server [ 'Bots ' ] = $ this ->Buffer ->GetByte ( );
256256
257257 if ( isset ( $ Mod ) )
@@ -262,7 +262,7 @@ public function GetInfo( )
262262 return $ Server ;
263263 }
264264
265- if ( $ Type != self :: S2A_INFO )
265+ if ( $ Type !== self :: S2A_INFO )
266266 {
267267 throw new SourceQueryException ( 'GetInfo: Packet header mismatch. (0x ' . DecHex ( $ Type ) . ') ' );
268268 }
@@ -278,11 +278,11 @@ public function GetInfo( )
278278 $ Server [ 'Bots ' ] = $ this ->Buffer ->GetByte ( );
279279 $ Server [ 'Dedicated ' ] = Chr ( $ this ->Buffer ->GetByte ( ) );
280280 $ Server [ 'Os ' ] = Chr ( $ this ->Buffer ->GetByte ( ) );
281- $ Server [ 'Password ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
282- $ Server [ 'Secure ' ] = $ this ->Buffer ->GetByte ( ) == 1 ;
281+ $ Server [ 'Password ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
282+ $ Server [ 'Secure ' ] = $ this ->Buffer ->GetByte ( ) === 1 ;
283283
284- // The Ship
285- if ( $ Server [ 'AppID ' ] == 2400 )
284+ // The Ship (they violate query protocol spec by modifying the response)
285+ if ( $ Server [ 'AppID ' ] === 2400 )
286286 {
287287 $ Server [ 'GameMode ' ] = $ this ->Buffer ->GetByte ( );
288288 $ Server [ 'WitnessCount ' ] = $ this ->Buffer ->GetByte ( );
@@ -294,7 +294,7 @@ public function GetInfo( )
294294 // Extra Data Flags
295295 if ( $ this ->Buffer ->Remaining ( ) > 0 )
296296 {
297- $ Flags = $ this ->Buffer ->GetByte ( );
297+ $ Server [ ' ExtraDataFlags ' ] = $ Flags = $ this ->Buffer ->GetByte ( );
298298
299299 // The server's game port
300300 if ( $ Flags & 0x80 )
@@ -305,7 +305,7 @@ public function GetInfo( )
305305 // The server's SteamID - does this serve any purpose?
306306 if ( $ Flags & 0x10 )
307307 {
308- $ Server [ 'ServerID ' ] = $ this ->Buffer ->GetUnsignedLong ( ) | ( $ this ->Buffer ->GetUnsignedLong ( ) << 32 );
308+ $ Server [ 'ServerID ' ] = $ this ->Buffer ->GetUnsignedLong ( ) | ( $ this ->Buffer ->GetUnsignedLong ( ) << 32 ); // TODO: verify this
309309 }
310310
311311 // The spectator port and then the spectator server name
@@ -321,7 +321,16 @@ public function GetInfo( )
321321 $ Server [ 'GameTags ' ] = $ this ->Buffer ->GetString ( );
322322 }
323323
324- // 0x01 - The server's 64-bit GameID
324+ // GameID -- alternative to AppID?
325+ if ( $ Flags & 0x01 )
326+ {
327+ $ Server [ 'GameID ' ] = $ this ->Buffer ->GetUnsignedLong ( ) | ( $ this ->Buffer ->GetUnsignedLong ( ) << 32 );
328+ }
329+
330+ if ( $ this ->Buffer ->Remaining ( ) > 0 )
331+ {
332+ throw new SourceQueryException ( 'GetInfo: unread data? ' . $ this ->Buffer ->Remaining ( ) . ' bytes remaining in the buffer. Please report it to the library developer. ' );
333+ }
325334 }
326335
327336 return $ Server ;
@@ -355,11 +364,11 @@ public function GetPlayers( )
355364
356365 $ Type = $ this ->Buffer ->GetByte ( );
357366
358- if ( $ Type == 0 )
367+ if ( $ Type === 0 )
359368 {
360369 return false ;
361370 }
362- else if ( $ Type != self :: S2A_PLAYER )
371+ else if ( $ Type !== self :: S2A_PLAYER )
363372 {
364373 throw new SourceQueryException ( 'GetPlayers: Packet header mismatch. (0x ' . DecHex ( $ Type ) . ') ' );
365374 }
@@ -412,11 +421,11 @@ public function GetRules( )
412421
413422 $ Type = $ this ->Buffer ->GetByte ( );
414423
415- if ( $ Type == 0 )
424+ if ( $ Type === 0 )
416425 {
417426 return false ;
418427 }
419- else if ( $ Type != self :: S2A_RULES )
428+ else if ( $ Type !== self :: S2A_RULES )
420429 {
421430 throw new SourceQueryException ( 'GetRules: Packet header mismatch. (0x ' . DecHex ( $ Type ) . ') ' );
422431 }
0 commit comments