diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs index 3bc3ab5a..b70a85b6 100644 --- a/GeneralMods/StardustCore/ModCore.cs +++ b/GeneralMods/StardustCore/ModCore.cs @@ -22,6 +22,13 @@ using System.Threading.Tasks; namespace StardustCore { + /* + *Known issues: + * Clients have a error on Serialization that says they run across unknown XML elements such as core objects. However, inventories for farmhands and modded objects still get serialized properly. + * Host loose serialized objects when closing the server. + */ + + public class ModCore : Mod { public static IModHelper ModHelper; @@ -108,6 +115,9 @@ namespace StardustCore private void Multiplayer_PeerDisconnected(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e) { this.playerJustDisconnected = true; + + ModMonitor.Log("Peer disconnected!!!"); + SerializationManager.cleanUpInventory(); SerializationManager.cleanUpWorld(); SerializationManager.cleanUpStorageContainers(); @@ -126,6 +136,7 @@ namespace StardustCore } else if (e.Type == MultiplayerSupport.RestoreModObjects) { + ModMonitor.Log("HEAL ALL BOBOS!"); SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); } } @@ -133,9 +144,11 @@ namespace StardustCore private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e) { - //ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!"); + if (SerializationManager == null) return; - + + ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!"); + SerializationManager.cleanUpInventory(); SerializationManager.cleanUpWorld(); SerializationManager.cleanUpStorageContainers(); @@ -271,6 +284,7 @@ namespace StardustCore playerIds.Add(f.uniqueMultiplayerID); } + ModMonitor.Log("RESEND ALL DATA!!!"); ModHelper.Multiplayer.SendMessage(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects, new string[] { ModManifest.UniqueID },playerIds.ToArray()); /* List> objs = new List>(); @@ -322,6 +336,7 @@ namespace StardustCore //Call the serialization if alone since the ReadyCheckDialogue menu never shows with just 1 player online. if (Game1.IsMultiplayer == false || (Game1.IsMultiplayer && Game1.getOnlineFarmers().Count==1)) { + ModMonitor.Log("SQUEEKY CLEAN!"); SerializationManager.cleanUpInventory(); SerializationManager.cleanUpWorld(); SerializationManager.cleanUpStorageContainers(); diff --git a/GeneralMods/StardustCore/Serialization/Serialization.cs b/GeneralMods/StardustCore/Serialization/Serialization.cs index eb2863f4..d8e34d64 100644 --- a/GeneralMods/StardustCore/Serialization/Serialization.cs +++ b/GeneralMods/StardustCore/Serialization/Serialization.cs @@ -100,6 +100,7 @@ namespace StardustCore.Serialization { foreach (Farmer f in Game1.getAllFarmhands()) { + f.items.Clear(); } } @@ -450,6 +451,7 @@ namespace StardustCore.Serialization } catch(Exception err) { + throw new Exception(err.ToString()); return; } //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false);