From 61f744e15d4e17266dd8fea8fb8ec71adac38cce Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 12 Jun 2018 20:19:08 -0700 Subject: [PATCH] Defer values for unregistered CVars --- hecl/include/hecl/CVarManager.hpp | 1 + hecl/lib/CVarManager.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hecl/include/hecl/CVarManager.hpp b/hecl/include/hecl/CVarManager.hpp index 08de2a389..8f2714cee 100755 --- a/hecl/include/hecl/CVarManager.hpp +++ b/hecl/include/hecl/CVarManager.hpp @@ -84,6 +84,7 @@ private: void restoreDeveloper(bool oldDeveloper); std::unordered_map> m_cvars; + std::unordered_map m_deferedCVars; }; } diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 40aea8426..d6d0bcf2d 100755 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -77,7 +77,22 @@ std::vector CVarManager::cvars(CVar::EFlags filter) const void CVarManager::deserialize(CVar* cvar) { - if (!cvar || (!cvar->isArchive() && !cvar->isInternalArchivable())) + if (!cvar) + return; + + /* First let's check for a deferred value */ + std::string lowName = cvar->name().data(); + athena::utility::tolower(lowName); + if (m_deferedCVars.find(lowName) != m_deferedCVars.end()) + { + std::string val = m_deferedCVars[lowName]; + m_deferedCVars.erase(lowName); + if (cvar->fromLiteralToType(val)) + return; + } + + /* We were either unable to find a deferred value or got an invalid value */ + if (!cvar->isArchive() && !cvar->isInternalArchivable()) return; #if _WIN32 @@ -305,6 +320,12 @@ void CVarManager::parseCommandLine(const std::vector& args) /* Make sure we're not overriding developer mode when we restore */ oldDeveloper = com_developer->toBoolean(); } + else + { + /* Unable to find an existing CVar, let's defer for the time being 8 */ + athena::utility::tolower(cvarName); + m_deferedCVars[cvarName] = cvarValue; + } } } }