]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
Added libcurl.[ch] to MSVC project files
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index 8bdc4e1de06e8b2a3c910d63a9136ff74aea1215..93ddfadaf729da136fc77971f65d65a44cfdb56c 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -21,7 +21,7 @@
 */
 
 #include "quakedef.h"
-
+#include "cl_video.h"
 
 /*
 key up events are sent even if in console mode
@@ -596,7 +596,7 @@ Key_SetBinding (int keynum, int bindmap, const char *binding)
        char *newbinding;
        size_t l;
 
-       if (keynum == -1)
+       if (keynum == -1 || keynum >= MAX_KEYS)
                return;
 
 // free old bindings
@@ -657,7 +657,7 @@ Key_In_Bind_f (void)
        }
 
        b = Key_StringToKeynum (Cmd_Argv (2));
-       if (b == -1) {
+       if (b == -1 || b >= MAX_KEYS) {
                Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (2));
                return;
        }
@@ -752,7 +752,7 @@ Key_Bind_f (void)
                return;
        }
        b = Key_StringToKeynum (Cmd_Argv (1));
-       if (b == -1) {
+       if (b == -1 || b >= MAX_KEYS) {
                Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (1));
                return;
        }
@@ -823,6 +823,8 @@ Key_Init (void)
 const char *Key_GetBind (int key)
 {
        const char *bind;
+       if (key < 0 || key >= MAX_KEYS)
+               return NULL;
        bind = keybindings[key_bmap][key];
        if (!bind)
                bind = keybindings[key_bmap2][key];
@@ -843,6 +845,9 @@ Key_Event (int key, char ascii, qboolean down)
        const char *bind;
        qboolean q;
 
+       if (key < 0 || key >= MAX_KEYS)
+               return;
+
        // get key binding
        bind = keybindings[key_bmap][key];
        if (!bind)
@@ -959,6 +964,13 @@ Key_Event (int key, char ascii, qboolean down)
                return;
        }
 
+       // ignore binds while a video is played, let the video system handle the key event
+       if (cl_videoplaying)
+       {
+               CL_Video_KeyEvent (key, ascii, keydown[key] != 0);
+               return;
+       }
+
        // anything else is a key press into the game, chat line, or menu
        switch (key_dest)
        {