mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
command.h: define xcommand_t, add COM_AddDebugCommand
This will become useful soon...
This commit is contained in:
parent
1d3a7c717e
commit
9dc277bc3d
3 changed files with 28 additions and 12 deletions
|
|
@ -332,14 +332,7 @@ void COM_ImmedExecute(const char *ptext)
|
||||||
// COMMAND EXECUTION
|
// COMMAND EXECUTION
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
typedef struct xcommand_s
|
xcommand_t *com_commands = NULL; // current commands
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
struct xcommand_s *next;
|
|
||||||
com_func_t function;
|
|
||||||
} xcommand_t;
|
|
||||||
|
|
||||||
static xcommand_t *com_commands = NULL; // current commands
|
|
||||||
|
|
||||||
#define MAX_ARGS 80
|
#define MAX_ARGS 80
|
||||||
static size_t com_argc;
|
static size_t com_argc;
|
||||||
|
|
@ -517,7 +510,7 @@ static void COM_TokenizeString(char *ptext)
|
||||||
* \param name Name of the command.
|
* \param name Name of the command.
|
||||||
* \param func Function called when the command is run.
|
* \param func Function called when the command is run.
|
||||||
*/
|
*/
|
||||||
void COM_AddCommand(const char *name, com_func_t func)
|
xcommand_t *COM_AddCommand(const char *name, com_func_t func)
|
||||||
{
|
{
|
||||||
xcommand_t *cmd;
|
xcommand_t *cmd;
|
||||||
|
|
||||||
|
|
@ -525,7 +518,7 @@ void COM_AddCommand(const char *name, com_func_t func)
|
||||||
if (CV_StringValue(name)[0] != '\0')
|
if (CV_StringValue(name)[0] != '\0')
|
||||||
{
|
{
|
||||||
I_Error("%s is a variable name\n", name);
|
I_Error("%s is a variable name\n", name);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail if the command already exists
|
// fail if the command already exists
|
||||||
|
|
@ -540,15 +533,25 @@ void COM_AddCommand(const char *name, com_func_t func)
|
||||||
if (cmd->function != COM_Lua_f)
|
if (cmd->function != COM_Lua_f)
|
||||||
I_Error("Command %s already exists\n", name);
|
I_Error("Command %s already exists\n", name);
|
||||||
|
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = ZZ_Alloc(sizeof *cmd);
|
cmd = ZZ_Alloc(sizeof *cmd);
|
||||||
cmd->name = name;
|
cmd->name = name;
|
||||||
cmd->function = func;
|
cmd->function = func;
|
||||||
|
cmd->debug = false;
|
||||||
cmd->next = com_commands;
|
cmd->next = com_commands;
|
||||||
com_commands = cmd;
|
com_commands = cmd;
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COM_AddDebugCommand(const char *name, com_func_t func)
|
||||||
|
{
|
||||||
|
xcommand_t *cmd = COM_AddCommand(name, func);
|
||||||
|
|
||||||
|
cmd->debug = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds a console command for Lua.
|
/** Adds a console command for Lua.
|
||||||
|
|
@ -579,6 +582,7 @@ int COM_AddLuaCommand(const char *name)
|
||||||
cmd = ZZ_Alloc(sizeof *cmd);
|
cmd = ZZ_Alloc(sizeof *cmd);
|
||||||
cmd->name = name;
|
cmd->name = name;
|
||||||
cmd->function = COM_Lua_f;
|
cmd->function = COM_Lua_f;
|
||||||
|
cmd->debug = false;
|
||||||
cmd->next = com_commands;
|
cmd->next = com_commands;
|
||||||
com_commands = cmd;
|
com_commands = cmd;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,18 @@ enum
|
||||||
|
|
||||||
typedef void (*com_func_t)(void);
|
typedef void (*com_func_t)(void);
|
||||||
|
|
||||||
void COM_AddCommand(const char *name, com_func_t func);
|
struct xcommand_t
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
xcommand_t *next;
|
||||||
|
com_func_t function;
|
||||||
|
boolean debug;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern xcommand_t *com_commands; // current commands
|
||||||
|
|
||||||
|
xcommand_t *COM_AddCommand(const char *name, com_func_t func);
|
||||||
|
void COM_AddDebugCommand(const char *name, com_func_t func);
|
||||||
int COM_AddLuaCommand(const char *name);
|
int COM_AddLuaCommand(const char *name);
|
||||||
|
|
||||||
size_t COM_Argc(void);
|
size_t COM_Argc(void);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ TYPEDEF (minigen_t);
|
||||||
TYPEDEF (vsbuf_t);
|
TYPEDEF (vsbuf_t);
|
||||||
TYPEDEF (CV_PossibleValue_t);
|
TYPEDEF (CV_PossibleValue_t);
|
||||||
TYPEDEF (consvar_t);
|
TYPEDEF (consvar_t);
|
||||||
|
TYPEDEF (xcommand_t);
|
||||||
|
|
||||||
// d_netcmd.h
|
// d_netcmd.h
|
||||||
TYPEDEF (changeteam_packet_t);
|
TYPEDEF (changeteam_packet_t);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue