foxygit / doom Log in
commit 16447cf340d51ef54d6780a28ebe6192cf2d1537
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Feb 7 12:58:53 2007 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Feb 7 12:58:53 2007 +0000

    Don't throw away keypress state when passing between levels - allows
    shift to be held down for run when moving between levels. Thanks to Zack
    Friedrich <zack18@comcast.net> for pointing this out.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 831
---
 NEWS         |  3 +++
 src/g_game.c | 53 +++++++++++++++++++++++++++++++----------------------
 2 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/NEWS b/NEWS
index f89e1f57..3ba80173 100644
--- a/NEWS
+++ b/NEWS
@@ -107,6 +107,9 @@
        is possible to disable sound, as with Vanilla.
      * Repeat key presses when the key is held down (this is the Vanilla
        behavior)  - thanks to Mad_Mac for pointing this out.
+     * Don't throw away key press state when starting a new level - allows
+       shift to be held down for run when moving between levels (thanks
+       to Zack Friedrich <zack18@comcast.net>.
      * Don't print a list of all arguments read from response files - Vanilla
        doesn't do this.
      * Autorun only when joyb_speed >= 10, not >= 4.  Thanks to Janizdreg
diff --git a/src/g_game.c b/src/g_game.c
index 8fd96ec4..87aae640 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -195,41 +195,42 @@ int             novert = 0;

 #define TURBOTHRESHOLD	0x32

-fixed_t		forwardmove[2] = {0x19, 0x32};
-fixed_t		sidemove[2] = {0x18, 0x28};
-fixed_t		angleturn[3] = {640, 1280, 320};	// + slow turn
+fixed_t         forwardmove[2] = {0x19, 0x32};
+fixed_t         sidemove[2] = {0x18, 0x28};
+fixed_t         angleturn[3] = {640, 1280, 320};    // + slow turn

 #define SLOWTURNTICS	6

 #define NUMKEYS		256

-boolean         gamekeydown[NUMKEYS];
-int             turnheld;				// for accelerative turning
+static boolean  gamekeydown_initialised = false;
+static boolean  gamekeydown[NUMKEYS];
+static int      turnheld;		// for accelerative turning

-boolean		mousearray[4];
-boolean*	mousebuttons = &mousearray[1];		// allow [-1]
+static boolean  mousearray[4];
+static boolean *mousebuttons = &mousearray[1];  // allow [-1]

 // mouse values are used once
 int             mousex;
-int		mousey;
+int             mousey;

-int             dclicktime;
-boolean	        dclickstate;
-int		dclicks;
-int             dclicktime2;
-boolean		dclickstate2;
-int		dclicks2;
+static int      dclicktime;
+static boolean  dclickstate;
+static int      dclicks;
+static int      dclicktime2;
+static boolean  dclickstate2;
+static int      dclicks2;

 // joystick values are repeated
-int             joyxmove;
-int		joyymove;
-boolean         joyarray[5];
-boolean*	joybuttons = &joyarray[1];		// allow [-1]
+static int      joyxmove;
+static int      joyymove;
+static boolean  joyarray[5];
+static boolean *joybuttons = &joyarray[1];		// allow [-1]

-int		savegameslot;
-char		savedescription[32];
+static int      savegameslot;
+static char     savedescription[32];

-int             testcontrols_mousespeed;
+static int      testcontrols_mousespeed;

 #define	BODYQUESIZE	32

@@ -643,7 +644,15 @@ void G_DoLoadLevel (void)
     Z_CheckHeap ();

     // clear cmd building stuff
-    memset (gamekeydown, 0, sizeof(gamekeydown));
+
+    // Initialise gamekeydown when the first level is loaded
+
+    if (!gamekeydown_initialised)
+    {
+        memset (gamekeydown, 0, sizeof(gamekeydown));
+        gamekeydown_initialised = true;
+    }
+
     joyxmove = joyymove = 0;
     mousex = mousey = 0;
     sendpause = sendsave = paused = false;