mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix clang-tidy warnings
Even fix a bug in the process, if `m_pDDNetInfo` is null.
This commit is contained in:
parent
53e9457965
commit
ad26358853
|
@ -130,6 +130,7 @@ void CServerBrowser::Con_LeakIpAddress(IConsole::IResult *pResult, void *pUserDa
|
|||
return net_addr_comp(&Addr1, &Addr2) < 0;
|
||||
}
|
||||
};
|
||||
aSortedServers.reserve(pThis->m_NumServers);
|
||||
for(int i = 0; i < pThis->m_NumServers; i++)
|
||||
{
|
||||
aSortedServers.push_back(i);
|
||||
|
@ -1010,10 +1011,12 @@ void CServerBrowser::UpdateFromHttp()
|
|||
}
|
||||
std::vector<int> aSortedServers;
|
||||
std::vector<int> aSortedLegacyServers;
|
||||
aSortedServers.reserve(NumServers);
|
||||
for(int i = 0; i < NumServers; i++)
|
||||
{
|
||||
aSortedServers.push_back(i);
|
||||
}
|
||||
aSortedLegacyServers.reserve(NumLegacyServers);
|
||||
for(int i = 0; i < NumLegacyServers; i++)
|
||||
{
|
||||
aSortedLegacyServers.push_back(i);
|
||||
|
@ -1489,12 +1492,15 @@ void CServerBrowser::LoadDDNetInfoJson()
|
|||
}
|
||||
|
||||
m_OwnLocation = CServerInfo::LOC_UNKNOWN;
|
||||
const json_value &Location = (*m_pDDNetInfo)["location"];
|
||||
if(Location.type != json_string || CServerInfo::ParseLocation(&m_OwnLocation, Location))
|
||||
if(m_pDDNetInfo)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "cannot parse location from info.sjon: '%s'", (const char *)Location);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "serverbrowse", aBuf);
|
||||
const json_value &Location = (*m_pDDNetInfo)["location"];
|
||||
if(Location.type != json_string || CServerInfo::ParseLocation(&m_OwnLocation, Location))
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "cannot parse location from info.sjon: '%s'", (const char *)Location);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "serverbrowse", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
|
||||
public:
|
||||
CJob(std::shared_ptr<CData> pData) :
|
||||
m_pData(pData) {}
|
||||
m_pData(std::move(pData)) {}
|
||||
virtual ~CJob() {}
|
||||
};
|
||||
|
||||
|
@ -114,7 +114,7 @@ void CChooseMaster::Refresh()
|
|||
void CChooseMaster::CJob::Run()
|
||||
{
|
||||
// Check masters in a random order.
|
||||
int aRandomized[MAX_URLS];
|
||||
int aRandomized[MAX_URLS] = {0};
|
||||
for(int i = 0; i < m_pData->m_NumUrls; i++)
|
||||
{
|
||||
aRandomized[i] = i;
|
||||
|
@ -436,7 +436,7 @@ static const char *DEFAULT_SERVERLIST_URLS[] = {
|
|||
IServerBrowserHttp *CreateServerBrowserHttp(IEngine *pEngine, IConsole *pConsole, IStorage *pStorage, const char *pPreviousBestUrl)
|
||||
{
|
||||
char aaUrls[CChooseMaster::MAX_URLS][256];
|
||||
const char *apUrls[CChooseMaster::MAX_URLS];
|
||||
const char *apUrls[CChooseMaster::MAX_URLS] = {0};
|
||||
const char **ppUrls = apUrls;
|
||||
int NumUrls = 0;
|
||||
IOHANDLE File = pStorage->OpenFile("serverlist_urls.cfg", IOFLAG_READ, IStorage::TYPE_ALL);
|
||||
|
|
Loading…
Reference in a new issue