Loosen up blender version requirements, add implicit true to command line boolean CVar

This commit is contained in:
Phillip Stephens 2021-03-06 18:43:47 -08:00
parent eb40c8843f
commit 6163a9a917
2 changed files with 25 additions and 6 deletions

View File

@ -51,7 +51,7 @@ namespace hecl::blender {
static const uint32_t MinBlenderMajorSearch = 2; static const uint32_t MinBlenderMajorSearch = 2;
static const uint32_t MaxBlenderMajorSearch = 2; static const uint32_t MaxBlenderMajorSearch = 2;
static const uint32_t MinBlenderMinorSearch = 83; static const uint32_t MinBlenderMinorSearch = 83;
static const uint32_t MaxBlenderMinorSearch = 91; static const uint32_t MaxBlenderMinorSearch = 92;
logvisor::Module BlenderLog("hecl::blender::Connection"); logvisor::Module BlenderLog("hecl::blender::Connection");
Token SharedBlenderToken; Token SharedBlenderToken;

View File

@ -19,6 +19,7 @@ CVar* com_enableCheats = nullptr;
CVar* com_cubemaps = nullptr; CVar* com_cubemaps = nullptr;
static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)"); static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)");
static const std::regex cmdLineRegexNoValue("\\+([\\w\\.]+)");
CVarManager* CVarManager::m_instance = nullptr; CVarManager* CVarManager::m_instance = nullptr;
static logvisor::Module CVarLog("CVarManager"); static logvisor::Module CVarLog("CVarManager");
@ -93,9 +94,13 @@ void CVarManager::deserialize(CVar* cvar) {
if (const auto iter = m_deferedCVars.find(lowName); iter != m_deferedCVars.end()) { if (const auto iter = m_deferedCVars.find(lowName); iter != m_deferedCVars.end()) {
std::string val = std::move(iter->second); std::string val = std::move(iter->second);
m_deferedCVars.erase(lowName); 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; return;
} }
}
/* Enforce isArchive and isInternalArchivable now that we've checked if it's been deferred */ /* Enforce isArchive and isInternalArchivable now that we've checked if it's been deferred */
if (!cvar->isArchive() && !cvar->isInternalArchivable()) { if (!cvar->isArchive() && !cvar->isInternalArchivable()) {
@ -300,14 +305,28 @@ void CVarManager::parseCommandLine(const std::vector<SystemString>& args) {
const std::string tmp(SystemUTF8Conv(arg).str()); const std::string tmp(SystemUTF8Conv(arg).str());
std::smatch matches; std::smatch matches;
std::string cvarName;
std::string cvarValue;
if (!std::regex_match(tmp, matches, cmdLineRegex)) { 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
cvarName = matches[1].str();
} else {
continue; 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)) { if (CVar* cv = findCVar(cvarName)) {
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); cv->fromLiteralToType(cvarValue);
}
athena::utility::tolower(cvarName); athena::utility::tolower(cvarName);
if (developerName == cvarName) if (developerName == cvarName)
/* Make sure we're not overriding developer mode when we restore */ /* Make sure we're not overriding developer mode when we restore */