diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 08:41:20 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 08:41:20 -0800 |
commit | e762e48d6fbab7bd5137c369fa49df25ccd5369d (patch) | |
tree | ef457564aff53d1880531c3f24d7da301988b2d8 /Source/Randomizer.cpp | |
parent | 1cad9871174728c15abbdb71ee5cbe2cf03ccf0c (diff) | |
download | witness-tutorializer-e762e48d6fbab7bd5137c369fa49df25ccd5369d.tar.gz witness-tutorializer-e762e48d6fbab7bd5137c369fa49df25ccd5369d.tar.bz2 witness-tutorializer-e762e48d6fbab7bd5137c369fa49df25ccd5369d.zip |
Warnings clean because fml
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r-- | Source/Randomizer.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index aaddf21..ce784be 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp | |||
@@ -21,7 +21,7 @@ | |||
21 | template <class T> | 21 | template <class T> |
22 | int find(const std::vector<T> &data, T search, size_t startIndex = 0) { | 22 | int find(const std::vector<T> &data, T search, size_t startIndex = 0) { |
23 | for (size_t i=startIndex ; i<data.size(); i++) { | 23 | for (size_t i=startIndex ; i<data.size(); i++) { |
24 | if (data[i] == search) return i; | 24 | if (data[i] == search) return static_cast<int>(i); |
25 | } | 25 | } |
26 | std::cout << "Couldn't find " << search << " in data!" << std::endl; | 26 | std::cout << "Couldn't find " << search << " in data!" << std::endl; |
27 | exit(-1); | 27 | exit(-1); |
@@ -44,10 +44,10 @@ void Randomizer::Randomize() | |||
44 | _lastRandomizedFrame = GetCurrentFrame(); | 44 | _lastRandomizedFrame = GetCurrentFrame(); |
45 | 45 | ||
46 | // Content swaps -- must happen before squarePanels | 46 | // Content swaps -- must happen before squarePanels |
47 | Randomize(upDownPanels, SWAP_LINES); | 47 | Randomize(upDownPanels, SWAP::LINES); |
48 | Randomize(leftForwardRightPanels, SWAP_LINES); | 48 | Randomize(leftForwardRightPanels, SWAP::LINES); |
49 | 49 | ||
50 | Randomize(squarePanels, SWAP_LINES); | 50 | Randomize(squarePanels, SWAP::LINES); |
51 | 51 | ||
52 | // Individual area modifications | 52 | // Individual area modifications |
53 | RandomizeTutorial(); | 53 | RandomizeTutorial(); |
@@ -88,7 +88,7 @@ void Randomizer::RandomizeSymmetry() { | |||
88 | } | 88 | } |
89 | 89 | ||
90 | void Randomizer::RandomizeDesert() { | 90 | void Randomizer::RandomizeDesert() { |
91 | Randomize(desertPanels, SWAP_LINES); | 91 | Randomize(desertPanels, SWAP::LINES); |
92 | 92 | ||
93 | // Turn off desert surface 8 | 93 | // Turn off desert surface 8 |
94 | _memory->WritePanelData<float>(0x09F94, POWER, {0.0, 0.0}); | 94 | _memory->WritePanelData<float>(0x09F94, POWER, {0.0, 0.0}); |
@@ -126,9 +126,9 @@ void Randomizer::RandomizeShadows() { | |||
126 | 126 | ||
127 | std::vector<int> randomOrder(shadowsPanels.size(), 0); | 127 | std::vector<int> randomOrder(shadowsPanels.size(), 0); |
128 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 128 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
129 | RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial | 129 | RandomizeRange(randomOrder, SWAP::NONE, 0, 8); // Tutorial |
130 | RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid | 130 | RandomizeRange(randomOrder, SWAP::NONE, 8, 16); // Avoid |
131 | RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow | 131 | RandomizeRange(randomOrder, SWAP::NONE, 16, 21); // Follow |
132 | ReassignTargets(shadowsPanels, randomOrder); | 132 | ReassignTargets(shadowsPanels, randomOrder); |
133 | // Turn off original starting panel | 133 | // Turn off original starting panel |
134 | _memory->WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); | 134 | _memory->WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); |
@@ -142,7 +142,7 @@ void Randomizer::RandomizeTown() { | |||
142 | void Randomizer::RandomizeMonastery() { | 142 | void Randomizer::RandomizeMonastery() { |
143 | std::vector<int> randomOrder(monasteryPanels.size(), 0); | 143 | std::vector<int> randomOrder(monasteryPanels.size(), 0); |
144 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 144 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
145 | RandomizeRange(randomOrder, SWAP_NONE, 3, 9); // Outer 2 & 3, Inner 1-4 | 145 | RandomizeRange(randomOrder, SWAP::NONE, 3, 9); // Outer 2 & 3, Inner 1-4 |
146 | ReassignTargets(monasteryPanels, randomOrder); | 146 | ReassignTargets(monasteryPanels, randomOrder); |
147 | } | 147 | } |
148 | 148 | ||
@@ -152,10 +152,10 @@ void Randomizer::RandomizeBunker() { | |||
152 | // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 | 152 | // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 |
153 | // Tutorial 1 cannot be randomized, since no other panel can start on | 153 | // Tutorial 1 cannot be randomized, since no other panel can start on |
154 | // Glass 1 will become door + glass 1, due to the targetting system | 154 | // Glass 1 will become door + glass 1, due to the targetting system |
155 | RandomizeRange(randomOrder, SWAP_NONE, 1, 10); | 155 | RandomizeRange(randomOrder, SWAP::NONE, 1, 10); |
156 | // Randomize Glass 1-3 into everything after the door/glass 1 | 156 | // Randomize Glass 1-3 into everything after the door/glass 1 |
157 | const size_t glass1Index = find(randomOrder, 9); | 157 | const size_t glass1Index = find(randomOrder, 9); |
158 | RandomizeRange(randomOrder, SWAP_NONE, glass1Index + 1, 12); | 158 | RandomizeRange(randomOrder, SWAP::NONE, glass1Index + 1, 12); |
159 | ReassignTargets(bunkerPanels, randomOrder); | 159 | ReassignTargets(bunkerPanels, randomOrder); |
160 | } | 160 | } |
161 | 161 | ||
@@ -163,8 +163,8 @@ void Randomizer::RandomizeJungle() { | |||
163 | std::vector<int> randomOrder(junglePanels.size(), 0); | 163 | std::vector<int> randomOrder(junglePanels.size(), 0); |
164 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 164 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
165 | // Waves 1 cannot be randomized, since no other panel can start on | 165 | // Waves 1 cannot be randomized, since no other panel can start on |
166 | RandomizeRange(randomOrder, SWAP_NONE, 1, 7); // Waves 2-7 | 166 | RandomizeRange(randomOrder, SWAP::NONE, 1, 7); // Waves 2-7 |
167 | RandomizeRange(randomOrder, SWAP_NONE, 8, 13); // Pitches 1-6 | 167 | RandomizeRange(randomOrder, SWAP::NONE, 8, 13); // Pitches 1-6 |
168 | ReassignTargets(junglePanels, randomOrder); | 168 | ReassignTargets(junglePanels, randomOrder); |
169 | } | 169 | } |
170 | 170 | ||
@@ -175,8 +175,8 @@ void Randomizer::RandomizeSwamp() { | |||
175 | 175 | ||
176 | void Randomizer::RandomizeMountain() { | 176 | void Randomizer::RandomizeMountain() { |
177 | // Randomize lasers & some of mountain | 177 | // Randomize lasers & some of mountain |
178 | Randomize(lasers, SWAP_TARGETS); | 178 | Randomize(lasers, SWAP::TARGETS); |
179 | Randomize(mountainMultipanel, SWAP_LINES); | 179 | Randomize(mountainMultipanel, SWAP::LINES); |
180 | 180 | ||
181 | // Randomize final pillars order | 181 | // Randomize final pillars order |
182 | std::vector<int> targets = {pillars[0] + 1}; | 182 | std::vector<int> targets = {pillars[0] + 1}; |
@@ -188,8 +188,8 @@ void Randomizer::RandomizeMountain() { | |||
188 | 188 | ||
189 | std::vector<int> randomOrder(pillars.size(), 0); | 189 | std::vector<int> randomOrder(pillars.size(), 0); |
190 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 190 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
191 | RandomizeRange(randomOrder, SWAP_NONE, 0, 4); // Left Pillars 1-4 | 191 | RandomizeRange(randomOrder, SWAP::NONE, 0, 4); // Left Pillars 1-4 |
192 | RandomizeRange(randomOrder, SWAP_NONE, 5, 9); // Right Pillars 1-4 | 192 | RandomizeRange(randomOrder, SWAP::NONE, 5, 9); // Right Pillars 1-4 |
193 | ReassignTargets(pillars, randomOrder, targets); | 193 | ReassignTargets(pillars, randomOrder, targets); |
194 | // Turn off original starting panels | 194 | // Turn off original starting panels |
195 | _memory->WritePanelData<float>(pillars[0], POWER, {0.0f, 0.0f}); | 195 | _memory->WritePanelData<float>(pillars[0], POWER, {0.0f, 0.0f}); |
@@ -206,7 +206,7 @@ void Randomizer::RandomizeMountain() { | |||
206 | void Randomizer::RandomizeChallenge() { | 206 | void Randomizer::RandomizeChallenge() { |
207 | std::vector<int> randomOrder(challengePanels.size(), 0); | 207 | std::vector<int> randomOrder(challengePanels.size(), 0); |
208 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 208 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
209 | RandomizeRange(randomOrder, SWAP_NONE, 1, 9); // Easy maze - Triple 2 | 209 | RandomizeRange(randomOrder, SWAP::NONE, 1, 9); // Easy maze - Triple 2 |
210 | std::vector<int> triple1Target = _memory->ReadPanelData<int>(0x00C80, TARGET, 1); | 210 | std::vector<int> triple1Target = _memory->ReadPanelData<int>(0x00C80, TARGET, 1); |
211 | _memory->WritePanelData<int>(0x00CA1, TARGET, triple1Target); | 211 | _memory->WritePanelData<int>(0x00CA1, TARGET, triple1Target); |
212 | _memory->WritePanelData<int>(0x00CB9, TARGET, triple1Target); | 212 | _memory->WritePanelData<int>(0x00CB9, TARGET, triple1Target); |
@@ -219,7 +219,7 @@ void Randomizer::RandomizeChallenge() { | |||
219 | void Randomizer::RandomizeAudioLogs() { | 219 | void Randomizer::RandomizeAudioLogs() { |
220 | std::vector<int> randomOrder(audiologs.size(), 0); | 220 | std::vector<int> randomOrder(audiologs.size(), 0); |
221 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 221 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
222 | Randomize(randomOrder, SWAP_NONE); | 222 | Randomize(randomOrder, SWAP::NONE); |
223 | ReassignNames(audiologs, randomOrder); | 223 | ReassignNames(audiologs, randomOrder); |
224 | } | 224 | } |
225 | 225 | ||
@@ -231,9 +231,9 @@ void Randomizer::Randomize(std::vector<int>& panels, int flags) { | |||
231 | void Randomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex) { | 231 | void Randomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex) { |
232 | if (panels.size() == 0) return; | 232 | if (panels.size() == 0) return; |
233 | if (startIndex >= endIndex) return; | 233 | if (startIndex >= endIndex) return; |
234 | if (endIndex >= panels.size()) endIndex = panels.size(); | 234 | if (endIndex >= panels.size()) endIndex = static_cast<int>(panels.size()); |
235 | for (size_t i = endIndex-1; i > startIndex; i--) { | 235 | for (size_t i = endIndex-1; i > startIndex; i--) { |
236 | const size_t target = Random::RandInt(startIndex, i); | 236 | const int target = Random::RandInt(static_cast<int>(startIndex), static_cast<int>(i)); |
237 | if (i != target) { | 237 | if (i != target) { |
238 | // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; | 238 | // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; |
239 | SwapPanels(panels[i], panels[target], flags); | 239 | SwapPanels(panels[i], panels[target], flags); |
@@ -245,13 +245,13 @@ void Randomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t star | |||
245 | void Randomizer::SwapPanels(int panel1, int panel2, int flags) { | 245 | void Randomizer::SwapPanels(int panel1, int panel2, int flags) { |
246 | std::map<int, int> offsets; | 246 | std::map<int, int> offsets; |
247 | 247 | ||
248 | if (flags & SWAP_TARGETS) { | 248 | if (flags & SWAP::TARGETS) { |
249 | offsets[TARGET] = sizeof(int); | 249 | offsets[TARGET] = sizeof(int); |
250 | } | 250 | } |
251 | if (flags & SWAP_AUDIO_NAMES) { | 251 | if (flags & SWAP::AUDIO_NAMES) { |
252 | offsets[AUDIO_LOG_NAME] = sizeof(void*); | 252 | offsets[AUDIO_LOG_NAME] = sizeof(void*); |
253 | } | 253 | } |
254 | if (flags & SWAP_LINES) { | 254 | if (flags & SWAP::LINES) { |
255 | offsets[PATH_COLOR] = 16; | 255 | offsets[PATH_COLOR] = 16; |
256 | offsets[REFLECTION_PATH_COLOR] = 16; | 256 | offsets[REFLECTION_PATH_COLOR] = 16; |
257 | offsets[DOT_COLOR] = 16; | 257 | offsets[DOT_COLOR] = 16; |