From 2ec60ccdf374cdcaff95b7ec8d536f38bdad916e Mon Sep 17 00:00:00 2001
From: jbzdarkid <jbzdarkid@gmail.com>
Date: Sat, 27 Oct 2018 12:55:54 -0700
Subject: [PATCH] Fix some bugs, comment out things I can't fix rn

---
 WitnessRandomizer/Panels.h                    |  2 +-
 WitnessRandomizer/WitnessRandomizer.cpp       | 33 +++++++++++++++----
 WitnessRandomizer/WitnessRandomizer.h         |  4 ++-
 .../WitnessRandomizerInstaller.vdproj         | 24 +++++++++++---
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/WitnessRandomizer/Panels.h b/WitnessRandomizer/Panels.h
index 29951701..7b9c96c5 100644
--- a/WitnessRandomizer/Panels.h
+++ b/WitnessRandomizer/Panels.h
@@ -96,7 +96,7 @@ const std::vector<int> upDownPanels = {
 	0x335AB, // UTM In Elevator Control
 	0x3369D, // UTM Lower Elevator Control
 	0x335AC, // UTM Upper Elevator Control
-	0x09EEB, // Mountain 2 Elevator
+//	0x09EEB, // Mountain 2 Elevator
 };
 
 // Note: Some of these (non-controls) are duplicated elsewhere
diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp
index e7ab2aae..7827ddbb 100644
--- a/WitnessRandomizer/WitnessRandomizer.cpp
+++ b/WitnessRandomizer/WitnessRandomizer.cpp
@@ -1,8 +1,12 @@
 /*
+ * TODO: Split out main() logic into another file, and move into separate functions for easier testing. Then write tests.
  * BUGS:
- * Shipwreck vault fails, possibly because of dot_reflection?
+ * Shipwreck vault fails, possibly because of dot_reflection? Sometimes?
  * Treehouse pivots *should* work, but I need to not copy style_flags.
    This seems to cause crashes when pivots appear elsewhere in the world.
+ * Some panels are impossible casually: (idc, I think)
+ ** Town Stars, Invisible dots
+ * Something is wrong with jungle
  * FEATURES:
  * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?)
  ** Think about: Jungle
@@ -34,7 +38,6 @@ size_t find(const std::vector<T> &data, T search, size_t startIndex = 0) {
 
 int main(int argc, char** argv)
 {
-	
 	WitnessRandomizer randomizer = WitnessRandomizer();
 
 	if (argc == 2) {
@@ -45,6 +48,22 @@ int main(int argc, char** argv)
 		srand(seed);
 	}
 
+	/*
+	randomizer.SwapPanels(0x0007C, 0x0005D, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 1
+	randomizer.SwapPanels(0x0007E, 0x0005E, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 2
+	randomizer.SwapPanels(0x00075, 0x0005F, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 3
+	randomizer.SwapPanels(0x00073, 0x00060, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 4
+	randomizer.SwapPanels(0x00077, 0x00061, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 5
+	0x00079; // Symmetry Island Colored Dots 6
+
+	0x0005D; // Outside Tutorial Dots Tutorial 1
+	0x0005E; // Outside Tutorial Dots Tutorial 2
+	0x0005F; // Outside Tutorial Dots Tutorial 3
+	0x00060; // Outside Tutorial Dots Tutorial 4
+	0x00061; // Outside Tutorial Dots Tutorial 5
+	*/
+
+
 	// Content swaps -- must happen before squarePanels
 	randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE);
 	randomizer.Randomize(leftForwardRightPanels, SWAP_LINES);
@@ -60,8 +79,10 @@ int main(int argc, char** argv)
 	std::vector<int> keepFrontLaserTarget = randomizer.ReadPanelData<int>(0x0360E, TARGET, 1);
 	randomizer.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
 
-	/* Jungle */
-	std::vector<int> randomOrder = std::vector(junglePanels.size(), 0);
+	std::vector<int> randomOrder;
+
+	/* Jungle
+	randomOrder = std::vector(junglePanels.size(), 0);
 	std::iota(randomOrder.begin(), randomOrder.end(), 0);
 	// Randomize Waves 2-7
 	// Waves 1 cannot be randomized, since no other panel can start on
@@ -69,6 +90,7 @@ int main(int argc, char** argv)
 	// Randomize Pitches 1-6 onto themselves
 	randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13);
 	randomizer.ReassignTargets(junglePanels, randomOrder);
+	 */
 
 	/* Bunker */
 	randomOrder = std::vector(bunkerPanels.size(), 0);
