From dbe3cadd0f8b428365eeaf287bf2772f4a99d923 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Tue, 22 Oct 2019 00:52:07 +0200
Subject: [PATCH] - refactored autorunning CVARs

---
 source/CMakeLists.txt                |  2 +-
 source/blood/src/config.cpp          |  2 --
 source/blood/src/config.h            |  1 -
 source/blood/src/controls.cpp        |  4 ++--
 source/blood/src/menus.cpp           |  2 +-
 source/common/gameconfigfile.cpp     | 30 +++++++-----------------
 source/common/gamecvars.cpp          | 17 ++++++++++++++
 source/common/gamecvars.h            | 11 +++++++++
 source/duke3d/src/config.cpp         |  1 -
 source/duke3d/src/game.cpp           |  5 ++--
 source/duke3d/src/game.h             |  2 +-
 source/duke3d/src/gamestructures.cpp |  4 ++--
 source/duke3d/src/menus.cpp          |  2 +-
 source/duke3d/src/player.cpp         |  3 ++-
 source/duke3d/src/savegame.cpp       |  1 -
 source/rr/src/config.cpp             |  1 -
 source/rr/src/game.cpp               |  9 ++++---
 source/rr/src/game.h                 |  2 +-
 source/rr/src/player.cpp             |  8 ++++---
 source/rr/src/savegame.cpp           |  1 -
 source/sw/src/game.cpp               | 17 +-------------
 source/sw/src/game.h                 |  2 --
 source/sw/src/network.cpp            |  6 -----
 source/sw/src/player.cpp             | 35 +++-------------------------
 24 files changed, 62 insertions(+), 106 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 67020e745..6fc6492bb 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -468,7 +468,7 @@ endif()
 if (WIN32)
 	include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/windows/include/sdl2")
 else ()
-include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${ENET_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
+include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
 endif()
 
 
diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp
index ff9093728..d1dfd8ee5 100644
--- a/source/blood/src/config.cpp
+++ b/source/blood/src/config.cpp
@@ -101,7 +101,6 @@ int32_t gShowWeapon;
 int32_t gMouseSensitivity;
 int32_t gMouseAiming;
 int32_t gMouseAimingFlipped;
-int32_t gRunKeyMode;
 bool gNoClip;
 bool gInfiniteAmmo;
 bool gFullMap;
@@ -358,7 +357,6 @@ void CONFIG_SetDefaults(void)
     //ud.msgdisptime            = 120;
     //ud.obituaries             = 1;
     //ud.pwlockout[0]           = '\0';
-    gRunKeyMode            = 0;
     //ud.screen_size            = 4;
     //ud.screen_tilting         = 1;
     //ud.screenfade             = 1;
diff --git a/source/blood/src/config.h b/source/blood/src/config.h
index 0b8b2917f..aab1f514a 100644
--- a/source/blood/src/config.h
+++ b/source/blood/src/config.h
@@ -82,7 +82,6 @@ extern int32_t gShowWeapon;
 extern int32_t gMouseSensitivity;
 extern int32_t gMouseAiming;
 extern int32_t gMouseAimingFlipped;
-extern int32_t gRunKeyMode;
 extern bool gNoClip;
 extern bool gInfiniteAmmo;
 extern bool gFullMap;
diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp
index 671354f0d..309cf7b51 100644
--- a/source/blood/src/controls.cpp
+++ b/source/blood/src/controls.cpp
@@ -404,8 +404,8 @@ void ctrlGetInput(void)
         gInput.keyFlags.holsterWeapon = 1;
     }
 
-    char run = gRunKeyMode ? (BUTTON(gamefunc_Run) | gAutoRun) : (BUTTON(gamefunc_Run) ^ gAutoRun);
-    char run2 = BUTTON(gamefunc_Run);
+    char run = G_CheckAutorun(BUTTON(gamefunc_Run));
+	char run2 = false; // What??? BUTTON(gamefunc_Run);
 
     gInput.syncFlags.run = run;
 
