From bbaa260007f67d6e3c88c1aae387b42b0c237063 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 2 Sep 2021 23:01:40 -0400 Subject: drop support for unofficial 64-bit mode --- src/SMAPI/Constants.cs | 12 ++---------- src/SMAPI/Framework/Content/ContentCache.cs | 2 -- src/SMAPI/Framework/Logging/LogManager.cs | 22 +--------------------- src/SMAPI/Framework/SCore.cs | 18 ++++++++---------- src/SMAPI/Metadata/InstructionMetadata.cs | 9 ++++----- src/SMAPI/Program.cs | 20 +++++++++----------- src/SMAPI/SMAPI.csproj | 6 +----- 7 files changed, 25 insertions(+), 64 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 247e32b7..ebb504db 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -39,14 +39,6 @@ namespace StardewModdingAPI /// The target game platform. internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform()); - /// Whether SMAPI is being compiled for Windows with a 64-bit Linux version of the game. This is highly specialized and shouldn't be used in most cases. - internal static bool IsWindows64BitHack { get; } = -#if SMAPI_FOR_WINDOWS_64BIT_HACK - true; -#else - false; -#endif - /// The game framework running the game. internal static GameFramework GameFramework { get; } = #if SMAPI_FOR_XNA @@ -56,7 +48,7 @@ namespace StardewModdingAPI #endif /// The game's assembly name. - internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows && !EarlyConstants.IsWindows64BitHack ? "Stardew Valley" : "StardewValley"; + internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows ? "Stardew Valley" : "StardewValley"; /// The value which should appear in the SMAPI log, if any. internal static int? LogScreenId { get; set; } @@ -269,7 +261,7 @@ namespace StardewModdingAPI targetAssemblies.Add(typeof(StardewModdingAPI.IManifest).Assembly); // get changes for platform - if (Constants.Platform != Platform.Windows || EarlyConstants.IsWindows64BitHack) + if (Constants.Platform != Platform.Windows) { removeAssemblyReferences.AddRange(new[] { diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs index 5c7ad778..7edc9ab9 100644 --- a/src/SMAPI/Framework/Content/ContentCache.cs +++ b/src/SMAPI/Framework/Content/ContentCache.cs @@ -57,8 +57,6 @@ namespace StardewModdingAPI.Framework.Content IReflectedMethod method = reflection.GetMethod(typeof(TitleContainer), "GetCleanPath"); this.NormalizeAssetNameForPlatform = path => method.Invoke(path); } - else if (EarlyConstants.IsWindows64BitHack) - this.NormalizeAssetNameForPlatform = PathUtilities.NormalizePath; else this.NormalizeAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load logic } diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index c6faa90d..6fe44d98 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -291,13 +291,7 @@ namespace StardewModdingAPI.Framework.Logging public void LogIntro(string modsPath, IDictionary customSettings) { // log platform & patches - { - this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform)}", LogLevel.Info); - - string[] patchLabels = this.GetPatchLabels().ToArray(); - if (patchLabels.Any()) - this.Monitor.Log($"Detected custom version: {string.Join(", ", patchLabels)}", LogLevel.Info); - } + this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform)}", LogLevel.Info); // log basic info this.Monitor.Log($"Mods go here: {modsPath}", LogLevel.Info); @@ -416,20 +410,6 @@ namespace StardewModdingAPI.Framework.Logging gameMonitor.Log(message, level); } - /// Get human-readable labels to log for detected SMAPI and Stardew Valley customizations. - private IEnumerable GetPatchLabels() - { - // custom game framework - if (EarlyConstants.IsWindows64BitHack) - yield return $"running 64-bit SMAPI with {Constants.GameFramework}"; - else if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows)) - yield return $"running {Constants.GameFramework}"; - - // patched by Stardew64Installer - if (Constants.IsPatchedByStardew64Installer(out ISemanticVersion patchedByVersion)) - yield return $"patched by Stardew64Installer {patchedByVersion}"; - } - /// Write a summary of mod warnings to the console and log. /// The loaded mods. /// The mods which could not be loaded. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index f7efc89e..ce5a701d 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -12,10 +12,10 @@ using System.Security; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.Xna.Framework; #if SMAPI_FOR_WINDOWS using Microsoft.Win32; #endif -using Microsoft.Xna.Framework; #if SMAPI_FOR_XNA using System.Windows.Forms; #endif @@ -436,7 +436,7 @@ namespace StardewModdingAPI.Framework Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice); // log GPU info -#if SMAPI_FOR_WINDOWS && !SMAPI_FOR_WINDOWS_64BIT_HACK +#if SMAPI_FOR_WINDOWS this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? ""}"); #endif } @@ -1267,10 +1267,8 @@ namespace StardewModdingAPI.Framework /// Set the titles for the game and console windows. private void UpdateWindowTitles() { - string smapiVersion = $"{Constants.ApiVersion}{(EarlyConstants.IsWindows64BitHack ? " [64-bit]" : "")}"; - - string consoleTitle = $"SMAPI {smapiVersion} - running Stardew Valley {Constants.GameVersion}"; - string gameTitle = $"Stardew Valley {Constants.GameVersion} - running SMAPI {smapiVersion}"; + string consoleTitle = $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}"; + string gameTitle = $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}"; if (this.ModRegistry.AreAllModsLoaded) { @@ -1737,10 +1735,10 @@ namespace StardewModdingAPI.Framework catch (Exception ex) { errorReasonPhrase = "its DLL couldn't be loaded."; -#if SMAPI_FOR_WINDOWS_64BIT_HACK - if (ex is BadImageFormatException && !EnvironmentUtility.Is64BitAssembly(assemblyPath)) - errorReasonPhrase = "it needs to be updated for 64-bit mode."; -#endif + // re-enable in Stardew Valley 1.5.5 + //if (ex is BadImageFormatException && !EnvironmentUtility.Is64BitAssembly(assemblyPath)) + // errorReasonPhrase = "it needs to be updated for 64-bit mode."; + errorDetails = $"Error: {ex.GetLogSummary()}"; failReason = ModFailReason.LoadFailed; return false; diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index 44d906ea..76371e50 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -48,13 +48,12 @@ namespace StardewModdingAPI.Metadata yield return new HeuristicFieldRewriter(this.ValidateReferencesToAssemblies); yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies); + // rewrite for 64-bit mode + // re-enable in Stardew Valley 1.5.5 + //yield return new ArchitectureAssemblyRewriter(); + // detect Harmony & rewrite for SMAPI 3.12 (Harmony 1.x => 2.0 update) yield return new HarmonyRewriter(); - - // rewrite for 64-bit mode -#if SMAPI_FOR_WINDOWS_64BIT_HACK - yield return new ArchitectureAssemblyRewriter(); -#endif } else yield return new HarmonyRewriter(shouldRewrite: false); diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index b6464f3c..3f97e531 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI /// The command-line arguments. public static void Main(string[] args) { - Console.Title = $"SMAPI {EarlyConstants.RawApiVersion}{(EarlyConstants.IsWindows64BitHack ? " 64-bit" : "")} - {Console.Title}"; + Console.Title = $"SMAPI {EarlyConstants.RawApiVersion} - {Console.Title}"; try { @@ -84,6 +84,14 @@ namespace StardewModdingAPI } catch (Exception ex) { + // unofficial 64-bit + if (EarlyConstants.Platform == GamePlatform.Windows) + { + FileInfo linuxExecutable = new FileInfo(Path.Combine(EarlyConstants.ExecutionPath, "StardewValley.exe")); + if (linuxExecutable.Exists && LowLevelEnvironmentUtility.Is64BitAssembly(linuxExecutable.FullName)) + Program.PrintErrorAndExit("Oops! You're running Stardew Valley in unofficial 64-bit mode, which is no longer supported. You can update to Stardew Valley 1.5.5 or later instead. See https://stardewvalleywiki.com/Modding:Migrate_to_64-bit_on_Windows for more info."); + } + // file doesn't exist if (!File.Exists(Path.Combine(EarlyConstants.ExecutionPath, $"{EarlyConstants.GameAssemblyName}.exe"))) Program.PrintErrorAndExit("Oops! SMAPI can't find the game. Make sure you're running StardewModdingAPI.exe in your game folder."); @@ -116,16 +124,6 @@ namespace StardewModdingAPI // max version if (Constants.MaximumGameVersion != null && Constants.GameVersion.IsNewerThan(Constants.MaximumGameVersion)) Program.PrintErrorAndExit($"Oops! You're running Stardew Valley {Constants.GameVersion}, but this version of SMAPI is only compatible up to Stardew Valley {Constants.MaximumGameVersion}. Please check for a newer version of SMAPI: https://smapi.io."); - - // bitness - bool is64BitGame = LowLevelEnvironmentUtility.Is64BitAssembly(Path.Combine(EarlyConstants.ExecutionPath, $"{EarlyConstants.GameAssemblyName}.exe")); -#if SMAPI_FOR_WINDOWS_64BIT_HACK - if (!is64BitGame) - Program.PrintErrorAndExit("Oops! This is the 64-bit version of SMAPI, but you have the 32-bit version of Stardew Valley. You can reinstall SMAPI using its installer to automatically install the correct version of SMAPI."); -#elif SMAPI_FOR_WINDOWS - if (is64BitGame) - Program.PrintErrorAndExit("Oops! This is the 32-bit version of SMAPI, but you have the 64-bit version of Stardew Valley. You can reinstall SMAPI using its installer to automatically install the correct version of SMAPI."); -#endif } /// Assert that the versions of all SMAPI components are correct. diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index 7d5e7ef9..0f1b0516 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -14,10 +14,6 @@ - - x64 - - @@ -39,7 +35,7 @@ - + -- cgit