foxygit / doom Log in
commit 0fea3b6cd1c5e80aaed4a045d11025db34a83d7f
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Jun 17 23:02:21 2013 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Jun 17 23:02:21 2013 +0000

    Refactor handling of novert to take place at the lower layers rather
    than in the game code. This makes the behavior closer to Vanilla and
    stops the mouse affecting the menus when novert is enabled (thanks
    manny).

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 2606
---
 src/d_main.c  | 18 ------------------
 src/g_game.c  | 12 +-----------
 src/i_video.c | 38 +++++++++++++++++++++++++++++++++++---
 3 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/src/d_main.c b/src/d_main.c
index 025c31eb..171a0f6c 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1427,24 +1427,6 @@ void D_DoomMain (void)
         startloadgame = -1;
     }

-    //!
-    // @category video
-    //
-    // Disable vertical mouse movement.
-    //
-
-    if (M_CheckParm("-novert"))
-        novert = true;
-
-    //!
-    // @category video
-    //
-    // Enable vertical mouse movement.
-    //
-
-    if (M_CheckParm("-nonovert"))
-        novert = false;
-
     if (W_CheckNumForName("SS_START") >= 0
      || W_CheckNumForName("FF_END") >= 0)
     {
diff --git a/src/g_game.c b/src/g_game.c
index fe168fae..33243b21 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -216,11 +216,6 @@ int             joybstraferight = -1;
 int             joybprevweapon = -1;
 int             joybnextweapon = -1;

-// fraggle: Disallow mouse and joystick movement to cause forward/backward
-// motion.  Specified with the '-novert' command line parameter.
-// This is an int to allow saving to config file
-
-int             novert = 0;



@@ -716,12 +711,7 @@ void G_BuildTiccmd (ticcmd_t* cmd)
         }
     }

-    // fraggle: allow disabling mouse y movement
-
-    if (!novert)
-    {
-        forward += mousey;
-    }
+    forward += mousey;

     if (strafe)
 	side += mousex*2;
diff --git a/src/i_video.c b/src/i_video.c
index fdde7766..8af04956 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -113,6 +113,12 @@ static boolean initialized = false;
 static boolean nomouse = false;
 extern int usemouse;

+// Disallow mouse and joystick movement to cause forward/backward
+// motion.  Specified with the '-novert' command line parameter.
+// This is an int to allow saving to config file.
+
+int             novert = 0;
+
 // Bit mask of mouse button state.

 static unsigned int mouse_button_state = 0;
@@ -703,8 +709,16 @@ static void I_ReadMouse(void)
         ev.type = ev_mouse;
         ev.data1 = mouse_button_state;
         ev.data2 = AccelerateMouse(x);
-        ev.data3 = -AccelerateMouse(y);
-
+
+        if (!novert)
+        {
+            ev.data3 = 0;
+        }
+        else
+        {
+            ev.data3 = -AccelerateMouse(y);
+        }
+
         D_PostEvent(&ev);
     }

@@ -1457,13 +1471,31 @@ static void CheckCommandLine(void)
     }

     //!
-    // @category video
+    // @category video
     //
     // Disable the mouse.
     //

     nomouse = M_CheckParm("-nomouse") > 0;

+    //!
+    // @category video
+    //
+    // Disable vertical mouse movement.
+    //
+
+    if (M_CheckParm("-novert"))
+        novert = true;
+
+    //!
+    // @category video
+    //
+    // Enable vertical mouse movement.
+    //
+
+    if (M_CheckParm("-nonovert"))
+        novert = false;
+
     //!
     // @category video
     // @arg <x>