Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 375e40e

Browse files
committed
Make the version string debug log actually work
1 parent b73969b commit 375e40e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

NeosModLoader/NeosVersionReset.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ internal static void Initialize()
2323
ModLoaderConfiguration config = ModLoaderConfiguration.Get();
2424
Engine engine = Engine.Current;
2525

26+
// get the version string before we mess with it
27+
string originalVersionString = engine.VersionString;
28+
2629
List<string> extraAssemblies = Engine.ExtraAssemblies;
2730
string assemblyFilename = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
2831
bool nmlPresent = extraAssemblies.Remove(assemblyFilename);
@@ -118,7 +121,7 @@ internal static void Initialize()
118121

119122
// we intentionally attempt to set the version string first, so if it fails the compatibilty hash is left on the original value
120123
// this is to prevent the case where a player simply doesn't know their version string is wrong
121-
if (!SpoofVersionString(engine))
124+
if (!SpoofVersionString(engine, originalVersionString))
122125
{
123126
Logger.WarnInternal("Version string spoofing failed");
124127
return;
@@ -215,10 +218,8 @@ private static bool SetCompatibilityHash(Engine engine, string Target)
215218
}
216219
}
217220

218-
private static bool SpoofVersionString(Engine engine)
221+
private static bool SpoofVersionString(Engine engine, string originalVersionString)
219222
{
220-
string cachedVersion = engine.VersionString;
221-
222223
FieldInfo field = AccessTools.DeclaredField(engine.GetType(), "_versionString");
223224
if (field == null)
224225
{
@@ -228,7 +229,7 @@ private static bool SpoofVersionString(Engine engine)
228229
// null the cached value
229230
field.SetValue(engine, null);
230231

231-
Logger.DebugFuncInternal(() => $"Changing version string from {cachedVersion} to {engine.VersionString}");
232+
Logger.DebugFuncInternal(() => $"Changing version string from {originalVersionString} to {engine.VersionString}");
232233
return true;
233234
}
234235

0 commit comments

Comments
 (0)