diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-06 09:19:21 -0800 |
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-06 09:19:21 -0800 |
| commit | 3a03f478e407f35bfafd192c22f82bc8c6e25a38 (patch) | |
| tree | 0af1c7ec125b098d5cf3c0e19ccf03b511f6d5b9 /Source/Randomizer.cpp | |
| parent | 66b2bc177853d33f4559eb240fbbca354b173fa2 (diff) | |
| download | witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.tar.gz witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.tar.bz2 witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.zip | |
And... it works?
Diffstat (limited to 'Source/Randomizer.cpp')
| -rw-r--r-- | Source/Randomizer.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
| diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 71ec89b..9b877cd 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp | |||
| @@ -109,23 +109,26 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) { | |||
| 109 | throw std::exception("Couldn't find value in data!"); | 109 | throw std::exception("Couldn't find value in data!"); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | bool Randomizer::GameIsRandomized() { | 112 | Randomizer::Randomizer(const std::shared_ptr<Memory>& memory) : _memory(memory) {} |
| 113 | int currentFrame = _memory->GetCurrentFrame(); | 113 | |
| 114 | if (currentFrame >= _lastRandomizedFrame) { | 114 | void Randomizer::Randomize() { |
| 115 | // Time went forwards, presumably we're still on the same save | 115 | // reveal_exit_hall - Prevent actually ending the game (EEE) |
| 116 | _lastRandomizedFrame = currentFrame; | 116 | _memory->AddSigScan({0x45, 0x8B, 0xF7, 0x48, 0x8B, 0x4D}, [&](int index){ |
| 117 | return true; | 117 | _memory->WriteData<byte>({index + 0x15}, {0xEB}); // jz -> jmp |
| 118 | } | 118 | }); |
| 119 | // Otherwise, time has gone backwards, so assume new game | 119 | |
| 120 | return false; | 120 | // begin_endgame_1 - Prevent actually ending the game (Wonkavator) |
| 121 | } | 121 | _memory->AddSigScan({0x83, 0x7C, 0x01, 0xD0, 0x04}, [&](int index){ |
| 122 | 122 | if (GLOBALS == 0x5B28C0) { // Version differences. | |
| 123 | void Randomizer::Randomize() | 123 | index += 0x75; |
| 124 | { | 124 | } else if (GLOBALS == 0x62D0A0) { |
| 125 | if (GameIsRandomized()) return; // Nice sanity check, but should be unnecessary (since Main checks anyways) | 125 | index += 0x86; |
| 126 | _lastRandomizedFrame = _memory->GetCurrentFrame(); | 126 | } |
| 127 | _memory->WriteData<byte>({index}, {0xEB}); // jz -> jmp | ||
| 128 | }); | ||
| 129 | // Sig scans will be run during challenge randomization. | ||
| 127 | 130 | ||
| 128 | // Seed challenge first for future-proofing (?) | 131 | // Seed challenge first for future-proofing |
| 129 | RandomizeChallenge(); | 132 | RandomizeChallenge(); |
| 130 | 133 | ||
| 131 | // Content swaps -- must happen before squarePanels | 134 | // Content swaps -- must happen before squarePanels |
