shithub: riscv

Download patch

ref: ec8d7cdf024949d73c5f887f23f060cd33c1df28
parent: 26cc14d67eb7a6c6e8d19d179333f205f98206a0
author: qwx <qwx@sciops.net>
date: Mon Aug 22 17:56:47 EDT 2022

games/doom: rename mouse use key for what it is and remove double click

one can still play with just the mouse via m_forward, there's no
longer any need for a button to move forward

--- a/sys/src/games/doom/g_game.c
+++ b/sys/src/games/doom/g_game.c
@@ -157,7 +157,7 @@
  
 int             mousebfire; 
 int             mousebstrafe; 
-int             mousebforward; 
+int             mousebuse; 
 int             m_forward;
  
 int             joybfire; 
@@ -190,13 +190,6 @@
 int		mousey;         
 extern int usemouse;
 
-int             dclicktime;
-int		dclickstate;
-int		dclicks; 
-int             dclicktime2;
-int		dclickstate2;
-int		dclicks2;
-
 // joystick values are repeated 
 int             joyxmove;
 int		joyymove;
@@ -238,7 +231,6 @@
 { 
     int		i; 
     boolean	strafe;
-    boolean	bstrafe; 
     int		speed;
     int		tspeed; 
     int		forward;
@@ -332,11 +324,7 @@
 	cmd->buttons |= BT_ATTACK; 
  
     if (gamekeydown[key_use] || joybuttons[joybuse] ) 
-    { 
 	cmd->buttons |= BT_USE;
-	// clear double clicks if hit use button 
-	dclicks = 0;                   
-    } 
 
     // chainsaw overrides 
     for (i=0 ; i<NUMWEAPONS-1 ; i++)        
@@ -348,60 +336,8 @@
 	}
     
     // mouse
-    if (mousebuttons[mousebforward]) 
-	forward += forwardmove[speed];
-    
-    // forward double click
-    if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) 
-    { 
-	dclickstate = mousebuttons[mousebforward]; 
-	if (dclickstate) 
-	    dclicks++; 
-	if (dclicks == 2) 
-	{ 
+    if (mousebuttons[mousebuse])
 	    cmd->buttons |= BT_USE; 
-	    dclicks = 0; 
-	} 
-	else 
-	    dclicktime = 0; 
-    } 
-    else 
-    { 
-	dclicktime += ticdup; 
-	if (dclicktime > 20) 
-	{ 
-	    dclicks = 0; 
-	    dclickstate = 0; 
-	} 
-    }
-    
-    // strafe double click
-    bstrafe =
-	mousebuttons[mousebstrafe] 
-	|| joybuttons[joybstrafe]; 
-    if (bstrafe != dclickstate2 && dclicktime2 > 1 ) 
-    { 
-	dclickstate2 = bstrafe; 
-	if (dclickstate2) 
-	    dclicks2++; 
-	if (dclicks2 == 2) 
-	{ 
-	    cmd->buttons |= BT_USE; 
-	    dclicks2 = 0; 
-	} 
-	else 
-	    dclicktime2 = 0; 
-    } 
-    else 
-    { 
-	dclicktime2 += ticdup; 
-	if (dclicktime2 > 20) 
-	{ 
-	    dclicks2 = 0; 
-	    dclickstate2 = 0; 
-	} 
-    } 
- 
     if (m_forward)
         forward += mousey; 
     if (strafe) 
--- a/sys/src/games/doom/m_misc.c
+++ b/sys/src/games/doom/m_misc.c
@@ -162,7 +162,7 @@
 
 extern int	mousebfire;
 extern int	mousebstrafe;
-extern int	mousebforward;
+extern int	mousebuse;
 extern int  m_forward;
 
 extern int	joybfire;
@@ -220,7 +220,7 @@
     {"use_mouse",&usemouse, 1},
     {"mouseb_fire",&mousebfire,0},
     {"mouseb_strafe",&mousebstrafe,1},
-    {"mouseb_forward",&mousebforward,2},
+    {"mouseb_use",&mousebuse,2},
     {"m_forward",&m_forward, 1},
 
     {"use_joystick",&usejoystick, 0},