diff --git a/source/blood/src/menus.cpp b/source/blood/src/menus.cpp
index dc1c1ce3b..eb6bee374 100644
--- a/source/blood/src/menus.cpp
+++ b/source/blood/src/menus.cpp
@@ -411,7 +411,7 @@ static MenuOptionSet_t MEOS_GAMESETUP_AIM_AUTO = MAKE_MENUOPTIONSET( MEOSN_GAMES
 static MenuOption_t MEO_GAMESETUP_AIM_AUTO = MAKE_MENUOPTION( &MF_Redfont, &MEOS_GAMESETUP_AIM_AUTO, &ud.config.AutoAim );
 static MenuEntry_t ME_GAMESETUP_AIM_AUTO = MAKE_MENUENTRY( "Auto aim:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_AIM_AUTO, Option );
 
-static MenuOption_t MEO_GAMESETUP_ALWAYS_RUN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_NoYes, &ud.auto_run);
+static MenuOption_t MEO_GAMESETUP_ALWAYS_RUN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_NoYes, &cl_autorun.Value);
 static MenuEntry_t ME_GAMESETUP_ALWAYS_RUN = MAKE_MENUENTRY( "Always run:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_ALWAYS_RUN, Option );
 
 static char const *MEOSN_GAMESETUP_WEAPSWITCH_PICKUP[] = { "Never", "If new", /*"If favored",*/ };
diff --git a/source/common/gameconfigfile.cpp b/source/common/gameconfigfile.cpp
index bc61d4e57..096acedb1 100644
--- a/source/common/gameconfigfile.cpp
+++ b/source/common/gameconfigfile.cpp
@@ -35,7 +35,7 @@
 #include <stdio.h>
 
 #include "gameconfigfile.h"
-//#include "c_cvars.h"
+#include "c_cvars.h"
 //#include "c_dispatch.h"
 //#include "c_bind.h"
 #include "m_argv.h"
@@ -258,7 +258,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
 
 	// The NetServerInfo section will be read and override anything loaded
 	// here when it's determined that a netgame is being played.
-#if 0
 	strncpy (subsection, "LocalServerInfo", sublen);
 	if (SetSection (section))
 	{
@@ -270,7 +269,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
 	{
 		ReadCVars (0);
 	}
-#endif
 	strncpy (subsection, "ConsoleAliases", sublen);
 	if (SetSection (section))
 	{
@@ -330,28 +328,17 @@ void FGameConfigFile::DoKeySetup(const char *gamename)
 
 void FGameConfigFile::ReadNetVars ()
 {
-#if 0
 	strncpy (subsection, "NetServerInfo", sublen);
 	if (SetSection (section))
 	{
 		ReadCVars (0);
 	}
-	if (bModSetup)
-	{
-		mysnprintf(subsection, sublen, "NetServerInfo.Mod");
-		if (SetSection(section))
-		{
-			ReadCVars(CVAR_MOD|CVAR_SERVERINFO|CVAR_IGNORE);
-		}
-	}
-#endif
 }
 
 // Read cvars from a cvar section of the ini. Flags are the flags to give
 // to newly-created cvars that were not already defined.
 void FGameConfigFile::ReadCVars (uint32_t flags)
 {
-	/*
 	const char *key, *value;
 	FBaseCVar *cvar;
 	UCVarValue val;
@@ -367,7 +354,6 @@ void FGameConfigFile::ReadCVars (uint32_t flags)
 		val.String = const_cast<char *>(value);
 		cvar->SetGenericRep (val, CVAR_String);
 	}
-	*/
 }
 
 void FGameConfigFile::ArchiveGameData (const char *gamename)
@@ -380,12 +366,12 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
 	strncpy (subsection, "Player", sublen);
 	SetSection (section, true);
 	ClearCurrentSection ();
-	//C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_USERINFO);
+	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_USERINFO);
 
 	strncpy (subsection, "ConsoleVariables", sublen);
 	SetSection (section, true);
 	ClearCurrentSection ();
-	//C_ArchiveCVars (this, CVAR_ARCHIVE);
+	C_ArchiveCVars (this, CVAR_ARCHIVE);
 
 #if 0
 	// Do not overwrite the serverinfo section if playing a netgame, and
@@ -395,14 +381,14 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
 		strncpy (subsection, netgame ? "NetServerInfo" : "LocalServerInfo", sublen);
 		SetSection (section, true);
 		ClearCurrentSection ();
-		//C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_SERVERINFO);
+		C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_SERVERINFO);
 	}
 #endif
 
 	strncpy (subsection, "UnknownConsoleVariables", sublen);
 	SetSection (section, true);
 	ClearCurrentSection ();
