CTimeProvider: Move global instance to cpp file

This isn't used anywhere externally, so we can keep it hidden in the cpp
file.
This commit is contained in:
Lioncash 2020-04-26 03:05:18 -04:00
parent 002102c530
commit deff9d054b
2 changed files with 12 additions and 11 deletions

View File

@ -3,21 +3,24 @@
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
namespace urde { namespace urde {
CTimeProvider* CTimeProvider::g_currentTimeProvider = nullptr; static CTimeProvider* s_currentTimeProvider = nullptr;
CTimeProvider::CTimeProvider(const float& time) : x0_currentTime(time), x8_lastProvider(g_currentTimeProvider) {
if (x8_lastProvider != nullptr)
x8_lastProvider->x4_first = false;
g_currentTimeProvider = this; CTimeProvider::CTimeProvider(const float& time) : x0_currentTime(time), x8_lastProvider(s_currentTimeProvider) {
if (x8_lastProvider != nullptr) {
x8_lastProvider->x4_first = false;
}
s_currentTimeProvider = this;
CGraphics::SetExternalTimeProvider(this); CGraphics::SetExternalTimeProvider(this);
} }
CTimeProvider::~CTimeProvider() { CTimeProvider::~CTimeProvider() {
g_currentTimeProvider = x8_lastProvider; s_currentTimeProvider = x8_lastProvider;
if (g_currentTimeProvider) if (s_currentTimeProvider != nullptr) {
g_currentTimeProvider->x4_first = true; s_currentTimeProvider->x4_first = true;
CGraphics::SetExternalTimeProvider(g_currentTimeProvider); }
CGraphics::SetExternalTimeProvider(s_currentTimeProvider);
} }
} // namespace urde } // namespace urde

View File

@ -1,9 +1,7 @@
#pragma once #pragma once
namespace urde { namespace urde {
class CTimeProvider;
class CTimeProvider { class CTimeProvider {
public: public:
static CTimeProvider* g_currentTimeProvider;
const float& x0_currentTime; // in seconds const float& x0_currentTime; // in seconds
bool x4_first = true; bool x4_first = true;
CTimeProvider* x8_lastProvider = nullptr; CTimeProvider* x8_lastProvider = nullptr;