From 441e0072c243c6a40ff0babd201a09e98449caa5 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sat, 23 Dec 2023 01:02:59 +0800 Subject: [PATCH] Fix WarningSystem.NewWarningData on client --- .../Patches/Dynamic/WarningSystem_Patch.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NebulaPatcher/Patches/Dynamic/WarningSystem_Patch.cs b/NebulaPatcher/Patches/Dynamic/WarningSystem_Patch.cs index 1710806c2..41a571c2d 100644 --- a/NebulaPatcher/Patches/Dynamic/WarningSystem_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/WarningSystem_Patch.cs @@ -12,7 +12,6 @@ namespace NebulaPatcher.Patches.Dynamic; internal class WarningSystem_Patch { [HarmonyPrefix] - [HarmonyPatch(typeof(WarningSystem), nameof(WarningSystem.NewWarningData))] [HarmonyPatch(typeof(WarningSystem), nameof(WarningSystem.RemoveWarningData))] [HarmonyPatch(typeof(WarningSystem), nameof(WarningSystem.WarningLogic))] public static bool AlterWarningData_Prefix() @@ -21,6 +20,22 @@ public static bool AlterWarningData_Prefix() return !Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost; } + [HarmonyPrefix] + [HarmonyPatch(typeof(WarningSystem), nameof(WarningSystem.NewWarningData))] + public static void NewWarningData_Prefix(WarningSystem __instance, ref int factoryId) + { + if (!Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost) + { + return; + } + + // Stop the code to access unreachable factory + factoryId = -1; + // Let it return a dummy WarningData pool[0] + __instance.warningRecycleCursor = 1; + __instance.warningRecycle[0] = 0; + } + [HarmonyPrefix] [HarmonyPatch(typeof(WarningSystem), nameof(WarningSystem.CalcFocusDetail))] public static void CalcFocusDetail_Prefix(int __0)