about summary refs log tree commit diff stats
path: root/Source/Randomizer.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-11-07 09:26:42 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2018-11-07 09:26:42 -0800
commit5ad08f6611c8c777c43cfa0d2380b6ad6554a54d (patch)
treee14b08857f15003bdeb47daca0dc5e741c033b94 /Source/Randomizer.cpp
parente762e48d6fbab7bd5137c369fa49df25ccd5369d (diff)
downloadwitness-tutorializer-5ad08f6611c8c777c43cfa0d2380b6ad6554a54d.tar.gz
witness-tutorializer-5ad08f6611c8c777c43cfa0d2380b6ad6554a54d.tar.bz2
witness-tutorializer-5ad08f6611c8c777c43cfa0d2380b6ad6554a54d.zip
Not sure what other feature work is valuable -- I'd rather work on exporting.
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r--Source/Randomizer.cpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index ce784be..a21b928 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -5,7 +5,6 @@
5 * FEATURES: 5 * FEATURES:
6 * Start the game if it isn't running? 6 * Start the game if it isn't running?
7 * Stop swapping colors in desert 7 * Stop swapping colors in desert
8 * Look into valid panel swaps for keep walk-ons.
9 * Randomize audio logs -- Hard, seem to be unloaded some times? 8 * Randomize audio logs -- Hard, seem to be unloaded some times?
10 * Swap sounds in jungle (along with panels) -- maybe impossible 9 * Swap sounds in jungle (along with panels) -- maybe impossible
11 * Make orange 7 (all of oranges?) hard. Like big = hard. (See: HARD_MODE) 10 * Make orange 7 (all of oranges?) hard. Like big = hard. (See: HARD_MODE)
@@ -24,11 +23,11 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
24 if (data[i] == search) return static_cast<int>(i); 23 if (data[i] == search) return static_cast<int>(i);
25 } 24 }
26 std::cout << "Couldn't find " << search << " in data!" << std::endl; 25 std::cout << "Couldn't find " << search << " in data!" << std::endl;
27 exit(-1); 26 throw std::exception("Couldn't find value in data!");
28} 27}
29 28
30bool Randomizer::GameIsRandomized() { 29bool Randomizer::GameIsRandomized() {
31 int currentFrame = GetCurrentFrame(); 30 int currentFrame = _memory->GetCurrentFrame();
32 if (currentFrame >= _lastRandomizedFrame) { 31 if (currentFrame >= _lastRandomizedFrame) {
33 // Time went forwards, presumably we're still on the same save 32 // Time went forwards, presumably we're still on the same save
34 _lastRandomizedFrame = currentFrame; 33 _lastRandomizedFrame = currentFrame;
@@ -41,7 +40,7 @@ bool Randomizer::GameIsRandomized() {
41void Randomizer::Randomize() 40void Randomizer::Randomize()
42{ 41{
43 if (GameIsRandomized()) return; // Nice sanity check, but should be unnecessary (since Main checks anyways) 42 if (GameIsRandomized()) return; // Nice sanity check, but should be unnecessary (since Main checks anyways)
44 _lastRandomizedFrame = GetCurrentFrame(); 43 _lastRandomizedFrame = _memory->GetCurrentFrame();
45 44
46 // Content swaps -- must happen before squarePanels 45 // Content swaps -- must happen before squarePanels
47 Randomize(upDownPanels, SWAP::LINES); 46 Randomize(upDownPanels, SWAP::LINES);
@@ -345,15 +344,3 @@ void Randomizer::ReassignNames(const std::vector<int>& panels, const std::vector
345 _memory->WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); 344 _memory->WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]});
346 } 345 }
347} 346}
348
349short Randomizer::ReadMetadata() {
350 return _memory->ReadData<short>({GLOBALS + METADATA}, 1)[0];
351}
352
353void Randomizer::WriteMetadata(short metadata) {
354 return _memory->WriteData<short>({GLOBALS + METADATA}, {metadata});
355}
356
357int Randomizer::GetCurrentFrame() {
358 return _memory->ReadData<int>({SCRIPT_FRAMES}, 1)[0];
359}