From a96601f1b44ed6310db083bc50c107152839d285 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 7 Feb 2016 08:15:43 -0800 Subject: [PATCH] Rename globals --- Runtime/CRandom16.cpp | 4 ++-- Runtime/CRandom16.hpp | 14 +++++++------- Runtime/CTimeProvider.cpp | 12 +++++------- Runtime/CTimeProvider.hpp | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Runtime/CRandom16.cpp b/Runtime/CRandom16.cpp index 76aecd774..5f61e848e 100644 --- a/Runtime/CRandom16.cpp +++ b/Runtime/CRandom16.cpp @@ -3,7 +3,7 @@ namespace Retro { -CRandom16* GLOBAL_RANDOM = nullptr; -CGlobalRandom* GLOBAL_RANDOM_TOKEN = nullptr; +CRandom16* CRandom16::g_randomNumber = nullptr; +CGlobalRandom* CGlobalRandom::g_currentGlobalRandom = nullptr; } diff --git a/Runtime/CRandom16.hpp b/Runtime/CRandom16.hpp index cfac70aa6..96d8cfb6e 100644 --- a/Runtime/CRandom16.hpp +++ b/Runtime/CRandom16.hpp @@ -6,12 +6,11 @@ namespace Retro { -extern class CRandom16* GLOBAL_RANDOM; -extern class CGlobalRandom* GLOBAL_RANDOM_TOKEN; class CRandom16 { u32 m_seed; + static CRandom16* g_randomNumber; public: CRandom16(u32 p) : m_seed(p) {} @@ -50,24 +49,25 @@ public: return rand % diff + min; } - static CRandom16* GetRandomNumber() {return GLOBAL_RANDOM;} - static void SetRandomNumber(CRandom16* rnd) {GLOBAL_RANDOM = rnd;} + static CRandom16* GetRandomNumber() {return g_randomNumber;} + static void SetRandomNumber(CRandom16* rnd) {g_randomNumber = rnd;} }; class CGlobalRandom { CRandom16& m_random; CGlobalRandom* m_prev; + static CGlobalRandom* g_currentGlobalRandom; public: CGlobalRandom(CRandom16& rand) - : m_random(rand), m_prev(GLOBAL_RANDOM_TOKEN) + : m_random(rand), m_prev(g_currentGlobalRandom) { - GLOBAL_RANDOM_TOKEN = this; + g_currentGlobalRandom = this; CRandom16::SetRandomNumber(&m_random); } ~CGlobalRandom() { - GLOBAL_RANDOM_TOKEN = m_prev; + g_currentGlobalRandom = m_prev; if (m_prev) CRandom16::SetRandomNumber(&m_prev->m_random); else diff --git a/Runtime/CTimeProvider.cpp b/Runtime/CTimeProvider.cpp index 49f8e7803..77e469eb0 100644 --- a/Runtime/CTimeProvider.cpp +++ b/Runtime/CTimeProvider.cpp @@ -5,12 +5,10 @@ namespace Retro { -CTimeProvider* g_TimeProvider = nullptr; +CTimeProvider* CTimeProvider::g_currentTimeProvider = nullptr; CTimeProvider::CTimeProvider(const float& time) - : x0_currentTime(time) + : x0_currentTime(time), x8_lastProvider(g_currentTimeProvider) { - x8_lastProvider = g_TimeProvider; - if (x8_lastProvider != nullptr) x8_lastProvider->x4_first = false; @@ -21,9 +19,9 @@ CTimeProvider::CTimeProvider(const float& time) CTimeProvider::~CTimeProvider() { - g_TimeProvider = x8_lastProvider; - if (g_TimeProvider) - g_TimeProvider->x4_first = true; + g_currentTimeProvider = x8_lastProvider; + if (g_currentTimeProvider) + g_currentTimeProvider->x4_first = true; #if 0 CGraphics::SetExternalTimeProvider(g_TimeProvider); #endif diff --git a/Runtime/CTimeProvider.hpp b/Runtime/CTimeProvider.hpp index b49104543..f1f2d9349 100644 --- a/Runtime/CTimeProvider.hpp +++ b/Runtime/CTimeProvider.hpp @@ -3,10 +3,10 @@ namespace Retro { class CTimeProvider; -extern CTimeProvider* g_TimeProvider; class CTimeProvider { public: + static CTimeProvider* g_currentTimeProvider; const float& x0_currentTime; // in seconds bool x4_first = true; CTimeProvider* x8_lastProvider = nullptr;