Skip to content

Commit 9058327

Browse files
committed
Optimizing (fixing?) a bit the ModuleManagerConflict check for 1.12
1 parent 5e3f4a2 commit 9058327

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Source/ModuleManagerWatchDog/Startup.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private void Start()
4141
msg = CheckModuleManagerDoppelganger18();
4242

4343
if (null == msg && SanityLib.IsEnforceable(1, 12))
44-
msg = CheckModuleManager112();
44+
msg = CheckModuleManagerConflict112();
4545

4646

4747
if ( null != msg )
@@ -104,29 +104,33 @@ private string CheckModuleManagerDoppelganger18()
104104
}
105105

106106
// KSP 1.12 makes my life harder with this new way of loading Assemblies electing by version.
107+
//
107108
// This will make badly installed DDLs a bit more dificult to diagnose.
109+
//
108110
// Now I have to detected if MM/L is installed together Canonical MM by brute force.
111+
//
109112
// If no MM/L is installed, I will let it go as is.
110113
static readonly string GAMEDATAMMDLL = System.IO.Path.Combine("GameData", "ModuleManager.dll");
111114
static readonly string DASHMMDLL = GAMEDATAMMDLL.Replace("GameData", "");
112-
private string CheckModuleManager112()
115+
static readonly string FULLMMPATH = SanityLib.GetPathFor("GameData", "ModuleManager.dll");
116+
private string CheckModuleManagerConflict112()
113117
{
114118
IEnumerable<System.Reflection.Assembly> loaded = SanityLib.FetchAssembliesByName(ASSEMBLY_NAME);
115119
#if DEBUG
116120
Log.dbg("CheckModuleManager112");
117121
foreach (System.Reflection.Assembly a in loaded)
118122
Log.dbg("{0} :: {1}", a.FullName, a.Location);
119123
#endif
120-
System.Reflection.Assembly assembly = loaded.First();
124+
Assembly assembly = loaded.First();
121125
AssemblyTitleAttribute attributes = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute), false);
122126
string assemblyTittle = attributes.Title ?? "";
123127
Log.dbg("First ({0}) = {1} :: {2}", assemblyTittle, assembly.FullName, assembly.Location);
124128
if (
125-
(System.IO.File.Exists(GAMEDATAMMDLL) && !assembly.Location.EndsWith(GAMEDATAMMDLL))
129+
(System.IO.File.Exists(FULLMMPATH) && !assembly.Location.EndsWith(GAMEDATAMMDLL))
126130
||
127-
(assemblyTittle.StartsWith("Module Manager /L") && !assembly.Location.EndsWith(GAMEDATAMMDLL))
131+
(assemblyTittle.StartsWith("Module Manager /L") && !assembly.Location.EndsWith(DASHMMDLL))
128132
||
129-
(assembly.Location.EndsWith(GAMEDATAMMDLL) && !assemblyTittle.StartsWith("Module Manager /L"))
133+
(assembly.Location.EndsWith(DASHMMDLL) && !assemblyTittle.StartsWith("Module Manager /L"))
130134
)
131135
return "There're conflicting Module Manager versions on your instalment! You need to choose one version and remove the other(s)!";
132136
return null;

0 commit comments

Comments
 (0)