From 36e678b292a947393cdaa259aaac4d6eef3cefc1 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Sun, 14 Apr 2019 15:17:47 -0700
Subject: [PATCH] Don't count down wait timer when executing a command

---
 src/command.c  | 20 ++++++++++++++------
 src/command.h  |  3 +++
 src/d_clisrv.c |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/command.c b/src/command.c
index ba0095e079..edc04bed1f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -148,6 +148,20 @@ void COM_BufInsertText(const char *ptext)
 	}
 }
 
+/** Progress the wait timer and flush waiting console commands when ready.
+  */
+void
+COM_BufTicker(void)
+{
+	if (com_wait)
+	{
+		com_wait--;
+		return;
+	}
+
+	COM_BufExecute();
+}
+
 /** Flushes (executes) console commands in the buffer.
   */
 void COM_BufExecute(void)
@@ -157,12 +171,6 @@ void COM_BufExecute(void)
 	char line[1024] = "";
 	INT32 quotes;
 
-	if (com_wait)
-	{
-		com_wait--;
-		return;
-	}
-
 	while (com_text.cursize)
 	{
 		// find a '\n' or; line break
diff --git a/src/command.h b/src/command.h
index e6767825c7..4682ba4a4c 100644
--- a/src/command.h
+++ b/src/command.h
@@ -45,6 +45,9 @@ void COM_ImmedExecute(const char *ptext);
 // Execute commands in buffer, flush them
 void COM_BufExecute(void);
 
+// As above; and progress the wait timer.
+void COM_BufTicker(void);
+
 // setup command buffer, at game tartup
 void COM_Init(void);
 
diff --git a/src/d_clisrv.c b/src/d_clisrv.c
index a0f9f40ab6..1b0cb523f8 100644
--- a/src/d_clisrv.c
+++ b/src/d_clisrv.c
@@ -4563,7 +4563,7 @@ void TryRunTics(tic_t realtics)
 
 	if (realtics >= 1)
 	{
-		COM_BufExecute();
+		COM_BufTicker();
 		if (mapchangepending)
 			D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change
 	}
-- 
GitLab