MP1: Convert MP1_VARIABLE_DELTA_TIME to cvar

This commit is contained in:
Luke Street 2020-04-14 14:40:49 -04:00
parent 3c8ce3dc99
commit 94be460a1b
3 changed files with 11 additions and 15 deletions

View File

@ -74,6 +74,7 @@ namespace hecl {
extern CVar* com_enableCheats;
extern CVar* com_developer;
extern CVar* com_cubemaps;
extern CVar* com_variableDt;
}; // namespace hecl
namespace urde::MP1 {
@ -838,16 +839,16 @@ bool CMain::Proc() {
}
float dt = 1 / 60.f;
#if MP1_VARIABLE_DELTA_TIME
auto now = delta_clock::now();
if (m_firstFrame) {
m_firstFrame = false;
} else {
using delta_duration = std::chrono::duration<float, std::ratio<1>>;
dt = std::min(std::chrono::duration_cast<delta_duration>(now - m_prevFrameTime).count(), 1 / 30.f);
if (hecl::com_variableDt->toBoolean()) {
auto now = delta_clock::now();
if (m_firstFrame) {
m_firstFrame = false;
} else {
using delta_duration = std::chrono::duration<float, std::ratio<1>>;
dt = std::min(std::chrono::duration_cast<delta_duration>(now - m_prevFrameTime).count(), 1 / 30.f);
}
m_prevFrameTime = now;
}
m_prevFrameTime = now;
#endif
m_console->proc();
if (!m_console->isOpen()) {

View File

@ -3,9 +3,6 @@
#ifndef MP1_USE_BOO
#define MP1_USE_BOO 0
#endif
#ifndef MP1_VARIABLE_DELTA_TIME
#define MP1_VARIABLE_DELTA_TIME 0
#endif
#include "IMain.hpp"
#include "CTweaks.hpp"
@ -250,11 +247,9 @@ private:
bool m_loadedPersistentResources = false;
bool m_doQuit = false;
#if MP1_VARIABLE_DELTA_TIME
bool m_firstFrame = true;
using delta_clock = std::chrono::high_resolution_clock;
std::chrono::time_point<delta_clock> m_prevFrameTime;
#endif
void InitializeSubsystems();
static void InitializeDiscord();

2
hecl

@ -1 +1 @@
Subproject commit f64ed44fe8164b06ed5bef6344d9f743e2c5d638
Subproject commit 90366475c1d45b53f080f57dd7e5626145fdd649