From c3d6b206440d2092ceb900524dbd289acb7d6419 Mon Sep 17 00:00:00 2001 From: Edo Date: Mon, 28 Nov 2022 23:15:21 +0000 Subject: [PATCH] [Command]: Fix definition of Cmd_AddCommand (#609) --- src/Components/Modules/Debug.cpp | 22 ++++++++++++++++++++++ src/Components/Modules/Debug.hpp | 1 + src/Game/Functions.hpp | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Debug.cpp b/src/Components/Modules/Debug.cpp index 0d968983..c0fb92ae 100644 --- a/src/Components/Modules/Debug.cpp +++ b/src/Components/Modules/Debug.cpp @@ -308,6 +308,27 @@ namespace Components } } + void Debug::Com_BugNameInc_f() + { + char buf[260]{}; + + if (std::strlen(BugName->current.string) < 4) + { + Game::Dvar_SetString(BugName, "bug0"); + return; + } + + if (strncmp(BugName->current.string, "bug", 3) != 0) + { + Game::Dvar_SetString(BugName, "bug0"); + return; + } + + const auto n = std::strtol(BugName->current.string + 3, nullptr, 10); + sprintf_s(buf, "bug%d", n + 1); + Game::Dvar_SetString(BugName, buf); + } + void Debug::CL_InitDebugDvars() { static const char* debugOverlayNames_0[] = @@ -338,6 +359,7 @@ namespace Components #ifdef _DEBUG Command::Add("bug", Com_Bug_f); + Command::Add("bug_name_inc", Com_BugNameInc_f); #endif } } diff --git a/src/Components/Modules/Debug.hpp b/src/Components/Modules/Debug.hpp index 3eaf8a78..893eb25b 100644 --- a/src/Components/Modules/Debug.hpp +++ b/src/Components/Modules/Debug.hpp @@ -43,6 +43,7 @@ namespace Components static void Com_Assert_f(); static void Com_Bug_f(Command::Params* params); + static void Com_BugNameInc_f(); static void CL_InitDebugDvars(); }; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index e307ef42..cd1c7c30 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -48,7 +48,7 @@ namespace Game typedef void(*CG_SetupWeaponDef_t)(int localClientNum, unsigned int weapIndex); extern CG_SetupWeaponDef_t CG_SetupWeaponDef; - typedef void(*Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_t* allocedCmd, bool isKey); + typedef void(*Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_t* allocedCmd, int isKey); extern Cmd_AddCommand_t Cmd_AddCommand; typedef void(*Cmd_AddServerCommand_t)(const char* name, void(*callback), cmd_function_t* data);