-	//C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_AUTO);
+	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_AUTO);
 
 	strncpy (subsection, "ConsoleAliases", sublen);
 	SetSection (section, true);
@@ -432,11 +418,11 @@ void FGameConfigFile::ArchiveGlobalData ()
 
 	SetSection ("GlobalSettings", true);
 	ClearCurrentSection ();
-	//C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
+	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
 
 	SetSection ("GlobalSettings.Unknown", true);
 	ClearCurrentSection ();
-	//C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_AUTO);
+	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_AUTO);
 }
 
 FString FGameConfigFile::GetConfigPath (bool tryProg)
@@ -499,4 +485,4 @@ CCMD (whereisini)
 	FString path = M_GetConfigPath(false);
 	Printf ("%s\n", path.GetChars());
 }
-*/
\ No newline at end of file
+*/
diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp
index e23195bb2..b458061d2 100644
--- a/source/common/gamecvars.cpp
+++ b/source/common/gamecvars.cpp
@@ -1,8 +1,18 @@
 #include "c_cvars.h"
 #include "common.h"
 
+/* Notes
+ 
+ RedNukem has this for the toggle autorun command. Todo: Check what this is supposed to accomplish. The implementation makes no sense at all.
+ (!RRRA || (!g_player[myconnectindex].ps->on_motorcycle && !g_player[myconnectindex].ps->on_boat)))
+ 
+ 
+ */
+
 CVARD(Bool, cl_crosshair, true, CVAR_ARCHIVE, "enable/disable crosshair");
 CVARD(Bool, cl_automsg, false, CVAR_ARCHIVE, "enable/disable automatically sending messages to all players")
+CVARD(Bool, cl_autorun, true, CVAR_ARCHIVE, "enable/disable autorun")
+CVARD(Bool, cl_runmode, true, CVAR_ARCHIVE, "enable/disable modernized run key operation")
 
 CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE, "enable/disable weapon autoaim")
 {
@@ -11,6 +21,12 @@ CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE, "enable/disable weapon autoaim")
 };
 
 
+bool G_CheckAutorun(bool button)
+{
+	if (cl_runmode) return button || cl_autorun;
+	else return button ^ !!cl_autorun;
+}
+
 
 #if 0
         { "cl_autorun", "enable/disable autorun", (void *)&ud.auto_run, CVAR_BOOL, 0, 1 },
@@ -19,6 +35,7 @@ CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE, "enable/disable weapon autoaim")
         { "cl_runmode", "enable/disable modernized run key operation", (void *)&ud.runkey_mode, CVAR_BOOL, 0, 1 },
 
 
