Skip to content

Commit 58b897c

Browse files
committed
Add 'sv_maps_base_url' to support map download https urls
1 parent 9797da8 commit 58b897c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/engine/server/server.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ void CServer::SendMap(int ClientId)
12141214
Msg.AddRaw(&m_aCurrentMapSha256[MapType].data, sizeof(m_aCurrentMapSha256[MapType].data));
12151215
Msg.AddInt(m_aCurrentMapCrc[MapType]);
12161216
Msg.AddInt(m_aCurrentMapSize[MapType]);
1217-
Msg.AddString("", 0); // HTTPS map download URL
1217+
Msg.AddString(m_MapDownloadUrl[MapType].c_str(), 0);
12181218
SendMsg(&Msg, MSGFLAG_VITAL, ClientId);
12191219
}
12201220
{
@@ -2590,6 +2590,16 @@ int CServer::LoadMap(const char *pMapName)
25902590
Storage()->ReadFile(aBuf, IStorage::TYPE_ALL, &pData, &m_aCurrentMapSize[MAP_TYPE_SIX]);
25912591
m_apCurrentMapData[MAP_TYPE_SIX] = (unsigned char *)pData;
25922592
}
2593+
2594+
if(Config()->m_SvMapsBaseUrl[0])
2595+
{
2596+
str_format(aBuf, sizeof(aBuf), "%s/%s_%s.map", Config()->m_SvMapsBaseUrl, pMapName, aSha256);
2597+
m_MapDownloadUrl[MAP_TYPE_SIX] = aBuf;
2598+
}
2599+
else
2600+
{
2601+
m_MapDownloadUrl[MAP_TYPE_SIX].clear();
2602+
}
25932603

25942604
// load sixup version of the map
25952605
if(Config()->m_SvSixup)

src/engine/server/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class CServer : public IServer
247247
unsigned m_aCurrentMapCrc[NUM_MAP_TYPES];
248248
unsigned char *m_apCurrentMapData[NUM_MAP_TYPES];
249249
unsigned int m_aCurrentMapSize[NUM_MAP_TYPES];
250+
std::string m_MapDownloadUrl[NUM_MAP_TYPES];
250251

251252
CDemoRecorder m_aDemoRecorder[NUM_RECORDERS];
252253
CAuthManager m_AuthManager;

src/engine/shared/config_variables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "U
439439
MACRO_CONFIG_STR(SvRegister, sv_register, 16, "1", CFGFLAG_SERVER, "Register server with master server for public listing, can also accept a comma-separated list of protocols to register on, like 'ipv4,ipv6'")
440440
MACRO_CONFIG_STR(SvRegisterExtra, sv_register_extra, 256, "", CFGFLAG_SERVER, "Extra headers to send to the register endpoint, comma separated 'Header: Value' pairs")
441441
MACRO_CONFIG_STR(SvRegisterUrl, sv_register_url, 128, "https://master1.ddnet.org/ddnet/15/register", CFGFLAG_SERVER, "Masterserver URL to register to")
442+
MACRO_CONFIG_STR(SvMapsBaseUrl, sv_maps_base_url, 128, "", CFGFLAG_SERVER, "Base path used to provide HTTPS map download URL to the clients")
442443
MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password (full access)")
443444
MACRO_CONFIG_STR(SvRconModPassword, sv_rcon_mod_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password for moderators (limited access)")
444445
MACRO_CONFIG_STR(SvRconHelperPassword, sv_rcon_helper_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password for helpers (limited access)")

0 commit comments

Comments
 (0)