[ServerList] Better and even more efficient sorting

This commit is contained in:
momo5502 2017-06-05 16:24:57 +02:00
parent edaa0fe033
commit ee220e1c51
2 changed files with 5 additions and 5 deletions

View File

@ -64,7 +64,7 @@ namespace Components
return ""; return "";
} }
const char* ServerList::GetServerInfoText(ServerList::ServerInfo* server, int column) const char* ServerList::GetServerInfoText(ServerList::ServerInfo* server, int column, bool sorting)
{ {
if (!server) return ""; if (!server) return "";
@ -89,7 +89,7 @@ namespace Components
{ {
if (server->svRunning) if (server->svRunning)
{ {
if (!Maps::CheckMapInstalled(server->mapname.data())) if (!sorting && !Maps::CheckMapInstalled(server->mapname.data()))
{ {
return Utils::String::VA("^1%s", Game::UI_LocalizeMapName(server->mapname.data())); return Utils::String::VA("^1%s", Game::UI_LocalizeMapName(server->mapname.data()));
} }
@ -581,8 +581,8 @@ namespace Components
return ((info1->clients < info2->clients) ^ !ServerList::SortAsc); return ((info1->clients < info2->clients) ^ !ServerList::SortAsc);
} }
std::string text1 = Colors::Strip(ServerList::GetServerInfoText(info1, ServerList::SortKey)); std::string text1 = Utils::String::ToLower(Colors::Strip(ServerList::GetServerInfoText(info1, ServerList::SortKey, true)));
std::string text2 = Colors::Strip(ServerList::GetServerInfoText(info2, ServerList::SortKey)); std::string text2 = Utils::String::ToLower(Colors::Strip(ServerList::GetServerInfoText(info2, ServerList::SortKey, true)));
// ASCII-based comparison // ASCII-based comparison
return ((text1.compare(text2) <= 0) ^ !ServerList::SortAsc); return ((text1.compare(text2) <= 0) ^ !ServerList::SortAsc);

View File

@ -110,7 +110,7 @@ namespace Components
static unsigned int GetServerCount(); static unsigned int GetServerCount();
static const char* GetServerText(unsigned int index, int column); static const char* GetServerText(unsigned int index, int column);
static const char* GetServerInfoText(ServerInfo* server, int column); static const char* GetServerInfoText(ServerInfo* server, int column, bool sorting = false);
static void SelectServer(unsigned int index); static void SelectServer(unsigned int index);
static void UpdateSource(); static void UpdateSource();