From 3557f0ba80942397a9d963208695b4fa80290cb0 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Tue, 30 Oct 2018 21:58:46 -0700 Subject: Infinite amounts of cleanup --- Source/RandomizerCore.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Source/RandomizerCore.cpp') diff --git a/Source/RandomizerCore.cpp b/Source/RandomizerCore.cpp index 684e19d..f14a76f 100644 --- a/Source/RandomizerCore.cpp +++ b/Source/RandomizerCore.cpp @@ -3,6 +3,17 @@ #include "Random.h" #include +static int lastKnownFrame = 1 << 30; + +RandomizerCore::RandomizerCore() { + int currentFrame = _memory.ReadData({SCRIPT_FRAMES}, 1)[0]; + if (currentFrame < lastKnownFrame) { + // Time went backwards, indicates new game + WriteMetadata(0); + } + lastKnownFrame = currentFrame; +} + void RandomizerCore::Randomize(std::vector& panels, int flags) { return RandomizeRange(panels, flags, 0, panels.size()); } @@ -125,3 +136,11 @@ void RandomizerCore::ReassignNames(const std::vector& panels, const std::ve WritePanelData(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); } } + +short RandomizerCore::ReadMetadata() { + return _memory.ReadData({GLOBALS + METADATA}, 1)[0]; +} + +void RandomizerCore::WriteMetadata(short metadata) { + return _memory.WriteData({GLOBALS + METADATA}, {metadata}); +} \ No newline at end of file -- cgit 1.4.1