+
 // DN3D
     static osdcvardata_t cvars_game[] =
     {
diff --git a/source/common/gamecvars.h b/source/common/gamecvars.h
index 6a31e97db..9c5d487f9 100644
--- a/source/common/gamecvars.h
+++ b/source/common/gamecvars.h
@@ -3,3 +3,14 @@
 EXTERN_CVAR(Bool, cl_crosshair)
 EXTERN_CVAR(Bool, cl_automsg)
 EXTERN_CVAR(Int, cl_autoaim)
+EXTERN_CVAR(Bool, cl_autorun)
+EXTERN_CVAR(Bool, cl_runmode)
+
+CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE, "enable/disable weapon autoaim")
+{
+	if (self < 0 || self > (playing_blood? 2 : 3)) self = 1;	// Note: The Shadow Warrior backend only has a bool for this.
+	//UpdatePlayerFromMenu(); todo: networking (only operational in EDuke32 frontend anyway.)
+};
+
+
+bool G_CheckAutorun(bool button);
diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp
index 98168fcc4..c254637b9 100644
--- a/source/duke3d/src/config.cpp
+++ b/source/duke3d/src/config.cpp
@@ -254,7 +254,6 @@ void CONFIG_SetDefaults(void)
 
     ud.althud                 = 1;
     ud.angleinterpolation     = 0;
-    ud.auto_run               = 1;
     ud.autosave               = 1;
     ud.autosavedeletion       = 1;
     ud.autovote               = 0;
diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp
index 71ba72989..251ac97a1 100644
--- a/source/duke3d/src/game.cpp
+++ b/source/duke3d/src/game.cpp
@@ -5049,8 +5049,8 @@ FAKE_F3:
     if (BUTTON(gamefunc_AutoRun))
     {
         CONTROL_ClearButton(gamefunc_AutoRun);
-        ud.auto_run = 1-ud.auto_run;
-        P_DoQuote(QUOTE_RUN_MODE_OFF + ud.auto_run, &myplayer);
+        cl_autorun= 1-cl_autorun;
+        P_DoQuote(QUOTE_RUN_MODE_OFF + cl_autorun, &myplayer);
     }
 
     if (BUTTON(gamefunc_Map))
@@ -6760,7 +6760,6 @@ MAIN_LOOP_RESTART:
 
 //    G_GameExit(" "); ///
 
-//    ud.auto_run = ud.config.RunMode;
     ud.showweapons = ud.config.ShowWeapons;
     P_SetupMiscInputSettings();
     g_player[myconnectindex].pteam = ud.team;
diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h
index cab752b4c..fbe275923 100644
--- a/source/duke3d/src/game.h
+++ b/source/duke3d/src/game.h
@@ -186,7 +186,7 @@ typedef struct {
     int32_t menu_slidebarz, menu_slidebarmargin, menu_slidecursorz;
     int32_t menu_scrollbartilenum, menu_scrollbarz, menu_scrollcursorz;
 
-    int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
+	int32_t entered_name,screen_tilting,shadows,fta_on,executions;
     int32_t coords,showfps,levelstats,m_coop,coop,screen_size,lockout;
     int32_t playerai,angleinterpolation,obituaries;
 
diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp
index 704067046..15eca72de 100644
--- a/source/duke3d/src/gamestructures.cpp
+++ b/source/duke3d/src/gamestructures.cpp
@@ -1411,7 +1411,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2)
         case USERDEFS_SHADOWS:                labelNum = ud.shadows;                      break;
         case USERDEFS_FTA_ON:                 labelNum = ud.fta_on;                       break;
         case USERDEFS_EXECUTIONS:             labelNum = ud.executions;                   break;
-        case USERDEFS_AUTO_RUN:               labelNum = ud.auto_run;                     break;
+        case USERDEFS_AUTO_RUN:               labelNum = cl_autorun;                      break;
         case USERDEFS_COORDS:                 labelNum = ud.coords;                       break;
         case USERDEFS_TICKRATE:               labelNum = ud.showfps;                      break;
         case USERDEFS_M_COOP:                 labelNum = ud.m_coop;                       break;
