]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
fixed a silly and harmless typo in RSurfShader_Water (*chain++ should have been chain++)
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index 9b4380a9788edfed646805fd8d60c9f03856dba2..eacffff03444352a4069f3d23cccd08593f8363b 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -211,7 +211,7 @@ void Key_Console (int key)
 
        if (key == K_DEL)               // delete char on cursor
        {
-               if (key_linepos < strlen(key_lines[edit_line]))
+               if ((size_t)key_linepos < strlen(key_lines[edit_line]))
                        strcpy(key_lines[edit_line] + key_linepos, key_lines[edit_line] + key_linepos + 1);
                return;
        }
@@ -221,9 +221,9 @@ void Key_Console (int key)
        // otherwise just go right one
        if (key == K_RIGHTARROW)
        {
-               if (strlen(key_lines[edit_line]) == key_linepos)
+               if (strlen(key_lines[edit_line]) == (size_t)key_linepos)
                {
-                       if (strlen(key_lines[(edit_line + 31) & 31]) <= key_linepos)
+                       if (strlen(key_lines[(edit_line + 31) & 31]) <= (size_t)key_linepos)
                                return; // no character to get
 
                        key_lines[edit_line][key_linepos] = key_lines[(edit_line + 31) & 31][key_linepos];
@@ -282,7 +282,7 @@ void Key_Console (int key)
 
        if (key == K_PGUP || key==K_MWHEELUP)
        {
-               con_backscroll += 2;
+               con_backscroll += ((int) scr_conlines >> 4);
                if (con_backscroll > con_totallines - (vid.conheight>>3) - 1)
                        con_backscroll = con_totallines - (vid.conheight>>3) - 1;
                return;
@@ -290,7 +290,7 @@ void Key_Console (int key)
 
        if (key == K_PGDN || key==K_MWHEELDOWN)
        {
-               con_backscroll -= 2;
+               con_backscroll -= ((int) scr_conlines >> 4);
                if (con_backscroll < 0)
                        con_backscroll = 0;
                return;
@@ -405,9 +405,9 @@ the given string.  Single ascii characters return themselves, while
 the K_* names are matched up.
 ===================
 */
-int Key_StringToKeynum (char *str)
+int Key_StringToKeynum (const char *str)
 {
-       keyname_t       *kn;
+       keyname_t *kn;
 
        if (!str || !str[0])
                return -1;
@@ -415,10 +415,8 @@ int Key_StringToKeynum (char *str)
                return str[0];
 
        for (kn=keynames ; kn->name ; kn++)
-       {
                if (!Q_strcasecmp(str,kn->name))
                        return kn->keynum;
-       }
        return -1;
 }
 
@@ -433,8 +431,8 @@ FIXME: handle quote special (general escape sequence?)
 */
 char *Key_KeynumToString (int keynum)
 {
-       keyname_t       *kn;
-       static  char    tinystr[2];
+       keyname_t *kn;
+       static char tinystr[2];
 
        if (keynum == -1)
                return "<KEY NOT FOUND>";
@@ -444,7 +442,7 @@ char *Key_KeynumToString (int keynum)
                tinystr[1] = 0;
                return tinystr;
        }
-       
+
        for (kn=keynames ; kn->name ; kn++)
                if (keynum == kn->keynum)
                        return kn->name;
@@ -463,7 +461,7 @@ void Key_SetBinding (int keynum, char *binding)
        char    *new;
        int             l;
                        
-       if (keynum == -1)
+       if (keynum < 0 || keynum >= 256)
                return;
 
 // free old bindings