Fix CopyAllowancesFrom patch for CE Custom Ammo compatibility

Thanks to @Epicguru for spotting the erroneous patch
This commit is contained in:
bradson
2023-12-12 11:39:24 +01:00
parent 3d8c8e4d29
commit 0247ad59a1
5 changed files with 10 additions and 7 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -254,12 +254,11 @@ public class WorkGiver_DoBillOptimization : ClassWithFishPatches
if (cachedSmallestList.Count != smallestFilter.allowedDefs.Count) if (cachedSmallestList.Count != smallestFilter.allowedDefs.Count)
{ {
// Log.Warning($"Cached list count: {cachedSmallestList.Count}, actual filter list count: { Log.Warning($"Cached list count: {cachedSmallestList.Count}, actual filter list count: {
// smallestFilter.allowedDefs.Count}. Forcing a refresh now to fix."); smallestFilter.allowedDefs.Count}. Forcing a refresh now to fix.");
ThingFilterPatches.ForceSynchronizeCache(smallestFilter); ThingFilterPatches.ForceSynchronizeCache(smallestFilter);
// Log.Warning($"New cached list count: {cachedSmallestList.Count}, actual filter list count: { Log.Warning($"New cached list count: {cachedSmallestList.Count}, actual filter list count: {
// smallestFilter.allowedDefs.Count}."); smallestFilter.allowedDefs.Count}.");
// didn't trigger in 1.3, but now does. Fuck
} }
var smallestListCount = cachedSmallestList.Count; var smallestListCount = cachedSmallestList.Count;
+6 -2
View File
@@ -101,8 +101,12 @@ public class ThingFilterPatches : ClassWithFishPatches
= static () => default(ThingFilter)!.CopyAllowancesFrom(null); = static () => default(ThingFilter)!.CopyAllowancesFrom(null);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Prefix(ThingFilter __instance) public static void Prefix(ThingFilter __instance, ThingFilter other)
=> AllowedDefsListCache.GetAndCheck<AllowedDefsListCacheValue>(__instance).Defs.Clear(); {
var defs = AllowedDefsListCache.GetAndCheck<AllowedDefsListCacheValue>(__instance).Defs;
defs.Clear();
defs.AddRange(other.AllowedThingDefs);
}
} }
public class SetAllow_Patch : FishPatch public class SetAllow_Patch : FishPatch