summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-04-02 21:30:55 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-04-02 21:30:55 -0400
commit3fa0433c9862d1922cd0540848d2bd8716934d1f (patch)
tree2b09a736395b9bda09e3a4c408cdff51dbd63f81 /src/SMAPI
parent62c1f11109b3a16e4e1d526e8ddc891015c507b0 (diff)
downloadSMAPI-3fa0433c9862d1922cd0540848d2bd8716934d1f.tar.gz
SMAPI-3fa0433c9862d1922cd0540848d2bd8716934d1f.tar.bz2
SMAPI-3fa0433c9862d1922cd0540848d2bd8716934d1f.zip
add initial support for 64-bit Windows hack (#767)
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Constants.cs56
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs3
-rw-r--r--src/SMAPI/Framework/SCore.cs2
-rw-r--r--src/SMAPI/SMAPI.csproj6
4 files changed, 38 insertions, 29 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 8b0c952d..af9b7aa2 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -38,6 +38,14 @@ 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
@@ -47,7 +55,7 @@ namespace StardewModdingAPI
#endif
/// <summary>The game's assembly name.</summary>
- internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows ? "Stardew Valley" : "StardewValley";
+ internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows && !EarlyConstants.IsWindows64BitHack ? "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; }
@@ -231,33 +239,27 @@ namespace StardewModdingAPI
targetAssemblies.Add(typeof(StardewModdingAPI.IManifest).Assembly);
// get changes for platform
- switch (targetPlatform)
+ if (Constants.Platform != Platform.Windows || EarlyConstants.IsWindows64BitHack)
{
- case Platform.Linux:
- case Platform.Mac:
- removeAssemblyReferences.AddRange(new[]
- {
- "Netcode",
- "Stardew Valley"
- });
- targetAssemblies.Add(
- typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac
- );
- break;
-
- case Platform.Windows:
- removeAssemblyReferences.Add(
- "StardewValley"
- );
- targetAssemblies.AddRange(new[]
- {
- typeof(Netcode.NetBool).Assembly,
- typeof(StardewValley.Game1).Assembly
- });
- break;
-
- default:
- throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
+ removeAssemblyReferences.AddRange(new[]
+ {
+ "Netcode",
+ "Stardew Valley"
+ });
+ targetAssemblies.Add(
+ typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac
+ );
+ }
+ else
+ {
+ removeAssemblyReferences.Add(
+ "StardewValley"
+ );
+ targetAssemblies.AddRange(new[]
+ {
+ typeof(Netcode.NetBool).Assembly,
+ typeof(StardewValley.Game1).Assembly
+ });
}
// get changes for game framework
diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs
index 243ca3ae..38d561e5 100644
--- a/src/SMAPI/Framework/Logging/LogManager.cs
+++ b/src/SMAPI/Framework/Logging/LogManager.cs
@@ -287,6 +287,9 @@ namespace StardewModdingAPI.Framework.Logging
string platformLabel = EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform);
if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows))
platformLabel += $" with {Constants.GameFramework}";
+#if SMAPI_FOR_WINDOWS_64BIT_HACK
+ platformLabel += " 64-bit hack";
+#endif
// init logging
this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {platformLabel}", LogLevel.Info);
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index ebb21555..22c58099 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -419,7 +419,7 @@ namespace StardewModdingAPI.Framework
Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
// log GPU info
-#if SMAPI_FOR_WINDOWS
+#if SMAPI_FOR_WINDOWS && !SMAPI_FOR_WINDOWS_64BIT_HACK
this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}");
#endif
}
diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj
index ceef33df..413d9f33 100644
--- a/src/SMAPI/SMAPI.csproj
+++ b/src/SMAPI/SMAPI.csproj
@@ -14,6 +14,10 @@
<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.3" />
@@ -34,7 +38,7 @@
<!-- Windows only -->
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
- <Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
+ <Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>