Skip to content

Commit 587f682

Browse files
committed
Reworking the doppelgänger check for 1.12 (damn, Squad, damn!!)
1 parent 9058327 commit 587f682

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Source/ModuleManagerWatchDog/Startup.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ private void Start()
4343
if (null == msg && SanityLib.IsEnforceable(1, 12))
4444
msg = CheckModuleManagerConflict112();
4545

46+
if (null == msg && SanityLib.IsEnforceable(1, 12))
47+
msg = CheckModuleManagerDoppelganger112();
48+
4649

4750
if ( null != msg )
4851
GUI.ShowStopperAlertBox.Show(msg);
@@ -135,5 +138,28 @@ private string CheckModuleManagerConflict112()
135138
return "There're conflicting Module Manager versions on your instalment! You need to choose one version and remove the other(s)!";
136139
return null;
137140
}
141+
142+
// Trashing KSP's Assembly Loader/Resolver is essemtially common place, but sometimes these guys outdo themselves.
143+
//
144+
// Besides preventing multiple instances of the ModuleManager Assembly from being loaded, since KSP 1.12
145+
// **they still start them nevertheless**! This means the multiple ModuleManager's instances from the same Assembly can run
146+
// in parallel, **duplicating** all patching!
147+
//
148+
// DAMN, SQUAD!!! :(
149+
//
150+
// See https://github.com/net-lisias-ksp/ModuleManagerWatchDog/issues/6 for details.
151+
//
152+
private string CheckModuleManagerDoppelganger112()
153+
{
154+
Log.dbg("CheckModuleManagerDoppelganger112");
155+
156+
int hits = 0;
157+
foreach (AssemblyLoader.LoadedAssembly m in AssemblyLoader.loadedAssemblies)
158+
if (ASSEMBLY_NAME.Equals(m.assembly.GetName().Name)) ++hits;
159+
160+
if (hits > 1) return "There're more than one Module Manager on this KSP installment! Please delete all but the one you intend to use!";
161+
return null;
162+
}
163+
138164
}
139165
}

0 commit comments

Comments
 (0)