Skip to content

Commit

Permalink
Fix WarningSystem.NewWarningData on client
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Dec 22, 2023
1 parent d88be28 commit 441e007
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion NebulaPatcher/Patches/Dynamic/WarningSystem_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 441e007

Please sign in to comment.