From: havoc Date: Wed, 17 Jul 2013 03:59:09 +0000 (+0000) Subject: Cmd_ExecuteString now calls Cbuf_LockThreadMutex X-Git-Tag: xonotic-v0.8.0~96^2~72 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2c2e33bbedfd3363e3c0429966e4b8dc05c60120;p=xonotic%2Fdarkplaces.git Cmd_ExecuteString now calls Cbuf_LockThreadMutex credit: EluanCM git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11968 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cmd.c b/cmd.c index ea486140..ba6aec5b 100644 --- a/cmd.c +++ b/cmd.c @@ -177,9 +177,6 @@ static sizebuf_t cmd_text; static unsigned char cmd_text_buf[CMDBUFSIZE]; void *cmd_text_mutex = NULL; -#define Cbuf_LockThreadMutex() (void)(cmd_text_mutex ? Thread_LockMutex(cmd_text_mutex) : 0) -#define Cbuf_UnlockThreadMutex() (void)(cmd_text_mutex ? Thread_UnlockMutex(cmd_text_mutex) : 0) - /* ============ Cbuf_AddText @@ -1913,7 +1910,8 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src, qboolean lockmutex) int found; cmd_function_t *cmd; cmdalias_t *a; - + if (lockmutex) + Cbuf_LockThreadMutex(); oldpos = cmd_tokenizebufferpos; cmd_source = src; found = false; @@ -1989,6 +1987,8 @@ command_found: done: cmd_tokenizebufferpos = oldpos; + if (lockmutex) + Cbuf_UnlockThreadMutex(); } diff --git a/cmd.h b/cmd.h index c8bf80ca..bb1a84f2 100644 --- a/cmd.h +++ b/cmd.h @@ -37,6 +37,10 @@ The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute (); #ifndef CMD_H #define CMD_H +extern void *cmd_text_mutex; +#define Cbuf_LockThreadMutex() (void)(cmd_text_mutex ? Thread_LockMutex(cmd_text_mutex) : 0) +#define Cbuf_UnlockThreadMutex() (void)(cmd_text_mutex ? Thread_UnlockMutex(cmd_text_mutex) : 0) + /// allocates an initial text buffer that will grow as needed void Cbuf_Init (void);