CVar: Ensure m_wasDeserialized set in deferred & command line cases

This commit is contained in:
Luke Street 2021-05-15 19:00:40 -04:00
parent e9b4cce6db
commit 789e23b16c
3 changed files with 8 additions and 7 deletions

View File

@ -78,8 +78,7 @@ void CTweakGame::initCVars(hecl::CVarManager* mgr) {
constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive; constexpr hecl::CVar::EFlags skDefaultFlags = hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive;
CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags); CREATE_CVAR(WorldPrefix, "", x4_worldPrefix, skDefaultFlags);
CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags); CREATE_CVAR(FieldOfView, "", x24_fov, skDefaultFlags);
CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, CREATE_CVAR(SplashScreensDisabled, "", x2b_splashScreensDisabled, skDefaultFlags);
hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive);
CREATE_CVAR(PressStartDelay, "", x30_pressStartDelay, skDefaultFlags); CREATE_CVAR(PressStartDelay, "", x30_pressStartDelay, skDefaultFlags);
CREATE_CVAR(WavecapIntensityNormal, "", x34_wavecapIntensityNormal, skDefaultFlags); CREATE_CVAR(WavecapIntensityNormal, "", x34_wavecapIntensityNormal, skDefaultFlags);
CREATE_CVAR(WavecapIntensityPoison, "", x38_wavecapIntensityPoison, skDefaultFlags); CREATE_CVAR(WavecapIntensityPoison, "", x38_wavecapIntensityPoison, skDefaultFlags);

View File

@ -218,10 +218,7 @@ bool CVar::toBoolean(bool* isValid) const {
return false; return false;
} }
if (isValid != nullptr) return athena::utility::parseBool(m_value, isValid);
*isValid = true;
return athena::utility::parseBool(m_value);
} }
int32_t CVar::toSigned(bool* isValid) const { int32_t CVar::toSigned(bool* isValid) const {

View File

@ -97,7 +97,11 @@ void CVarManager::deserialize(CVar* cvar) {
if (cvar->isBoolean() && val.empty()) { if (cvar->isBoolean() && val.empty()) {
// We were deferred without a value, assume true // We were deferred without a value, assume true
cvar->fromBoolean(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; return;
} }
} }
@ -327,6 +331,7 @@ void CVarManager::parseCommandLine(const std::vector<SystemString>& args) {
} else if (!cvarValue.empty()) { } else if (!cvarValue.empty()) {
cv->fromLiteralToType(cvarValue); cv->fromLiteralToType(cvarValue);
} }
cv->m_wasDeserialized = true;
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 */