Skip to content

Commit

Permalink
Tweaks: Fix duplicate modules from incorrectly being loaded multiple …
Browse files Browse the repository at this point in the history
…times
  • Loading branch information
samfundev committed Aug 5, 2023
1 parent 7910f11 commit 3fd1d69
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Tweaks/TweaksAssembly/DemandBasedLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static IEnumerator GetModules()
// Loading a module
public static int modsLoading = 0;
public static readonly Dictionary<string, Mod> loadedMods = ModManager.Instance.GetValue<Dictionary<string, Mod>>("loadedMods");
private static readonly Dictionary<string, bool> modLoading = new Dictionary<string, bool>();
private static readonly HashSet<string> modLoading = new HashSet<string>();

private static int totalModules = 0;

Expand All @@ -282,9 +282,9 @@ private static IEnumerator LoadModule(BombComponent fakeModule, BombInfo bombInf
string SteamID = fakeModule.gameObject.name.Replace("(Clone)", "");
string ModuleID = fakeModule.GetModuleID();

if (modLoading.ContainsKey(SteamID))
if (modLoading.Contains(SteamID))
{
yield return new WaitUntil(() => !modLoading[SteamID]);
yield return new WaitUntil(() => !modLoading.Contains(SteamID));
}

if (!manuallyLoadedMods.TryGetValue(SteamID, out Mod mod))
Expand All @@ -293,7 +293,7 @@ private static IEnumerator LoadModule(BombComponent fakeModule, BombInfo bombInf
if (!Directory.Exists(modPath))
yield break;

modLoading[SteamID] = true;
modLoading.Add(SteamID);

mod = Mod.LoadMod(modPath, ModSourceEnum.Local);

Expand Down Expand Up @@ -330,7 +330,7 @@ private static IEnumerator LoadModule(BombComponent fakeModule, BombInfo bombInf

manuallyLoadedMods[SteamID] = mod;
loadedMods[modPath] = mod;
modLoading[SteamID] = false;
modLoading.Remove(SteamID);
}

loadOrder.Remove(SteamID);
Expand Down

0 comments on commit 3fd1d69

Please sign in to comment.