2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-04-23 06:43:36 +03:00

Mark cmd_function_t.name const and apply adjustments to related functions.

This commit is contained in:
Lev 2017-01-25 19:51:49 +05:00
parent 830ff3b2ce
commit ad8a157346
7 changed files with 27 additions and 27 deletions

View File

@ -52,7 +52,7 @@ cvar_t console;
#endif //HOOK_ENGINE #endif //HOOK_ENGINE
void CL_RecordHUDCommand(char *cmdname) { } void CL_RecordHUDCommand(const char *cmdname) { }
void R_DecalRemoveAll(int textureIndex) { } void R_DecalRemoveAll(int textureIndex) { }
void CL_CheckForResend(void) { } void CL_CheckForResend(void) { }
qboolean CL_CheckFile(sizebuf_t *msg, char *filename) { return 1; } qboolean CL_CheckFile(sizebuf_t *msg, char *filename) { return 1; }

View File

@ -289,7 +289,7 @@ extern cvar_t cl_name;
extern cvar_t rate_; extern cvar_t rate_;
extern cvar_t console; extern cvar_t console;
void CL_RecordHUDCommand(char *cmdname); void CL_RecordHUDCommand(const char *cmdname);
void R_DecalRemoveAll(int textureIndex); void R_DecalRemoveAll(int textureIndex);
void CL_CheckForResend(void); void CL_CheckForResend(void);
qboolean CL_CheckFile(sizebuf_t *msg, char *filename); qboolean CL_CheckFile(sizebuf_t *msg, char *filename);

View File

