Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NotNite/GDWeave
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Nov 1, 2024
2 parents 9921d56 + 5ed074a commit de097ba
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions GDWeave/Loader/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ private void Register() {
: null
};

if (loadedMod.AssemblyPath != null && !File.Exists(loadedMod.AssemblyPath)) {
this.logger.Warning("Assembly at {AssemblyPath} does not exist", loadedMod.AssemblyPath);
continue;
}

if (loadedMod.PackPath != null && !File.Exists(loadedMod.PackPath)) {
this.logger.Warning("Pack file at {PackPath} does not exist", loadedMod.PackPath);
continue;
}

this.LoadedMods.Add(loadedMod);
} catch (Exception e) {
this.logger.Warning(e, "Failed to load mod at {ModDir}", modDir);
Expand Down Expand Up @@ -97,6 +107,8 @@ private void Sort() {
}

private void LoadAssemblies() {
var invalidMods = new List<LoadedMod>();

foreach (var loadedMod in this.LoadedMods) {
if (loadedMod.AssemblyPath is not { } assemblyPath) continue;

Expand All @@ -107,8 +119,13 @@ private void LoadAssemblies() {
loadedMod.AssemblyMod = assemblyMod;
} catch (Exception e) {
this.logger.Warning(e, "Failed to load assembly for mod {ModId}", loadedMod.Manifest.Id);
invalidMods.Add(loadedMod);
}
}

foreach (var invalidMod in invalidMods) {
this.LoadedMods.Remove(invalidMod);
}
}

private IMod? LoadAssembly(string id, string assemblyPath) {
Expand Down

0 comments on commit de097ba

Please sign in to comment.