[Command]: Fix definition of Cmd_AddCommand (#609)

This commit is contained in:
Edo 2022-11-28 23:15:21 +00:00 committed by GitHub
parent 9689682432
commit c3d6b20644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -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
}
}

View File

@ -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();
};

View File

@ -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);