@@ -1607,7 +1607,7 @@ void __fastcall VM_SetUserdef(int const labelNum, int const lParm2, int32_t cons
         case USERDEFS_SHADOWS:                      ud.shadows                       = iSet; break;
         case USERDEFS_FTA_ON:                       ud.fta_on                        = iSet; break;
         case USERDEFS_EXECUTIONS:                   ud.executions                    = iSet; break;
-        case USERDEFS_AUTO_RUN:                     ud.auto_run                      = iSet; break;
+        case USERDEFS_AUTO_RUN:                     cl_autorun                       = iSet; break; //!!!
         case USERDEFS_COORDS:                       ud.coords                        = iSet; break;
         case USERDEFS_TICKRATE:                     ud.showfps                       = iSet; break;
         case USERDEFS_M_COOP:                       ud.m_coop                        = iSet; break;
diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp
index d628d106f..fb6447620 100644
--- a/source/duke3d/src/menus.cpp
+++ b/source/duke3d/src/menus.cpp
@@ -410,7 +410,7 @@ static MenuOptionSet_t MEOS_GAMESETUP_AIM_AUTO = MAKE_MENUOPTIONSET( MEOSN_GAMES
 static MenuOption_t MEO_GAMESETUP_AIM_AUTO = MAKE_MENUOPTION( &MF_Redfont, &MEOS_GAMESETUP_AIM_AUTO, &cl_autoaim.Value );
 static MenuEntry_t ME_GAMESETUP_AIM_AUTO = MAKE_MENUENTRY( "Auto aim:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_AIM_AUTO, Option );
 
-static MenuOption_t MEO_GAMESETUP_ALWAYS_RUN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_NoYes, &ud.auto_run);
+static MenuOption_t MEO_GAMESETUP_ALWAYS_RUN = MAKE_MENUOPTION( &MF_Redfont, &MEOS_NoYes, &cl_autorun.Value);
 static MenuEntry_t ME_GAMESETUP_ALWAYS_RUN = MAKE_MENUENTRY( "Always run:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_ALWAYS_RUN, Option );
 
 static char const *MEOSN_GAMESETUP_WEAPSWITCH_PICKUP[] = { "Never", "If new", /*"If favored",*/ };
diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp
index 9ed3b9078..0c3775b38 100644
--- a/source/duke3d/src/player.cpp
+++ b/source/duke3d/src/player.cpp
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "demo.h"
 #include "enet.h"
 #include "sjson.h"
+#include "gamcvars.h"
 
 BEGIN_DUKE_NS
 
@@ -2944,7 +2945,7 @@ void P_GetInput(int const playerNum)
     }
 
     // JBF: Run key behaviour is selectable
-    int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
+    int const playerRunning = G_CheckAutorun(BUTTON(gamefunc_Run));
     int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
     constexpr int const analogTurnAmount = (NORMALTURN << 1);
     int const keyMove    = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp
index 00bad1631..a2d806251 100644
--- a/source/duke3d/src/savegame.cpp
+++ b/source/duke3d/src/savegame.cpp
@@ -1403,7 +1403,6 @@ static const dataspec_t svgm_udnetw[] =
     { DS_NOCHK, &ud.respawn_items, sizeof(ud.respawn_items), 1 },
     { DS_NOCHK, &ud.respawn_inventory, sizeof(ud.respawn_inventory), 1 },
     { 0, &ud.god, sizeof(ud.god), 1 },
-    { 0, &ud.auto_run, sizeof(ud.auto_run), 1 },
     { DS_NOCHK, &ud.monsters_off, sizeof(ud.monsters_off), 1 },
     { DS_NOCHK, &ud.last_level, sizeof(ud.last_level), 1 },
     { 0, &ud.eog, sizeof(ud.eog), 1 },
diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp
index 397242904..05312bbc1 100644
--- a/source/rr/src/config.cpp
+++ b/source/rr/src/config.cpp
@@ -234,7 +234,6 @@ void CONFIG_SetDefaults(void)
     ud.config.NumVoices = 64;
 #endif
     ud.config.ReverseStereo = 0;
-    ud.auto_run = 1;
     ud.config.ShowOpponentWeapons = 0;
     ud.config.SmoothInput = 1;
     ud.config.SoundToggle = 1;
diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp
index 3cbc58714..d1392dd85 100644
--- a/source/rr/src/game.cpp
+++ b/source/rr/src/game.cpp
@@ -1,4 +1,4 @@
-//-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 /*
 Copyright (C) 2016 EDuke32 developers and contributors
 
@@ -6560,11 +6560,11 @@ FAKE_F3:
         G_UpdateScreenArea();
     }
 
-    if (BUTTON(gamefunc_AutoRun) && (!RRRA || (!g_player[myconnectindex].ps->on_motorcycle && !g_player[myconnectindex].ps->on_boat)))
+    if (BUTTON(gamefunc_AutoRun))
     {
         CONTROL_ClearButton(gamefunc_AutoRun);
-        ud.auto_run = 1-ud.auto_run;
-        P_DoQuote(QUOTE_RUN_MODE_OFF+ud.auto_run,g_player[myconnectindex].ps);
+		cl_autorun = !cl_autorun;
+        P_DoQuote(QUOTE_RUN_MODE_OFF+cl_autorun,g_player[myconnectindex].ps);
     }
 
     if (BUTTON(gamefunc_Map))
@@ -8137,7 +8137,6 @@ MAIN_LOOP_RESTART:
 
 //    G_GameExit(" "); ///
 
-//    ud.auto_run = ud.config.RunMode;
     ud.showweapons = ud.config.ShowOpponentWeapons;
     P_SetupMiscInputSettings();
     g_player[myconnectindex].pteam = ud.team;
diff --git a/source/rr/src/game.h b/source/rr/src/game.h
index 1b323a8c0..e9689ba0f 100644
--- a/source/rr/src/game.h
+++ b/source/rr/src/game.h
@@ -165,7 +165,7 @@ typedef struct {
     int32_t menu_slidebarz, menu_slidebarmargin, menu_slidecursorz;
     int32_t menu_scrollbartilenum, menu_scrollbarz, menu_scrollcursorz;
 
-    int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
+    int32_t entered_name,screen_tilting,shadows,fta_on,executions;
     int32_t coords,showfps,levelstats,m_coop,coop,screen_size,lockout,crosshair;
     int32_t playerai,angleinterpolation,obituaries;
 
diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp
index 3c1e47bea..4da9e3b99 100644
--- a/source/rr/src/player.cpp
+++ b/source/rr/src/player.cpp
@@ -2795,7 +2795,9 @@ void P_GetInput(int playerNum)
     }
 
     // JBF: Run key behaviour is selectable
-    int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
+	int playerRunning = false;
+	
+	 int const playerRunning = G_CheckAutorun(BUTTON(gamefunc_Run));
     int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
     constexpr int const analogTurnAmount = (NORMALTURN << 1);
     int const keyMove    = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
@@ -3100,7 +3102,7 @@ void P_GetInputMotorcycle(int playerNum)
     }
 
     // JBF: Run key behaviour is selectable
