aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2022-06-25 21:58:54 +0200
committerGitHub <noreply@github.com>2022-06-25 21:58:54 +0200
commit660062b934ac98077f08fde9a18f795be0b58b0f (patch)
tree82c99e2165b0720d600977f0f4a6226533a13a31
parentbb7a4c00dea90e6d578d07618ae86a172aec58f2 (diff)
downloadNorthstarLauncher-660062b934ac98077f08fde9a18f795be0b58b0f.tar.gz
NorthstarLauncher-660062b934ac98077f08fde9a18f795be0b58b0f.zip
Log all clientcommands if `ns_should_log_all_clientcommands` is set (#209)v1.8.2-rc2
* Log all clientcommands if responding convar is set * Also log UID * Formatting * Use `GetBool()` instead of `GetInt()` * Adjust output print format as suggested in review
-rw-r--r--NorthstarDedicatedTest/serverauthentication.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp
index 2ef26479..ac1985cf 100644
--- a/NorthstarDedicatedTest/serverauthentication.cpp
+++ b/NorthstarDedicatedTest/serverauthentication.cpp
@@ -18,6 +18,9 @@
const char* AUTHSERVER_VERIFY_STRING = "I am a northstar server!";
+// This convar defines whether to log all client commands
+ConVar* Cvar_ns_should_log_all_clientcommands;
+
// hook types
typedef void* (*CBaseServer__ConnectClientType)(
@@ -480,6 +483,12 @@ CCommand__TokenizeType CCommand__Tokenize;
char CGameClient__ExecuteStringCommandHook(void* self, uint32_t unknown, const char* pCommandString)
{
+ // Only log clientcommands if the convar `ns_should_log_all_clientcommands` equals 1
+ if (Cvar_ns_should_log_all_clientcommands->GetBool())
+ {
+ spdlog::info("{} (UID: {}) executed command: \"{}\"", (char*)self + 0x16, (char*)self + 0xF500, pCommandString);
+ }
+
if (CVar_sv_quota_stringcmdspersecond->GetInt() != -1)
{
// note: this isn't super perfect, legit clients can trigger it in lobby, mostly good enough tho imo
@@ -672,6 +681,8 @@ void InitialiseServerAuthentication(HMODULE baseAddress)
"100",
FCVAR_GAMEDLL,
"Netchannel processing is limited to so many milliseconds, abort connection if exceeding budget");
+ Cvar_ns_should_log_all_clientcommands =
+ new ConVar("ns_should_log_all_clientcommands", "0", FCVAR_NONE, "Whether to log all clientcommands");
Cvar_ns_player_auth_port = new ConVar("ns_player_auth_port", "8081", FCVAR_GAMEDLL, "");
Cvar_sv_querylimit_per_sec = new ConVar("sv_querylimit_per_sec", "15", FCVAR_GAMEDLL, "");
Cvar_sv_max_chat_messages_per_sec = new ConVar("sv_max_chat_messages_per_sec", "5", FCVAR_GAMEDLL, "");