Add invalid mod warn

This commit is contained in:
vaxerski 2022-05-12 12:41:28 +02:00
parent 0de058beb1
commit 2a368ef994

View file

@ -284,6 +284,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
auto valueCopy = value; auto valueCopy = value;
const auto MOD = g_pKeybindManager->stringToModMask(valueCopy.substr(0, valueCopy.find_first_of(","))); const auto MOD = g_pKeybindManager->stringToModMask(valueCopy.substr(0, valueCopy.find_first_of(",")));
const auto MODSTR = valueCopy.substr(0, valueCopy.find_first_of(","));
valueCopy = valueCopy.substr(valueCopy.find_first_of(",") + 1); valueCopy = valueCopy.substr(valueCopy.find_first_of(",") + 1);
const auto KEY = valueCopy.substr(0, valueCopy.find_first_of(",")); const auto KEY = valueCopy.substr(0, valueCopy.find_first_of(","));
@ -302,6 +303,12 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
return; return;
} }
if (MOD == 0 && MODSTR != "") {
Debug::log(ERR, "Invalid mod!");
parseError = "Invalid mod, requested mod \"" + MODSTR + "\" is not a valid mod.";
return;
}
if (KEY != "") if (KEY != "")
g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND}); g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND});
} }