Remove regex hack in CVarManager, support filepaths in arguments

This commit is contained in:
Phillip Stephens 2021-06-02 06:01:27 -07:00
parent 281da0bfd4
commit 65c989d463
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 6 additions and 10 deletions

View File

@ -18,8 +18,7 @@ CVar* com_configfile = nullptr;
CVar* com_enableCheats = nullptr;
CVar* com_cubemaps = nullptr;
static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)");
static const std::regex cmdLineRegexNoValue("\\+([\\w\\.]+)");
static const std::regex cmdLineRegex(R"(\+([\w\.]+)([=])?([\"\/\\\s\w\.\-]+)?)");
CVarManager* CVarManager::m_instance = nullptr;
static logvisor::Module CVarLog("CVarManager");
@ -312,16 +311,13 @@ void CVarManager::parseCommandLine(const std::vector<SystemString>& args) {
std::string cvarName;
std::string cvarValue;
if (!std::regex_match(tmp, matches, cmdLineRegex)) {
if (std::regex_match(tmp, matches, cmdLineRegexNoValue)) {
// No Value was supplied, assume the player wanted to set value to 1
if (std::regex_match(tmp, matches, cmdLineRegex)) {
if (matches.size() == 3) {
cvarName = matches[1].str();
} else {
continue;
} else if (matches.size() == 4) {
cvarName = matches[1].str();
cvarValue = matches[3].str();
}
} else {
cvarName = matches[1].str();
cvarValue = matches[2].str();
}
if (CVar* cv = findCVar(cvarName)) {