Skip to content

Commit

Permalink
Add 'sv_maps_base_url' to support map download https urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Dec 16, 2024
1 parent 9797da8 commit d57390e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,14 @@ void CServer::SendMap(int ClientId)
Msg.AddRaw(&m_aCurrentMapSha256[MapType].data, sizeof(m_aCurrentMapSha256[MapType].data));
Msg.AddInt(m_aCurrentMapCrc[MapType]);
Msg.AddInt(m_aCurrentMapSize[MapType]);
Msg.AddString("", 0); // HTTPS map download URL
if(!m_MapDownloadUrl[MapType].empty())
{
Msg.AddString(m_MapDownloadUrl[MapType].c_str(), 0);
}
else
{
Msg.AddString("", 0);
}
SendMsg(&Msg, MSGFLAG_VITAL, ClientId);
}
{
Expand Down Expand Up @@ -2591,6 +2598,16 @@ int CServer::LoadMap(const char *pMapName)
m_apCurrentMapData[MAP_TYPE_SIX] = (unsigned char *)pData;
}

if(Config()->m_SvMapsBaseUrl[0])
{
str_format(aBuf, sizeof(aBuf), "%s/%s_%s.map", Config()->m_SvMapsBaseUrl, pMapName, aSha256);
m_MapDownloadUrl[MAP_TYPE_SIX] = aBuf;
}
else
{
m_MapDownloadUrl[MAP_TYPE_SIX].clear();
}

// load sixup version of the map
if(Config()->m_SvSixup)
{
Expand Down
1 change: 1 addition & 0 deletions src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class CServer : public IServer
unsigned m_aCurrentMapCrc[NUM_MAP_TYPES];
unsigned char *m_apCurrentMapData[NUM_MAP_TYPES];
unsigned int m_aCurrentMapSize[NUM_MAP_TYPES];
std::string m_MapDownloadUrl[NUM_MAP_TYPES];

CDemoRecorder m_aDemoRecorder[NUM_RECORDERS];
CAuthManager m_AuthManager;
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "U
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'")
MACRO_CONFIG_STR(SvRegisterExtra, sv_register_extra, 256, "", CFGFLAG_SERVER, "Extra headers to send to the register endpoint, comma separated 'Header: Value' pairs")
MACRO_CONFIG_STR(SvRegisterUrl, sv_register_url, 128, "https://master1.ddnet.org/ddnet/15/register", CFGFLAG_SERVER, "Masterserver URL to register to")
MACRO_CONFIG_STR(SvMapsBaseUrl, sv_maps_base_url, 128, "", CFGFLAG_SERVER, "Base path used to provide HTTPS map download URL to the clients")
MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password (full access)")
MACRO_CONFIG_STR(SvRconModPassword, sv_rcon_mod_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password for moderators (limited access)")
MACRO_CONFIG_STR(SvRconHelperPassword, sv_rcon_helper_password, 128, "", CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Remote console password for helpers (limited access)")
Expand Down

0 comments on commit d57390e

Please sign in to comment.