From f6d45ca3b7485b11e2fd2fd7081eb77701a93a48 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 13 May 2023 10:34:51 +0100 Subject: [PATCH 1/4] fix(server_status): format it properly --- src/client/component/patches.cpp | 3 -- src/client/component/status.cpp | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/client/component/status.cpp diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 662ccf97..11254632 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -44,9 +44,6 @@ namespace patches { void post_unpack() override { - // print hexadecimal xuids in status command - utils::hook::copy_string(game::select(0x143050560, 0x140E85B00), "%12llx "); - // print hexadecimal xuids in chat game log command utils::hook::set(game::select(0x142FD9362, 0x140E16FA2), 'x'); diff --git a/src/client/component/status.cpp b/src/client/component/status.cpp new file mode 100644 index 00000000..620260a3 --- /dev/null +++ b/src/client/component/status.cpp @@ -0,0 +1,47 @@ +#include +#include "loader/component_loader.hpp" +#include + +#include + +namespace status +{ + namespace + { + int client_num_; + + void print_client_num(int channel, int label, const char* fmt, const int client_num) + { + client_num_ = client_num; + game::Com_Printf(channel, label, fmt, client_num); + } + + void print_client_xuid(int channel, int label, [[maybe_unused]] const char* fmt, const uint64_t xuid) + { + if (game::SV_IsTestClient(client_num_)) + { + game::Com_Printf(channel, label, "%16s ", "bot0"); + return; + } + + game::Com_Printf(channel, label, "%12llx ", xuid); + } + } + + struct component final : generic_component + { + void post_unpack() override + { + // Patch the status command for test clients + utils::hook::call(game::select(0x142246E37, 0x14052C527), print_client_num); + utils::hook::call(game::select(0x142246EDE, 0x14052C5CE), print_client_xuid); + + utils::hook::copy_string(game::select(0x143050480, 0x140E85A20), + "num score ping xuid name address qport \n"); + utils::hook::copy_string(game::select(0x1430504E0, 0x140E85A80), + "--- ----- ---- ---------------- ---------------- ------------------------ ------ \n"); + } + }; +} + +REGISTER_COMPONENT(status::component) From 66c64704aa53d9a4b6062c7f6bfa10c9e06fb0c8 Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 13 May 2023 17:52:15 +0100 Subject: [PATCH 2/4] status: rename xuid to guid --- src/client/component/status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/component/status.cpp b/src/client/component/status.cpp index 620260a3..83c6b686 100644 --- a/src/client/component/status.cpp +++ b/src/client/component/status.cpp @@ -37,7 +37,7 @@ namespace status utils::hook::call(game::select(0x142246EDE, 0x14052C5CE), print_client_xuid); utils::hook::copy_string(game::select(0x143050480, 0x140E85A20), - "num score ping xuid name address qport \n"); + "num score ping guid name address qport \n"); utils::hook::copy_string(game::select(0x1430504E0, 0x140E85A80), "--- ----- ---- ---------------- ---------------- ------------------------ ------ \n"); } From ebbb3fe1958a96575a47deac4300e3b587ccc05c Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 13 May 2023 18:11:19 +0100 Subject: [PATCH 3/4] Update status.cpp --- src/client/component/status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/component/status.cpp b/src/client/component/status.cpp index 83c6b686..620260a3 100644 --- a/src/client/component/status.cpp +++ b/src/client/component/status.cpp @@ -37,7 +37,7 @@ namespace status utils::hook::call(game::select(0x142246EDE, 0x14052C5CE), print_client_xuid); utils::hook::copy_string(game::select(0x143050480, 0x140E85A20), - "num score ping guid name address qport \n"); + "num score ping xuid name address qport \n"); utils::hook::copy_string(game::select(0x1430504E0, 0x140E85A80), "--- ----- ---- ---------------- ---------------- ------------------------ ------ \n"); } From 48f21ee71daf90d7184ca11e40cc275848b927b5 Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 13 May 2023 20:45:55 +0100 Subject: [PATCH 4/4] status: thread local --- src/client/component/status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/component/status.cpp b/src/client/component/status.cpp index 620260a3..a9e3380f 100644 --- a/src/client/component/status.cpp +++ b/src/client/component/status.cpp @@ -8,7 +8,7 @@ namespace status { namespace { - int client_num_; + thread_local int client_num_; void print_client_num(int channel, int label, const char* fmt, const int client_num) {