Skip to content

Commit

Permalink
Fix (Royalty) transport ships
Browse files Browse the repository at this point in the history
Currently, sending a transport ships in some circumstances (like summoning one through royal permits) would result in them disappearing with all pawns and items they carry when arriving at their destinations.

The issue was caused due to transport ships themselves not being registered in shared cross refs, which caused them to fail syncing them as IExposable.
  • Loading branch information
SokyranTheDragon committed Sep 1, 2023
1 parent 6871f20 commit 18a7091
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Source/Client/Saving/CrossRefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,37 @@ static void Postfix(ThingOwner __instance)
}
}
}

[HarmonyPatch(typeof(TransportShipManager), nameof(TransportShipManager.RegisterShipObject))]
public static class TransportShipAddPatch
{
public static void Postfix(TransportShip s)
{
if (Multiplayer.game == null) return;
ScribeUtil.sharedCrossRefs.RegisterLoaded(s);
}
}

[HarmonyPatch(typeof(TransportShipManager), nameof(TransportShipManager.DeregisterShipObject))]
public static class TransportShipRemovePatch
{
public static void Postfix(TransportShip s)
{
if (Multiplayer.game == null) return;
ScribeUtil.sharedCrossRefs.Unregister(s);
}
}

[HarmonyPatch(typeof(TransportShipManager), nameof(TransportShipManager.ExposeData))]
public static class TransportShipExposePatch
{
static void Postfix(TransportShipManager __instance)
{
if (Multiplayer.game == null) return;

if (Scribe.mode == LoadSaveMode.PostLoadInit)
foreach (var ship in __instance.ships)
ScribeUtil.sharedCrossRefs.RegisterLoaded(ship);
}
}
}

0 comments on commit 18a7091

Please sign in to comment.