Skip to content

Commit

Permalink
Fix a critical bug with loaded regions.
Browse files Browse the repository at this point in the history
Basically, now it will not add a new region even if you include it in the Regions folder if it doesn't match the region ID.
(For example, you include AR in The Root, it will skip it in the region list.
  • Loading branch information
Garrakx committed Dec 3, 2020
1 parent b3a4d98 commit 9cca60b
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions Custom-Regions/OverWorldHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public static void ApplyHooks()
{
On.OverWorld.LoadFirstWorld += OverWorld_LoadFirstWorld;

//On.OverWorld.GetRegion += OverWorld_GetRegion;

On.OverWorld.GetRegion_1 += OverWorld_GetRegion_1;
On.OverWorld.LoadWorld += OverWorld_LoadWorld;
}
Expand Down Expand Up @@ -159,31 +157,6 @@ private static Region OverWorld_GetRegion_1(On.OverWorld.orig_GetRegion_1 orig,
return orig(self, rName);
}

/// <summary>
/// Used for debugging purposes
/// </summary>
private static Region OverWorld_GetRegion(On.OverWorld.orig_GetRegion orig, OverWorld self, AbstractRoom room)
{
string[] array = Regex.Split(room.name, "_");
CustomWorldMod.Log($"Custom Region: Getting region. AbstractRoom [{room.name}] (splitted {array[0]}).");
if (array.Length == 2)
{
CustomWorldMod.Log($"Custom Region: Region obtained [{self.GetRegion(array[0])}]");
}
string debug = "Custom Region: All regions: {";
for (int i = 0; i < self.regions.Length; i++)
{

debug += $" {self.regions[i]},";

}
debug += "}";

CustomWorldMod.Log(debug);

return orig(self, room);
}

public static void AddMissingRegions(OverWorld self)
{
int num = self.regions[self.regions.Length - 1].firstRoomIndex;
Expand All @@ -199,6 +172,11 @@ public static void AddMissingRegions(OverWorld self)
foreach (string regionEach in regions)
{
string regionToAdd = Path.GetFileNameWithoutExtension(regionEach);
if (regionToAdd != keyValues.Key)
{
continue;
}

bool shouldAdd = true;

for (int i = 0; i < self.regions.Length; i++)
Expand Down

0 comments on commit 9cca60b

Please sign in to comment.