[ServerList] Ignore patch version for filtering (only major/minor version)

This commit is contained in:
momo5502 2017-02-15 14:11:36 +01:00
parent 2b1dad00a2
commit 1ba7b44d4d
2 changed files with 23 additions and 1 deletions

View File

@ -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);

View File

@ -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;