//=============================================================================
-void Cbuf_Lock(cbuf_t *cbuf)
+void Cbuf_Lock(cmd_buf_t *cbuf)
{
Thread_LockMutex(cbuf->lock);
}
-void Cbuf_Unlock(cbuf_t *cbuf)
+void Cbuf_Unlock(cmd_buf_t *cbuf)
{
Thread_UnlockMutex(cbuf->lock);
}
Cause a command to be executed after a delay.
============
*/
-static cmd_input_t *Cbuf_LinkGet(cbuf_t *cbuf, cmd_input_t *existing);
+static cmd_input_t *Cbuf_LinkGet(cmd_buf_t *cbuf, cmd_input_t *existing);
static void Cmd_Defer_f (cmd_state_t *cmd)
{
cmd_input_t *current;
- cbuf_t *cbuf = cmd->cbuf;
+ cmd_buf_t *cbuf = cmd->cbuf;
if(Cmd_Argc(cmd) == 1)
{
=============================================================================
*/
-static cmd_input_t *Cbuf_LinkGet(cbuf_t *cbuf, cmd_input_t *existing)
+static cmd_input_t *Cbuf_LinkGet(cmd_buf_t *cbuf, cmd_input_t *existing)
{
cmd_input_t *ret = NULL;
if(existing && existing->pending)
static void Cbuf_LinkCreate(cmd_state_t *cmd, llist_t *head, cmd_input_t *existing, const char *text)
{
char *in = (char *)&text[0];
- cbuf_t *cbuf = cmd->cbuf;
+ cmd_buf_t *cbuf = cmd->cbuf;
size_t totalsize = 0, newsize = 0;
cmd_input_t *current = NULL;
void Cbuf_AddText (cmd_state_t *cmd, const char *text)
{
size_t l = strlen(text);
- cbuf_t *cbuf = cmd->cbuf;
+ cmd_buf_t *cbuf = cmd->cbuf;
llist_t llist = {&llist, &llist};
Cbuf_Lock(cbuf);
*/
void Cbuf_InsertText (cmd_state_t *cmd, const char *text)
{
- cbuf_t *cbuf = cmd->cbuf;
+ cmd_buf_t *cbuf = cmd->cbuf;
llist_t llist = {&llist, &llist};
size_t l = strlen(text);
Cbuf_Execute_Deferred --blub
============
*/
-static void Cbuf_Execute_Deferred (cbuf_t *cbuf)
+static void Cbuf_Execute_Deferred (cmd_buf_t *cbuf)
{
llist_t *pos;
cmd_input_t *current;
============
*/
static qbool Cmd_PreprocessString(cmd_state_t *cmd, const char *intext, char *outtext, unsigned maxoutlen, cmd_alias_t *alias );
-void Cbuf_Execute (cbuf_t *cbuf)
+void Cbuf_Execute (cmd_buf_t *cbuf)
{
cmd_input_t *current;
char preprocessed[MAX_INPUTLINE];
}
}
-void Cbuf_Frame(cbuf_t *cbuf)
+void Cbuf_Frame(cmd_buf_t *cbuf)
{
Cbuf_Execute_Deferred(cbuf);
if (cbuf->size)
void Cmd_Init(void)
{
cmd_iter_t *cmd_iter;
- cbuf_t *cbuf = (cbuf_t *)Z_Malloc(sizeof(cbuf_t));
+ cmd_buf_t *cbuf = (cmd_buf_t *)Z_Malloc(sizeof(cmd_buf_t));
cbuf->maxsize = 655360;
cbuf->lock = Thread_CreateMutex();
cbuf->wait = false;
typedef void(*xcommand_t) (struct cmd_state_s *cmd);
-typedef enum
+typedef enum cmd_source_s
{
src_client, ///< came in over a net connection as a clc_stringcmd
///< host_client will be valid during this state.
}
cmd_userdefined_t;
+typedef struct cmd_buf_s
+{
+ llist_t start;
+ llist_t deferred;
+ llist_t free;
+ qbool wait;
+ size_t maxsize;
+ size_t size;
+ char tokenizebuffer[CMD_TOKENIZELENGTH];
+ int tokenizebufferpos;
+ double deferred_oldtime;
+ void *lock;
+} cmd_buf_t;
+
/// command interpreter state - the tokenizing and execution of commands, as well as pointers to which cvars and aliases they can access
typedef struct cmd_state_s
{
const char *args;
cmd_source_t source;
- struct cbuf_s *cbuf;
+ cmd_buf_t *cbuf;
cmd_userdefined_t *userdefined; // possible csqc functions and aliases to execute
qbool pending;
} cmd_input_t;
-typedef struct cbuf_s
-{
- llist_t start;
- llist_t deferred;
- llist_t free;
- qbool wait;
- size_t maxsize;
- size_t size;
- char tokenizebuffer[CMD_TOKENIZELENGTH];
- int tokenizebufferpos;
- double deferred_oldtime;
- void *lock;
-} cbuf_t;
-
extern cmd_userdefined_t cmd_userdefined_all; // aliases and csqc functions
extern cmd_userdefined_t cmd_userdefined_null; // intentionally empty
extern qbool host_stuffcmdsrun;
-void Cbuf_Lock(cbuf_t *cbuf);
-void Cbuf_Unlock(cbuf_t *cbuf);
+void Cbuf_Lock(cmd_buf_t *cbuf);
+void Cbuf_Unlock(cmd_buf_t *cbuf);
/*! as new commands are generated from the console or keybindings,
* the text is added to the end of the command buffer.
* Normally called once per frame, but may be explicitly invoked.
* \note Do not call inside a command function!
*/
-void Cbuf_Execute (cbuf_t *cbuf);
+void Cbuf_Execute (cmd_buf_t *cbuf);
/*! Performs deferred commands and runs Cbuf_Execute, called by Host_Frame */
-void Cbuf_Frame (cbuf_t *cbuf);
+void Cbuf_Frame (cmd_buf_t *cbuf);
//===========================================================================