server browser colorization + fixes

closes #694
This commit is contained in:
m 2024-01-17 06:59:17 -06:00
parent 45d1617d22
commit f8eb92fff4
3 changed files with 39 additions and 9 deletions

View File

@ -18,7 +18,7 @@ local columns = {{
text = "@MENU_TYPE1", text = "@MENU_TYPE1",
dataindex = 3 dataindex = 3
}, { }, {
offset = 780, offset = 790,
text = "@EXE_SV_INFO_MOD", text = "@EXE_SV_INFO_MOD",
dataindex = 6 dataindex = 6
}, { }, {

View File

@ -261,7 +261,12 @@ namespace party
{ {
if (!file.optional) 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; return;

View File

@ -1,13 +1,14 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "loader/component_loader.hpp" #include "loader/component_loader.hpp"
#include "server_list.hpp" #include "command.hpp"
#include "console.hpp"
#include "fastfiles.hpp"
#include "localized_strings.hpp" #include "localized_strings.hpp"
#include "network.hpp" #include "network.hpp"
#include "scheduler.hpp"
#include "party.hpp" #include "party.hpp"
#include "console.hpp" #include "scheduler.hpp"
#include "command.hpp" #include "server_list.hpp"
#include "game/game.hpp" #include "game/game.hpp"
#include "game/dvars.hpp" #include "game/dvars.hpp"
@ -137,7 +138,20 @@ namespace server_list
case 0: case 0:
return servers[i].host_name.empty() ? "" : servers[i].host_name.data(); return servers[i].host_name.empty() ? "" : servers[i].host_name.data();
case 1: 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: case 2:
{ {
const auto client_count = servers[i].clients - servers[i].bots; const auto client_count = servers[i].clients - servers[i].bots;
@ -147,7 +161,18 @@ namespace server_list
case 3: case 3:
return servers[i].game_type.empty() ? "" : servers[i].game_type.data(); return servers[i].game_type.empty() ? "" : servers[i].game_type.data();
case 4: 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: case 5:
return servers[i].is_private ? "1" : "0"; return servers[i].is_private ? "1" : "0";
case 6: case 6:
@ -368,7 +393,7 @@ namespace server_list
server_info server{}; server_info server{};
server.address = address; server.address = address;
server.host_name = info.get("hostname"); 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.game_type = game::UI_GetGameTypeDisplayName(info.get("gametype").data());
server.mod_name = info.get("fs_game"); server.mod_name = info.get("fs_game");
server.play_mode = playmode; server.play_mode = playmode;