From 72ee547e1e0eb502a90381b3c9f1da3a9c5f2b18 Mon Sep 17 00:00:00 2001 From: atravita-mods <94934860+atravita-mods@users.noreply.github.com> Date: Sat, 15 Oct 2022 11:03:39 -0400 Subject: And fixing the indexing math again. --- src/SMAPI/Framework/Content/AssetDataForImage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs index 241c09a8..7c8cc6a8 100644 --- a/src/SMAPI/Framework/Content/AssetDataForImage.cs +++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs @@ -192,7 +192,7 @@ namespace StardewModdingAPI.Framework.Content int topOffset = startIndex / sourceArea.Width; int bottomOffset = endIndex / sourceArea.Width; - targetArea = new(targetArea.X, targetArea.Y + topOffset, targetArea.Width, bottomOffset - topOffset + 1); + targetArea = new(targetArea.X, targetArea.Y + topOffset - startRow, targetArea.Width, bottomOffset - topOffset + 1); pixelCount = targetArea.Width * targetArea.Height; sourceOffset = topOffset * sourceArea.Width; } -- cgit From e31c96d5b816caa9b0b9e950306b9292a87380d7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 16 Oct 2022 15:08:39 -0400 Subject: add missing test adapter package --- src/SMAPI.Tests/SMAPI.Tests.csproj | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/SMAPI.Tests/SMAPI.Tests.csproj b/src/SMAPI.Tests/SMAPI.Tests.csproj index 2c32a932..597cd7dd 100644 --- a/src/SMAPI.Tests/SMAPI.Tests.csproj +++ b/src/SMAPI.Tests/SMAPI.Tests.csproj @@ -19,6 +19,7 @@ + -- cgit From 0e4dd8a7b446d85d4603d55043af42aac5968b5a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 17 Oct 2022 20:02:19 -0400 Subject: prevent Steam vdf read errors from crashing the installer --- docs/release-notes.md | 3 ++ .../Framework/GameScanning/GameScanner.cs | 63 +++++++++++++--------- 2 files changed, 40 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/docs/release-notes.md b/docs/release-notes.md index ff5d61ba..02d085d5 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,9 @@ --> ## Upcoming release +* For players: + * Fixed installer crash if Steam's library data is invalid or in an old format; it'll now be ignored instead. + * For mod authors: * Fixed image patches sometimes applied one pixel higher than expected after 3.17.0 (thanks to atravita!). diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs index 1d518738..88142805 100644 --- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs @@ -261,39 +261,50 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning /// The game directory, if found. private string? GetPathFromSteamLibrary(string? steamPath) { - if (steamPath == null) - return null; - - // get .vdf file path - string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf"); - if (!File.Exists(libraryFoldersPath)) - return null; - - // read data - using FileStream fileStream = File.OpenRead(libraryFoldersPath); - VdfDeserializer deserializer = new(); - dynamic libraries = deserializer.Deserialize(fileStream); - if (libraries?.libraryfolders is null) - return null; - - // get path from Stardew Valley app (if any) - foreach (dynamic pair in libraries.libraryfolders) + try { - dynamic library = pair.Value; - - foreach (dynamic app in library.apps) + if (steamPath == null) + return null; + + // get .vdf file path + string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf"); + if (!File.Exists(libraryFoldersPath)) + return null; + + // read data + using FileStream fileStream = File.OpenRead(libraryFoldersPath); + VdfDeserializer deserializer = new(); + dynamic libraries = deserializer.Deserialize(fileStream); + if (libraries?.libraryfolders is null) + return null; + + // get path from Stardew Valley app (if any) + foreach (dynamic pair in libraries.libraryfolders) { - string key = app.Key; - if (key == GameScanner.SteamAppId) + dynamic library = pair.Value; + + foreach (dynamic app in library.apps) { - string path = library.path; + string key = app.Key; + if (key == GameScanner.SteamAppId) + { + string path = library.path; - return Path.Combine(path.Replace("\\\\", "\\"), "steamapps", "common", "Stardew Valley"); + return Path.Combine(path.Replace("\\\\", "\\"), "steamapps", "common", "Stardew Valley"); + } } } - } - return null; + return null; + } + catch + { + // The file might not be parseable in some cases (e.g. some players have an older Steam version using + // a different format). Ideally we'd log an error to know when it's actually an issue, but the SMAPI + // installer doesn't have a logging mechanism (and third-party code calling the toolkit may not either). + // So for now, just ignore the error and fallback to the other discovery mechanisms. + return null; + } } #endif } -- cgit From 8090b30c6e489ae213493328d6f84f15ca18a592 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 21 Oct 2022 20:12:02 -0400 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 5 +++-- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.ErrorHandler/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/build/common.targets b/build/common.targets index 2f1f822e..3c22b913 100644 --- a/build/common.targets +++ b/build/common.targets @@ -7,7 +7,7 @@ repo. It imports the other MSBuild files as needed. - 3.17.1 + 3.17.2 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 02d085d5..a8ddb0a0 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,10 +7,11 @@ _If needed, you can update to SMAPI 3.16.0 first and then install the latest version._ --> -## Upcoming release +## 3.17.2 +Released 21 October 2022 for Stardew Valley 1.5.6 or later. + * For players: * Fixed installer crash if Steam's library data is invalid or in an old format; it'll now be ignored instead. - * For mod authors: * Fixed image patches sometimes applied one pixel higher than expected after 3.17.0 (thanks to atravita!). diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index ecac30bf..d1296dbe 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.17.1", + "Version": "3.17.2", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.17.1" + "MinimumApiVersion": "3.17.2" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index 3d708876..c3757e8f 100644 --- a/src/SMAPI.Mods.ErrorHandler/manifest.json +++ b/src/SMAPI.Mods.ErrorHandler/manifest.json @@ -1,9 +1,9 @@ { "Name": "Error Handler", "Author": "SMAPI", - "Version": "3.17.1", + "Version": "3.17.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.17.1" + "MinimumApiVersion": "3.17.2" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index c2bf5f05..78821a3e 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.17.1", + "Version": "3.17.2", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.17.1" + "MinimumApiVersion": "3.17.2" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index ea41a4ee..77900ca6 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -52,7 +52,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.17.1"; + internal static string RawApiVersion = "3.17.2"; } /// Contains SMAPI's constants and assumptions. -- cgit