mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Remove servers_legacy
support
This commit is contained in:
parent
cd81b1f253
commit
8f96584f40
|
@ -1080,7 +1080,6 @@ void CServerBrowser::UpdateFromHttp()
|
|||
}
|
||||
|
||||
int NumServers = m_pHttp->NumServers();
|
||||
int NumLegacyServers = m_pHttp->NumLegacyServers();
|
||||
std::function<bool(const NETADDR *, int)> Want = [](const NETADDR *pAddrs, int NumAddrs) { return true; };
|
||||
if(m_ServerlistType == IServerBrowser::TYPE_FAVORITES)
|
||||
{
|
||||
|
@ -1139,16 +1138,6 @@ void CServerBrowser::UpdateFromHttp()
|
|||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,14 +319,6 @@ public:
|
|||
{
|
||||
return m_vServers[Index];
|
||||
}
|
||||
int NumLegacyServers() const override
|
||||
{
|
||||
return m_vLegacyServers.size();
|
||||
}
|
||||
const NETADDR &LegacyServer(int Index) const override
|
||||
{
|
||||
return m_vLegacyServers[Index];
|
||||
}
|
||||
|
||||
private:
|
||||
enum
|
||||
|
@ -338,7 +330,7 @@ private:
|
|||
};
|
||||
|
||||
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;
|
||||
|
||||
|
@ -347,7 +339,6 @@ private:
|
|||
std::unique_ptr<CChooseMaster> m_pChooseMaster;
|
||||
|
||||
std::vector<CServerInfo> m_vServers;
|
||||
std::vector<NETADDR> m_vLegacyServers;
|
||||
};
|
||||
|
||||
CServerBrowserHttp::CServerBrowserHttp(IEngine *pEngine, IHttp *pHttp, const char **ppUrls, int NumUrls, int PreviousBestIndex) :
|
||||
|
@ -398,7 +389,7 @@ void CServerBrowserHttp::Update()
|
|||
bool Success = true;
|
||||
json_value *pJson = pGetServers->State() == EHttpState::DONE ? pGetServers->ResultJson() : nullptr;
|
||||
Success = Success && pJson;
|
||||
Success = Success && !Parse(pJson, &m_vServers, &m_vLegacyServers);
|
||||
Success = Success && !Parse(pJson, &m_vServers);
|
||||
json_value_free(pJson);
|
||||
if(!Success)
|
||||
{
|
||||
|
@ -438,18 +429,15 @@ bool ServerbrowserParseUrl(NETADDR *pOut, const char *pUrl)
|
|||
bool CServerBrowserHttp::Validate(json_value *pJson)
|
||||
{
|
||||
std::vector<CServerInfo> vServers;
|
||||
std::vector<NETADDR> vLegacyServers;
|
||||
return Parse(pJson, &vServers, &vLegacyServers);
|
||||
return Parse(pJson, &vServers);
|
||||
}
|
||||
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<NETADDR> vLegacyServers;
|
||||
|
||||
const json_value &Json = *pJson;
|
||||
const json_value &Servers = Json["servers"];
|
||||
const json_value &LegacyServers = Json["servers_legacy"];
|
||||
if(Servers.type != json_array || (LegacyServers.type != json_array && LegacyServers.type != json_none))
|
||||
if(Servers.type != json_array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -509,21 +497,7 @@ bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvSe
|
|||
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;
|
||||
*pvLegacyServers = vLegacyServers;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ public:
|
|||
|
||||
virtual int NumServers() 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);
|
||||
|
|
Loading…
Reference in a new issue