@@ -104,7 +126,6 @@ int main(int argc, char** argv)
 
 	randomizer.ReassignTargets(monasteryPanels, randomOrder);
 	*/
-
 }
 
 WitnessRandomizer::WitnessRandomizer()
@@ -117,7 +138,7 @@ WitnessRandomizer::WitnessRandomizer()
 	// Distance-gate shadows laser to prevent sniping through the bars
 	WritePanelData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5f});
 	// Change the shadows tutorial cable to only activate avoid
-	WritePanelData<int>(0x319A8, 0xD8, {0});
+	WritePanelData<int>(0x319A8, CABLE_TARGET_2, {0});
 	// Change shadows avoid 8 to power shadows follow
 	WritePanelData<int>(0x1972F, TARGET, {0x1C34C});
 
diff --git a/WitnessRandomizer/WitnessRandomizer.h b/WitnessRandomizer/WitnessRandomizer.h
index 3d748d1c..0c73b89c 100644
--- a/WitnessRandomizer/WitnessRandomizer.h
+++ b/WitnessRandomizer/WitnessRandomizer.h
@@ -91,6 +91,7 @@ class WitnessRandomizer {
 #define COLORED_REGIONS 0x4A8
 #define PANEL_TARGET 0x4B0
 #define SPECULAR_TEXTURE 0x4D8
+#define CABLE_TARGET_2 0xD8
 #elif GLOBALS == 0x62A080
 #define PATH_COLOR 0xC0
 #define REFLECTION_PATH_COLOR 0xD0
@@ -104,7 +105,7 @@ class WitnessRandomizer {
 #define ERROR_COLOR 0x160
 #define PATTERN_POINT_COLOR 0x180
 #define PATTERN_POINT_COLOR_A 0x190
-#define PATTERN_POINT_COLOR_B 0x200
+#define PATTERN_POINT_COLOR_B 0x1A0
 #define SYMBOL_A 0x1B0
 #define SYMBOL_B 0x1C0
 #define SYMBOL_C 0x1D0
@@ -151,4 +152,5 @@ class WitnessRandomizer {
 #define COLORED_REGIONS 0x4A0
 #define PANEL_TARGET 0x4A8
 #define SPECULAR_TEXTURE 0x4D0
+#define CABLE_TARGET_2 0xD0
 #endif
\ No newline at end of file
diff --git a/WitnessRandomizerInstaller/WitnessRandomizerInstaller.vdproj b/WitnessRandomizerInstaller/WitnessRandomizerInstaller.vdproj
index 7951e39b..a2cf5177 100644
--- a/WitnessRandomizerInstaller/WitnessRandomizerInstaller.vdproj
+++ b/WitnessRandomizerInstaller/WitnessRandomizerInstaller.vdproj
@@ -37,6 +37,14 @@
         "PrivateKeyFile" = "8:"
         "TimeStampServer" = "8:"
         "InstallerBootstrapper" = "3:2"
+            "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
+            {
+            "Enabled" = "11:TRUE"
+            "PromptEnabled" = "11:TRUE"
+            "PrerequisitesLocation" = "2:1"
+            "Url" = "8:"
+            "ComponentsUrl" = "8:"
+            }
         }
         "Release"
         {
@@ -53,6 +61,14 @@
         "PrivateKeyFile" = "8:"
         "TimeStampServer" = "8:"
         "InstallerBootstrapper" = "3:2"
+            "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
+            {
+            "Enabled" = "11:TRUE"
+            "PromptEnabled" = "11:TRUE"
+            "PrerequisitesLocation" = "2:1"
+            "Url" = "8:"
+            "ComponentsUrl" = "8:"
+            }
         }
     }
     "Deployable"
@@ -130,15 +146,15 @@
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:WitnessRandomizer"
-        "ProductCode" = "8:{1D8F70FD-4741-4C9F-B0FE-9207F15FEC1A}"
-        "PackageCode" = "8:{FF874506-B46A-40E9-B6C2-C87CFE189AFF}"
+        "ProductCode" = "8:{9EB4E1F3-2D4E-4D2B-B8AA-B51C12F8149B}"
+        "PackageCode" = "8:{2D819EE6-D857-426F-A0B0-48CDB593BCD3}"
         "UpgradeCode" = "8:{B2AF0F34-4917-4AEC-B892-FE4FD4B9584A}"
         "AspNetVersion" = "8:2.0.50727.0"
         "RestartWWWService" = "11:FALSE"
-        "RemovePreviousVersions" = "11:FALSE"
+        "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:1.0.1"
+        "ProductVersion" = "8:1.0.2"
         "Manufacturer" = "8:jbzdarkid"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:"