r1053 - trunk/code/client
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Mar 22 18:03:00 EDT 2007
Author: tjw
Date: 2007-03-22 18:03:00 -0400 (Thu, 22 Mar 2007)
New Revision: 1053
Modified:
trunk/code/client/cl_keys.c
trunk/code/client/keycodes.h
trunk/code/client/keys.h
Log:
* (bug 2741) replace K_LAST_KEY with MAX_KEYS. K_LAST_KEY is now defined
at 256 for mod compatability reasons. ioq3-only mods may
chose to use MAX_KEYS for checking binds in order to get full
key support, but at the cost of breaking compatability with
older clients.
* (bug 2741) remove some lingering 256-key hardcoding
* properly check bounds of keynum in Key_IsDown(), Key_SetBinding(),
and Key_GetBinding()
Modified: trunk/code/client/cl_keys.c
===================================================================
--- trunk/code/client/cl_keys.c 2007-03-19 21:50:42 UTC (rev 1052)
+++ trunk/code/client/cl_keys.c 2007-03-22 22:03:00 UTC (rev 1053)
@@ -782,7 +782,7 @@
===================
*/
qboolean Key_IsDown( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return qfalse;
}
@@ -902,7 +902,7 @@
===================
*/
void Key_SetBinding( int keynum, const char *binding ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return;
}
@@ -926,7 +926,7 @@
===================
*/
char *Key_GetBinding( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return "";
}
@@ -943,7 +943,7 @@
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;
}
@@ -986,7 +986,7 @@
{
int i;
- for (i=0 ; i<256 ; i++)
+ for (i=0 ; i < MAX_KEYS; i++)
if (keys[i].binding)
Key_SetBinding (i, "");
}
Modified: trunk/code/client/keycodes.h
===================================================================
--- trunk/code/client/keycodes.h 2007-03-19 21:50:42 UTC (rev 1052)
+++ trunk/code/client/keycodes.h 2007-03-22 22:03:00 UTC (rev 1053)
@@ -260,9 +260,13 @@
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
Modified: trunk/code/client/keys.h
===================================================================
--- trunk/code/client/keys.h 2007-03-19 21:50:42 UTC (rev 1052)
+++ trunk/code/client/keys.h 2007-03-22 22:03:00 UTC (rev 1053)
@@ -21,8 +21,6 @@
*/
#include "keycodes.h"
-#define MAX_KEYS 384
-
typedef struct {
qboolean down;
int repeats; // if > 1, it is autorepeating
More information about the quake3-commits
mailing list