[ServerList] Ignore patch version for filtering (only major/minor version)
This commit is contained in:
parent
2b1dad00a2
commit
1ba7b44d4d
@ -504,7 +504,7 @@ namespace Components
|
|||||||
if (info.get("gamename") == "IW4"
|
if (info.get("gamename") == "IW4"
|
||||||
&& server.matchType
|
&& server.matchType
|
||||||
#if !defined(DEBUG) && defined(VERSION_FILTER)
|
#if !defined(DEBUG) && defined(VERSION_FILTER)
|
||||||
&& server.shortversion == SHORTVERSION
|
&& ServerList::CompareVersion(server.shortversion, SHORTVERSION)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -526,6 +526,26 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServerList::CompareVersion(std::string version1, std::string version2)
|
||||||
|
{
|
||||||
|
std::vector<std::string> subVersions1 = Utils::String::Explode(version1, '.');
|
||||||
|
std::vector<std::string> subVersions2 = Utils::String::Explode(version2, '.');
|
||||||
|
|
||||||
|
while (subVersions1.size() >= 3) subVersions1.pop_back();
|
||||||
|
while (subVersions2.size() >= 3) subVersions2.pop_back();
|
||||||
|
if (subVersions1.size() != subVersions2.size()) return false;
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < subVersions1.size(); ++i)
|
||||||
|
{
|
||||||
|
if(atoi(subVersions1[i].data()) != atoi(subVersions2[i].data()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ServerList::ServerInfo* ServerList::GetCurrentServer()
|
ServerList::ServerInfo* ServerList::GetCurrentServer()
|
||||||
{
|
{
|
||||||
return ServerList::GetServer(ServerList::CurrentServer);
|
return ServerList::GetServer(ServerList::CurrentServer);
|
||||||
|
@ -126,6 +126,8 @@ namespace Components
|
|||||||
static ServerInfo* GetServer(unsigned int index);
|
static ServerInfo* GetServer(unsigned int index);
|
||||||
static std::vector<ServerInfo>* GetList();
|
static std::vector<ServerInfo>* GetList();
|
||||||
|
|
||||||
|
static bool CompareVersion(std::string version1, std::string version2);
|
||||||
|
|
||||||
static int SortKey;
|
static int SortKey;
|
||||||
static bool SortAsc;
|
static bool SortAsc;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user