summaryrefslogtreecommitdiffstats
path: root/src/core/Clock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/Clock.cpp')
-rw-r--r--src/core/Clock.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/Clock.cpp b/src/core/Clock.cpp
index e4b908e0..a3298343 100644
--- a/src/core/Clock.cpp
+++ b/src/core/Clock.cpp
@@ -4,6 +4,7 @@
#include "Pad.h"
#include "Clock.h"
#include "Stats.h"
+#include "VarConsole.h"
_TODO("gbFastTime");
bool gbFastTime;
@@ -18,6 +19,10 @@ uint32 CClock::ms_nMillisecondsPerGameMinute;
uint32 CClock::ms_nLastClockTick;
bool CClock::ms_bClockHasBeenStored;
+#ifndef MASTER
+bool gbFreezeTime;
+#endif
+
void
CClock::Initialise(uint32 scale)
{
@@ -29,6 +34,10 @@ CClock::Initialise(uint32 scale)
ms_nLastClockTick = CTimer::GetTimeInMilliseconds();
ms_bClockHasBeenStored = false;
debug("CClock ready\n");
+#ifndef MASTER
+ VarConsole.Add("Time (hour of day)", &ms_nGameClockHours, 1, 0, 23, true);
+ VarConsole.Add("Freeze time", &gbFreezeTime, true);
+#endif
}
void
@@ -48,6 +57,10 @@ CClock::Update(void)
}
}
+#ifndef MASTER
+ else if (gbFreezeTime)
+ ms_nLastClockTick = CTimer::GetTimeInMilliseconds();
+#endif
else if(CTimer::GetTimeInMilliseconds() - ms_nLastClockTick > ms_nMillisecondsPerGameMinute || gbFastTime)
{
ms_nGameClockMinutes++;
@@ -73,8 +86,14 @@ CClock::Update(void)
void
CClock::SetGameClock(uint8 h, uint8 m)
{
- ms_nGameClockHours = h;
+ while (m >= 60) {
+ m -= 60;
+ h++;
+ }
ms_nGameClockMinutes = m;
+ while (h >= 24)
+ h -= 24;
+ ms_nGameClockHours = h;
ms_nGameClockSeconds = 0;
ms_nLastClockTick = CTimer::GetTimeInMilliseconds();
}