From d4f91ef3a61b4933881a55384f950ede15455260 Mon Sep 17 00:00:00 2001 From: Jari van der Kaap Date: Tue, 11 Apr 2023 00:27:21 +0200 Subject: [PATCH 1/2] fix: support for hardcore on the serverbrowser --- src/client/component/getinfo.cpp | 5 +++-- src/client/game/symbols.hpp | 1 + src/client/steam/interfaces/matchmaking_servers.cpp | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/component/getinfo.cpp b/src/client/component/getinfo.cpp index ee848f15..26903d1f 100644 --- a/src/client/component/getinfo.cpp +++ b/src/client/component/getinfo.cpp @@ -103,7 +103,7 @@ namespace getinfo info.set("description", game::is_server() ? game::get_dvar_string("live_steam_server_description") : ""); info.set("xuid", utils::string::va("%llX", steam::SteamUser()->GetSteamID().bits)); - info.set("mapname", game::get_dvar_string("mapname")); + info.set("mapname", game::get_dvar_string("mapname")); info.set("isPrivate", game::get_dvar_string("g_password").empty() ? "0" : "1"); info.set("clients", utils::string::va("%zu", get_client_count())); info.set("bots", utils::string::va("%zu", get_bot_count())); @@ -112,7 +112,8 @@ namespace getinfo info.set("playmode", utils::string::va("%i", game::Com_SessionMode_GetMode())); info.set("gamemode", utils::string::va("%i", Com_SessionMode_GetGameMode())); info.set("sv_running", utils::string::va("%i", game::is_server_running())); - info.set("dedicated", utils::string::va("%i", game::is_server() ? 1 : 0)); + info.set("dedicated", utils::string::va("%i", game::is_server() ? 1 : 0)); + info.set("hc", utils::string::va("%i", game::Com_GametypeSettings_GetUInt("hardcoremode", false))); info.set("shortversion", SHORTVERSION); network::send(target, "infoResponse", info.build(), '\n'); diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 205c0348..38090235 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -31,6 +31,7 @@ namespace game WEAK symbol Com_GametypeSettings_SetGametype{ 0x1420F5980 }; + WEAK symbol Com_GametypeSettings_GetUInt{0x1420F4E00, 0x1404FE5C0}; WEAK symbol Com_IsRunningUILevel{0x142148350}; WEAK symbol Com_SwitchMode{ 0x14214A4D0 diff --git a/src/client/steam/interfaces/matchmaking_servers.cpp b/src/client/steam/interfaces/matchmaking_servers.cpp index 13d25e84..79f0f784 100644 --- a/src/client/steam/interfaces/matchmaking_servers.cpp +++ b/src/client/steam/interfaces/matchmaking_servers.cpp @@ -55,9 +55,10 @@ namespace steam const auto mode = game::eModes(std::atoi(playmode.data())); const auto* tags = ::utils::string::va( - R"(\gametype\%s\dedicated\%s\ranked\false\hardcore\false\zombies\%s\modName\\playerCount\%d\bots\%d\)", + R"(\gametype\%s\dedicated\%s\ranked\false\hardcore\%s\zombies\%s\modName\\playerCount\%d\bots\%d\)", info.get("gametype").data(), - info.get("dedicated") == "1" ? "true" : "false", + info.get("dedicated") == "1" ? "true" : "false", + info.get("hc") == "1" ? "true" : "false", mode == game::MODE_ZOMBIES ? "true" : "false", server.m_nPlayers, atoi(info.get("bots").data())); From f60528895477b36c1868ef3b4cd8fce8f49f3c74 Mon Sep 17 00:00:00 2001 From: Jari van der Kaap Date: Tue, 11 Apr 2023 00:38:45 +0200 Subject: [PATCH 2/2] changed string literal to %u --- src/client/component/getinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/component/getinfo.cpp b/src/client/component/getinfo.cpp index 26903d1f..67c8f3b6 100644 --- a/src/client/component/getinfo.cpp +++ b/src/client/component/getinfo.cpp @@ -113,7 +113,7 @@ namespace getinfo info.set("gamemode", utils::string::va("%i", Com_SessionMode_GetGameMode())); info.set("sv_running", utils::string::va("%i", game::is_server_running())); info.set("dedicated", utils::string::va("%i", game::is_server() ? 1 : 0)); - info.set("hc", utils::string::va("%i", game::Com_GametypeSettings_GetUInt("hardcoremode", false))); + info.set("hc", utils::string::va("%u", game::Com_GametypeSettings_GetUInt("hardcoremode", false))); info.set("shortversion", SHORTVERSION); network::send(target, "infoResponse", info.build(), '\n');