-    int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
+    int const playerRunning = G_CheckAutorun(BUTTON(gamefunc_Run));
     constexpr int const analogTurnAmount = (NORMALTURN << 1);
     int const keyMove    = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
     constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
@@ -3398,7 +3400,7 @@ void P_GetInputBoat(int playerNum)
     }
 
     // JBF: Run key behaviour is selectable
-    int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
+    int const playerRunning = G_CheckAutorun(BUTTON(gamefunc_Run));
     constexpr int const analogTurnAmount = (NORMALTURN << 1);
     int const keyMove    = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
     constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp
index 00b6c52d0..0de9064b7 100644
--- a/source/rr/src/savegame.cpp
+++ b/source/rr/src/savegame.cpp
@@ -1089,7 +1089,6 @@ static const dataspec_t svgm_udnetw[] =
     { DS_NOCHK, &ud.respawn_items, sizeof(ud.respawn_items), 1 },
     { DS_NOCHK, &ud.respawn_inventory, sizeof(ud.respawn_inventory), 1 },
     { 0, &ud.god, sizeof(ud.god), 1 },
-    { 0, &ud.auto_run, sizeof(ud.auto_run), 1 },
     { DS_NOCHK, &ud.monsters_off, sizeof(ud.monsters_off), 1 },
     { DS_NOCHK, &ud.last_level, sizeof(ud.last_level), 1 },
     { 0, &ud.eog, sizeof(ud.eog), 1 },
diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp
index 0762b2199..cc5675f0d 100644
--- a/source/sw/src/game.cpp
+++ b/source/sw/src/game.cpp
@@ -3056,12 +3056,6 @@ void InitPlayerGameSettings(void)
             RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
     }
 
-    // everyone had their own Auto Run
-    if (gs.AutoRun)
-        SET(Player[myconnectindex].Flags, PF_LOCK_RUN);
-    else
-        RESET(Player[myconnectindex].Flags, PF_LOCK_RUN);
-
     if (gs.MouseAimingOn)
         SET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON);
     else
@@ -5143,7 +5137,7 @@ getinput(SW_PACKET *loc)
 
     SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!KEY_PRESSED(KEYSC_SPACE)) | BUTTON(gamefunc_Open)));
 
-    running = BUTTON(gamefunc_Run) || TEST(pp->Flags, PF_LOCK_RUN);
+    running = G_CheckAutorun(BUTTON(gamefunc_Run));
 
     if (BUTTON(gamefunc_Strafe) && !pp->sop)
         svel = -info.dyaw;
@@ -5260,15 +5254,6 @@ getinput(SW_PACKET *loc)
     loc->angvel = angvel;
     loc->aimvel = aimvel;
 
-    if (MenuButtonAutoRun)
-    {
-        MenuButtonAutoRun = FALSE;
-        if ((!!TEST(pp->Flags, PF_LOCK_RUN)) != !!gs.AutoRun)
-            SET_LOC_KEY(loc->bits, SK_RUN_LOCK, TRUE);
-    }
-
-    SET_LOC_KEY(loc->bits, SK_RUN_LOCK, BUTTON(gamefunc_AutoRun));
-
     if (!CommEnabled)
     {
         if (MenuButtonAutoAim)
diff --git a/source/sw/src/game.h b/source/sw/src/game.h
index ec0beee83..c00ec8650 100644
--- a/source/sw/src/game.h
+++ b/source/sw/src/game.h
@@ -259,7 +259,6 @@ extern char MessageOutputString[256];
 #define SK_AUTO_AIM    7
 #define SK_CENTER_VIEW 8
 #define SK_PAUSE       9
-#define SK_RUN_LOCK   10
 
 #define SK_MESSAGE    11
 #define SK_LOOK_UP    12
@@ -1252,7 +1251,6 @@ extern PLAYER Player[MAX_SW_PLAYERS_REG+1];
 #define PF_DIVING           (BIT(17))
 #define PF_DIVING_IN_LAVA   (BIT(18))
 #define PF_TWO_UZI          (BIT(19))
-#define PF_LOCK_RUN         (BIT(20))
 #define PF_TURN_180         (BIT(21))
 #define PF_DEAD_HEAD        (BIT(22)) // are your a dead head
 #define PF_HEAD_CONTROL     (BIT(23)) // have control of turning when a head?
diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp
index 02b43e40c..ba9b655e1 100644
--- a/source/sw/src/network.cpp
+++ b/source/sw/src/network.cpp
@@ -1562,12 +1562,6 @@ getpackets(void)
             pp = Player + otherconnectindex;
             p = (PACKET_OPTIONSp)packbuf;
 
-            // auto run
-            if (p->AutoRun)
-                SET(pp->Flags, PF_LOCK_RUN);
-            else
-                RESET(pp->Flags, PF_LOCK_RUN);
-
             // palette
             pp->TeamColor = p->Color;
             pp->SpriteP->pal = PALETTE_PLAYER0 + pp->TeamColor;
diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp
index 985019779..3e9f9ef62 100644
--- a/source/sw/src/player.cpp
+++ b/source/sw/src/player.cpp
@@ -122,21 +122,6 @@ extern SWBOOL FinishedLevel;
 #define TANK_FRICTION (53248L)
 #define PLAYER_SLIDE_FRICTION (53248L)
 
-#define PLAYER_RUN_LOCK(pp)                                 \
-    if (TEST_SYNC_KEY((pp), SK_RUN_LOCK))               \
-    {                                               \
-        if (FLAG_KEY_PRESSED((pp), SK_RUN_LOCK))        \
-        {                                           \
-            FLAG_KEY_RELEASE((pp), SK_RUN_LOCK);        \
-            FLIP((pp)->Flags, PF_LOCK_RUN);             \
-            gs.AutoRun = !!TEST((pp)->Flags, PF_LOCK_RUN); \
-            sprintf(ds, "Run mode %s", TEST((pp)->Flags, PF_LOCK_RUN) ? "ON" : "OFF"); \
-            PutStringInfo((pp), ds);                    \
-        }                                           \
-    }                                               \
-    else                                                \
-        FLAG_KEY_RESET((pp), SK_RUN_LOCK)               \
-
 #define JUMP_STUFF 4
 
 // just like 2 except can jump higher - less gravity
@@ -2011,7 +1996,7 @@ DoPlayerBob(PLAYERp pp)
         dist = 0;
 
     // if running make a longer stride
-    if (TEST_SYNC_KEY(pp, SK_RUN) || TEST(pp->Flags, PF_LOCK_RUN))
+    if (G_CheckAutorun(TEST_SYNC_KEY(pp, SK_RUN)))
     {
         //amt = 10;
         amt = 12;
@@ -2457,7 +2442,7 @@ MoveScrollMode2D(PLAYERp pp)
         Follow_posy = pp->posy;
     }
 
-    running = BUTTON(gamefunc_Run) || TEST(pp->Flags, PF_LOCK_RUN);
+    running = G_CheckAutorun(BUTTON(gamefunc_Run));
 
     if (BUTTON(gamefunc_Strafe))
         mfsvel -= scrl_input.dyaw>>2;
@@ -2596,9 +2581,7 @@ DoPlayerMove(PLAYERp pp)
     void SlipSlope(PLAYERp pp);
 
     SlipSlope(pp);
-
-    PLAYER_RUN_LOCK(pp);
-
+	
     DoPlayerTurn(pp);
 
     pp->oldposx = pp->posx;
@@ -2863,8 +2846,6 @@ DoPlayerMoveBoat(PLAYERp pp)
             PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND);
     }
 
