Skip to content

Commit 6db852c

Browse files
committed
Creating a MM check for KSP 1.12 (things changed a lot on DLL loading)
1 parent 7bd1e20 commit 6db852c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Source/ModuleManagerWatchDog/Startup.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ private void Start()
4141
if (null == msg && SanityLib.IsEnforceable(1, 8))
4242
msg = CheckModuleManager18();
4343

44+
if (null == msg && SanityLib.IsEnforceable(1, 12))
45+
msg = CheckModuleManager112();
46+
4447
if ( null != msg )
4548
GUI.ShowStopperAlertBox.Show(msg);
4649
}
@@ -81,5 +84,26 @@ private string CheckModuleManager18()
8184
if (1 != loaded.Count()) return "There're more than one Module Manager on this KSP installment! Please delete all but the one you intend to use!";
8285
return null;
8386
}
87+
88+
// KSP 1.12 makes my life harder with this new way of loading Assemblies electing by version.
89+
// This will make badly installed DDLs a bit more dificult to diagnose.
90+
// Now I have to detected if MM/L is installed together Canonical MM by brute force.
91+
// If no MM/L is installed, I will let it go as is.
92+
private string CheckModuleManager112()
93+
{
94+
IEnumerable<System.Reflection.Assembly> loaded = SanityLib.FetchAssembliesByName(ASSEMBLY_NAME);
95+
System.Reflection.Assembly assembly = loaded.First();
96+
AssemblyTitleAttribute attributes = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute), false);
97+
string assemblyTittle = attributes.Title ?? "";
98+
if (
99+
(System.IO.File.Exists("GameData/ModuleManager.dll") && !assembly.Location.EndsWith("GameData/ModuleManager.dll"))
100+
||
101+
(assemblyTittle.StartsWith("Module Manager /L") && !assembly.Location.EndsWith("/ModuleManager.dll"))
102+
||
103+
(assembly.Location.EndsWith("/ModuleManager.dll") && !assemblyTittle.StartsWith("Module Manager /L"))
104+
)
105+
return "There're conflicting Module Manager versions on your instalment! You need to choose one version and remove the other(s)!";
106+
return null;
107+
}
84108
}
85109
}

0 commit comments

Comments
 (0)