From cb9d6ae5ad9252c2a36174856b28f12344d026f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 4 Dec 2021 23:47:27 -0500 Subject: improve error when installer is pointed at a SDV 1.5.4 folder --- src/SMAPI.Installer/InteractiveInstaller.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index d8c27a2d..424fe42b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -704,7 +704,15 @@ namespace StardewModdingApi.Installer } if (!context.LooksLikeGameFolder(directory)) { - this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); + if (context.LooksLikeStardewValley154(directory)) + { + this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier."); + this.PrintWarning("Please update your game to the latest version to use SMAPI."); + } + else + { + this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); + } continue; } -- cgit From 98d01d522d488192b5d5da50d70752a8c0739a94 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 5 Dec 2021 00:51:24 -0500 Subject: improve error when installer is pointed at a compatibility-branch game folder --- docs/release-notes.md | 2 +- src/SMAPI.Installer/Framework/InstallerContext.cs | 6 +- src/SMAPI.Installer/InteractiveInstaller.cs | 65 ++++++++++++++++------ .../Framework/GameScanning/GameFolderType.cs | 21 +++++++ .../Framework/GameScanning/GameScanner.cs | 54 ++++++++++++------ 5 files changed, 111 insertions(+), 37 deletions(-) create mode 100644 src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs') diff --git a/docs/release-notes.md b/docs/release-notes.md index aa9b488c..8c2b6a9e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -4,7 +4,7 @@ ## Upcoming version * For players: * You no longer need .NET 5 installed to run SMAPI or the installer. - * The installer now detects when the game folder contains an incompatible older game version. + * The installer now detects when the game folder contains an incompatible legacy game version. * Updated for the latest Stardew Valley 1.5.5 hotfix. * For SMAPI maintainers: diff --git a/src/SMAPI.Installer/Framework/InstallerContext.cs b/src/SMAPI.Installer/Framework/InstallerContext.cs index 68df2001..bb973230 100644 --- a/src/SMAPI.Installer/Framework/InstallerContext.cs +++ b/src/SMAPI.Installer/Framework/InstallerContext.cs @@ -55,11 +55,11 @@ namespace StardewModdingAPI.Installer.Framework return this.GameScanner.LooksLikeGameFolder(dir); } - /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier. + /// Get whether a folder seems to contain the game, and which version it contains if so. /// The folder to check. - public bool LooksLikeStardewValley154(DirectoryInfo dir) + public GameFolderType GetGameFolderType(DirectoryInfo dir) { - return this.GameScanner.LooksLikeStardewValley154(dir); + return this.GameScanner.GetGameFolderType(dir); } } } diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 424fe42b..6694c257 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -10,6 +10,7 @@ using StardewModdingAPI.Installer.Framework; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework; +using StardewModdingAPI.Toolkit.Framework.GameScanning; using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Utilities; @@ -633,18 +634,39 @@ namespace StardewModdingApi.Installer // use specified path if (specifiedPath != null) { + string errorPrefix = $"You specified --game-path \"{specifiedPath}\", but"; + var dir = new DirectoryInfo(specifiedPath); if (!dir.Exists) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't exist."); + this.PrintError($"{errorPrefix} that folder doesn't exist."); return null; } - if (!context.LooksLikeGameFolder(dir)) + + switch (context.GetGameFolderType(dir)) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't contain the Stardew Valley executable."); - return null; + case GameFolderType.Valid: + return dir; + + case GameFolderType.Legacy154OrEarlier: + this.PrintWarning($"{errorPrefix} that directory seems to have Stardew Valley 1.5.4 or earlier."); + this.PrintWarning("Please update your game to the latest version to use SMAPI."); + return null; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + return null; + + case GameFolderType.NoGameFound: + this.PrintWarning($"{errorPrefix} that directory doesn't contain a Stardew Valley executable."); + return null; + + default: + this.PrintWarning($"{errorPrefix} that directory doesn't seem to contain a valid game install."); + return null; } - return dir; } // let user choose detected path @@ -702,23 +724,32 @@ namespace StardewModdingApi.Installer this.PrintWarning("That directory doesn't seem to exist."); continue; } - if (!context.LooksLikeGameFolder(directory)) + + switch (context.GetGameFolderType(directory)) { - if (context.LooksLikeStardewValley154(directory)) - { + case GameFolderType.Valid: + this.PrintInfo(" OK!"); + return directory; + + case GameFolderType.Legacy154OrEarlier: this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier."); this.PrintWarning("Please update your game to the latest version to use SMAPI."); - } - else - { + continue; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + continue; + + case GameFolderType.NoGameFound: this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); - } - continue; - } + continue; - // looks OK - this.PrintInfo(" OK!"); - return directory; + default: + this.PrintWarning("That directory doesn't seem to contain a valid game install."); + continue; + } } } diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs new file mode 100644 index 00000000..d18af59b --- /dev/null +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameFolderType.cs @@ -0,0 +1,21 @@ +namespace StardewModdingAPI.Toolkit.Framework.GameScanning +{ + /// The detected validity for a Stardew Valley game folder based on file structure heuristics. + public enum GameFolderType + { + /// The folder seems to contain a valid Stardew Valley 1.5.5+ install. + Valid, + + /// The folder doesn't contain Stardew Valley. + NoGameFound, + + /// The folder contains Stardew Valley 1.5.4 or earlier. This version uses XNA Framework and 32-bit .NET Framework 4.5.2 on Windows and Mono on Linux/macOS, and isn't compatible with current versions of SMAPI. + Legacy154OrEarlier, + + /// The folder contains Stardew Valley from the game's legacy compatibility branch, which backports newer changes to the format. + LegacyCompatibilityBranch, + + /// The folder seems to contain Stardew Valley files, but they failed to load for unknown reasons (e.g. corrupted executable). + InvalidUnknown + } +} diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs index c7ebe6e0..37e4f263 100644 --- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs +++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs @@ -55,36 +55,58 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning /// The folder to check. public bool LooksLikeGameFolder(DirectoryInfo dir) { - return - dir.Exists - && dir.EnumerateFiles("Stardew Valley.dll").Any(); + return this.GetGameFolderType(dir) == GameFolderType.Valid; } - /// Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier. + /// Detect the validity of a game folder based on file structure heuristics. /// The folder to check. - public bool LooksLikeStardewValley154(DirectoryInfo dir) + public GameFolderType GetGameFolderType(DirectoryInfo dir) { - if (!dir.Exists || this.LooksLikeGameFolder(dir)) - return false; + // no such folder + if (!dir.Exists) + return GameFolderType.NoGameFound; - // get legacy executable - FileInfo executable = new FileInfo(Path.Combine(dir.FullName, "Stardew Valley.exe")); + // apparently valid + if (dir.EnumerateFiles("Stardew Valley.dll").Any()) + return GameFolderType.Valid; + + // doesn't contain any version of Stardew Valley + FileInfo executable = new(Path.Combine(dir.FullName, "Stardew Valley.exe")); if (!executable.Exists) - executable = new FileInfo(Path.Combine(dir.FullName, "StardewValley.exe")); + executable = new(Path.Combine(dir.FullName, "StardewValley.exe")); // pre-1.5.5 Linux/macOS executable if (!executable.Exists) - return false; + return GameFolderType.NoGameFound; - // check if it's a standard .NET assembly - // This will fail in Stardew Valley 1.5.5+, where it's a binary wrapper around Stardew Valley.dll. + // get assembly version + Version version; try { - Version version = AssemblyName.GetAssemblyName(executable.FullName).Version; - return true; + version = AssemblyName.GetAssemblyName(executable.FullName).Version; } catch { - return false; + // The executable exists but it doesn't seem to be a valid assembly. This would + // happen with Stardew Valley 1.5.5+, but that should have been flagged as a valid + // folder before this point. + return GameFolderType.InvalidUnknown; } + + // ignore Stardew Valley 1.5.5+ at this point + if (version.Major == 1 && version.Minor == 3 && version.Build == 37) + return GameFolderType.InvalidUnknown; + + // incompatible version + if (version.Major == 1 && version.Minor < 4) + { + // Stardew Valley 1.5.4 and earlier have assembly versions <= 1.3.7853.31734 + if (version.Minor < 3 || version.Build <= 7853) + return GameFolderType.Legacy154OrEarlier; + + // Stardew Valley 1.5.5+ legacy compatibility branch + return GameFolderType.LegacyCompatibilityBranch; + } + + return GameFolderType.InvalidUnknown; } /********* -- cgit From 5b5dd47c22a1332a4c432d6a1cd414b5c83388d7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 5 Dec 2021 19:10:28 -0500 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 8 +++++--- src/SMAPI.Installer/InteractiveInstaller.cs | 4 ++-- 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 +- 7 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs') diff --git a/build/common.targets b/build/common.targets index ed860eee..1021c2a1 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,7 +1,7 @@ - 3.13.1 + 3.13.2 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 8a26514d..499fa322 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,9 +1,11 @@ ← [README](README.md) # Release notes -## Upcoming version +## 3.13.2 +Released 05 December 2021 for Stardew Valley 1.5.5 or later. + * For players: - * You no longer need .NET 5 installed to run SMAPI or the installer. + * You no longer need .NET 5 to install or use SMAPI. * The installer now detects when the game folder contains an incompatible legacy game version. * Updated for the latest Stardew Valley 1.5.5 hotfix. * Updated compatibility list. @@ -12,7 +14,7 @@ * Fixed the JSON validator marking `.fnt` files invalid in Content Patcher files. * For SMAPI maintainers: - * Added a new [scripted release package process](technical/smapi.md), which removes the need to compile SMAPI on multiple platforms and manually combine them. + * Added [release package scripts](technical/smapi.md) to streamline preparing SMAPI releases. ## 3.13.1 Released 30 November 2021 for Stardew Valley 1.5.5 or later. diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 6694c257..1257f12b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -655,7 +655,7 @@ namespace StardewModdingApi.Installer case GameFolderType.LegacyCompatibilityBranch: this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); - this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); this.PrintWarning("Please update your game to the main branch to use SMAPI."); return null; @@ -738,7 +738,7 @@ namespace StardewModdingApi.Installer case GameFolderType.LegacyCompatibilityBranch: this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); - this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); this.PrintWarning("Please update your game to the main branch to use SMAPI."); continue; diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index ac6ff6ea..216a4c32 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.13.1", + "Version": "3.13.2", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index e19a6a7f..beb52020 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.13.1", + "Version": "3.13.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.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 3e55ce42..2bd20a63 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.13.1", + "Version": "3.13.2", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.13.1" + "MinimumApiVersion": "3.13.2" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index c5ad215c..5de28f84 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -49,7 +49,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.13.1"; + internal static string RawApiVersion = "3.13.2"; } /// Contains SMAPI's constants and assumptions. -- cgit