From b34cbb5b860ac4cd4a4b9e564e6e53245be3e790 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 25 Nov 2018 13:14:45 -0500 Subject: fix error when leaving & rejoining a server in the same session --- src/SMAPI/Framework/SGame.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index 75cf4c52..9c6ff4dd 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -206,6 +206,15 @@ namespace StardewModdingAPI.Framework this.Events.ModMessageReceived.RaiseForMods(new ModMessageReceivedEventArgs(message), mod => mod != null && modIDs.Contains(mod.Manifest.UniqueID)); } + /// A callback raised when the player quits a save and returns to the title screen. + private void OnReturnedToTitle() + { + this.Monitor.Log("Context: returned to title", LogLevel.Trace); + this.Multiplayer.Peers.Clear(); + this.Events.ReturnedToTitle.RaiseEmpty(); + this.Events.Legacy_AfterReturnToTitle.Raise(); + } + /// Constructor a content manager to read XNB files. /// The service provider to use to locate services. /// The root directory to search for content. @@ -430,11 +439,7 @@ namespace StardewModdingAPI.Framework ** Load / return-to-title events *********/ if (wasWorldReady && !Context.IsWorldReady) - { - this.Monitor.Log("Context: returned to title", LogLevel.Trace); - this.Events.ReturnedToTitle.RaiseEmpty(); - this.Events.Legacy_AfterReturnToTitle.Raise(); - } + this.OnReturnedToTitle(); else if (!this.RaisedAfterLoadEvent && Context.IsWorldReady) { // print context -- cgit