diff --git a/lib/mod_list.dart b/lib/mod_list.dart index 4f0efd1..89caf08 100644 --- a/lib/mod_list.dart +++ b/lib/mod_list.dart @@ -280,6 +280,7 @@ class ModList { loadOrder.errors.add( "Cyclic dependency detected: ${cyclePath.join(' -> ')}", ); + return; } if (!mod.visited) { @@ -514,12 +515,17 @@ class ModList { LoadOrder? loadOrder, List? toEnable, Map? seen, + List? cyclePath, ]) { final mod = mods[modId]!; loadOrder ??= LoadOrder(); toEnable ??= []; seen ??= {}; - + cyclePath ??= []; + + // Add current mod to cycle path + cyclePath.add(modId); + for (final dep in mod.dependencies) { if (!mods.containsKey(dep)) { loadOrder.errors.add( @@ -529,14 +535,22 @@ class ModList { } final depMod = mods[dep]!; if (seen[dep] == true) { - loadOrder.errors.add('Cyclic dependency detected: $modId -> $dep'); + // Find the start of the cycle + int cycleStart = cyclePath.indexOf(dep); + if (cycleStart >= 0) { + // Extract the cycle part + List cycleIds = [...cyclePath.sublist(cycleStart), modId]; + loadOrder.errors.add('Cyclic dependency detected: ${cycleIds.join(' -> ')}'); + } else { + loadOrder.errors.add('Cyclic dependency detected: $modId -> $dep'); + } continue; } seen[dep] = true; toEnable.add(depMod.id); - loadDependencies(depMod.id, loadOrder, toEnable, seen); + loadDependencies(depMod.id, loadOrder, toEnable, seen, List.from(cyclePath)); } - + return loadOrder; }