Fixed goldkeys.cfg parser to accept characters which conflicts with the hashed values

This commit is contained in:
Alexander S. Aganichev 2002-06-16 10:13:02 +00:00
parent d6142085f7
commit 7373e3e991

View File

@ -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);