about summary refs log tree commit diff stats
path: root/Source/RandomizerCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/RandomizerCore.cpp')
-rw-r--r--Source/RandomizerCore.cpp19
1 files changed, 19 insertions, 0 deletions
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 @@
3#include "Random.h" 3#include "Random.h"
4#include <sstream> 4#include <sstream>
5 5
6static int lastKnownFrame = 1 << 30;
7
8RandomizerCore::RandomizerCore() {
9 int currentFrame = _memory.ReadData<int>({SCRIPT_FRAMES}, 1)[0];
10 if (currentFrame < lastKnownFrame) {
11 // Time went backwards, indicates new game
12 WriteMetadata(0);
13 }
14 lastKnownFrame = currentFrame;
15}
16
6void RandomizerCore::Randomize(std::vector<int>& panels, int flags) { 17void RandomizerCore::Randomize(std::vector<int>& panels, int flags) {
7 return RandomizeRange(panels, flags, 0, panels.size()); 18 return RandomizeRange(panels, flags, 0, panels.size());
8} 19}
@@ -125,3 +136,11 @@ void RandomizerCore::ReassignNames(const std::vector<int>& panels, const std::ve
125 WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); 136 WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]});
126 } 137 }
127} 138}
139
140short RandomizerCore::ReadMetadata() {
141 return _memory.ReadData<short>({GLOBALS + METADATA}, 1)[0];
142}
143
144void RandomizerCore::WriteMetadata(short metadata) {
145 return _memory.WriteData<short>({GLOBALS + METADATA}, {metadata});
146} \ No newline at end of file