]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Cmd_ExecuteString now calls Cbuf_LockThreadMutex
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 17 Jul 2013 03:59:09 +0000 (03:59 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 17 Jul 2013 03:59:09 +0000 (03:59 +0000)
credit: EluanCM

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11968 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c
cmd.h

diff --git a/cmd.c b/cmd.c
index ea486140bce595ec383ce744b6c6630fe254dc73..ba6aec5bd6c19385818b05310e795041f83058a3 100644 (file)
--- 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 c8bf80ca4b6a1647040d8d716805c2b362b4b22d..bb1a84f2f8c8db3bb9b56a938c459a3587fdc173 100644 (file)
--- 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);