Use old ddnet-ranks.json when new one can't be fetched currently

This commit is contained in:
def 2017-08-31 22:40:55 +02:00
parent e36d7ce9a1
commit 8ebac31c03
2 changed files with 3 additions and 1 deletions

View file

@ -2274,6 +2274,7 @@ void CClient::ResetDDNetRanks()
void CClient::FinishDDNetRanks() void CClient::FinishDDNetRanks()
{ {
ResetDDNetRanks(); ResetDDNetRanks();
m_pStorage->RenameFile("ddnet-ranks.json.tmp", "ddnet-ranks.json", IStorage::TYPE_SAVE);
m_ServerBrowser.LoadDDNetRanks(); m_ServerBrowser.LoadDDNetRanks();
} }
@ -3780,7 +3781,7 @@ void CClient::RequestDDNetRanks()
str_format(aUrl, sizeof(aUrl), "https://ddnet.tw/players/?json=%s", aEscaped); str_format(aUrl, sizeof(aUrl), "https://ddnet.tw/players/?json=%s", aEscaped);
m_pDDNetRanksTask = new CFetchTask(true, /*UseDDNetCA*/ true); m_pDDNetRanksTask = new CFetchTask(true, /*UseDDNetCA*/ true);
Fetcher()->QueueAdd(m_pDDNetRanksTask, aUrl, "ddnet-ranks.json", IStorage::TYPE_SAVE); Fetcher()->QueueAdd(m_pDDNetRanksTask, aUrl, "ddnet-ranks.json.tmp", IStorage::TYPE_SAVE);
} }
int CClient::GetPredictionTime() int CClient::GetPredictionTime()

View file

@ -594,6 +594,7 @@ void CServerBrowser::Refresh(int Type)
else if(Type == IServerBrowser::TYPE_DDNET) else if(Type == IServerBrowser::TYPE_DDNET)
{ {
LoadDDNetServers(); LoadDDNetServers();
LoadDDNetRanks();
// remove unknown elements of exclude list // remove unknown elements of exclude list
DDNetCountryFilterClean(); DDNetCountryFilterClean();