about summary refs log tree commit diff stats
path: root/Source/RandomizerCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/RandomizerCore.cpp')
-rw-r--r--Source/RandomizerCore.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/RandomizerCore.cpp b/Source/RandomizerCore.cpp index c673e2d..77977c6 100644 --- a/Source/RandomizerCore.cpp +++ b/Source/RandomizerCore.cpp
@@ -30,9 +30,6 @@ void RandomizerCore::SwapPanels(int panel1, int panel2, int flags) {
30 if (flags & SWAP_AUDIO_NAMES) { 30 if (flags & SWAP_AUDIO_NAMES) {
31 offsets[AUDIO_LOG_NAME] = sizeof(void*); 31 offsets[AUDIO_LOG_NAME] = sizeof(void*);
32 } 32 }
33 if (flags & SWAP_BACK_DISTANCE) {
34 offsets[EXTRA_BACK_DISTANCE] = sizeof(float);
35 }
36 if (flags & SWAP_LINES) { 33 if (flags & SWAP_LINES) {
37 offsets[PATH_COLOR] = 16; 34 offsets[PATH_COLOR] = 16;
38 offsets[REFLECTION_PATH_COLOR] = 16; 35 offsets[REFLECTION_PATH_COLOR] = 16;
@@ -99,18 +96,20 @@ void RandomizerCore::SwapPanels(int panel1, int panel2, int flags) {
99 } 96 }
100} 97}
101 98
102void RandomizerCore::ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order) { 99void RandomizerCore::ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets) {
103 // This list is offset by 1, so the target of the Nth panel is in position N (aka the N+1th element) 100 if (targets.empty()) {
104 // The first panel may not have a wire to power it, so we use the panel ID itself. 101 // This list is offset by 1, so the target of the Nth panel is in position N (aka the N+1th element)
105 std::vector<int> targetToActivatePanel = {panels[0] + 1}; 102 // The first panel may not have a wire to power it, so we use the panel ID itself.
106 for (const int panel : panels) { 103 targets = {panels[0] + 1};
107 int target = ReadPanelData<int>(panel, TARGET, 1)[0]; 104 for (const int panel : panels) {
108 targetToActivatePanel.push_back(target); 105 int target = ReadPanelData<int>(panel, TARGET, 1)[0];
106 targets.push_back(target);
107 }
109 } 108 }
110 109
111 for (size_t i=0; i<order.size() - 1; i++) { 110 for (size_t i=0; i<order.size() - 1; i++) {
112 // Set the target of order[i] to order[i+1], using the "real" target as determined above. 111 // Set the target of order[i] to order[i+1], using the "real" target as determined above.
113 const int panelTarget = targetToActivatePanel[order[i+1]]; 112 const int panelTarget = targets[order[i+1]];
114 WritePanelData<int>(panels[order[i]], TARGET, {panelTarget}); 113 WritePanelData<int>(panels[order[i]], TARGET, {panelTarget});
115 } 114 }
116} 115}