Stop recursion scanning if it runs too long (#481)

This commit is contained in:
TerrificTrifid 2023-01-07 13:31:04 -06:00 committed by GitHub
commit a974f354fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,6 +256,7 @@ namespace NewHorizons.Builder.Body
foreach (var senderWarp in outerFogWarpVolume._senderWarps.ToList())
{
var currentWarp = senderWarp;
var n = 0;
while (currentWarp.GetContainerWarpVolume() != null)
{
if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion
@ -264,6 +265,8 @@ namespace NewHorizons.Builder.Body
break;
}
currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume();
n++;
if (n > 100) break; // just in case it gets caught in something else's recursion or there's no outside exit
}
}
});