Con_Printf("%i result%s\n\n", count, (count > 1) ? "s" : "");
}
-static cmd_state_t *Cmd_AddInterpreter(cmd_buf_t *cbuf, cvar_state_t *cvars, int cvars_flagsmask, int cmds_flagsmask, cmd_userdefined_t *userdefined)
+static cmd_state_t *Cmd_AddInterpreter(cmd_buf_t *cbuf, cvar_state_t *cvars, unsigned cvars_flagsmask, unsigned cmds_flagsmask, cmd_userdefined_t *userdefined)
{
cmd_state_t *cmd = (cmd_state_t *)Mem_Alloc(tempmempool, sizeof(cmd_state_t));
cmd->cvars = cvars;
cmd->cvars_flagsmask = cvars_flagsmask;
- cmd->cmd_flags = cmds_flagsmask;
+ cmd->cmd_flagsmask = cmds_flagsmask;
cmd->userdefined = userdefined;
return cmd;
void Cmd_Init(void)
{
cmd_buf_t *cbuf;
+ unsigned cvars_flagsmask, cmds_flagsmask;
+
cbuf_mempool = Mem_AllocPool("Command buffer", 0, NULL);
cbuf = (cmd_buf_t *)Mem_Alloc(cbuf_mempool, sizeof(cmd_buf_t));
cbuf->maxsize = CMDBUFSIZE;
cmd_iter_all = (cmd_iter_t *)Mem_Alloc(tempmempool, sizeof(cmd_iter_t) * 3);
// local console
- cmd_iter_all[0].cmd = cmd_local = Cmd_AddInterpreter(cbuf, &cvars_all, CF_CLIENT | CF_SERVER, CF_CLIENT | CF_CLIENT_FROM_SERVER | CF_SERVER_FROM_CLIENT, &cmd_userdefined_all);
+ if (cls.state == ca_dedicated)
+ {
+ cvars_flagsmask = CF_SERVER;
+ cmds_flagsmask = CF_SERVER | CF_SERVER_FROM_CLIENT;
+ }
+ else
+ {
+ cvars_flagsmask = CF_CLIENT | CF_SERVER;
+ cmds_flagsmask = CF_CLIENT | CF_SERVER | CF_CLIENT_FROM_SERVER | CF_SERVER_FROM_CLIENT;
+ }
+ cmd_iter_all[0].cmd = cmd_local = Cmd_AddInterpreter(cbuf, &cvars_all, cvars_flagsmask, cmds_flagsmask, &cmd_userdefined_all);
cmd_local->Handle = Cmd_CL_Callback;
// server commands received from clients have no reason to access cvars, cvar expansion seems perilous.
Cmd_AddCommand
============
*/
-void Cmd_AddCommand(int flags, const char *cmd_name, xcommand_t function, const char *description)
+void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
{
cmd_function_t *func;
cmd_function_t *prev, *current;
for (i = 0; i < 2; i++)
{
cmd = cmd_iter_all[i].cmd;
- if (flags & cmd->cmd_flags)
+ if (flags & cmd->cmd_flagsmask)
{
// fail if the command is a variable name
if (Cvar_FindVar(cmd->cvars, cmd_name, ~0))
typedef struct cmd_function_s
{
- int flags;
+ unsigned flags;
struct cmd_function_s *next;
const char *name;
const char *description;
cmd_function_t *engine_functions;
struct cvar_state_s *cvars; // which cvar system is this cmd state able to access? (&cvars_all or &cvars_null)
- int cvars_flagsmask; // which CVAR_* flags should be visible to this interpreter? (CF_CLIENT | CF_SERVER, or just CF_SERVER)
-
- int cmd_flags; // cmd flags that identify this interpreter
+ unsigned cvars_flagsmask; // which CVAR_* flags should be visible to this interpreter? (CF_CLIENT | CF_SERVER, or just CF_SERVER)
+ unsigned cmd_flagsmask; // cmd flags that identify this interpreter
qbool (*Handle)(struct cmd_state_s *, struct cmd_function_s *, const char *, enum cmd_source_s);
}
// called by FS_GameDir_f, this restores cvars, commands and aliases to init values
void Cmd_RestoreInitState(void);
-void Cmd_AddCommand(int flags, const char *cmd_name, xcommand_t function, const char *description);
+void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description);
// called by the init functions of other parts of the program to
// register commands and functions to call for them.
// The cmd_name is referenced later, so it should not be in temp memory