Discovered that some errors need to be fixed by updating SMAPI

This commit is contained in:
Joshua Navarro 2018-12-16 03:14:52 -08:00
parent 98392f520e
commit 33364076a4
2 changed files with 19 additions and 2 deletions

View File

@ -22,6 +22,13 @@ using System.Threading.Tasks;
namespace StardustCore 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 class ModCore : Mod
{ {
public static IModHelper ModHelper; public static IModHelper ModHelper;
@ -108,6 +115,9 @@ namespace StardustCore
private void Multiplayer_PeerDisconnected(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e) private void Multiplayer_PeerDisconnected(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e)
{ {
this.playerJustDisconnected = true; this.playerJustDisconnected = true;
ModMonitor.Log("Peer disconnected!!!");
SerializationManager.cleanUpInventory(); SerializationManager.cleanUpInventory();
SerializationManager.cleanUpWorld(); SerializationManager.cleanUpWorld();
SerializationManager.cleanUpStorageContainers(); SerializationManager.cleanUpStorageContainers();
@ -126,6 +136,7 @@ namespace StardustCore
} }
else if (e.Type == MultiplayerSupport.RestoreModObjects) else if (e.Type == MultiplayerSupport.RestoreModObjects)
{ {
ModMonitor.Log("HEAL ALL BOBOS!");
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
} }
} }
@ -133,9 +144,11 @@ namespace StardustCore
private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e) private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e)
{ {
//ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!");
if (SerializationManager == null) return; if (SerializationManager == null) return;
ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!");
SerializationManager.cleanUpInventory(); SerializationManager.cleanUpInventory();
SerializationManager.cleanUpWorld(); SerializationManager.cleanUpWorld();
SerializationManager.cleanUpStorageContainers(); SerializationManager.cleanUpStorageContainers();
@ -271,6 +284,7 @@ namespace StardustCore
playerIds.Add(f.uniqueMultiplayerID); playerIds.Add(f.uniqueMultiplayerID);
} }
ModMonitor.Log("RESEND ALL DATA!!!");
ModHelper.Multiplayer.SendMessage<string>(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects, new string[] { ModManifest.UniqueID },playerIds.ToArray()); ModHelper.Multiplayer.SendMessage<string>(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects, new string[] { ModManifest.UniqueID },playerIds.ToArray());
/* /*
List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>(); List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>();
@ -322,6 +336,7 @@ namespace StardustCore
//Call the serialization if alone since the ReadyCheckDialogue menu never shows with just 1 player online. //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)) if (Game1.IsMultiplayer == false || (Game1.IsMultiplayer && Game1.getOnlineFarmers().Count==1))
{ {
ModMonitor.Log("SQUEEKY CLEAN!");
SerializationManager.cleanUpInventory(); SerializationManager.cleanUpInventory();
SerializationManager.cleanUpWorld(); SerializationManager.cleanUpWorld();
SerializationManager.cleanUpStorageContainers(); SerializationManager.cleanUpStorageContainers();

View File

@ -100,6 +100,7 @@ namespace StardustCore.Serialization
{ {
foreach (Farmer f in Game1.getAllFarmhands()) foreach (Farmer f in Game1.getAllFarmhands())
{ {
f.items.Clear(); f.items.Clear();
} }
} }
@ -450,6 +451,7 @@ namespace StardustCore.Serialization
} }
catch(Exception err) catch(Exception err)
{ {
throw new Exception(err.ToString());
return; return;
} }
//Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false);