From 4dcc565e5d8f6039d2c40e81cd40a7101148822f Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Thu, 19 Sep 2024 15:21:48 +0200 Subject: [PATCH] info: "finishes" shouldn't be under "icon" either Actually moving to those new paths shouldn't be done until we get a breaking change of this JSON, as it would otherwise unnecessarily break old clients. Once a new endpoint is created, the backward compatibility can be removed. --- src/engine/client/serverbrowser.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index 6c93b3aba..b2c91dfab 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -1468,15 +1468,21 @@ void CServerBrowser::LoadDDNetServers() const json_value &IconUrl = Icon["url"]; const json_value &Name = Community["name"]; const json_value HasFinishes = Community["has_finishes"]; - const json_value *pFinishes = &Icon["finishes"]; + const json_value *pFinishes = &Community["finishes"]; const json_value *pServers = &Community["servers"]; - // We accidentally set servers to be part of icon, so support that as a - // fallback for now. Can be removed in a few versions when the - // communities.json has been updated. + // We accidentally set finishes/servers to be part of icon in + // the past, so support that, too. Can be removed once we make + // a breaking change to the whole thing, necessitating a new + // endpoint. + if(pFinishes->type == json_none) + { + pServers = &Icon["finishes"]; + } if(pServers->type == json_none) { pServers = &Icon["servers"]; } + // Backward compatibility. if(pFinishes->type == json_none) { if(str_comp(Id, COMMUNITY_DDNET) == 0) @@ -1484,7 +1490,6 @@ void CServerBrowser::LoadDDNetServers() pFinishes = &(*m_pDDNetInfo)["maps"]; } } - // Backward compatibility. if(pServers->type == json_none) { if(str_comp(Id, COMMUNITY_DDNET) == 0)