From 5f20368fe2ea5f252b0e534c69c76f06c2b04f07 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 19 Mar 2025 00:03:42 +0100 Subject: [PATCH] The expansions must be loaded in correct order.... fuck --- lib/mod.dart | 2 +- lib/mod_list.dart | 14 +++++++++---- test/mod_list_regressive_test.dart | 14 ++++++------- test/mod_list_test.dart | 32 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/lib/mod.dart b/lib/mod.dart index 647b549..269ab7d 100644 --- a/lib/mod.dart +++ b/lib/mod.dart @@ -361,4 +361,4 @@ class Mod { enabled: enabled ?? this.enabled, ); } -} +} \ No newline at end of file diff --git a/lib/mod_list.dart b/lib/mod_list.dart index 09623a1..9a2553f 100644 --- a/lib/mod_list.dart +++ b/lib/mod_list.dart @@ -240,7 +240,11 @@ class ModList { final modId = modElement.innerText.toLowerCase(); if (specialMods.containsKey(modId)) { - mods[modId] = specialMods[modId]!; + logger.info('Loading special mod: $modId'); + mods[modId] = specialMods[modId]!.copyWith(); + setEnabled(modId, true); + logger.info('Enabled special mod: $modId'); + yield mods[modId]!; continue; } @@ -382,12 +386,14 @@ class ModList { loadOrder ??= LoadOrder(); final logger = Logger.instance; logger.info('Generating load order...'); - - for (var mod in activeMods.values) { + for (final mod in activeMods.values) { logger.info('Checking mod: ${mod.id}'); if (specialMods.containsKey(mod.id)) { logger.info('Special mod: ${mod.id}'); - mod = specialMods[mod.id]!.copyWith(); + // Replace our fake base game mod with the chad one + // This is a bit of a hack, but it works + activeMods[mod.id] = specialMods[mod.id]!.copyWith(); + mods[mod.id] = specialMods[mod.id]!.copyWith(); } logger.info('Mod details: ${mod.toString()}'); for (final incomp in mod.incompatibilities) { diff --git a/test/mod_list_regressive_test.dart b/test/mod_list_regressive_test.dart index 3e0e5dc..f459784 100644 --- a/test/mod_list_regressive_test.dart +++ b/test/mod_list_regressive_test.dart @@ -200,10 +200,10 @@ void main() { final expected = [ 'brrainz.harmony', 'ludeon.rimworld', - 'ludeon.rimworld.anomaly', - 'ludeon.rimworld.biotech', - 'ludeon.rimworld.ideology', 'ludeon.rimworld.royalty', + 'ludeon.rimworld.ideology', + 'ludeon.rimworld.biotech', + 'ludeon.rimworld.anomaly', 'dubwise.rimatomics', 'jecrell.doorsexpanded', 'dubwise.rimefeller', @@ -304,10 +304,10 @@ void main() { 'brrainz.harmony', 'ludeon.rimworld', 'bs.betterlog', - 'ludeon.rimworld.anomaly', 'ludeon.rimworld.royalty', 'ludeon.rimworld.ideology', 'ludeon.rimworld.biotech', + 'ludeon.rimworld.anomaly', ]; expect(order.loadOrder, equals(expected)); }); @@ -712,10 +712,10 @@ void main() { 'brrainz.harmony', 'ludeon.rimworld', 'bs.betterlog', - 'ludeon.rimworld.anomaly', - 'ludeon.rimworld.biotech', - 'ludeon.rimworld.ideology', 'ludeon.rimworld.royalty', + 'ludeon.rimworld.ideology', + 'ludeon.rimworld.biotech', + 'ludeon.rimworld.anomaly', 'rah.rbse', 'mlie.usethisinstead', 'dubwise.rimatomics', diff --git a/test/mod_list_test.dart b/test/mod_list_test.dart index adf0445..d926255 100644 --- a/test/mod_list_test.dart +++ b/test/mod_list_test.dart @@ -182,6 +182,38 @@ void main() { expect(result.errors, isEmpty); expect(result.loadOrder, equals(expected)); }); + test('Expansions should load in the correct order', () { + final list = ModList(); + // Intentionally left barren because that's how we get it out of the box + // It is up to generateLoadOrder to fill in the details + list.mods = { + 'ludeon.rimworld': makeDummy().copyWith(id: 'ludeon.rimworld'), + 'ludeon.rimworld.anomaly': makeDummy().copyWith( + id: 'ludeon.rimworld.anomaly', + ), + 'ludeon.rimworld.ideology': makeDummy().copyWith( + id: 'ludeon.rimworld.ideology', + ), + 'ludeon.rimworld.biotech': makeDummy().copyWith( + id: 'ludeon.rimworld.biotech', + ), + 'ludeon.rimworld.royalty': makeDummy().copyWith( + id: 'ludeon.rimworld.royalty', + ), + }; + list.enableAll(); + final result = list.generateLoadOrder(); + + final expected = [ + 'ludeon.rimworld', + 'ludeon.rimworld.royalty', + 'ludeon.rimworld.ideology', + 'ludeon.rimworld.biotech', + 'ludeon.rimworld.anomaly', + ]; + expect(result.errors, isEmpty); + expect(result.loadOrder, equals(expected)); + }); }); group('Test loadRequired', () {