Rename globals

This commit is contained in:
Phillip Stephens 2016-02-07 08:15:43 -08:00
parent 8fbe6a953c
commit a96601f1b4
4 changed files with 15 additions and 17 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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;