Skip to content

Commit fe3c957

Browse files
collectVoodMrBlue
authored andcommitted
Fix double loading of extensions if referenced by harmony mods
1 parent bb2331d commit fe3c957

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/Extensions/ExtensionManager.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ public Library GetLibrary(string name)
113113
/// Loads the extension at the specified filename
114114
/// </summary>
115115
/// <param name="filename"></param>
116-
/// <param name="isCoreOrGameExtension"></param>
117-
public void LoadExtension(string filename, bool isCoreOrGameExtension = false)
116+
public void LoadExtension(string filename)
118117
{
119118
string name = Utility.GetFileNameWithoutExtension(filename);
120119

@@ -125,9 +124,11 @@ public void LoadExtension(string filename, bool isCoreOrGameExtension = false)
125124
return;
126125
}
127126

128-
Assembly assembly = null;
129-
if (isCoreOrGameExtension) // Prevent double loading of core extensions
127+
try
130128
{
129+
Assembly assembly = null;
130+
131+
// Check if the assembly is already loaded
131132
foreach (Assembly loadedAssembly in AppDomain.CurrentDomain.GetAssemblies())
132133
{
133134
if (loadedAssembly.GetName().Name != name)
@@ -138,10 +139,7 @@ public void LoadExtension(string filename, bool isCoreOrGameExtension = false)
138139
assembly = loadedAssembly;
139140
break;
140141
}
141-
}
142142

143-
try
144-
{
145143
if (assembly == null)
146144
{
147145
// Read the assembly from file
@@ -267,7 +265,7 @@ public void ReloadExtension(string filename)
267265
// If the extension isn't already loaded, load it
268266
if (extension == null)
269267
{
270-
LoadExtension(filename, false);
268+
LoadExtension(filename);
271269
return;
272270
}
273271

@@ -287,7 +285,7 @@ public void ReloadExtension(string filename)
287285

288286
UnloadExtension(filename);
289287

290-
LoadExtension(filename, false);
288+
LoadExtension(filename);
291289
}
292290

293291
/// <summary>
@@ -349,12 +347,12 @@ public void LoadAllExtensions(string directory)
349347

350348
foreach (string extPath in foundCore)
351349
{
352-
LoadExtension(Path.Combine(directory, extPath), true);
350+
LoadExtension(Path.Combine(directory, extPath));
353351
}
354352

355353
foreach (string extPath in foundGame)
356354
{
357-
LoadExtension(Path.Combine(directory, extPath), true);
355+
LoadExtension(Path.Combine(directory, extPath));
358356
}
359357

360358
foreach (string extPath in foundOther)

src/OxideMod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public bool LoadExtension(string name)
602602
return false;
603603
}
604604

605-
extensionManager.LoadExtension(extPath, false);
605+
extensionManager.LoadExtension(extPath);
606606
return true;
607607
}
608608

0 commit comments

Comments
 (0)