drop support for unofficial 64-bit mode

This commit is contained in:
Jesse Plamondon-Willard 2021-09-02 23:01:40 -04:00
parent 169ce01810
commit bbaa260007
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
13 changed files with 48 additions and 119 deletions

View File

@ -6,13 +6,8 @@
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
<!--uncomment for 64-bit Stardew Valley on Windows-->
<!--<GamePath>D:\dev\SDV 64-bit\6125897</GamePath>
<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS_64BIT_HACK</DefineConstants>-->
<!--set platform-->
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
<DefineConstants Condition="$(OS) == 'Windows_NT' AND !$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))">$(DefineConstants);SMAPI_FOR_XNA</DefineConstants>
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS;SMAPI_FOR_XNA</DefineConstants>
</PropertyGroup>
<!--find game folder-->

View File

@ -5,7 +5,8 @@
* For players:
* Added friendly error when using SMAPI 3.2._x_ with Stardew Valley 1.5.5 or later.
* Improved mod compatibility in 64-bit mode (thanks to spacechase0!).
* Reducing load time when scanning/rewriting many mods for compatibility.
* Reduced load time when scanning/rewriting many mods for compatibility.
* **Dropped support for unofficial 64-bit mode**. You can now use the [official 64-bit Stardew Valley 1.5.5 beta](https://stardewvalleywiki.com/Modding:Migrate_to_64-bit_on_Windows) instead.
* Updated compatibility list.
* For mod authors:

View File

@ -57,8 +57,7 @@ SMAPI uses a small number of conditional compilation constants, which you can se
flag | purpose
---- | -------
`SMAPI_FOR_WINDOWS` | Whether SMAPI is being compiled for Windows; if not set, the code assumes Linux/macOS. Set automatically in `common.targets`.
`SMAPI_FOR_WINDOWS_64BIT_HACK` | Whether SMAPI is being [compiled for Windows with a 64-bit Linux version of the game](https://github.com/Pathoschild/SMAPI/issues/767). This is highly specialized and shouldn't be used in most cases. False by default.
`SMAPI_FOR_XNA` | Whether SMAPI is being compiled for XNA Framework; if not set, the code assumes MonoGame. Set automatically in `common.targets` with the same value as `SMAPI_FOR_WINDOWS` (unless `SMAPI_FOR_WINDOWS_64BIT_HACK` is set).
`SMAPI_FOR_XNA` | Whether SMAPI is being compiled for XNA Framework; if not set, the code assumes MonoGame. Set automatically in `common.targets` with the same value as `SMAPI_FOR_WINDOWS`.
## For SMAPI developers
### Compiling from source
@ -81,9 +80,7 @@ To prepare a crossplatform SMAPI release, you'll need to compile it on two platf
[crossplatforming info](https://stardewvalleywiki.com/Modding:Modder_Guide/Test_and_Troubleshoot#Testing_on_all_platforms)
on the wiki for the first-time setup.
1. [Install a separate 64-bit version of Stardew Valley](https://github.com/Steviegt6/Stardew64Installer#readme)
on Windows.
2. Update the version numbers in `build/common.targets`, `Constants`, and the `manifest.json` for
1. Update the version numbers in `build/common.targets`, `Constants`, and the `manifest.json` for
bundled mods. Make sure you use a [semantic version](https://semver.org). Recommended format:
build type | format | example
@ -91,14 +88,9 @@ on the wiki for the first-time setup.
dev build | `<version>-alpha.<date>` | `3.0.0-alpha.20171230`
prerelease | `<version>-beta.<date>` | `3.0.0-beta.20171230`
release | `<version>` | `3.0.0`
3. In Windows:
2. In Windows:
1. Rebuild the solution with the _release_ solution configuration.
2. Back up the `bin/SMAPI installer` and `bin/SMAPI installer for developers` folders.
3. Edit `common.targets` and uncomment the Stardew Valley 64-bit section at the top.
4. Rebuild the solution again.
5. Rename the compiled `StardewModdingAPI.exe` file to `StardewModdingAPI-x64.exe`, and copy it
into the `windows-install.dat` files from step ii.
6. Copy the folders from step ii to Linux/MacOS.
2. Copy the `bin/SMAPI installer` and `bin/SMAPI installer for developers` folders to Linux/macOS.
4. In Linux/macOS:
1. Rebuild the solution with the _release_ solution configuration.
2. Add the `windows-install.*` files from Windows to the `bin/SMAPI installer` and

View File

@ -275,21 +275,20 @@ namespace StardewModdingApi.Installer
/*********
** Step 4: detect 64-bit Stardew Valley
** Step 4: validate assumptions
*********/
// detect 64-bit mode
bool isWindows64Bit = false;
// not 64-bit on Windows
if (context.Platform == Platform.Windows)
{
FileInfo linuxExecutable = new FileInfo(Path.Combine(paths.GamePath, "StardewValley.exe"));
isWindows64Bit = linuxExecutable.Exists && this.Is64Bit(linuxExecutable.FullName);
if (isWindows64Bit)
paths.SetExecutableFileName(linuxExecutable.Name);
if (linuxExecutable.Exists && this.Is64Bit(linuxExecutable.FullName))
{
this.PrintError("Oops! The detected game install path seems to be 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.");
Console.ReadLine();
return;
}
}
/*********
** Step 5: validate assumptions
*********/
// executable exists
if (!File.Exists(paths.ExecutablePath))
{
@ -301,7 +300,7 @@ namespace StardewModdingApi.Installer
// not Stardew Valley 1.5.5+
if (File.Exists(Path.Combine(paths.GamePath, "Stardew Valley.dll")))
{
this.PrintError($"Oops! The detected game install path seems to be Stardew Valley 1.5.5 or later, but this version of SMAPI is only compatible up to Stardew Valley 1.5.4. Please check for a newer version of SMAPI: https://smapi.io.");
this.PrintError("Oops! The detected game install path seems to be Stardew Valley 1.5.5 or later, but this version of SMAPI is only compatible up to Stardew Valley 1.5.4. Please check for a newer version of SMAPI: https://smapi.io.");
Console.ReadLine();
return;
}
@ -320,7 +319,7 @@ namespace StardewModdingApi.Installer
/*********
** Step 6: ask what to do
** Step 5: ask what to do
*********/
ScriptAction action;
{
@ -328,7 +327,7 @@ namespace StardewModdingApi.Installer
** print header
****/
this.PrintInfo("Hi there! I'll help you install or remove SMAPI. Just one question first.");
this.PrintDebug($"Game path: {paths.GamePath}{(context.IsWindows ? $" [{(isWindows64Bit ? "64-bit" : "32-bit")}]" : "")}");
this.PrintDebug($"Game path: {paths.GamePath}");
this.PrintDebug($"Color scheme: {this.GetDisplayText(scheme)}");
this.PrintDebug("----------------------------------------------------------------------------");
Console.WriteLine();
@ -366,14 +365,14 @@ namespace StardewModdingApi.Installer
/*********
** Step 7: apply
** Step 6: apply
*********/
{
/****
** print header
****/
this.PrintInfo($"That's all I need! I'll {action.ToString().ToLower()} SMAPI now.");
this.PrintDebug($"Game path: {paths.GamePath}{(context.IsWindows ? $" [{(isWindows64Bit ? "64-bit" : "32-bit")}]" : "")}");
this.PrintDebug($"Game path: {paths.GamePath}");
this.PrintDebug($"Color scheme: {this.GetDisplayText(scheme)}");
this.PrintDebug("----------------------------------------------------------------------------");
Console.WriteLine();
@ -434,25 +433,6 @@ namespace StardewModdingApi.Installer
this.RecursiveCopy(sourceEntry, paths.GameDir);
}
// handle 64-bit file
{
FileInfo x64Executable = new FileInfo(Path.Combine(paths.GameDir.FullName, "StardewModdingAPI-x64.exe"));
if (isWindows64Bit)
{
this.PrintDebug("Making SMAPI 64-bit...");
if (x64Executable.Exists)
{
string targetPath = Path.Combine(paths.GameDir.FullName, "StardewModdingAPI.exe");
this.InteractivelyDelete(targetPath);
x64Executable.MoveTo(targetPath);
}
else
this.PrintError($"Oops! Could not find the required '{x64Executable.Name}' installer file. SMAPI may not work correctly.");
}
else if (x64Executable.Exists)
x64Executable.Delete();
}
// replace mod launcher (if possible)
if (context.IsUnix)
{
@ -547,7 +527,7 @@ namespace StardewModdingApi.Installer
/*********
** Step 7: final instructions
** Step 6: final instructions
*********/
if (context.IsWindows)
{

View File

@ -19,7 +19,7 @@
<!-- Windows only -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
</ItemGroup>
<!-- Game framework -->

View File

@ -21,7 +21,7 @@
<!-- Windows only -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
</ItemGroup>
<!-- Game framework -->

View File

@ -39,14 +39,6 @@ namespace StardewModdingAPI
/// <summary>The target game platform.</summary>
internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform());
/// <summary>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.</summary>
internal static bool IsWindows64BitHack { get; } =
#if SMAPI_FOR_WINDOWS_64BIT_HACK
true;
#else
false;
#endif
/// <summary>The game framework running the game.</summary>
internal static GameFramework GameFramework { get; } =
#if SMAPI_FOR_XNA
@ -56,7 +48,7 @@ namespace StardewModdingAPI
#endif
/// <summary>The game's assembly name.</summary>
internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows && !EarlyConstants.IsWindows64BitHack ? "Stardew Valley" : "StardewValley";
internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows ? "Stardew Valley" : "StardewValley";
/// <summary>The <see cref="Context.ScreenId"/> value which should appear in the SMAPI log, if any.</summary>
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[]
{

View File

@ -57,8 +57,6 @@ namespace StardewModdingAPI.Framework.Content
IReflectedMethod method = reflection.GetMethod(typeof(TitleContainer), "GetCleanPath");
this.NormalizeAssetNameForPlatform = path => method.Invoke<string>(path);
}
else if (EarlyConstants.IsWindows64BitHack)
this.NormalizeAssetNameForPlatform = PathUtilities.NormalizePath;
else
this.NormalizeAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load<T> logic
}

View File

@ -291,14 +291,8 @@ namespace StardewModdingAPI.Framework.Logging
public void LogIntro(string modsPath, IDictionary<string, object> 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);
}
// log basic info
this.Monitor.Log($"Mods go here: {modsPath}", LogLevel.Info);
if (modsPath != Constants.DefaultModsPath)
@ -416,20 +410,6 @@ namespace StardewModdingAPI.Framework.Logging
gameMonitor.Log(message, level);
}
/// <summary>Get human-readable labels to log for detected SMAPI and Stardew Valley customizations.</summary>
private IEnumerable<string> 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}";
}
/// <summary>Write a summary of mod warnings to the console and log.</summary>
/// <param name="mods">The loaded mods.</param>
/// <param name="skippedMods">The mods which could not be loaded.</param>

View File

@ -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 ?? "<unknown>"}");
#endif
}
@ -1267,10 +1267,8 @@ namespace StardewModdingAPI.Framework
/// <summary>Set the titles for the game and console windows.</summary>
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;

View File

@ -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);

View File

@ -26,7 +26,7 @@ namespace StardewModdingAPI
/// <param name="args">The command-line arguments.</param>
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
}
/// <summary>Assert that the versions of all SMAPI components are correct.</summary>

View File

@ -14,10 +14,6 @@
<Import Project="..\..\build\common.targets" />
<PropertyGroup Condition="$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LargeAddressAware" Version="1.0.5" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
@ -39,7 +35,7 @@
<!-- Windows only -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>