summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/cl_keys.c10
-rw-r--r--src/client/keycodes.h6
-rw-r--r--src/client/keys.h2
3 files changed, 10 insertions, 8 deletions
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c
index c768e743..fe88526a 100644
--- a/src/client/cl_keys.c
+++ b/src/client/cl_keys.c
@@ -783,7 +783,7 @@ Key_IsDown
===================
*/
qboolean Key_IsDown( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return qfalse;
}
@@ -903,7 +903,7 @@ Key_SetBinding
===================
*/
void Key_SetBinding( int keynum, const char *binding ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return;
}
@@ -927,7 +927,7 @@ Key_GetBinding
===================
*/
char *Key_GetBinding( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return "";
}
@@ -944,7 +944,7 @@ int Key_GetKey(const char *binding) {
int i;
if (binding) {
- for (i=0 ; i<256 ; i++) {
+ for (i=0 ; i < MAX_KEYS ; i++) {
if (keys[i].binding && Q_stricmp(binding, keys[i].binding) == 0) {
return i;
}
@@ -987,7 +987,7 @@ void Key_Unbindall_f (void)
{
int i;
- for (i=0 ; i<256 ; i++)
+ for (i=0 ; i < MAX_KEYS; i++)
if (keys[i].binding)
Key_SetBinding (i, "");
}
diff --git a/src/client/keycodes.h b/src/client/keycodes.h
index b18c04f6..ae6f189d 100644
--- a/src/client/keycodes.h
+++ b/src/client/keycodes.h
@@ -262,9 +262,13 @@ typedef enum {
K_EURO,
K_UNDO,
- K_LAST_KEY // this had better be < MAX_KEYS!
+ MAX_KEYS
} keyNum_t;
+// MAX_KEYS replaces K_LAST_KEY, however some mods may have used K_LAST_KEY
+// in detecting binds, so we leave it defined to the old hardcoded value
+// of maxiumum keys to prevent mods from crashing older versions of the engine
+#define K_LAST_KEY 256
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
diff --git a/src/client/keys.h b/src/client/keys.h
index c768fc99..3c3fe802 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -22,8 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "keycodes.h"
-#define MAX_KEYS 384
-
typedef struct {
qboolean down;
int repeats; // if > 1, it is autorepeating