From 499dbd269a5d85578777fd48f1768c1c67ef9119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Tue, 8 Apr 2025 03:28:01 +0300 Subject: [PATCH] Basic ignore of duplicate mods Only load the mod with highest priority for now. Proper behavior would be to keep metadata for all duplicates and load the first that isn't disabled. This allows easy mod source switching (for example, user mods and development mods) --- electron/src/mods/loader.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/electron/src/mods/loader.ts b/electron/src/mods/loader.ts index 79917906..1906e3cb 100644 --- a/electron/src/mods/loader.ts +++ b/electron/src/mods/loader.ts @@ -45,6 +45,12 @@ export class ModLoader { continue; } + // TODO: Only check this after applying disabled state + if (this.isModPresent(metadata.id)) { + console.warn(`Ignoring duplicate mod ${location.source}::${location.file}`); + continue; + } + mods.push({ ...location, disabled: false, @@ -69,6 +75,10 @@ export class ModLoader { return [...this.mods]; } + isModPresent(id: string): boolean { + return this.mods.some(mod => mod.metadata.id === id); + } + getModById(id: string): Mod | undefined { return this.mods.find(mod => mod.metadata.id === id); }