Skip to content

Commit

Permalink
Merge pull request #643 from starfi5h/pr-0.9.0bugfix1
Browse files Browse the repository at this point in the history
Fix SetFilter error when client placing blueprint of storagebox on remote planets
  • Loading branch information
starfi5h authored Jan 11, 2024
2 parents c2f08e4 + 412efe1 commit ba4da86
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions NebulaPatcher/Patches/Dynamic/BuildingParameters_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region

using HarmonyLib;
using NebulaWorld;

#endregion

namespace NebulaPatcher.Patches.Dynamic;

[HarmonyPatch(typeof(BuildingParameters))]
internal class BuildingParameters_Patch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(BuildingParameters.ApplyPrebuildParametersToEntity))]
[HarmonyPatch(nameof(BuildingParameters.PasteToFactoryObject))]
public static void ApplyPrebuildParametersToEntity_Prefix()
{
if (Multiplayer.IsActive)
{
// Let the upper patch handle the SetBans, SetFilter syncing
Multiplayer.Session.Storage.IsHumanInput = false;
}
}

[HarmonyPostfix]
[HarmonyPatch(nameof(BuildingParameters.ApplyPrebuildParametersToEntity))]
[HarmonyPatch(nameof(BuildingParameters.PasteToFactoryObject))]
public static void ApplyPrebuildParametersToEntity_Postfix()
{
if (Multiplayer.IsActive)
{
Multiplayer.Session.Storage.IsHumanInput = true;
}
}
}
3 changes: 2 additions & 1 deletion NebulaPatcher/Patches/Dynamic/StorageComponent_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public static bool TakeItemFromGrid_Prefix(StorageComponent __instance, int grid
[HarmonyPatch(nameof(StorageComponent.SetBans))]
public static void SetBans_Postfix(StorageComponent __instance, int _bans)
{
if (Multiplayer.IsActive && !Multiplayer.Session.Storage.IsIncomingRequest && GameMain.data.localPlanet != null)
if (Multiplayer.IsActive && !Multiplayer.Session.Storage.IsIncomingRequest &&
Multiplayer.Session.Storage.IsHumanInput && GameMain.data.localPlanet != null)
{
HandleUserInteraction(__instance, new StorageSyncSetBansPacket(__instance.id, GameMain.data.localPlanet.id, _bans));
}
Expand Down

0 comments on commit ba4da86

Please sign in to comment.