Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,8 @@ if(CLIENT)
components/chat.h
components/community_icons.cpp
components/community_icons.h
components/map_previews.cpp
components/map_previews.h
components/console.cpp
components/console.h
components/controls.cpp
Expand Down
21 changes: 21 additions & 0 deletions src/engine/client/serverbrowser_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,28 @@ bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvSe
}
CServerInfo SetInfo = ParsedInfo;
SetInfo.m_Location = ParsedLocation;
const json_value &MapUrl = Info["map"]["url"];
if(MapUrl.type == json_string && !str_has_cc(MapUrl))
str_copy(SetInfo.m_aMapUrl, MapUrl);
SetInfo.m_NumAddresses = 0;

// Keep map metadata from the master list. The normal server-browser model
// historically discarded these fields, but map preview downloads need the
// SHA-256 because maps.ddnet.org uses <name>_<sha256>.map filenames.
const json_value &MapSha256 = Info["map"]["sha256"];
const json_value &MapSize = Info["map"]["size"];
if(MapSha256.type == json_string && MapSize.type == json_integer)
{
SHA256_DIGEST ParsedMapSha256;
const int64_t ParsedMapSize = static_cast<int>(MapSize.u.integer);
if(ParsedMapSize > 0 && ParsedMapSize <= 1024ll * 1024ll * 1024ll &&
sha256_from_str(&ParsedMapSha256, MapSha256.u.string.ptr) == 0)
{
SetInfo.m_HasMapSha256 = true;
SetInfo.m_MapSha256 = ParsedMapSha256;
SetInfo.m_MapSize = (int)ParsedMapSize;
}
}
bool GotVersion6 = false;
for(unsigned int a = 0; a < Addresses.u.array.length; a++)
{
Expand Down
3 changes: 3 additions & 0 deletions src/engine/serverbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class CServerInfo
char m_aMap[MAX_MAP_LENGTH];
int m_MapCrc;
int m_MapSize;
bool m_HasMapSha256;
SHA256_DIGEST m_MapSha256;
char m_aMapUrl[512];
char m_aVersion[32];
char m_aAddress[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE];
CClient m_aClients[SERVERINFO_MAX_CLIENTS];
Expand Down
Loading