Defer values for unregistered CVars

This commit is contained in:
Phillip Stephens 2018-06-12 20:19:08 -07:00
parent 801214d9a8
commit 61f744e15d
2 changed files with 23 additions and 1 deletions

View File

@ -84,6 +84,7 @@ private:
void restoreDeveloper(bool oldDeveloper); void restoreDeveloper(bool oldDeveloper);
std::unordered_map<std::string, std::unique_ptr<CVar>> m_cvars; std::unordered_map<std::string, std::unique_ptr<CVar>> m_cvars;
std::unordered_map<std::string, std::string> m_deferedCVars;
}; };
} }

View File

@ -77,7 +77,22 @@ std::vector<CVar*> CVarManager::cvars(CVar::EFlags filter) const
void CVarManager::deserialize(CVar* cvar) 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; return;
#if _WIN32 #if _WIN32
@ -305,6 +320,12 @@ void CVarManager::parseCommandLine(const std::vector<SystemString>& args)
/* Make sure we're not overriding developer mode when we restore */ /* Make sure we're not overriding developer mode when we restore */
oldDeveloper = com_developer->toBoolean(); 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;
}
} }
} }
} }