From f0c486edf47bc75b10a12b2ee707b1c9d9b87069 Mon Sep 17 00:00:00 2001 From: Foxtr0t1337 <48181014+Foxtr0t1337@users.noreply.github.com> Date: Sun, 16 Jun 2024 04:07:27 +0800 Subject: [PATCH] Try to fix game hang caused by shelf linking. Fixing an infinite loop caused by unchecked cache invalidation. Sometime when you link shelves, a storageGroup in cache will not null, but with no SpawnedMember. If unchecked, it will cause groupsOfPriorityCount to decrease by -1, which is a infinite loop. This fix will FixCache when a group have no member. --- Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs b/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs index 717966d..9cd6e17 100644 --- a/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs +++ b/Source/PerformanceFish/Hauling/StoreUtilityPrepatches.cs @@ -291,6 +291,9 @@ public sealed class StoreUtilityPrepatches : ClassWithFishPrepatches if (storageGroup != null) { otherGroupMembers = storageGroup.SpawnedMemberCount() - 1; + if (otherGroupMembers < 0) + goto FixCache; + Debug.VerifyStorageGroup(otherGroupMembers, listInPriorityOrder, i, storageGroup); groupsOfPriorityCount -= otherGroupMembers;