boolean B_ParseKeyId(const char* desc, int* id) { // The possibilies: symbolic key name, or "codeNNN". if(!strncasecmp(desc, "code", 4) && strlen(desc) == 7) { if(desc[4] == 'x' || desc[4] == 'X') { // Hexadecimal. *id = strtoul(desc + 5, NULL, 16); } else { // Decimal. *id = strtoul(desc + 4, NULL, 10); if(*id <= 0 || *id > 255) { Con_Message("B_ParseKeyId: Key code %i out of range.", *id); return false; } } } else { // Symbolic key name. *id = B_KeyForShortName(desc); if(!*id) { Con_Message("B_ParseKeyId: Unknown key \"%s\".", desc); return false; } } return true; }
dd_bool B_ParseKeyId(const char* desc, int* id) { LOG_AS("B_ParseKeyId"); // The possibilies: symbolic key name, or "codeNNN". if(!strncasecmp(desc, "code", 4) && strlen(desc) == 7) { if(desc[4] == 'x' || desc[4] == 'X') { // Hexadecimal. *id = strtoul(desc + 5, NULL, 16); } else { // Decimal. *id = strtoul(desc + 4, NULL, 10); if(*id <= 0 || *id > 255) { LOGDEV_INPUT_WARNING("Key code %i out of range") << *id; return false; } } } else { // Symbolic key name. *id = B_KeyForShortName(desc); if(!*id) { LOG_INPUT_WARNING("Unknown key \"%s\"") << desc; return false; } } return true; }