about summary refs log tree commit diff stats
path: root/Source/RandomizerCore.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-10-30 21:58:46 -0700
committerjbzdarkid <jbzdarkid@gmail.com>2018-10-30 21:58:46 -0700
commit3557f0ba80942397a9d963208695b4fa80290cb0 (patch)
treed754d0f1b56ca10c133804639882d12d6686f7ec /Source/RandomizerCore.cpp
parente66a408e38849107a3d35a317ff6f2b23dcaeead (diff)
downloadwitness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.tar.gz
witness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.tar.bz2
witness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.zip
Infinite amounts of cleanup
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