shithub: choc

Download patch

ref: e32215d28ef9e0ed883c5e78e43101c9f0958570
parent: f6912e1de63e3e5e0cf842afeebeec393546e5cc
author: Simon Howard <[email protected]>
date: Tue Jun 9 16:22:12 EDT 2009

Make Heretic weapon keys reconfigurable.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1584

--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -743,6 +743,7 @@
 
     M_BindBaseControls();
     M_BindHereticControls();
+    M_BindWeaponControls();
 
     M_BindMenuControls();
     M_BindMapControls();
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -147,6 +147,17 @@
 fixed_t sidemove[2] = { 0x18, 0x28 };
 fixed_t angleturn[3] = { 640, 1280, 320 };      // + slow turn
 
+static int *weapon_keys[] =
+{
+    &key_weapon1,
+    &key_weapon2,
+    &key_weapon3,
+    &key_weapon4,
+    &key_weapon5,
+    &key_weapon6,
+    &key_weapon7
+};
+
 #define SLOWTURNTICS    6
 
 #define NUMKEYS 256
@@ -393,15 +404,18 @@
         dclicks = 0;            // clear double clicks if hit use button
     }
 
-    for (i = 0; i < NUMWEAPONS - 2; i++)
+    for (i=0; i<arrlen(weapon_keys); ++i)
     {
-        if (gamekeydown['1' + i])
+        int key = *weapon_keys[i];
+
+        if (gamekeydown[key])
         {
-            cmd->buttons |= BT_CHANGE;
-            cmd->buttons |= i << BT_WEAPONSHIFT;
-            break;
+	    cmd->buttons |= BT_CHANGE; 
+	    cmd->buttons |= i<<BT_WEAPONSHIFT; 
+	    break; 
         }
     }
+    
 
 //
 // mouse