From f8eb92fff48509e03fb055628b650a24b68438f1 Mon Sep 17 00:00:00 2001 From: m Date: Wed, 17 Jan 2024 06:59:17 -0600 Subject: [PATCH] server browser colorization + fixes closes #694 --- .../ui_scripts/server_list/serverlist.lua | 2 +- src/client/component/party.cpp | 7 +++- src/client/component/server_list.cpp | 39 +++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/data/cdata/ui_scripts/server_list/serverlist.lua b/data/cdata/ui_scripts/server_list/serverlist.lua index bf9525e8..ca294f3a 100644 --- a/data/cdata/ui_scripts/server_list/serverlist.lua +++ b/data/cdata/ui_scripts/server_list/serverlist.lua @@ -18,7 +18,7 @@ local columns = {{ text = "@MENU_TYPE1", dataindex = 3 }, { - offset = 780, + offset = 790, text = "@EXE_SV_INFO_MOD", dataindex = 6 }, { diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index b1dda51f..91a4f073 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -261,7 +261,12 @@ namespace party { if (!file.optional) { - throw std::runtime_error(utils::string::va("Server %s is empty", file.name.data())); + std::string missing_value = "Server %s is empty"; + if (file.name == "usermap_hash"s) + { + missing_value += " (or you are missing content for map '%s')\n"; + } + throw std::runtime_error(utils::string::va(missing_value.data(), file.name.data(), mapname.data())); } return; diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index e3577e2e..98341c6c 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -1,13 +1,14 @@ #include #include "loader/component_loader.hpp" -#include "server_list.hpp" +#include "command.hpp" +#include "console.hpp" +#include "fastfiles.hpp" #include "localized_strings.hpp" #include "network.hpp" -#include "scheduler.hpp" #include "party.hpp" -#include "console.hpp" -#include "command.hpp" +#include "scheduler.hpp" +#include "server_list.hpp" #include "game/game.hpp" #include "game/dvars.hpp" @@ -137,7 +138,20 @@ namespace server_list case 0: return servers[i].host_name.empty() ? "" : servers[i].host_name.data(); case 1: - return servers[i].map_name.empty() ? "Unknown" : servers[i].map_name.data(); + { + const auto& map_name = servers[i].map_name; + if (map_name.empty()) + { + return "Unknown"; + } + + auto map_display_name = game::UI_GetMapDisplayName(map_name.data()); + if (!fastfiles::exists(map_name, false)) + { + map_display_name = utils::string::va("^1%s", map_display_name); + } + return map_display_name; + } case 2: { const auto client_count = servers[i].clients - servers[i].bots; @@ -147,7 +161,18 @@ namespace server_list case 3: return servers[i].game_type.empty() ? "" : servers[i].game_type.data(); case 4: - return servers[i].ping ? utils::string::va("%i", servers[i].ping) : "999"; + { + const auto ping = servers[i].ping ? servers[i].ping : 999; + if (ping < 75) + { + return utils::string::va("^2%d", ping); + } + else if (ping < 150) + { + return utils::string::va("^3%d", ping); + } + return utils::string::va("^1%d", ping); + } case 5: return servers[i].is_private ? "1" : "0"; case 6: @@ -368,7 +393,7 @@ namespace server_list server_info server{}; server.address = address; server.host_name = info.get("hostname"); - server.map_name = game::UI_GetMapDisplayName(info.get("mapname").data()); + server.map_name = info.get("mapname"); server.game_type = game::UI_GetGameTypeDisplayName(info.get("gametype").data()); server.mod_name = info.get("fs_game"); server.play_mode = playmode;