mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Avoid copies of server info in CGameClient::OnNewSnapshot
Only copy the server info with the `GetServerInfo` function once, as it should not change within a call of the `CGameClient::OnNewSnapshot` function.
This commit is contained in:
parent
cb9521d29f
commit
74426b05a3
|
@ -1161,7 +1161,7 @@ void CGameClient::ProcessEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize, CServerInfo *pFallbackServerInfo)
|
static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize, const CServerInfo *pFallbackServerInfo)
|
||||||
{
|
{
|
||||||
int Version = -1;
|
int Version = -1;
|
||||||
if(InfoExSize >= 12)
|
if(InfoExSize >= 12)
|
||||||
|
@ -1376,6 +1376,9 @@ void CGameClient::OnNewSnapshot()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CServerInfo ServerInfo;
|
||||||
|
Client()->GetServerInfo(&ServerInfo);
|
||||||
|
|
||||||
bool FoundGameInfoEx = false;
|
bool FoundGameInfoEx = false;
|
||||||
bool GotSwitchStateTeam = false;
|
bool GotSwitchStateTeam = false;
|
||||||
m_aSwitchStateTeam[g_Config.m_ClDummy] = -1;
|
m_aSwitchStateTeam[g_Config.m_ClDummy] = -1;
|
||||||
|
@ -1614,8 +1617,6 @@ void CGameClient::OnNewSnapshot()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FoundGameInfoEx = true;
|
FoundGameInfoEx = true;
|
||||||
CServerInfo ServerInfo;
|
|
||||||
Client()->GetServerInfo(&ServerInfo);
|
|
||||||
m_GameInfo = GetGameInfo((const CNetObj_GameInfoEx *)Item.m_pData, Item.m_DataSize, &ServerInfo);
|
m_GameInfo = GetGameInfo((const CNetObj_GameInfoEx *)Item.m_pData, Item.m_DataSize, &ServerInfo);
|
||||||
}
|
}
|
||||||
else if(Item.m_Type == NETOBJTYPE_GAMEDATA)
|
else if(Item.m_Type == NETOBJTYPE_GAMEDATA)
|
||||||
|
@ -1701,8 +1702,6 @@ void CGameClient::OnNewSnapshot()
|
||||||
|
|
||||||
if(!FoundGameInfoEx)
|
if(!FoundGameInfoEx)
|
||||||
{
|
{
|
||||||
CServerInfo ServerInfo;
|
|
||||||
Client()->GetServerInfo(&ServerInfo);
|
|
||||||
m_GameInfo = GetGameInfo(0, 0, &ServerInfo);
|
m_GameInfo = GetGameInfo(0, 0, &ServerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1807,12 +1806,10 @@ void CGameClient::OnNewSnapshot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CServerInfo CurrentServerInfo;
|
|
||||||
Client()->GetServerInfo(&CurrentServerInfo);
|
|
||||||
CTuningParams StandardTuning;
|
CTuningParams StandardTuning;
|
||||||
if(CurrentServerInfo.m_aGameType[0] != '0')
|
if(ServerInfo.m_aGameType[0] != '0')
|
||||||
{
|
{
|
||||||
if(str_comp(CurrentServerInfo.m_aGameType, "DM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "TDM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "CTF") != 0)
|
if(str_comp(ServerInfo.m_aGameType, "DM") != 0 && str_comp(ServerInfo.m_aGameType, "TDM") != 0 && str_comp(ServerInfo.m_aGameType, "CTF") != 0)
|
||||||
m_ServerMode = SERVERMODE_MOD;
|
m_ServerMode = SERVERMODE_MOD;
|
||||||
else if(mem_comp(&StandardTuning, &m_aTuning[g_Config.m_ClDummy], 33) == 0)
|
else if(mem_comp(&StandardTuning, &m_aTuning[g_Config.m_ClDummy], 33) == 0)
|
||||||
m_ServerMode = SERVERMODE_PURE;
|
m_ServerMode = SERVERMODE_PURE;
|
||||||
|
|
Loading…
Reference in a new issue