From da199bf90ce64c7719dad359019034887931dfe2 Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 18:20:49 -0600 Subject: [PATCH] Prevent recursion from causing hard crash --- .../Builder/Body/BrambleDimensionBuilder.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index ccaf5c89..26bd51ad 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -245,12 +245,26 @@ namespace NewHorizons.Builder.Body cloak._sectors = new Sector[] { sector }; cloak.GetComponent().enabled = true; - // Cull stuff // Do next update so other nodes can be built first Delay.FireOnNextUpdate(() => { + // Cull stuff var cullController = go.AddComponent(); cullController.SetSector(sector); + + // Prevent recursion from causing hard crash + foreach (var senderWarp in outerFogWarpVolume._senderWarps) + { + var currentWarp = senderWarp; + while (currentWarp.GetContainerWarpVolume() != null) + { + if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion + { + outerFogWarpVolume._senderWarps.Remove(senderWarp); + } + else currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); + } + } }); // finalize