-    PLAYER_RUN_LOCK(pp);
-
     DoPlayerTurnBoat(pp);
 
     if (PLAYER_MOVING(pp) == 0)
@@ -3270,8 +3251,6 @@ DoPlayerMoveTank(PLAYERp pp)
             PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND);
     }
 
-    PLAYER_RUN_LOCK(pp);
-
     if (PLAYER_MOVING(pp) == 0)
         RESET(pp->Flags, PF_PLAYER_MOVED);
     else
@@ -3450,8 +3429,6 @@ DoPlayerMoveTurret(PLAYERp pp)
     short save_sectnum;
     USERp u = User[pp->PlayerSprite];
 
-    PLAYER_RUN_LOCK(pp);
-
     DoPlayerTurnTurret(pp);
 
     if (PLAYER_MOVING(pp) == 0)
@@ -3904,9 +3881,6 @@ DoPlayerClimb(PLAYERp pp)
     if (dot < 0)
         climbvel = -climbvel;
 
-    // Run lock - routine doesn't call DoPlayerMove
-    PLAYER_RUN_LOCK(pp);
-
     // need to rewrite this for FAF stuff
 
     // Jump off of the ladder
@@ -6852,9 +6826,6 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
     // allow turning
     if ((TEST(pp->Flags, PF_DEAD_HEAD) && pp->input.angvel != 0) || TEST(pp->Flags, PF_HEAD_CONTROL))
     {
-        // Allow them to turn fast
-        PLAYER_RUN_LOCK(pp);
-
         DoPlayerTurn(pp);
         return;
     }