| 1303 | } |
| 1304 | |
| 1305 | void CClient::ProcessServerInfo(int RawType, NETADDR *pFrom, const void *pData, int DataSize) |
| 1306 | { |
| 1307 | CServerBrowser::CServerEntry *pEntry = m_ServerBrowser.Find(*pFrom); |
| 1308 | |
| 1309 | CServerInfo Info = {0}; |
| 1310 | int SavedType = SavedServerInfoType(RawType); |
| 1311 | if(SavedType == SERVERINFO_EXTENDED && pEntry && pEntry->m_GotInfo && SavedType == pEntry->m_Info.m_Type) |
| 1312 | { |
| 1313 | Info = pEntry->m_Info; |
| 1314 | } |
| 1315 | else |
| 1316 | { |
| 1317 | Info.m_NumAddresses = 1; |
| 1318 | Info.m_aAddresses[0] = *pFrom; |
| 1319 | } |
| 1320 | |
| 1321 | Info.m_Type = SavedType; |
| 1322 | |
| 1323 | net_addr_str(pFrom, Info.m_aAddress, sizeof(Info.m_aAddress), true); |
| 1324 | |
| 1325 | CUnpacker Up; |
| 1326 | Up.Reset(pData, DataSize); |
| 1327 | |
| 1328 | #define GET_STRING(array) str_copy(array, Up.GetString(CUnpacker::SANITIZE_CC | CUnpacker::SKIP_START_WHITESPACES), sizeof(array)) |
| 1329 | #define GET_INT(integer) (integer) = str_toint(Up.GetString()) |
| 1330 | |
| 1331 | int Token; |
| 1332 | int PacketNo = 0; // Only used if SavedType == SERVERINFO_EXTENDED |
| 1333 | |
| 1334 | GET_INT(Token); |
| 1335 | if(RawType != SERVERINFO_EXTENDED_MORE) |
| 1336 | { |
| 1337 | GET_STRING(Info.m_aVersion); |
| 1338 | GET_STRING(Info.m_aName); |
| 1339 | GET_STRING(Info.m_aMap); |
| 1340 | |
| 1341 | if(SavedType == SERVERINFO_EXTENDED) |
| 1342 | { |
| 1343 | GET_INT(Info.m_MapCrc); |
| 1344 | GET_INT(Info.m_MapSize); |
| 1345 | } |
| 1346 | |
| 1347 | GET_STRING(Info.m_aGameType); |
| 1348 | GET_INT(Info.m_Flags); |
| 1349 | GET_INT(Info.m_NumPlayers); |
| 1350 | GET_INT(Info.m_MaxPlayers); |
| 1351 | GET_INT(Info.m_NumClients); |
| 1352 | GET_INT(Info.m_MaxClients); |
| 1353 | |
| 1354 | // don't add invalid info to the server browser list |
| 1355 | if(Info.m_NumClients < 0 || Info.m_MaxClients < 0 || |
| 1356 | Info.m_NumPlayers < 0 || Info.m_MaxPlayers < 0 || |
| 1357 | Info.m_NumPlayers > Info.m_NumClients || Info.m_MaxPlayers > Info.m_MaxClients) |
| 1358 | { |
| 1359 | return; |
| 1360 | } |
| 1361 | |
| 1362 | m_ServerBrowser.UpdateServerCommunity(&Info); |
nothing calls this directly
no test coverage detected