Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Aug 5, 2021
2 parents 2e442bf + b6e058c commit 80d3dd1
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
<Version>3.12.1</Version>
<Version>3.12.2</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Expand Down
11 changes: 11 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
[README](README.md)

# Release notes
## 3.12.2
Released 04 August 2021 for Stardew Valley 1.5.4 or later.

* For players:
* Fixed error creating a new save or joining a multiplayer world in 3.12.1.

* For mod authors:
* Reverted the `Constants.Save*` fix in SMAPI 3.12.1.
_The change caused a number of other issues, and is only needed for rare cases where the save folder was invalid. This may be revisited in a future version instead._
* Fixed `NullReferenceException` in SMAPI's error-handling when trying to handle an invalid `ReflectionTypeLoadException`.

## 3.12.1
Released 03 August 2021 for Stardew Valley 1.5.4 or later.

Expand Down
6 changes: 3 additions & 3 deletions src/SMAPI.Internal/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static string GetLogSummary(this Exception exception)
return $"Failed loading type '{ex.TypeName}': {exception}";

case ReflectionTypeLoadException ex:
string summary = exception.ToString();
foreach (Exception childEx in ex.LoaderExceptions)
summary += $"\n\n{childEx.GetLogSummary()}";
string summary = ex.ToString();
foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0])
summary += $"\n\n{childEx?.GetLogSummary()}";
return summary;

default:
Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ConsoleCommands/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
"Version": "3.12.1",
"Version": "3.12.2",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.12.1"
"MinimumApiVersion": "3.12.2"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ErrorHandler/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Error Handler",
"Author": "SMAPI",
"Version": "3.12.1",
"Version": "3.12.2",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll",
"MinimumApiVersion": "3.12.1"
"MinimumApiVersion": "3.12.2"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.SaveBackup/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
"Version": "3.12.1",
"Version": "3.12.2",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.12.1"
"MinimumApiVersion": "3.12.2"
}
33 changes: 26 additions & 7 deletions src/SMAPI/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using StardewModdingAPI.Enums;
using StardewModdingAPI.Framework;
Expand Down Expand Up @@ -60,7 +61,7 @@ internal static class EarlyConstants
internal static int? LogScreenId { get; set; }

/// <summary>SMAPI's current raw semantic version.</summary>
internal static string RawApiVersion = "3.12.1";
internal static string RawApiVersion = "3.12.2";
}

/// <summary>Contains SMAPI's constants and assumptions.</summary>
Expand Down Expand Up @@ -164,9 +165,6 @@ public static class Constants
/// <summary>The language code for non-translated mod assets.</summary>
internal static LocalizedContentManager.LanguageCode DefaultLanguage { get; } = LocalizedContentManager.LanguageCode.en;

/// <summary>The name of the last save file loaded by the game.</summary>
internal static string LastRawSaveFileName { get; set; }


/*********
** Internal methods
Expand Down Expand Up @@ -343,9 +341,30 @@ private static DirectoryInfo GetSaveFolder()
if (Context.LoadStage == LoadStage.None)
return null;

// get save
string rawSaveName = Constants.LastRawSaveFileName;
return new DirectoryInfo(Path.Combine(Constants.SavesPath, rawSaveName));
// 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;
}
}
}
8 changes: 0 additions & 8 deletions src/SMAPI/Framework/SCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public void RunInteractively()
MiniMonoModHotfix.Apply();
HarmonyPatcher.Apply("SMAPI", this.Monitor,
new Game1Patcher(this.Reflection, this.OnLoadStageChanged),
new SaveGamePatcher(this.OnSaveFileReading),
new TitleMenuPatcher(this.OnLoadStageChanged)
);

Expand Down Expand Up @@ -1102,13 +1101,6 @@ internal void OnLoadStageChanged(LoadStage newStage)
this.EventManager.ReturnedToTitle.RaiseEmpty();
}

/// <summary>Raised before the game begins reading a save file.</summary>
/// <param name="fileName">The save folder name.</param>
internal void OnSaveFileReading(string fileName)
{
Constants.LastRawSaveFileName = fileName;
}

/// <summary>Apply fixes to the save after it's loaded.</summary>
private void ApplySaveFixes()
{
Expand Down
55 changes: 0 additions & 55 deletions src/SMAPI/Patches/SaveGamePatcher.cs

This file was deleted.

0 comments on commit 80d3dd1

Please sign in to comment.