Skip to content

Commit 2d83c55

Browse files
authored
fix(#454): Ignore invalid version specifiers. (#463)
This should fix #454; if the version specified in mod-list.json is not found, we (like Factorio) will now load the newest version instead of failing.
2 parents f523fa4 + ae39330 commit 2d83c55

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Yafc.Parser/FactorioDataSource.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ public static Project Parse(string factorioPath, string modPath, string projectP
235235
foreach (var mod in allFoundMods) {
236236
CurrentLoadingMod = mod.name;
237237

238-
if (mod.ValidForFactorioVersion(factorioVersion) && allMods.TryGetValue(mod.name, out var existing) && (existing == null || mod.parsedVersion > existing.parsedVersion || (mod.parsedVersion == existing.parsedVersion && existing.zipArchive != null && mod.zipArchive == null)) && (!versionSpecifiers.TryGetValue(mod.name, out var version) || mod.parsedVersion == version)) {
238+
ModInfo? existing = null;
239+
bool modFound = mod.ValidForFactorioVersion(factorioVersion) && allMods.TryGetValue(mod.name, out existing);
240+
bool higherVersionOrFolder = existing == null || mod.parsedVersion > existing.parsedVersion || (mod.parsedVersion == existing.parsedVersion && existing.zipArchive != null && mod.zipArchive == null);
241+
bool existingMatchesVersionDirective = versionSpecifiers.TryGetValue(mod.name, out var version) && existing?.parsedVersion == version;
242+
243+
if (modFound && higherVersionOrFolder && !existingMatchesVersionDirective) {
239244
existing?.Dispose();
240245
allMods[mod.name] = mod;
241246
}

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date:
2121
- Prevent productivity bonuses from exceeding +300%, unless otherwise allowed by mods.
2222
- When loading duplicate research productivity effects, obey both of them, instead of failing.
2323
- Fixed a crash when item.weight == 0, related to ultracube.
24+
- If the requested mod version isn't found, use the latest, like Factorio.
2425
----------------------------------------------------------------------------------------------------------------------
2526
Version: 2.11.1
2627
Date: April 5th 2025

0 commit comments

Comments
 (0)