From 7373e3e991e3c045e512143cb1d0164bb6c066b6 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Sun, 16 Jun 2002 10:13:02 +0000 Subject: [PATCH] Fixed goldkeys.cfg parser to accept characters which conflicts with the hashed values --- golded3/gckeys.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/golded3/gckeys.cpp b/golded3/gckeys.cpp index ac62973..35664de 100644 --- a/golded3/gckeys.cpp +++ b/golded3/gckeys.cpp @@ -986,9 +986,17 @@ int ReadKeysCfg(int force) { continue; } *ptr++ = NUL; - keycmd = SwitchKeyDefs(strCrc16(strupr(ptr2)), &keytype); - if(keycmd) { - if(keytype) { + // If either straight Key or $Key do not make lookup by CRC + if(*ptr2 == '$') { + uint _keyval = 0; + sscanf(ptr2+1, "%4x", &_keyval); + keyval = (gkey)_keyval; + } + else if(strlen(ptr2) == 1) + keyval = (gkey)tolower(*ptr2); // Always convert to lowercase internally + else { + keycmd = SwitchKeyDefs(strCrc16(strupr(ptr2)), &keytype); + if(not keycmd or keytype) { std::cout << "* " << cfgname << ": Invalid key \"" << ptr2 << "\" in line " << line << "." << std::endl; SayBibi(); cfgerrors++; @@ -996,21 +1004,6 @@ int ReadKeysCfg(int force) { } keyval = keycmd; } - else { // Either straight Key or $Key - if(*ptr2 == '$') { - uint _keyval = 0; - sscanf(ptr2+1, "%4x", &_keyval); - keyval = (gkey)_keyval; - } - else if(strlen(ptr2) == 1) - keyval = (gkey)tolower(*ptr2); // Always convert to lowercase internally - else { - std::cout << "* " << cfgname << ": Invalid key \"" << ptr2 << "\" in line " << line << "." << std::endl; - SayBibi(); - cfgerrors++; - continue; - } - } ptr = strskip_wht(ptr); ptr2 = ptr; ptr = strskip_txt(ptr);