From 6163a9a9173720621f4582be29d0c9a1963c589b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 6 Mar 2021 18:43:47 -0800 Subject: [PATCH] Loosen up blender version requirements, add implicit true to command line boolean CVar --- hecl/lib/Blender/Connection.cpp | 2 +- hecl/lib/CVarManager.cpp | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/hecl/lib/Blender/Connection.cpp b/hecl/lib/Blender/Connection.cpp index 4aff5250d..643d11151 100644 --- a/hecl/lib/Blender/Connection.cpp +++ b/hecl/lib/Blender/Connection.cpp @@ -51,7 +51,7 @@ namespace hecl::blender { static const uint32_t MinBlenderMajorSearch = 2; static const uint32_t MaxBlenderMajorSearch = 2; static const uint32_t MinBlenderMinorSearch = 83; -static const uint32_t MaxBlenderMinorSearch = 91; +static const uint32_t MaxBlenderMinorSearch = 92; logvisor::Module BlenderLog("hecl::blender::Connection"); Token SharedBlenderToken; diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 831014938..29e784dc8 100644 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -19,6 +19,7 @@ CVar* com_enableCheats = nullptr; CVar* com_cubemaps = nullptr; static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)"); +static const std::regex cmdLineRegexNoValue("\\+([\\w\\.]+)"); CVarManager* CVarManager::m_instance = nullptr; static logvisor::Module CVarLog("CVarManager"); @@ -93,8 +94,12 @@ void CVarManager::deserialize(CVar* cvar) { if (const auto iter = m_deferedCVars.find(lowName); iter != m_deferedCVars.end()) { std::string val = std::move(iter->second); m_deferedCVars.erase(lowName); - if (cvar->fromLiteralToType(val)) + if (cvar->isBoolean() && val.empty()) { + // We were deferred without a value, assume true + cvar->fromBoolean(true); + } else if (!val.empty() && cvar->fromLiteralToType(val)) { return; + } } /* Enforce isArchive and isInternalArchivable now that we've checked if it's been deferred */ @@ -300,14 +305,28 @@ void CVarManager::parseCommandLine(const std::vector& args) { const std::string tmp(SystemUTF8Conv(arg).str()); std::smatch matches; + std::string cvarName; + std::string cvarValue; + if (!std::regex_match(tmp, matches, cmdLineRegex)) { - continue; + if (std::regex_match(tmp, matches, cmdLineRegexNoValue)) { + // No Value was supplied, assume the player wanted to set value to 1 + cvarName = matches[1].str(); + } else { + continue; + } + } else { + cvarName = matches[1].str(); + cvarValue = matches[2].str(); } - std::string cvarName = matches[1].str(); - std::string cvarValue = matches[2].str(); if (CVar* cv = findCVar(cvarName)) { - cv->fromLiteralToType(cvarValue); + if (cvarValue.empty() && cv->isBoolean()) { + // We were set from the command line with an empty value, assume true + cv->fromBoolean(true); + } else if (!cvarValue.empty()) { + cv->fromLiteralToType(cvarValue); + } athena::utility::tolower(cvarName); if (developerName == cvarName) /* Make sure we're not overriding developer mode when we restore */