From 2146eaa094f6b09a5b8460d4c2b6f9737fde9628 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 26 Jul 2007 21:10:27 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1183 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/console.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/source/src/console.cpp b/source/src/console.cpp index 9753fdac..c8e59891 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -101,9 +101,6 @@ struct keym }; vector keyms; -keym *keypressed = NULL; -char *keyaction = NULL; - void keymap(char *code, char *key, char *action) { keym &km = keyms.add(); @@ -114,17 +111,21 @@ void keymap(char *code, char *key, char *action) COMMAND(keymap, ARG_3STR); +keym *findbind(char *key) +{ + loopv(keyms) if(!strcasecmp(keyms[i].name, key)) return &keyms[i]; + return NULL; +} + +keym *keypressed = NULL; +char *keyaction = NULL; + void bindkey(char *key, char *action) { - for(char *x = key; *x; x++) *x = toupper(*x); - loopv(keyms) if(!strcmp(keyms[i].name, key)) - { - keym &km = keyms[i]; - if(!keypressed || keyaction!=km.action) delete[] km.action; - km.action = newstring(action); - return; - } - conoutf("unknown key \"%s\"", key); + keym *km = findbind(key); + if(!km) { conoutf("unknown key \"%s\"", key); return; } + if(!keypressed || keyaction!=km->action) delete[] km->action; + km->action = newstring(action); } COMMANDN(bind, bindkey, ARG_2STR);