void CCmd_Depots::OnOutputInfo( char level, LPCTSTR data, LPCTSTR msg ) { if( APP_ABORTING( ) && m_Asynchronous ) { ReleaseServerLock(); ExitThread(0); } if ( StrNCmp(data, _T("Depot "), 6) ==0 ) m_GotDepot = TRUE; else ASSERT(0); CTokenString str; str.Create( data + 6); CString depotName; depotName.Format(_T("//%s"), str.GetToken()); CString date= str.GetToken(); ASSERT(StrStr(date, _T("/"))); CString depotType= str.GetToken(); if( depotType.CompareNoCase(_T("local")) == 0) m_LocalDepotList.AddHead( depotName ); else if( depotType.CompareNoCase(_T("remote")) == 0) m_RemoteDepotList.AddHead( depotName ); else if( depotType.CompareNoCase(_T("spec")) == 0) { if (GET_SERVERLEVEL() >= 18) m_RemoteDepotList.AddHead( depotName ); } else ASSERT(0); }
void CCmd_Fstat::OnOutputStat( StrDict *varList ) { // Check for possible abort request if(APP_ABORTING()) { ReleaseServerLock(); ExitThread(0); } else { CP4FileStats *stats= new CP4FileStats; if(stats->Create(varList)) AddFstatRow(stats); else delete stats; } }
void CCmd_Labels::OnOutputStat( StrDict *varList ) { // Check for possible abort request if(APP_ABORTING()) { ReleaseServerLock(); ExitThread(0); } else { CP4Label *label= new CP4Label; if(label->Create(varList)) m_Labels.Add(label); else delete label; } }
DWORD Q4_Get_ServerStatus(SERVER_INFO *pSI,long (*UpdatePlayerListView)(PLAYERDATA *q4players),long (*UpdateRulesListView)(SERVER_RULES *pServRules)) { if(pSI==NULL) { dbg_print("Invalid pointer argument @Get_ServerStatus!\n"); return -1; } SOCKET pSocket = getsockudp(pSI->szIPaddress ,(unsigned short)pSI->usPort); if(pSocket==INVALID_SOCKET) { dbg_print("Error at getsockudp()\n"); return -1; } char sendbuf[]={"\xFF\xFFgetInfo\x00\x01\x00\x00\x00"}; size_t packetlen = 0; //Some default values pSI->dwPing = 9999; //If country shortname is EU or zz (Unknown) try to find a country based on the IP address. if( ((pSI->szShortCountryName[0]=='E') && (pSI->szShortCountryName[1]=='U')) || ((pSI->szShortCountryName[0]=='z') && (pSI->szShortCountryName[1]=='z'))) { char szShortName[4]; g_IPtoCountry.IPtoCountry(pSI->dwIP,szShortName); strncpy_s(pSI->szShortCountryName,sizeof(pSI->szShortCountryName),szShortName,_TRUNCATE); } DWORD dwRetries=0; retry: packetlen = send(pSocket, sendbuf, 14, 0); if(packetlen==SOCKET_ERROR) { dbg_print("Error at send()\n"); closesocket(pSocket); pSI->cPurge++; // pSI->bLocked = FALSE; return -1; } unsigned char *packet=NULL; DWORD dwStartTick=0; dwStartTick = GetTickCount(); packet=(unsigned char*)getpacket(pSocket, &packetlen); if(packet==NULL) { if(dwRetries<AppCFG.dwRetries) { dwRetries++; goto retry; } } if(packet) { pSI->dwPing = (GetTickCount() - dwStartTick); //pSI->cPure=0; //dbg_dumpbuf("dump.bin", packet, packetlen); SERVER_RULES *pServRules=NULL; char *end = (char*)((packet)+packetlen); GetServerLock(pSI); CleanUp_ServerInfo(pSI); char *pCurrPointer=NULL; //will contain the start address for the player data pCurrPointer = Q4_ParseServerRules(pSI,pServRules,(char*)packet,packetlen); pSI->pServerRules = pServRules; if(pServRules!=NULL) { char *szVarValue = NULL; pSI->szServerName = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_SERVERNAME).sRuleValue.c_str(),pSI->pServerRules); pSI->szMap = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_MAP).sRuleValue.c_str(),pSI->pServerRules); pSI->szMod = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_MOD).sRuleValue.c_str(),pSI->pServerRules); pSI->szGameTypeName = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_GAMETYPE).sRuleValue.c_str(),pSI->pServerRules); pSI->szVersion = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_VERSION).sRuleValue.c_str(),pSI->pServerRules); pSI->szFS_GAME = Get_RuleValue("fs_game",pSI->pServerRules); szVarValue= Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_PRIVATE).sRuleValue.c_str(),pSI->pServerRules); if(szVarValue!=NULL) pSI->bPrivate = (char)atoi(szVarValue); if(Get_RuleValue("net_serverPunkbusterEnabled",pServRules)!=NULL) pSI->bPunkbuster = (char)atoi(Get_RuleValue("net_serverPunkbusterEnabled",pServRules)); else if(Get_RuleValue("sv_punkbuster",pServRules)!=NULL) pSI->bPunkbuster = (char)atoi(Get_RuleValue("sv_punkbuster",pServRules)); PLAYERDATA *pQ4Players=NULL; DWORD nPlayers=0; //--------------------------------- //Retrieve players if any exsist... //--------------------------------- pQ4Players = Q4_ParsePlayers(pSI,pCurrPointer,end,&nPlayers); pSI->pPlayerData = pQ4Players; //----------------------------------- //Update server info from rule values //----------------------------------- time(&pSI->timeLastScan); pSI->bUpdated = 1; pSI->nPlayers = nPlayers; pSI->cPurge = 0; if(Get_RuleValue("si_maxPlayers",pServRules)!=NULL) pSI->nMaxPlayers = atoi(Get_RuleValue("si_maxPlayers",pServRules)); // if(Get_RuleValue("si_tv",pServRules)!=NULL) // pSI->bTV = atoi(Get_RuleValue("si_tv",pServRules)); if(Get_RuleValue("si_privatePlayers",pServRules)!=NULL) pSI->nPrivateClients = atoi(Get_RuleValue("si_privatePlayers",pServRules)); else if(Get_RuleValue("si_privateClients",pServRules)!=NULL) //ETQW { pSI->nPrivateClients = atoi(Get_RuleValue("si_privateClients",pServRules)); pSI->nMaxPlayers -= pSI->nPrivateClients; } } //end if(pServRules!=NULL) ReleaseServerLock(pSI); if(Q4_Callback_CheckForBuddy!=NULL) Q4_Callback_CheckForBuddy(pSI->pPlayerData,pSI); free(packet); } //end if(packet) else pSI->cPurge++; if(UpdatePlayerListView!=NULL) UpdatePlayerListView(pSI->pPlayerData); if(UpdateRulesListView!=NULL) UpdateRulesListView(pSI->pServerRules); //pSI->bLocked = FALSE; closesocket(pSocket); return 0; }
DWORD Q3_Get_ServerStatus(SERVER_INFO *pSI,long (*UpdatePlayerListView)(PLAYERDATA *Q3players),long (*UpdateRulesListView)(SERVER_RULES *pServerRules)) { SOCKET pSocket = NULL; unsigned char *packet=NULL; DWORD dwStartTick=0; if(pSI==NULL) { dbg_print("Invalid pointer argument @Get_ServerStatus!\n"); return (DWORD)0xdead; } pSocket = getsockudp(pSI->szIPaddress ,(unsigned short)pSI->usPort); if(pSocket==INVALID_SOCKET) { dbg_print("Error at getsockudp()\n"); return 0x000002; } size_t packetlen = 0; //Some default values pSI->dwPing = 9999; if( ((pSI->szShortCountryName[0]=='E') && (pSI->szShortCountryName[1]=='U')) || ((pSI->szShortCountryName[0]=='z') && (pSI->szShortCountryName[1]=='z'))) { char szShortName[4]; g_IPtoCountry.IPtoCountry(pSI->dwIP,szShortName);//optimized since v1.31 strncpy_s(pSI->szShortCountryName,sizeof(pSI->szShortCountryName),szShortName,_TRUNCATE); } DWORD dwRetries=0; int len = 0; //(int)strlen(sendbuf); char sendbuf[80]; ZeroMemory(sendbuf,sizeof(sendbuf)); len = UTILZ_ConvertEscapeCodes(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo,sendbuf,sizeof(sendbuf)); retry: if(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo!=NULL) packetlen = send(pSocket, sendbuf, len+1, 0); else packetlen=SOCKET_ERROR; if(packetlen==SOCKET_ERROR) { dbg_print("Error at send()\n"); closesocket(pSocket); pSI->cPurge++; return -1; } dwStartTick = GetTickCount(); packet=(unsigned char*)getpacket(pSocket, &packetlen); if(pSI->cGAMEINDEX==WARSOW_SERVERLIST && packet==NULL) packet = Warsow_patch(pSocket,pSI,&dwStartTick,&packetlen); if(packet==NULL) { if(dwRetries<AppCFG.dwRetries) { dwRetries++; goto retry; } } if(packet) { pSI->dwPing = (GetTickCount() - dwStartTick); GetServerLock(pSI); CleanUp_ServerInfo(pSI); //dbg_dumpbuf("dump.bin", packet, packetlen); SERVER_RULES *pServRules=NULL; char *end = (char*)((packet)+packetlen); char *pCurrPointer=NULL; //will contain the start address for the player data pCurrPointer = Q3_ParseServerRules(pServRules,(char*)packet,packetlen); pSI->pServerRules = pServRules; if(pServRules!=NULL) { char szP_ET[150]; if(pSI->cGAMEINDEX == ET_SERVERLIST) { ZeroMemory(&szP_ET,sizeof(szP_ET)); char *szPVarValue=NULL; szPVarValue = Get_RuleValue("P",pServRules); if(szPVarValue!=NULL) strcpy(szP_ET,szPVarValue); } char *szVarValue=NULL; GAME_INFO *pGI = &gm.GamesInfo[pSI->cGAMEINDEX]; pSI->szServerName = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_SERVERNAME).sRuleValue.c_str(),pSI->pServerRules); pSI->szMap = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_MAP).sRuleValue.c_str(),pSI->pServerRules); pSI->szMod = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_MOD).sRuleValue.c_str(),pSI->pServerRules); pSI->szGameTypeName = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_GAMETYPE).sRuleValue.c_str(),pSI->pServerRules); pSI->szVersion = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_VERSION).sRuleValue.c_str(),pSI->pServerRules); PLAYERDATA *pQ3Players=NULL; DWORD nPlayers=0; //--------------------------------- //Retrieve players if any exsist... //--------------------------------- switch(pSI->cGAMEINDEX) { case WARSOW_SERVERLIST: { const char *szTVvalue = Get_RuleValue((TCHAR*)"tv",pSI->pServerRules); if(szTVvalue!=NULL) { if(strcmp("1",szTVvalue)==0) pSI->szServerName = Get_RuleValue((TCHAR*)"tv_name",pSI->pServerRules); const char* szClients = Get_RuleValue((TCHAR*)"clients",pSI->pServerRules); if(szClients!=NULL) nPlayers = atoi(szClients); } else { pQ3Players = Q3_ParsePlayers2(pSI,pCurrPointer,end,&nPlayers); } } break; case QW_SERVERLIST: case Q2_SERVERLIST: pQ3Players = QW_ParsePlayers(pSI,pCurrPointer,end,&nPlayers); break; default: pQ3Players = Q3_ParsePlayers2(pSI,pCurrPointer,end,&nPlayers,szP_ET); break; } pSI->pPlayerData = pQ3Players; //----------------------------------- //Update server info from rule values //----------------------------------- pSI->bUpdated = 1; pSI->cPurge = 0; pSI->nPlayers = nPlayers; szVarValue= Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_PRIVATE).sRuleValue.c_str(),pSI->pServerRules); if(szVarValue!=NULL) pSI->bPrivate = (char)atoi(szVarValue); szVarValue = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_PB).sRuleValue.c_str(),pServRules); if(szVarValue!=NULL) pSI->bPunkbuster = (char)atoi(szVarValue); //getting status value switch(pSI->cGAMEINDEX) { case QW_SERVERLIST: pSI->szSTATUS = Get_RuleValue("status",pSI->pServerRules); break; case Q2_SERVERLIST: { //Lets enumerate through vars for the best match to sue as a status... pSI->szSTATUS = Get_RuleValue("time_remaining",pSI->pServerRules); if(pSI->szSTATUS==NULL) { pSI->szSTATUS = Get_RuleValue("#time_left",pSI->pServerRules); if(pSI->szSTATUS==NULL) { pSI->szSTATUS = Get_RuleValue("gamestats",pSI->pServerRules); } } } break; case Q3_SERVERLIST: pSI->szSTATUS = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_STATUS).sRuleValue.c_str(),pSI->pServerRules); break; } szVarValue = Get_RuleValue("sv_privateClients",pServRules); if(szVarValue!=NULL) pSI->nPrivateClients = atoi(szVarValue); szVarValue = Get_RuleValue("sv_maxclients",pServRules); if(szVarValue!=NULL) { unsigned int maxClient = atoi(szVarValue); if(maxClient>pSI->nPrivateClients) pSI->nMaxPlayers = maxClient-pSI->nPrivateClients; else pSI->nMaxPlayers = pSI->nPrivateClients-maxClient; } else { //for QW szVarValue = Get_RuleValue("maxclients",pServRules); if(szVarValue!=NULL) pSI->nMaxPlayers = atoi(szVarValue)-pSI->nPrivateClients; } time(&pSI->timeLastScan); } //end if(pServRules!=NULL) ReleaseServerLock(pSI); if(Callback_CheckForBuddy!=NULL) Callback_CheckForBuddy(pSI->pPlayerData,pSI); free(packet); } //end if(packet) else pSI->cPurge++; //increase purge counter when the server is not responding if(UpdatePlayerListView!=NULL) UpdatePlayerListView(pSI->pPlayerData); if(UpdateRulesListView!=NULL) UpdateRulesListView(pSI->pServerRules); closesocket(pSocket); // pSI->bLocked = FALSE; return 0; }
DWORD COD4_Get_ServerStatus(SERVER_INFO *pSI,long (*UpdatePlayerListView)(PLAYERDATA *Q3players),long (*UpdateRulesListView)(SERVER_RULES *pServerRules)) { SOCKET pSocket = NULL; unsigned char *packet=NULL; DWORD dwStartTick=0; if(pSI==NULL) { dbg_print("Invalid pointer argument @Get_ServerStatus!\n"); return (DWORD)0x000001; } pSocket = getsockudp(pSI->szIPaddress ,(unsigned short)pSI->usPort); if(pSocket==INVALID_SOCKET) { dbg_print("Error at getsockudp()\n"); return 0x000002; } size_t packetlen = 0; //Some default values pSI->dwPing = 9999; if( ((pSI->szShortCountryName[0]=='E') && (pSI->szShortCountryName[1]=='U')) || ((pSI->szShortCountryName[0]=='z') && (pSI->szShortCountryName[1]=='z'))) { char szShortName[4]; g_IPtoCountry.IPtoCountry(pSI->dwIP,szShortName);//optimized since v1.31 strncpy_s(pSI->szShortCountryName,sizeof(pSI->szShortCountryName),szShortName,_TRUNCATE); } DWORD dwRetries=0; int len = 0; //(int)strlen(sendbuf); char sendbuf[80]; ZeroMemory(sendbuf,sizeof(sendbuf)); len = UTILZ_ConvertEscapeCodes(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo,sendbuf,sizeof(sendbuf)); retry: if(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo!=NULL) packetlen = send(pSocket, sendbuf, len+1, 0); else packetlen=SOCKET_ERROR; if(packetlen==SOCKET_ERROR) { dbg_print("Error at send()\n"); closesocket(pSocket); pSI->cPurge++; // pSI->bLocked = FALSE; return -1; } dwStartTick = GetTickCount(); //ping data start packet=(unsigned char*)getpacket(pSocket, &packetlen); if(packet==NULL) { if(dwRetries<AppCFG.dwRetries) { dwRetries++; goto retry; } } if(packet) { pSI->dwPing = (GetTickCount() - dwStartTick); //ping data stop //dbg_dumpbuf("dump.bin", packet, packetlen); GetServerLock(pSI); CleanUp_ServerInfo(pSI); SERVER_RULES *pServRules=NULL; char *end = (char*)((packet)+packetlen); char *pCurrPointer=NULL; //will contain the start address for the player data pCurrPointer = Q3_ParseServerRules(pServRules,(char*)packet,packetlen); pSI->pServerRules = pServRules; if(pServRules!=NULL) { PLAYERDATA *pQ3Players=NULL; DWORD nPlayers=0; //--------------------------------- //Retrieve players if any exsist... //--------------------------------- pSI->szServerName = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_SERVERNAME).sRuleValue.c_str(),pSI->pServerRules,1); pSI->szMap = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_MAP).sRuleValue.c_str(),pSI->pServerRules); pSI->szMod = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_MOD).sRuleValue.c_str(),pSI->pServerRules); pSI->szGameTypeName = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_GAMETYPE).sRuleValue.c_str(),pSI->pServerRules); pSI->szVersion = Get_RuleValue((TCHAR*)gm.GamesInfo[pSI->cGAMEINDEX].vGAME_SPEC_COL.at(COL_VERSION).sRuleValue.c_str(),pSI->pServerRules); pQ3Players = Q3_ParsePlayers2(pSI,pCurrPointer,end,&nPlayers); pSI->pPlayerData = pQ3Players; //----------------------------------- //Update server info from rule values //----------------------------------- pSI->bUpdated = 1; pSI->cPurge = 0; pSI->nPlayers = nPlayers; char *szVarValue=NULL; char *pVarValue = NULL; szVarValue = Get_RuleValue("pswrd",pServRules); //CoD & Cod2 if(szVarValue!=NULL) pSI->bPrivate = atoi(szVarValue); szVarValue = Get_RuleValue("sv_punkbuster",pServRules); if(szVarValue!=NULL) pSI->bPunkbuster = (char)atoi(szVarValue); szVarValue = Get_RuleValue("sv_privateClients",pServRules); if(szVarValue!=NULL) pSI->nPrivateClients = atoi(szVarValue); szVarValue = Get_RuleValue("sv_maxclients",pServRules); if(szVarValue!=NULL) { unsigned int maxClient = atoi(szVarValue); if(maxClient>pSI->nPrivateClients) pSI->nMaxPlayers = maxClient-pSI->nPrivateClients; else pSI->nMaxPlayers = pSI->nPrivateClients-maxClient; } free(packet); packet =NULL; // pCurrPointer = Q3_ParseServerRules(pServRules,(char*)packet,packetlen); ZeroMemory(sendbuf,sizeof(sendbuf)); len = UTILZ_ConvertEscapeCodes("\xFF\xFF\xFF\xFFgetinfo x73",sendbuf,sizeof(sendbuf)); // Sleep(50); packetlen = send(pSocket, sendbuf, len+1, 0); packet=(unsigned char*)getpacket(pSocket, &packetlen); if(packet) { //dbg_dumpbuf("dump.bin", packet, packetlen); SERVER_RULES *pServRulestemp=NULL; SERVER_RULES *pServRules2=NULL; char *end = (char*)((packet)+packetlen); char *pCurrPointer2=NULL; //will contain the start address for the player data pCurrPointer2 = Q3_ParseServerRules(pServRules2,(char*)packet,packetlen); pServRulestemp = pSI->pServerRules ; while(pServRulestemp!=NULL) { if(pServRulestemp->pNext==NULL) break; pServRulestemp = pServRulestemp->pNext; } pServRulestemp->pNext = pServRules2; free(packet); packet = NULL; } time(&pSI->timeLastScan); } //end if(pServRules!=NULL) ReleaseServerLock(pSI); if(Callback_CheckForBuddy!=NULL) //This has to be done after the lock to avoid deadlock Callback_CheckForBuddy(pSI->pPlayerData,pSI); } //end if(packet) else pSI->cPurge++; //increase purge counter when the server is not responding if(UpdatePlayerListView!=NULL) UpdatePlayerListView(pSI->pPlayerData); if(UpdateRulesListView!=NULL) UpdateRulesListView(pSI->pServerRules); closesocket(pSocket); // pSI->bLocked = FALSE; return 0; }
DWORD BFBC2_Get_ServerStatus(SERVER_INFO *pSI,long (*UpdatePlayerListView)(PLAYERDATA *Q3players),long (*UpdateRulesListView)(SERVER_RULES *pServerRules)) { SOCKET pSocket = NULL; unsigned char *packet=NULL; DWORD dwStartTick=0; if(pSI==NULL) { dbg_print("Invalid pointer argument @Get_ServerStatus!\n"); return (DWORD)0xdead; } pSI->usQueryPort = 48888; pSocket = getsockudp(pSI->szIPaddress ,(unsigned short)pSI->usQueryPort); if(pSocket==INVALID_SOCKET) { dbg_print("Error at getsockudp()\n"); return 0x000002; } size_t packetlen = 0; //Some default values pSI->dwPing = 9999; if( ((pSI->szShortCountryName[0]=='E') && (pSI->szShortCountryName[1]=='U')) || ((pSI->szShortCountryName[0]=='z') && (pSI->szShortCountryName[1]=='z'))) { char szShortName[4]; g_IPtoCountry.IPtoCountry(pSI->dwIP,szShortName);//optimized since v1.31 strncpy_s(pSI->szShortCountryName,sizeof(pSI->szShortCountryName),szShortName,_TRUNCATE); } DWORD dwRetries=0; int len = 0; //(int)strlen(sendbuf); char sendbuf[80]; ZeroMemory(sendbuf,sizeof(sendbuf)); //memcpy( buf, "\x00\x00\x00\x00\x1b\x00\x00\x00\x01\x00\x00\x00\x0a\x00\x00\x00serverInfo\x00", size ); //memcpy( buf, "\x01\x00\x00\x00\x15\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00quit\x00", size ); len = UTILZ_ConvertEscapeCodes(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo,sendbuf,sizeof(sendbuf)); retry: //if(gm.GamesInfo[pSI->cGAMEINDEX].szServerRequestInfo!=NULL) packetlen = send(pSocket, "\x00\x00\x00\x00\x1b\x00\x00\x00\x01\x00\x00\x00\x0a\x00\x00\x00serverInfo\x00", 27, 0); // else // packetlen=SOCKET_ERROR; if(packetlen==SOCKET_ERROR) { dbg_print("Error at send()\n"); closesocket(pSocket); pSI->cPurge++; return -1; } dwStartTick = GetTickCount(); packet=(unsigned char*)getpacket(pSocket, &packetlen); if(packet==NULL) { if(dwRetries<AppCFG.dwRetries) { dwRetries++; goto retry; } } if(packet) { pSI->dwPing = (GetTickCount() - dwStartTick); GetServerLock(pSI); if(pSI->pPlayerData!=NULL) CleanUp_PlayerList(pSI->pPlayerData); pSI->pPlayerData = NULL; if(pSI->pServerRules!=NULL) CleanUp_ServerRules(pSI->pServerRules); pSI->pServerRules = NULL; //dbg_dumpbuf("dump.bin", packet, packetlen); SERVER_RULES *pServRules=NULL; char *end = (char*)((packet)+packetlen); char *pCurrPointer=NULL; //will contain the start address for the player data //pCurrPointer = Q3_ParseServerRules(pServRules,(char*)packet,packetlen); pSI->pServerRules = pServRules; if(pServRules!=NULL) { char *szVarValue=NULL; GAME_INFO *pGI = &gm.GamesInfo[pSI->cGAMEINDEX]; // pSI->szServerName = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_SERVERNAME).sRuleValue.c_str(),pSI->pServerRules); // pSI->szMap = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_MAP).sRuleValue.c_str(),pSI->pServerRules); // pSI->szMod = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_MOD).sRuleValue.c_str(),pSI->pServerRules); // pSI->szGameTypeName = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_GAMETYPE).sRuleValue.c_str(),pSI->pServerRules); // pSI->szVersion = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_VERSION).sRuleValue.c_str(),pSI->pServerRules); PLAYERDATA *pQ3Players=NULL; DWORD nPlayers=0; //--------------------------------- //Retrieve players if any exsist... //--------------------------------- // pQ3Players = Q3_ParsePlayers2(pSI,pCurrPointer,end,&nPlayers,szP_ET); pSI->pPlayerData = pQ3Players; //----------------------------------- //Update server info from rule values //----------------------------------- pSI->bUpdated = 1; pSI->cPurge = 0; pSI->nPlayers = nPlayers; szVarValue= Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_PRIVATE).sRuleValue.c_str(),pSI->pServerRules); if(szVarValue!=NULL) pSI->bPrivate = (char)atoi(szVarValue); szVarValue = Get_RuleValue((TCHAR*)pGI->vGAME_SPEC_COL.at(COL_PB).sRuleValue.c_str(),pServRules); if(szVarValue!=NULL) pSI->bPunkbuster = (char)atoi(szVarValue); szVarValue = Get_RuleValue("sv_privateClients",pServRules); if(szVarValue!=NULL) pSI->nPrivateClients = atoi(szVarValue); time(&pSI->timeLastScan); } //end if(pServRules!=NULL) ReleaseServerLock(pSI); if(Callback_CheckForBuddy!=NULL) Callback_CheckForBuddy(pSI->pPlayerData,pSI); free(packet); } //end if(packet) else pSI->cPurge++; //increase purge counter when the server is not responding if(UpdatePlayerListView!=NULL) UpdatePlayerListView(pSI->pPlayerData); if(UpdateRulesListView!=NULL) UpdateRulesListView(pSI->pServerRules); closesocket(pSocket); // pSI->bLocked = FALSE; return 0; }