Add variableDt cvar

This commit is contained in:
Luke Street 2020-04-14 14:40:03 -04:00
parent 776e9394ac
commit aba42eba52
2 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,7 @@ extern CVar* com_developer;
extern CVar* com_configfile; extern CVar* com_configfile;
extern CVar* com_enableCheats; extern CVar* com_enableCheats;
extern CVar* com_cubemaps; extern CVar* com_cubemaps;
extern CVar* com_variableDt;
class CVarManager final { class CVarManager final {
using CVarContainer = DNACVAR::CVarContainer; using CVarContainer = DNACVAR::CVarContainer;
template <typename T> template <typename T>
@ -105,6 +106,7 @@ public:
void setDeveloperMode(bool v, bool setDeserialized = false); void setDeveloperMode(bool v, bool setDeserialized = false);
void setCheatsEnabled(bool v, bool setDeserialized = false); void setCheatsEnabled(bool v, bool setDeserialized = false);
void setVariableDtEnabled(bool v, bool setDeserialized = false);
bool restartRequired() const; bool restartRequired() const;
void parseCommandLine(const std::vector<SystemString>& args); void parseCommandLine(const std::vector<SystemString>& args);

View File

@ -17,6 +17,7 @@ CVar* com_developer = nullptr;
CVar* com_configfile = nullptr; CVar* com_configfile = nullptr;
CVar* com_enableCheats = nullptr; CVar* com_enableCheats = nullptr;
CVar* com_cubemaps = nullptr; CVar* com_cubemaps = nullptr;
CVar* com_variableDt = nullptr;
static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)"); static const std::regex cmdLineRegex("\\+([\\w\\.]+)=([\\w\\.\\-]+)");
CVarManager* CVarManager::m_instance = nullptr; CVarManager* CVarManager::m_instance = nullptr;
@ -35,6 +36,8 @@ CVarManager::CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary)
(CVar::EFlags::System | CVar::EFlags::ReadOnly | CVar::EFlags::Hidden | CVar::EFlags::InternalArchivable)); (CVar::EFlags::System | CVar::EFlags::ReadOnly | CVar::EFlags::Hidden | CVar::EFlags::InternalArchivable));
com_cubemaps = newCVar("cubemaps", "Enable cubemaps", false, com_cubemaps = newCVar("cubemaps", "Enable cubemaps", false,
(CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable)); (CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable));
com_variableDt = newCVar("variableDt", "Enable variable delta time (experimental)", false,
(CVar::EFlags::Game | CVar::EFlags::ReadOnly | CVar::EFlags::InternalArchivable));
} }
CVarManager::~CVarManager() {} CVarManager::~CVarManager() {}
@ -276,6 +279,15 @@ void CVarManager::setCheatsEnabled(bool v, bool setDeserialized) {
com_enableCheats->setModified(); com_enableCheats->setModified();
} }
void CVarManager::setVariableDtEnabled(bool v, bool setDeserialized) {
com_variableDt->unlock();
com_variableDt->fromBoolean(v);
if (setDeserialized)
com_variableDt->m_wasDeserialized = true;
com_variableDt->lock();
com_variableDt->setModified();
}
bool CVarManager::restartRequired() const { bool CVarManager::restartRequired() const {
return std::any_of(m_cvars.cbegin(), m_cvars.cend(), [](const auto& entry) { return std::any_of(m_cvars.cbegin(), m_cvars.cend(), [](const auto& entry) {
return entry.second->isModified() && entry.second->modificationRequiresRestart(); return entry.second->isModified() && entry.second->modificationRequiresRestart();