From 789e23b16c34274b77d6decc79f3191ffd9d1390 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 15 May 2021 19:00:40 -0400 Subject: [PATCH] CVar: Ensure m_wasDeserialized set in deferred & command line cases --- DataSpec/DNAMP1/Tweaks/CTweakGame.cpp | 3 +-- hecl/lib/CVar.cpp | 5 +---- hecl/lib/CVarManager.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGame.cpp b/DataSpec/DNAMP1/Tweaks/CTweakGame.cpp index e4bf27155..8b30dbfa1 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGame.cpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGame.cpp @@ -78,8 +78,7 @@ void CTweakGame::initCVars(hecl::CVarManager* mgr) { constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive; CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags); CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags); - CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, - hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive); + CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, skDefaultFlags); CREATE_CVAR(PressStartDelay, "", x30_pressStartDelay, skDefaultFlags); CREATE_CVAR(WavecapIntensityNormal, "", x34_wavecapIntensityNormal, skDefaultFlags); CREATE_CVAR(WavecapIntensityPoison, "", x38_wavecapIntensityPoison, skDefaultFlags); diff --git a/hecl/lib/CVar.cpp b/hecl/lib/CVar.cpp index e323b4a32..3dcf8aa71 100644 --- a/hecl/lib/CVar.cpp +++ b/hecl/lib/CVar.cpp @@ -218,10 +218,7 @@ bool CVar::toBoolean(bool* isValid) const { return false; } - if (isValid != nullptr) - *isValid = true; - - return athena::utility::parseBool(m_value); + return athena::utility::parseBool(m_value, isValid); } int32_t CVar::toSigned(bool* isValid) const { diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 6e691ed01..86b3fab51 100644 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -97,7 +97,11 @@ void CVarManager::deserialize(CVar* cvar) { if (cvar->isBoolean() && val.empty()) { // We were deferred without a value, assume true cvar->fromBoolean(true); - } else if (!val.empty() && cvar->fromLiteralToType(val)) { + cvar->m_wasDeserialized = true; + return; + } + if (!val.empty() && cvar->fromLiteralToType(val)) { + cvar->m_wasDeserialized = true; return; } } @@ -327,6 +331,7 @@ void CVarManager::parseCommandLine(const std::vector& args) { } else if (!cvarValue.empty()) { cv->fromLiteralToType(cvarValue); } + cv->m_wasDeserialized = true; athena::utility::tolower(cvarName); if (developerName == cvarName) /* Make sure we're not overriding developer mode when we restore */