From 954543228f565e3dc7ac39d40ce59e73b56cf265 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Mar 2022 01:00:27 +0100 Subject: [PATCH] Dedi hostname & discord changes --- src/client/component/dedicated.cpp | 3 --- src/client/component/discord.cpp | 10 +++++++--- src/client/component/patches.cpp | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/client/component/dedicated.cpp b/src/client/component/dedicated.cpp index 6e63f082..dd9f920f 100644 --- a/src/client/component/dedicated.cpp +++ b/src/client/component/dedicated.cpp @@ -196,9 +196,6 @@ namespace dedicated // Disable r_preloadShaders dvars::override::register_bool("r_preloadShaders", false, game::DVAR_FLAG_READ); - // Don't allow sv_hostname to be changed by the game - dvars::disable::set_string("sv_hostname"); - // Stop crashing from sys_errors utils::hook::jump(0x140511520, sys_error_stub); diff --git a/src/client/component/discord.cpp b/src/client/component/discord.cpp index 7d55c989..0bd8c4dc 100644 --- a/src/client/component/discord.cpp +++ b/src/client/component/discord.cpp @@ -49,17 +49,21 @@ namespace discord discord_presence.details = utils::string::va("%s on %s", gametype, mapname); - auto host_name = game::Dvar_FindVar("sv_hostname")->current.string; + char clean_hostname[0x100] = {0}; + utils::string::strip(game::Dvar_FindVar("sv_hostname")->current.string, + clean_hostname, sizeof(clean_hostname)); auto max_clients = game::Dvar_FindVar("sv_maxclients")->current.integer; + if (game::SV_Loaded()) { + strcpy_s(clean_hostname, "Private Match"); max_clients = party::server_client_count(); } - auto clients = *(reinterpret_cast(0x14621BE00)); + auto clients = *reinterpret_cast(0x14621BE00); discord_presence.partySize = clients; discord_presence.partyMax = max_clients; - discord_presence.state = host_name; + discord_presence.state = clean_hostname; discord_presence.largeImageKey = map; } else if (game::environment::is_sp()) diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index e8897ce5..a8ee11fc 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -268,6 +268,9 @@ namespace patches utils::hook::jump(0x140578D30, realloc); utils::hook::jump(0x140578B60, _aligned_realloc); } + + // Change default hostname and make it replicated + dvars::override::register_string("sv_hostname", "^2H1-Mod^7 Default Server", game::DVAR_FLAG_REPLICATED); } }; }