allow cbufs to have a callback for unknown commands. if the callback

returns non-zero the unknown command is assumed to have been handled and no
error is reported
This commit is contained in:
Bill Currie 2003-11-20 07:02:14 +00:00
parent 481c9c4e8d
commit b3c6e763cd
2 changed files with 14 additions and 11 deletions

View file

@ -39,7 +39,7 @@
typedef struct cbuf_args_s {
int argc;
struct dstring_s **argv;
void **argm; // Metadata (optional)
void **argm; // Metadata (optional)
const char **args;
int argv_size;
} cbuf_args_t;
@ -49,21 +49,22 @@ typedef struct cbuf_s {
cbuf_args_t *args;
struct cbuf_interpreter_s *interpreter;
struct cbuf_s *up, *down; // The stack
struct cbuf_s *up, *down; // The stack
enum {
CBUF_STATE_NORMAL = 0, // Normal condition
CBUF_STATE_WAIT, // Buffer is stalled until next frame
CBUF_STATE_BLOCKED, // Buffer is blocked until further notice
CBUF_STATE_ERROR, // An unrecoverable error occured
CBUF_STATE_STACK, // A buffer has been added to the stack
CBUF_STATE_JUNK // Buffer can be freed or reused
CBUF_STATE_NORMAL = 0, // Normal condition
CBUF_STATE_WAIT, // Buffer is stalled until next frame
CBUF_STATE_BLOCKED, // Buffer is blocked until further notice
CBUF_STATE_ERROR, // An unrecoverable error occured
CBUF_STATE_STACK, // A buffer has been added to the stack
CBUF_STATE_JUNK // Buffer can be freed or reused
} state;
qboolean strict; // Should we tolerate unknown commands?
double resumetime; // Time when stack can be executed again
int (*unknown_command)(void); // handle unkown commands. !0 = handled
qboolean strict; // Should we tolerate unknown commands?
double resumetime; // Time when stack can be executed again
void *data; // Pointer to interpreter data
void *data; // Pointer to interpreter data
} cbuf_t;
typedef struct cbuf_interpreter_s {

View file

@ -128,6 +128,8 @@ Cmd_Command (cbuf_args_t *args)
// check cvars
if (Cvar_Command ())
return 0;
if (cbuf_active->unknown_command && cbuf_active->unknown_command ())
return 0;
if (cbuf_active->strict)
return -1;
else if (cmd_warncmd->int_val || developer->int_val)