@ -417,7 +417,7 @@ void Cmd_Echo_f(void)
Con_Printf("\n"); Con_Printf("\n");
} }
char *CopyString(char *in) char *CopyString(const char *in)
{ {
char *out = (char *)Z_Malloc(Q_strlen(in) + 1); char *out = (char *)Z_Malloc(Q_strlen(in) + 1);
Q_strcpy(out, in); Q_strcpy(out, in);
@ -652,7 +652,7 @@ void EXT_FUNC Cmd_TokenizeString(char *text)
} }
} }
NOXREF cmd_function_t *Cmd_FindCmd(char *cmd_name) NOXREF cmd_function_t *Cmd_FindCmd(const char *cmd_name)
{ {
NOXREFCHECK; NOXREFCHECK;
@ -669,7 +669,7 @@ NOXREF cmd_function_t *Cmd_FindCmd(char *cmd_name)
return NULL; return NULL;
} }
cmd_function_t *Cmd_FindCmdPrev(char *cmd_name) cmd_function_t *Cmd_FindCmdPrev(const char *cmd_name)
{ {
cmd_function_t *cmd = NULL; cmd_function_t *cmd = NULL;
@ -715,7 +715,7 @@ void Cmd_InsertCommand(cmd_function_t *cmd)
} }
// Use this for engine inside call only, not from user code, because it doesn't alloc string for the name. // Use this for engine inside call only, not from user code, because it doesn't alloc string for the name.
void Cmd_AddCommand(char *cmd_name, xcommand_t function) void Cmd_AddCommand(const char *cmd_name, xcommand_t function)
{ {
cmd_function_t *cmd; cmd_function_t *cmd;
@ -748,7 +748,7 @@ void Cmd_AddCommand(char *cmd_name, xcommand_t function)
} }
// Use this for call from user code, because it alloc string for the name. // Use this for call from user code, because it alloc string for the name.
void Cmd_AddMallocCommand(char *cmd_name, xcommand_t function, int flag) void Cmd_AddMallocCommand(const char *cmd_name, xcommand_t function, int flag)
{ {
cmd_function_t *cmd; cmd_function_t *cmd;
@ -775,26 +775,26 @@ void Cmd_AddMallocCommand(char *cmd_name, xcommand_t function, int flag)
Cmd_InsertCommand(cmd); Cmd_InsertCommand(cmd);
} }
NOXREF void Cmd_AddHUDCommand(char *cmd_name, xcommand_t function) NOXREF void Cmd_AddHUDCommand(const char *cmd_name, xcommand_t function)
{ {
NOXREFCHECK; NOXREFCHECK;
Cmd_AddMallocCommand(cmd_name, function, FCMD_HUD_COMMAND); Cmd_AddMallocCommand(cmd_name, function, FCMD_HUD_COMMAND);
} }
NOXREF void Cmd_AddWrapperCommand(char *cmd_name, xcommand_t function) NOXREF void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function)
{ {
NOXREFCHECK; NOXREFCHECK;
Cmd_AddMallocCommand(cmd_name, function, FCMD_WRAPPER_COMMAND); Cmd_AddMallocCommand(cmd_name, function, FCMD_WRAPPER_COMMAND);
} }
void EXT_FUNC Cmd_AddGameCommand(char *cmd_name, xcommand_t function) void EXT_FUNC Cmd_AddGameCommand(const char *cmd_name, xcommand_t function)
{ {
Cmd_AddMallocCommand(cmd_name, function, FCMD_GAME_COMMAND); Cmd_AddMallocCommand(cmd_name, function, FCMD_GAME_COMMAND);
} }
void EXT_FUNC Cmd_RemoveCmd(char *cmd_name) void EXT_FUNC Cmd_RemoveCmd(const char *cmd_name)
{ {
auto prev = Cmd_FindCmdPrev(cmd_name); auto prev = Cmd_FindCmdPrev(cmd_name);
@ -802,7 +802,7 @@ void EXT_FUNC Cmd_RemoveCmd(char *cmd_name)
auto cmd = prev->next; auto cmd = prev->next;
prev->next = cmd->next; prev->next = cmd->next;
Z_Free(cmd->name); Z_Free((void*)cmd->name);
Mem_Free(cmd); Mem_Free(cmd);
} }
} }
@ -818,7 +818,7 @@ void Cmd_RemoveMallocedCmds(int flag)
if (c->flags & flag) if (c->flags & flag)
{ {
*p = c->next; *p = c->next;
Z_Free(c->name); Z_Free((void*)c->name);
Mem_Free(c); Mem_Free(c);
c = *p; c = *p;
continue; continue;
@ -862,7 +862,7 @@ qboolean Cmd_Exists(const char *cmd_name)
return FALSE; return FALSE;
} }
NOXREF char *Cmd_CompleteCommand(char *search, int forward) NOXREF const char *Cmd_CompleteCommand(char *search, int forward)
{ {
NOXREFCHECK; NOXREFCHECK;

View File

@ -93,7 +93,7 @@ void Cbuf_Execute(void);
void Cmd_StuffCmds_f(void); void Cmd_StuffCmds_f(void);
void Cmd_Exec_f(void); void Cmd_Exec_f(void);
void Cmd_Echo_f(void); void Cmd_Echo_f(void);
char *CopyString(char *in); char *CopyString(const char *in);
void Cmd_Alias_f(void); void Cmd_Alias_f(void);
struct cmd_function_s *Cmd_GetFirstCmd(void); struct cmd_function_s *Cmd_GetFirstCmd(void);
void Cmd_Init(void); void Cmd_Init(void);
@ -102,20 +102,20 @@ int Cmd_Argc(void);
const char *Cmd_Argv(int arg); const char *Cmd_Argv(int arg);
const char *Cmd_Args(void); const char *Cmd_Args(void);
void Cmd_TokenizeString(char *text); void Cmd_TokenizeString(char *text);
NOXREF cmd_function_t *Cmd_FindCmd(char *cmd_name); NOXREF cmd_function_t *Cmd_FindCmd(const char *cmd_name);
cmd_function_t *Cmd_FindCmdPrev(char *cmd_name); cmd_function_t *Cmd_FindCmdPrev(const char *cmd_name);
void Cmd_AddCommand(char *cmd_name, xcommand_t function); void Cmd_AddCommand(const char *cmd_name, xcommand_t function);
void Cmd_AddMallocCommand(char *cmd_name, xcommand_t function, int flag); void Cmd_AddMallocCommand(const char *cmd_name, xcommand_t function, int flag);
NOXREF void Cmd_AddHUDCommand(char *cmd_name, xcommand_t function); NOXREF void Cmd_AddHUDCommand(const char *cmd_name, xcommand_t function);
NOXREF void Cmd_AddWrapperCommand(char *cmd_name, xcommand_t function); NOXREF void Cmd_AddWrapperCommand(const char *cmd_name, xcommand_t function);
void Cmd_AddGameCommand(char *cmd_name, xcommand_t function); void Cmd_AddGameCommand(const char *cmd_name, xcommand_t function);
void Cmd_RemoveCmd(char *cmd_name); void Cmd_RemoveCmd(const char *cmd_name);
void Cmd_RemoveMallocedCmds(int flag); void Cmd_RemoveMallocedCmds(int flag);
NOXREF void Cmd_RemoveHudCmds(void); NOXREF void Cmd_RemoveHudCmds(void);
void Cmd_RemoveGameCmds(void); void Cmd_RemoveGameCmds(void);
void Cmd_RemoveWrapperCmds(void); void Cmd_RemoveWrapperCmds(void);
qboolean Cmd_Exists(const char *cmd_name); qboolean Cmd_Exists(const char *cmd_name);
NOXREF char *Cmd_CompleteCommand(char *search, int forward); NOXREF const char *Cmd_CompleteCommand(char *search, int forward);
void Cmd_ExecuteString(char *text, cmd_source_t src); void Cmd_ExecuteString(char *text, cmd_source_t src);
qboolean Cmd_ForwardToServerInternal(sizebuf_t *pBuf); qboolean Cmd_ForwardToServerInternal(sizebuf_t *pBuf);
void Cmd_ForwardToServer(void); void Cmd_ForwardToServer(void);

View File

@ -33,7 +33,7 @@ typedef void(*xcommand_t)(void);
typedef struct cmd_function_s typedef struct cmd_function_s
{ {
struct cmd_function_s *next; struct cmd_function_s *next;
char *name; const char *name;
xcommand_t function; xcommand_t function;
int flags; int flags;
} cmd_function_t; } cmd_function_t;

View File

@ -258,7 +258,7 @@ typedef struct enginefuncs_s
void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss );
void (*pfnAddServerCommand) ( char *cmd_name, void (*function) (void) ); void (*pfnAddServerCommand) ( const char *cmd_name, void (*function) (void) );
// For voice communications, set which clients hear eachother. // For voice communications, set which clients hear eachother.
// NOTE: these functions take player entity indices (starting at 1). // NOTE: these functions take player entity indices (starting at 1).

View File

@ -282,7 +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); 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); void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
bool(*StripUnprintableAndSpace)(char *pch); bool(*StripUnprintableAndSpace)(char *pch);
void(*Cmd_RemoveCmd)(char *cmd_name); void(*Cmd_RemoveCmd)(const char *cmd_name);
}; };
class IRehldsApi { class IRehldsApi {