diff --git a/src/base/system.c b/src/base/system.c index 3ddfa1423..bf29b44c0 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -907,9 +907,8 @@ int net_host_lookup(const char *hostname, NETADDR *addr, int types) if(priv_net_extract(hostname, host, sizeof(host), &port)) return -1; - + dbg_msg("host lookup", "host='%s' port=%d %d", host, port, types); - mem_zero(&hints, sizeof(hints)); diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index b55f47dbf..3d9542179 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -431,7 +431,7 @@ void CClient::Rcon(const char *pCmd) { CServerInfo Info; GetServerInfo(&Info); - if(RconAuthed() && (str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet"))) + if(RconAuthed() && IsDDNet(&Info)) { // Against IP spoofing on DDNet servers CMsgPacker Msg(NETMSG_RCON_AUTH); Msg.AddString("", 32); @@ -1398,7 +1398,7 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket) } } - if (strstr(Info.m_aGameType, "64") || strstr(Info.m_aName, "64") || strstr(Info.m_aGameType, "DDraceNet") || strstr(Info.m_aGameType, "DDNet")) + if (Is64Player(&Info)) { pEntry = m_ServerBrowser.Find(pPacket->m_Address); if (pEntry) @@ -1831,8 +1831,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize); CServerInfo Info; GetServerInfo(&Info); - bool IsDDNet = str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet"); - if(IsDDNet) + if(IsDDNet(&Info)) SnapshotRemoveExtraInfo(aExtraInfoRemoved); // add snapshot to demo @@ -1875,8 +1874,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) if(m_RecivedSnapshots[g_Config.m_ClDummy] > 50 && !m_TimeoutCodeSent[g_Config.m_ClDummy]) { - if(str_find_nocase(m_CurrentServerInfo.m_aGameType, "ddracenetw") - || str_find_nocase(m_CurrentServerInfo.m_aGameType, "ddnet")) + if(IsDDNet(&m_CurrentServerInfo)) { m_TimeoutCodeSent[g_Config.m_ClDummy] = true; CNetMsg_Cl_Say Msg; diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 192e0f220..5bd26fb71 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -51,6 +51,11 @@ public: CClient m_aClients[MAX_CLIENTS]; }; +bool IsRace(const CServerInfo *pInfo); +bool IsDDRace(const CServerInfo *pInfo); +bool IsDDNet(const CServerInfo *pInfo); +bool Is64Player(const CServerInfo *pInfo); + class IServerBrowser : public IInterface { MACRO_INTERFACE("serverbrowser", 0) diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index 5c337a178..9931b376f 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -25,7 +25,7 @@ void CCamera::OnRender() { CServerInfo Info; Client()->GetServerInfo(&Info); - if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || Client()->State() == IClient::STATE_DEMOPLAYBACK)) + if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || Client()->State() == IClient::STATE_DEMOPLAYBACK)) m_Zoom = 1.0f; // update camera center @@ -88,7 +88,7 @@ void CCamera::ConZoomPlus(IConsole::IResult *pResult, void *pUserData) CCamera *pSelf = (CCamera *)pUserData; CServerInfo Info; pSelf->Client()->GetServerInfo(&Info); - if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK) + if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK) ((CCamera *)pUserData)->m_Zoom *= ZoomStep; } void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData) @@ -96,7 +96,7 @@ void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData) CCamera *pSelf = (CCamera *)pUserData; CServerInfo Info; pSelf->Client()->GetServerInfo(&Info); - if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK) + if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK) ((CCamera *)pUserData)->m_Zoom *= 1/ZoomStep; } void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData) diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 74b55fc59..477b21efd 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -128,10 +128,8 @@ static void ConKeyInputState(IConsole::IResult *pResult, void *pUserData) CServerInfo Info; pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info); - bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); - bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace"); - if ((IsGameTypeRace || IsGameTypeDDRace) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active) + if ((IsRace(&Info) || IsDDRace(&Info)) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active) return; if (g_Config.m_ClDummy) @@ -146,10 +144,8 @@ static void ConKeyInputCounter(IConsole::IResult *pResult, void *pUserData) CServerInfo Info; pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info); - bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); - bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace"); - if ((IsGameTypeRace || IsGameTypeDDRace) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active) + if ((IsRace(&Info) || IsDDRace(&Info)) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active) return; int *v; @@ -438,10 +434,8 @@ void CControls::OnRender() CServerInfo Info; GameClient()->Client()->GetServerInfo(&Info); - bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); - bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace"); - if( g_Config.m_ClAutoswitchWeaponsOutOfAmmo && !IsGameTypeRace && !IsGameTypeDDRace && m_pClient->m_Snap.m_pLocalCharacter ) + if( g_Config.m_ClAutoswitchWeaponsOutOfAmmo && !IsRace(&Info) && !IsDDRace(&Info) && m_pClient->m_Snap.m_pLocalCharacter ) { // Keep track of ammo count, we know weapon ammo only when we switch to that weapon, this is tracked on server and protocol does not track that m_AmmoCount[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS] = m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount; diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 4b6830140..93b875999 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -59,14 +59,12 @@ void CHud::RenderGameTimer() CServerInfo Info; Client()->GetServerInfo(&Info); - bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); - bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace"); if(Time <= 0 && g_Config.m_ClShowDecisecs) str_format(Buf, sizeof(Buf), "00:00.0"); else if(Time <= 0) str_format(Buf, sizeof(Buf), "00:00"); - else if(IsGameTypeRace && !IsGameTypeDDRace && m_ServerRecord >= 0) + else if(IsRace(&Info) && !IsDDRace(&Info) && m_ServerRecord >= 0) str_format(Buf, sizeof(Buf), "%02d:%02d", (int)(m_ServerRecord*100)/60, ((int)(m_ServerRecord*100)%60)); else if(g_Config.m_ClShowDecisecs) str_format(Buf, sizeof(Buf), "%02d:%02d.%d", Time/60, Time%60, m_DDRaceTick/10); @@ -220,8 +218,7 @@ void CHud::RenderScoreHud() { CServerInfo Info; Client()->GetServerInfo(&Info); - bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); - if(IsGameTypeRace && g_Config.m_ClDDRaceScoreBoard) + if(IsRace(&Info) && g_Config.m_ClDDRaceScoreBoard) { if (apPlayerInfo[t]->m_Score != -9999) str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", abs(apPlayerInfo[t]->m_Score)/60, abs(apPlayerInfo[t]->m_Score)%60); diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 8068d18d0..2fdb3436a 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -75,8 +75,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID) CServerInfo Info; Client()->GetServerInfo(&Info); - bool IsDDNet = str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet"); - ExtractInfo(pCurrent, &StartPos, &StartVel, IsDDNet); + ExtractInfo(pCurrent, &StartPos, &StartVel, IsDDNet(&Info)); vec2 Pos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct); vec2 PrevPos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct-0.001f); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index cd7a1b307..e61dbe1a5 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -487,15 +487,12 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) hsl = vec3(0.00f, 1.0f, 0.75f); // Instagib else if (str_find_nocase(pItem->m_aGameType, "fng")) hsl = vec3(0.83f, 1.0f, 0.75f); // FNG - else if (str_find_nocase(pItem->m_aGameType, "ddracenetw") - || str_find_nocase(pItem->m_aGameType, "ddnet")) + else if (IsDDNet(pItem)) hsl = vec3(0.58f, 1.0f, 0.75f); // DDNet - else if (str_find_nocase(pItem->m_aGameType, "ddrace") - || str_find_nocase(pItem->m_aGameType, "mkrace")) + else if (IsDDRace(pItem)) hsl = vec3(0.75f, 1.0f, 0.75f); // DDRace - else if (str_find_nocase(pItem->m_aGameType, "race") - || !str_comp(pItem->m_aGameType, "FastCap")) - hsl = vec3(0.46f, 1.0f, 0.75f); // Races + else if (IsRace(pItem)) + hsl = vec3(0.46f, 1.0f, 0.75f); // Race vec3 rgb = HslToRgb(hsl); TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f); @@ -894,7 +891,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View) if(!pSelectedServer->m_aClients[i].m_Player) str_copy(aTemp, "SPEC", sizeof(aTemp)); - else if(str_find_nocase(pSelectedServer->m_aGameType, "race") || str_find_nocase(pSelectedServer->m_aGameType, "fastcap")) + else if(IsRace(pSelectedServer)) { if(pSelectedServer->m_aClients[i].m_Score == -9999 || pSelectedServer->m_aClients[i].m_Score == 0) aTemp[0] = 0; diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 87442ad0c..a4455d2c6 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -32,7 +32,7 @@ void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData) CServerInfo Info; pSelf->Client()->GetServerInfo(&Info); - pSelf->m_IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); + pSelf->m_IsGameTypeRace = IsRace(&Info); pSelf->m_Active = pResult->GetInteger(0) != 0; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 1ca417faf..f1dd50b34 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1249,7 +1249,6 @@ void CGameClient::OnPredict() CServerInfo Info; Client()->GetServerInfo(&Info); - bool IsRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap"); const int MaxProjectiles = 128; class CLocalProjectile PredictedProjectiles[MaxProjectiles]; int NumProjectiles = 0; @@ -1383,7 +1382,7 @@ void CGameClient::OnPredict() WillFire = true; if(!WillFire) break; - if(!IsRace && !m_Snap.m_pLocalCharacter->m_AmmoCount && Local->m_ActiveWeapon != WEAPON_HAMMER) + if(!IsRace(&Info) && !m_Snap.m_pLocalCharacter->m_AmmoCount && Local->m_ActiveWeapon != WEAPON_HAMMER) break; int ExpectedStartTick = Tick-1;