Fix crash in serverbrowser initialization

Another missing commit.

Fixes #3875.

CC #3772 #3855
This commit is contained in:
heinrich5991 2021-06-03 00:27:00 +02:00
parent 67bb0c3c07
commit 26a577b891
3 changed files with 7 additions and 5 deletions

View file

@ -3103,6 +3103,7 @@ void CClient::Run()
} }
GameClient()->OnInit(); GameClient()->OnInit();
m_ServerBrowser.OnInit();
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion()); str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion());

View file

@ -106,6 +106,11 @@ void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVers
RegisterCommands(); RegisterCommands();
} }
void CServerBrowser::OnInit()
{
m_pHttp = CreateServerBrowserHttp(m_pEngine, m_pConsole, m_pStorage, g_Config.m_BrCachedBestServerinfoUrl);
}
void CServerBrowser::RegisterCommands() void CServerBrowser::RegisterCommands()
{ {
m_pConsole->Register("leak_ip_address_to_all_servers", "", CFGFLAG_CLIENT, Con_LeakIpAddress, this, "Leaks your IP address to all servers by pinging each of them, also acquiring the latency in the process"); m_pConsole->Register("leak_ip_address_to_all_servers", "", CFGFLAG_CLIENT, Con_LeakIpAddress, this, "Leaks your IP address to all servers by pinging each of them, also acquiring the latency in the process");
@ -1145,11 +1150,6 @@ void CServerBrowser::Update(bool ForceResort)
int64 Timeout = time_freq(); int64 Timeout = time_freq();
int64 Now = time_get(); int64 Now = time_get();
if(!m_pHttp)
{
m_pHttp = CreateServerBrowserHttp(m_pEngine, m_pConsole, m_pStorage, g_Config.m_BrCachedBestServerinfoUrl);
}
const char *pHttpBestUrl; const char *pHttpBestUrl;
if(!m_pHttp->GetBestUrl(&pHttpBestUrl) && pHttpBestUrl != m_pHttpPrevBestUrl) if(!m_pHttp->GetBestUrl(&pHttpBestUrl) && pHttpBestUrl != m_pHttpPrevBestUrl)
{ {

View file

@ -136,6 +136,7 @@ public:
void SetCurrentServerPing(const NETADDR &Addr, int Ping); void SetCurrentServerPing(const NETADDR &Addr, int Ping);
void SetBaseInfo(class CNetClient *pClient, const char *pNetVersion); void SetBaseInfo(class CNetClient *pClient, const char *pNetVersion);
void OnInit();
void RequestImpl64(const NETADDR &Addr, CServerEntry *pEntry) const; void RequestImpl64(const NETADDR &Addr, CServerEntry *pEntry) const;
void QueueRequest(CServerEntry *pEntry); void QueueRequest(CServerEntry *pEntry);