diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-21 23:28:18 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-21 23:28:18 -0400 |
commit | 88be0cee94cced9a31efe7ff76684514fcdc638d (patch) | |
tree | 4ee5a1414c6ca21a252f07ae2c69fa5de0f7bc9f /src/SMAPI/Program.cs | |
parent | 163511e68e3e94dcda6ffc8b7e32d91c1f6c0c17 (diff) | |
download | SMAPI-88be0cee94cced9a31efe7ff76684514fcdc638d.tar.gz SMAPI-88be0cee94cced9a31efe7ff76684514fcdc638d.tar.bz2 SMAPI-88be0cee94cced9a31efe7ff76684514fcdc638d.zip |
fix new validation checks
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r-- | src/SMAPI/Program.cs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index e6e51ac6..3249e02f 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -116,7 +116,7 @@ namespace StardewModdingAPI // bitness bool is64BitGame = LowLevelEnvironmentUtility.Is64BitAssembly(Path.Combine(EarlyConstants.ExecutionPath, $"{EarlyConstants.GameAssemblyName}.exe")); #if SMAPI_FOR_WINDOWS_64BIT_HACK - if (!is64bit) + 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) @@ -128,13 +128,16 @@ namespace StardewModdingAPI /// <remarks>Players sometimes have mismatched versions (particularly when installed through Vortex), which can cause some very confusing bugs without this check.</remarks> private static void AssertSmapiVersions() { - // SMAPI toolkit + // get SMAPI version without prerelease suffix (since we can't get that from the assembly versions) + ISemanticVersion smapiVersion = new SemanticVersion(Constants.ApiVersion.MajorVersion, Constants.ApiVersion.MinorVersion, Constants.ApiVersion.PatchVersion); + + // compare with assembly versions foreach (var type in new[] { typeof(IManifest), typeof(Manifest) }) { - Assembly assembly = type.Assembly; - var assemblyVersion = new SemanticVersion(assembly.GetName().Version); - if (!assemblyVersion.Equals(Constants.ApiVersion)) - Program.PrintErrorAndExit($"Oops! The 'smapi-internal/{assembly.GetName().Name}.dll' file is version {assemblyVersion} instead of the required {Constants.ApiVersion}. SMAPI doesn't seem to be installed correctly."); + AssemblyName assemblyName = type.Assembly.GetName(); + ISemanticVersion assemblyVersion = new SemanticVersion(assemblyName.Version); + if (!assemblyVersion.Equals(smapiVersion)) + Program.PrintErrorAndExit($"Oops! The 'smapi-internal/{assemblyName.Name}.dll' file is version {assemblyVersion} instead of the required {Constants.ApiVersion}. SMAPI doesn't seem to be installed correctly."); } } |