diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 82a2ffca..09520bf5 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -669,10 +669,8 @@ NOXREF cmd_function_t *Cmd_FindCmd(char *cmd_name) return NULL; } -NOXREF cmd_function_t *Cmd_FindCmdPrev(char *cmd_name) +cmd_function_t *Cmd_FindCmdPrev(char *cmd_name) { - NOXREFCHECK; - cmd_function_t *cmd = NULL; if (cmd_functions == NULL) @@ -796,6 +794,19 @@ void EXT_FUNC Cmd_AddGameCommand(char *cmd_name, xcommand_t function) Cmd_AddMallocCommand(cmd_name, function, FCMD_GAME_COMMAND); } +void EXT_FUNC Cmd_RemoveCmd(char *cmd_name) +{ + auto prev = Cmd_FindCmdPrev(cmd_name); + + if (prev) { + auto cmd = prev->next; + prev->next = cmd->next; + + Z_Free(cmd->name); + Mem_Free(cmd); + } +} + void Cmd_RemoveMallocedCmds(int flag) { cmd_function_t *c, **p; diff --git a/rehlds/engine/cmd.h b/rehlds/engine/cmd.h index 6fd947c3..6d874dd5 100644 --- a/rehlds/engine/cmd.h +++ b/rehlds/engine/cmd.h @@ -103,12 +103,13 @@ const char *Cmd_Argv(int arg); const char *Cmd_Args(void); void Cmd_TokenizeString(char *text); NOXREF cmd_function_t *Cmd_FindCmd(char *cmd_name); -NOXREF cmd_function_t *Cmd_FindCmdPrev(char *cmd_name); +cmd_function_t *Cmd_FindCmdPrev(char *cmd_name); void Cmd_AddCommand(char *cmd_name, xcommand_t function); void Cmd_AddMallocCommand(char *cmd_name, xcommand_t function, int flag); NOXREF void Cmd_AddHUDCommand(char *cmd_name, xcommand_t function); NOXREF void Cmd_AddWrapperCommand(char *cmd_name, xcommand_t function); void Cmd_AddGameCommand(char *cmd_name, xcommand_t function); +void Cmd_RemoveCmd(char *cmd_name); void Cmd_RemoveMallocedCmds(int flag); NOXREF void Cmd_RemoveHudCmds(void); void Cmd_RemoveGameCmds(void); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 0b0a5881..b0fbc903 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -35,7 +35,7 @@ #include "model.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 0 +#define REHLDS_API_VERSION_MINOR 1 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -282,6 +282,7 @@ struct RehldsFuncs_t { bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); void(*SV_UpdateUserInfo)(IGameClient *pGameClient); bool(*StripUnprintableAndSpace)(char *pch); + void(*Cmd_RemoveCmd)(char *cmd_name); }; class IRehldsApi { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 9d5676ac..e34d2bc5 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -210,7 +210,8 @@ RehldsFuncs_t g_RehldsApiFuncs = &SV_StartSound_api, &SV_EmitSound2_api, &SV_UpdateUserInfo_api, - &StripUnprintableAndSpace_api + &StripUnprintableAndSpace_api, + &Cmd_RemoveCmd }; bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)