From 5256b738b486aa1591c6b25b41410973f1feaf46 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 2 Aug 2021 21:14:22 -0400 Subject: use more reliable method to get save folder name SMAPI now tracks the actual folder name being loaded to avoid edge cases where the folder name doesn't match the save ID. --- src/SMAPI/Constants.cs | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'src/SMAPI/Constants.cs') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 3877e17a..bfaee70e 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; using StardewModdingAPI.Enums; using StardewModdingAPI.Framework; @@ -165,6 +164,9 @@ namespace StardewModdingAPI /// The language code for non-translated mod assets. internal static LocalizedContentManager.LanguageCode DefaultLanguage { get; } = LocalizedContentManager.LanguageCode.en; + /// The name of the last save file loaded by the game. + internal static string LastRawSaveFileName { get; set; } + /********* ** Internal methods @@ -341,30 +343,9 @@ namespace StardewModdingAPI if (Context.LoadStage == LoadStage.None) return null; - // get basic info - string rawSaveName = Game1.GetSaveGameName(set_value: false); - ulong saveID = Context.LoadStage == LoadStage.SaveParsed - ? SaveGame.loaded.uniqueIDForThisGame - : Game1.uniqueIDForThisGame; - - // get best match (accounting for rare case where folder name isn't sanitized) - DirectoryInfo folder = null; - foreach (string saveName in new[] { rawSaveName, new string(rawSaveName.Where(char.IsLetterOrDigit).ToArray()) }) - { - try - { - folder = new DirectoryInfo(Path.Combine(Constants.SavesPath, $"{saveName}_{saveID}")); - if (folder.Exists) - return folder; - } - catch (ArgumentException) - { - // ignore invalid path - } - } - - // if save doesn't exist yet, return the default one we expect to be created - return folder; + // get save + string rawSaveName = Constants.LastRawSaveFileName; + return new DirectoryInfo(Path.Combine(Constants.SavesPath, rawSaveName)); } } } -- cgit From 1bb51b2c41bf5acdffb8e25c37187e9bdf9d3dd4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 3 Aug 2021 19:11:26 -0400 Subject: prepare for release --- src/SMAPI/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI/Constants.cs') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index bfaee70e..05800970 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -60,7 +60,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.12.0"; + internal static string RawApiVersion = "3.12.1"; } /// Contains SMAPI's constants and assumptions. -- cgit