Merge pull request #8649 from furo321/remove-servers_legacy

Remove `servers_legacy` support
This commit is contained in:
Dennis Felsing 2024-07-25 15:48:02 +00:00 committed by GitHub
commit 27ca58f257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 54 deletions

View file

@ -1080,7 +1080,6 @@ void CServerBrowser::UpdateFromHttp()
} }
int NumServers = m_pHttp->NumServers(); int NumServers = m_pHttp->NumServers();
int NumLegacyServers = m_pHttp->NumLegacyServers();
std::function<bool(const NETADDR *, int)> Want = [](const NETADDR *pAddrs, int NumAddrs) { return true; }; std::function<bool(const NETADDR *, int)> Want = [](const NETADDR *pAddrs, int NumAddrs) { return true; };
if(m_ServerlistType == IServerBrowser::TYPE_FAVORITES) if(m_ServerlistType == IServerBrowser::TYPE_FAVORITES)
{ {
@ -1139,16 +1138,6 @@ void CServerBrowser::UpdateFromHttp()
pEntry->m_RequestIgnoreInfo = true; pEntry->m_RequestIgnoreInfo = true;
} }
for(int i = 0; i < NumLegacyServers; i++)
{
NETADDR Addr = m_pHttp->LegacyServer(i);
if(!Want(&Addr, 1))
{
continue;
}
QueueRequest(Add(&Addr, 1));
}
if(m_ServerlistType == IServerBrowser::TYPE_FAVORITES) if(m_ServerlistType == IServerBrowser::TYPE_FAVORITES)
{ {
const IFavorites::CEntry *pFavorites; const IFavorites::CEntry *pFavorites;
@ -2289,16 +2278,6 @@ bool CServerBrowser::IsRegistered(const NETADDR &Addr)
} }
} }
} }
const int NumLegacyServers = m_pHttp->NumLegacyServers();
for(int i = 0; i < NumLegacyServers; i++)
{
if(net_addr_comp(&m_pHttp->LegacyServer(i), &Addr) == 0)
{
return true;
}
}
return false; return false;
} }

View file

@ -319,14 +319,6 @@ public:
{ {
return m_vServers[Index]; return m_vServers[Index];
} }
int NumLegacyServers() const override
{
return m_vLegacyServers.size();
}
const NETADDR &LegacyServer(int Index) const override
{
return m_vLegacyServers[Index];
}
private: private:
enum enum
@ -338,7 +330,7 @@ private:
}; };
static bool Validate(json_value *pJson); static bool Validate(json_value *pJson);
static bool Parse(json_value *pJson, std::vector<CServerInfo> *pvServers, std::vector<NETADDR> *pvLegacyServers); static bool Parse(json_value *pJson, std::vector<CServerInfo> *pvServers);
IHttp *m_pHttp; IHttp *m_pHttp;
@ -347,7 +339,6 @@ private:
std::unique_ptr<CChooseMaster> m_pChooseMaster; std::unique_ptr<CChooseMaster> m_pChooseMaster;
std::vector<CServerInfo> m_vServers; std::vector<CServerInfo> m_vServers;
std::vector<NETADDR> m_vLegacyServers;
}; };
CServerBrowserHttp::CServerBrowserHttp(IEngine *pEngine, IHttp *pHttp, const char **ppUrls, int NumUrls, int PreviousBestIndex) : CServerBrowserHttp::CServerBrowserHttp(IEngine *pEngine, IHttp *pHttp, const char **ppUrls, int NumUrls, int PreviousBestIndex) :
@ -398,7 +389,7 @@ void CServerBrowserHttp::Update()
bool Success = true; bool Success = true;
json_value *pJson = pGetServers->State() == EHttpState::DONE ? pGetServers->ResultJson() : nullptr; json_value *pJson = pGetServers->State() == EHttpState::DONE ? pGetServers->ResultJson() : nullptr;
Success = Success && pJson; Success = Success && pJson;
Success = Success && !Parse(pJson, &m_vServers, &m_vLegacyServers); Success = Success && !Parse(pJson, &m_vServers);
json_value_free(pJson); json_value_free(pJson);
if(!Success) if(!Success)
{ {
@ -438,18 +429,15 @@ bool ServerbrowserParseUrl(NETADDR *pOut, const char *pUrl)
bool CServerBrowserHttp::Validate(json_value *pJson) bool CServerBrowserHttp::Validate(json_value *pJson)
{ {
std::vector<CServerInfo> vServers; std::vector<CServerInfo> vServers;
std::vector<NETADDR> vLegacyServers; return Parse(pJson, &vServers);
return Parse(pJson, &vServers, &vLegacyServers);
} }
bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvServers, std::vector<NETADDR> *pvLegacyServers) bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvServers)
{ {
std::vector<CServerInfo> vServers; std::vector<CServerInfo> vServers;
std::vector<NETADDR> vLegacyServers;
const json_value &Json = *pJson; const json_value &Json = *pJson;
const json_value &Servers = Json["servers"]; const json_value &Servers = Json["servers"];
const json_value &LegacyServers = Json["servers_legacy"]; if(Servers.type != json_array)
if(Servers.type != json_array || (LegacyServers.type != json_array && LegacyServers.type != json_none))
{ {
return true; return true;
} }
@ -509,21 +497,7 @@ bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvSe
vServers.push_back(SetInfo); vServers.push_back(SetInfo);
} }
} }
if(LegacyServers.type == json_array)
{
for(unsigned int i = 0; i < LegacyServers.u.array.length; i++)
{
const json_value &Address = LegacyServers[i];
NETADDR ParsedAddr;
if(Address.type != json_string || net_addr_from_str(&ParsedAddr, Address))
{
return true;
}
vLegacyServers.push_back(ParsedAddr);
}
}
*pvServers = vServers; *pvServers = vServers;
*pvLegacyServers = vLegacyServers;
return false; return false;
} }

View file

@ -21,8 +21,6 @@ public:
virtual int NumServers() const = 0; virtual int NumServers() const = 0;
virtual const CServerInfo &Server(int Index) const = 0; virtual const CServerInfo &Server(int Index) const = 0;
virtual int NumLegacyServers() const = 0;
virtual const NETADDR &LegacyServer(int Index) const = 0;
}; };
IServerBrowserHttp *CreateServerBrowserHttp(IEngine *pEngine, IStorage *pStorage, IHttp *pHttp, const char *pPreviousBestUrl); IServerBrowserHttp *CreateServerBrowserHttp(IEngine *pEngine, IStorage *pStorage, IHttp *pHttp, const char *pPreviousBestUrl);