From: cloudwalk Date: Thu, 17 Sep 2020 05:18:03 +0000 (+0000) Subject: cmd: Rename cbuf_t to cmd_buf_t X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a4c79739b828de9dd538f75d999953428d64e3ad;p=xonotic%2Fdarkplaces.git cmd: Rename cbuf_t to cmd_buf_t git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12927 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cmd.c b/cmd.c index 01a28ae6..a6d76726 100644 --- a/cmd.c +++ b/cmd.c @@ -47,12 +47,12 @@ qbool host_stuffcmdsrun = false; //============================================================================= -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); } @@ -79,11 +79,11 @@ Cmd_Defer_f 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) { @@ -176,7 +176,7 @@ static void Cmd_Centerprint_f (cmd_state_t *cmd) ============================================================================= */ -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) @@ -309,7 +309,7 @@ static size_t Cmd_ParseInput (cmd_input_t **output, char **input) 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; @@ -348,7 +348,7 @@ Adds command text at the end of the buffer 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); @@ -374,7 +374,7 @@ FIXME: actually change the command buffer to do less copying */ 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); @@ -398,7 +398,7 @@ void Cbuf_InsertText (cmd_state_t *cmd, const char *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; @@ -431,7 +431,7 @@ Cbuf_Execute ============ */ 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]; @@ -490,7 +490,7 @@ void Cbuf_Execute (cbuf_t *cbuf) } } -void Cbuf_Frame(cbuf_t *cbuf) +void Cbuf_Frame(cmd_buf_t *cbuf) { Cbuf_Execute_Deferred(cbuf); if (cbuf->size) @@ -1608,7 +1608,7 @@ Cmd_Init 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; diff --git a/cmd.h b/cmd.h index 336af38a..9ef9a9ab 100644 --- a/cmd.h +++ b/cmd.h @@ -64,7 +64,7 @@ struct cmd_state_s; 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. @@ -103,6 +103,20 @@ typedef struct cmd_userdefined_s } 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 { @@ -114,7 +128,7 @@ 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 @@ -148,20 +162,6 @@ typedef struct cmd_input_s 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 @@ -177,8 +177,8 @@ extern cmd_state_t cmd_serverfromclient; 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. @@ -196,9 +196,9 @@ void Cbuf_InsertText (cmd_state_t *cmd, const char *text); * 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); //=========================================================================== diff --git a/quakedef.h b/quakedef.h index 2d2b10f0..6571dd51 100644 --- a/quakedef.h +++ b/quakedef.h @@ -549,7 +549,7 @@ typedef struct host_s double sleeptime; // time spent sleeping overall qbool restless; // don't sleep qbool paused; // global paused state, pauses both client and server - cbuf_t *cbuf; + cmd_buf_t *cbuf; struct {