mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #3566
3566: Use map download url from info2.ddnet.tw (fixes #3546) r=heinrich5991 a=def- which info2.ddnet.tw provides using a geolite db to provide a better server for players in China <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
a404be6702
|
@ -49,6 +49,7 @@ protected:
|
|||
|
||||
public:
|
||||
char m_aNews[3000];
|
||||
char m_aMapDownloadUrl[256];
|
||||
int m_Points;
|
||||
int64 m_ReconnectTime;
|
||||
|
||||
|
|
|
@ -330,6 +330,7 @@ CClient::CClient() :
|
|||
str_format(m_aDDNetInfoTmp, sizeof(m_aDDNetInfoTmp), DDNET_INFO ".%d.tmp", pid());
|
||||
m_pDDNetInfoTask = NULL;
|
||||
m_aNews[0] = '\0';
|
||||
m_aMapDownloadUrl[0] = '\0';
|
||||
m_Points = -1;
|
||||
|
||||
m_CurrentServerInfoRequestTime = -1;
|
||||
|
@ -1743,7 +1744,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
char aUrl[256];
|
||||
char aEscaped[256];
|
||||
EscapeUrl(aEscaped, sizeof(aEscaped), aFilename);
|
||||
str_format(aUrl, sizeof(aUrl), "%s/%s", g_Config.m_ClMapDownloadUrl, aEscaped);
|
||||
bool UseConfigUrl = str_comp(g_Config.m_ClMapDownloadUrl, "https://maps2.ddnet.tw") != 0 || m_aMapDownloadUrl[0] == '\0';
|
||||
str_format(aUrl, sizeof(aUrl), "%s/%s", UseConfigUrl ? g_Config.m_ClMapDownloadUrl : m_aMapDownloadUrl, aEscaped);
|
||||
|
||||
m_pMapdownloadTask = std::make_shared<CGetFile>(Storage(), aUrl, m_aMapdownloadFilename, IStorage::TYPE_SAVE, CTimeout{g_Config.m_ClMapDownloadConnectTimeoutMs, g_Config.m_ClMapDownloadLowSpeedLimit, g_Config.m_ClMapDownloadLowSpeedTime});
|
||||
Engine()->AddJob(m_pMapdownloadTask);
|
||||
|
@ -2529,6 +2531,13 @@ void CClient::LoadDDNetInfo()
|
|||
str_copy(m_aNews, pNewsString, sizeof(m_aNews));
|
||||
}
|
||||
|
||||
const json_value *pMapDownloadUrl = json_object_get(pDDNetInfo, "map-download-url");
|
||||
if(pMapDownloadUrl->type == json_string)
|
||||
{
|
||||
const char *pMapDownloadUrlString = json_string_get(pMapDownloadUrl);
|
||||
str_copy(m_aMapDownloadUrl, pMapDownloadUrlString, sizeof(m_aMapDownloadUrl));
|
||||
}
|
||||
|
||||
const json_value *pPoints = json_object_get(pDDNetInfo, "points");
|
||||
if(pPoints->type == json_integer)
|
||||
m_Points = pPoints->u.integer;
|
||||
|
|
Loading…
Reference in a new issue