From 1f2077485e580b3b1d582298281ac6272df18d8d Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Sat, 27 Oct 2018 01:27:29 -0700 Subject: /W3 clean, add .msi installer project --- WitnessRandomizer/WitnessRandomizer.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'WitnessRandomizer/WitnessRandomizer.cpp') diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp index efe18b5..d71cc21 100644 --- a/WitnessRandomizer/WitnessRandomizer.cpp +++ b/WitnessRandomizer/WitnessRandomizer.cpp @@ -1,5 +1,6 @@ /* * BUGS: + * Shipwreck vault fails, possibly because of dot_reflection? * Treehouse pivots *should* work, but I need to not copy style_flags. This seems to cause crashes when pivots appear elsewhere in the world. * FEATURES: @@ -17,23 +18,26 @@ #include #include #include +#include template -int find(const std::vector &data, T search, int startIndex = 0) { - for (int i=startIndex ; i &data, T search, size_t startIndex = 0) { + for (size_t i=startIndex ; i(0x002C2, CURSOR_SPEED_SCALE, {1.0}); } -void WitnessRandomizer::Randomize(std::vector &panels, int flags) { +void WitnessRandomizer::Randomize(const std::vector& panels, int flags) { return RandomizeRange(panels, flags, 0, panels.size()); } // Range is [start, end) -void WitnessRandomizer::RandomizeRange(std::vector &panels, int flags, size_t startIndex, size_t endIndex) { +void WitnessRandomizer::RandomizeRange(std::vector panels, int flags, size_t startIndex, size_t endIndex) { if (panels.size() == 0) return; if (startIndex >= endIndex) return; if (endIndex >= panels.size()) endIndex = panels.size(); for (size_t i = endIndex-1; i > startIndex+1; i--) { - size_t target = rand() % (i - startIndex) + startIndex; + const size_t target = rand() % (i - startIndex) + startIndex; if (i != target) { // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; SwapPanels(panels[i], panels[target], flags); @@ -215,17 +219,17 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) { } void WitnessRandomizer::ReassignTargets(const std::vector& panels, const std::vector& order) { + // This list is offset by 1, so the target of the Nth panel is in position N (aka the N+1th element) + // The first panel may not have a wire to power it, so we use the panel ID itself. std::vector targetToActivatePanel = {panels[0] + 1}; - for (int panel : panels) { + for (const int panel : panels) { int target = ReadPanelData(panel, TARGET, 1)[0]; targetToActivatePanel.push_back(target); } - for (int i=0; i(panels[order[i]], TARGET, {panelTarget}); } } -- cgit 1.4.1