Skip to content

Commit d9573fb

Browse files
committed
Add 'sv_maps_base_url' to support map download https urls
1 parent 41e37fc commit d9573fb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/engine/server/server.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ CServer::CServer()
251251
m_ReloadedWhenEmpty = false;
252252
m_aCurrentMap[0] = '\0';
253253
m_pCurrentMapName = m_aCurrentMap;
254+
m_aMapDownloadUrl[0] = '\0';
254255

255256
m_RconClientId = IServer::RCON_CID_SERV;
256257
m_RconAuthLevel = AUTHED_ADMIN;
@@ -1214,7 +1215,14 @@ void CServer::SendMap(int ClientId)
12141215
Msg.AddRaw(&m_aCurrentMapSha256[MapType].data, sizeof(m_aCurrentMapSha256[MapType].data));
12151216
Msg.AddInt(m_aCurrentMapCrc[MapType]);
12161217
Msg.AddInt(m_aCurrentMapSize[MapType]);
1217-
Msg.AddString("", 0); // HTTPS map download URL
1218+
if(m_aMapDownloadUrl[0])
1219+
{
1220+
Msg.AddString(m_aMapDownloadUrl, 0);
1221+
}
1222+
else
1223+
{
1224+
Msg.AddString("", 0);
1225+
}
12181226
SendMsg(&Msg, MSGFLAG_VITAL, ClientId);
12191227
}
12201228
{
@@ -2591,6 +2599,16 @@ int CServer::LoadMap(const char *pMapName)
25912599
m_apCurrentMapData[MAP_TYPE_SIX] = (unsigned char *)pData;
25922600
}
25932601

2602+
if(Config()->m_SvMapsBaseUrl[0])
2603+
{
2604+
str_format(aBuf, sizeof(aBuf), "%s%s_%s.map", Config()->m_SvMapsBaseUrl, pMapName, aSha256);
2605+
EscapeUrl(m_aMapDownloadUrl, aBuf);
2606+
}
2607+
else
2608+
{
2609+
m_aMapDownloadUrl[0] = '\0';
2610+
}
2611+
25942612
// load sixup version of the map
25952613
if(Config()->m_SvSixup)
25962614
{

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+
char m_aMapDownloadUrl[256];
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)