From 54bf73af3d5c2529a8dad6adab5142ef1d7b28cb Mon Sep 17 00:00:00 2001 From: fgsfds <4870330+fgsfds@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:46:37 +0500 Subject: [PATCH] added support for addons with multiple jsons, updated to 0.27.0 --- Directory.Build.props | 2 +- src/Addons/Helpers/AutoloadModsValidator.cs | 73 +- .../Providers/InstalledAddonsProvider.cs | 743 ++++++++++-------- .../InstalledAddonsProviderFactory.cs | 11 +- src/Ports/Ports/BasePort.cs | 7 +- .../CmdArguments/AutoloadModsProvider.cs | 61 +- .../CmdArguments/BloodCmdArgumentsTests.cs | 66 +- .../BloodLooseMapCmdArgumentsTests.cs | 24 +- .../CmdArguments/DukeCmdArgumentsTests.cs | 33 +- .../DukeLooseMapCmdArgumentsTests.cs | 24 +- .../CmdArguments/FuryCmdArgumentsTests.cs | 8 +- .../CmdArguments/WangCmdArgumentsTests.cs | 16 +- .../WangLooseMapsCmdArgumentsTests.cs | 16 +- 13 files changed, 611 insertions(+), 473 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index e71bc82..1f06eb4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 0.26.0 + 0.27.0 net9.0 enable latest diff --git a/src/Addons/Helpers/AutoloadModsValidator.cs b/src/Addons/Helpers/AutoloadModsValidator.cs index b6a99ef..5602a06 100644 --- a/src/Addons/Helpers/AutoloadModsValidator.cs +++ b/src/Addons/Helpers/AutoloadModsValidator.cs @@ -42,36 +42,70 @@ public static bool ValidateAutoloadMod(AutoloadMod autoloadMod, IAddon campaign, return false; } + var areDependenciesPassed = CheckDependencies(autoloadMod, campaign, mods); + + if (!areDependenciesPassed) + { + return false; + } + + var areIncompatiblesPassed = CheckIncompatibles(autoloadMod, campaign, mods); + + return areIncompatiblesPassed; + } + + + /// + /// Check if addon has all required dependencies + /// + private static bool CheckDependencies( + AutoloadMod autoloadMod, + IAddon campaign, + Dictionary mods) + { if (autoloadMod.DependentAddons is not null) { - foreach (var dependantAddon in autoloadMod.DependentAddons) + byte passedDependenciesCount = 0; + + foreach (var dependentAddon in autoloadMod.DependentAddons) { - if (campaign.Id.Equals(dependantAddon.Key, StringComparison.InvariantCultureIgnoreCase) && - (dependantAddon.Value is null || VersionComparer.Compare(campaign.Version, dependantAddon.Value))) + if (dependentAddon.Key.Equals(campaign.Id, StringComparison.InvariantCultureIgnoreCase) && + (dependentAddon.Value is null || VersionComparer.Compare(campaign.Version, dependentAddon.Value))) { - return true; + passedDependenciesCount++; } foreach (var addon in mods) { - if (!dependantAddon.Key.Equals(addon.Key.Id, StringComparison.InvariantCultureIgnoreCase)) + if (!dependentAddon.Key.Equals(addon.Key.Id, StringComparison.InvariantCultureIgnoreCase)) { continue; } - else if (dependantAddon.Value is null) + + if (dependentAddon.Value is null) { - return true; + passedDependenciesCount++; } - else if (VersionComparer.Compare(addon.Key.Version, dependantAddon.Value)) + else if (VersionComparer.Compare(addon.Key.Version, dependentAddon.Value)) { - return true; + passedDependenciesCount++; } } } - return false; + return autoloadMod.DependentAddons.Count == passedDependenciesCount; + } + else + { + return true; } + } + /// + /// Check if addon doesn't have any loaded incompatibles + /// + private static bool CheckIncompatibles(AutoloadMod autoloadMod, IAddon campaign, Dictionary mods) + { if (autoloadMod.IncompatibleAddons is not null) { foreach (var incompatibleAddon in autoloadMod.IncompatibleAddons) @@ -79,10 +113,13 @@ public static bool ValidateAutoloadMod(AutoloadMod autoloadMod, IAddon campaign, //What a fucking mess... //if campaign id equals addon id if (campaign.Id.Equals(incompatibleAddon.Key, StringComparison.InvariantCultureIgnoreCase) && - //AND either both campaign's and addon's versions are null - ((incompatibleAddon.Value is null && campaign.Version is null) || + //AND either campaign's id is null + (incompatibleAddon.Value is null || + //OR addon's versions are null + campaign.Version is null || //OR addon's version is not null and does match the comparer - (incompatibleAddon.Value is not null && VersionComparer.Compare(campaign.Version, incompatibleAddon.Value)))) + (incompatibleAddon.Value is not null && VersionComparer.Compare(campaign.Version, incompatibleAddon.Value)) + )) { //the addon is incompatible return false; @@ -94,12 +131,14 @@ public static bool ValidateAutoloadMod(AutoloadMod autoloadMod, IAddon campaign, { continue; } + if (addon.Value is AutoloadMod aMod && !aMod.IsEnabled) { continue; } - else if (incompatibleAddon.Value is null) + + if (incompatibleAddon.Value is null) { return false; } @@ -112,7 +151,9 @@ public static bool ValidateAutoloadMod(AutoloadMod autoloadMod, IAddon campaign, return true; } - - return true; + else + { + return true; + } } } diff --git a/src/Addons/Providers/InstalledAddonsProvider.cs b/src/Addons/Providers/InstalledAddonsProvider.cs index a55292a..b712a8d 100644 --- a/src/Addons/Providers/InstalledAddonsProvider.cs +++ b/src/Addons/Providers/InstalledAddonsProvider.cs @@ -8,6 +8,7 @@ using Common.Interfaces; using Common.Serializable.Addon; using CommunityToolkit.Diagnostics; +using Microsoft.Extensions.Logging; using SharpCompress.Archives; using System.Text.Json; @@ -20,6 +21,7 @@ public sealed class InstalledAddonsProvider : IInstalledAddonsProvider { private readonly IGame _game; private readonly IConfigProvider _config; + private readonly ILogger _logger; private readonly Dictionary> _cache; @@ -32,11 +34,13 @@ public sealed class InstalledAddonsProvider : IInstalledAddonsProvider [Obsolete($"Don't create directly. Use {nameof(InstalledAddonsProvider)}.")] public InstalledAddonsProvider( IGame game, - IConfigProvider config + IConfigProvider config, + ILogger logger ) { _game = game; _config = config; + _logger = logger; _cache = []; } @@ -45,6 +49,7 @@ IConfigProvider config /// Try to parse and copy addon into suitable folder /// /// Path to addon file + /// Copied successfully public async Task CopyAddonIntoFolder(string pathToFile) { if (!pathToFile.EndsWith(".zip", StringComparison.OrdinalIgnoreCase) && @@ -118,9 +123,11 @@ await Task.Run(async () => foreach (var dir in dirs) { - if (File.Exists(Path.Combine(dir, "addon.json"))) + var addonJsons = Directory.GetFiles(dir, "addon*.json"); + + if (addonJsons.Length > 0) { - filesTcs.Add(Path.Combine(dir, "addon.json")); + filesTcs.AddRange(addonJsons); } } @@ -171,9 +178,9 @@ await Task.Run(async () => AddonsChangedEvent?.Invoke(_game, null); } - catch + catch (Exception ex) { - //do nothing + _logger.LogCritical(ex, "=== Error while creating installed addons cache ==="); } finally { @@ -188,31 +195,34 @@ public async Task AddAddonAsync(string pathToFile) { Guard.IsNotNull(_cache); - var addon = await GetAddonFromFileAsync(pathToFile).ConfigureAwait(false); + var addons = await GetAddonFromFileAsync(pathToFile).ConfigureAwait(false); - if (addon is null) + if (addons is null or []) { await CreateCache(true).ConfigureAwait(false); return; } - if (!_cache.TryGetValue(addon.Type, out _)) + foreach (var addon in addons) { - _cache.Add(addon.Type, []); - } + if (!_cache.TryGetValue(addon.Type, out _)) + { + _cache.Add(addon.Type, []); + } - var dict = _cache[addon.Type]; + var dict = _cache[addon.Type]; - if (dict.TryGetValue(new(addon.Id, addon.Version), out _)) - { - dict[new(addon.Id, addon.Version)] = addon; - } - else - { - dict.Add(new(addon.Id, addon.Version), addon); - } + if (dict.TryGetValue(new(addon.Id, addon.Version), out _)) + { + dict[new(addon.Id, addon.Version)] = addon; + } + else + { + dict.Add(new(addon.Id, addon.Version), addon); + } - AddonsChangedEvent?.Invoke(_game, addon.Type); + AddonsChangedEvent?.Invoke(_game, addon.Type); + } } /// @@ -221,6 +231,9 @@ public void DeleteAddon(IAddon addon) Guard.IsNotNull(_cache); Guard.IsNotNull(addon.PathToFile); + addon.GridImage?.Dispose(); + addon.PreviewImage?.Dispose(); + if (addon.IsFolder) { Directory.Delete(Path.GetDirectoryName(addon.PathToFile)!, true); @@ -289,11 +302,11 @@ public Dictionary GetInstalledCampaigns() if (result is not null) { + //hack to make SW addons appear at the top of the list foreach (var customCamp in result - //hack so SW addons end up at the beginning of the list - .OrderByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.TwinDragon), StringComparison.InvariantCultureIgnoreCase)) - .ThenByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.Wanton), StringComparison.InvariantCultureIgnoreCase)) - .ThenBy(static x => x.Value.Title)) + .OrderByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.TwinDragon), StringComparison.InvariantCultureIgnoreCase)) + .ThenByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.Wanton), StringComparison.InvariantCultureIgnoreCase)) + .ThenBy(static x => x.Value.Title)) { campaigns.Add(customCamp.Key, customCamp.Value); } @@ -344,34 +357,44 @@ private async Task> GetAddonsFromFilesAsync(IEn { try { - var newAddon = await GetAddonFromFileAsync(file).ConfigureAwait(false); + var newAddons = await GetAddonFromFileAsync(file).ConfigureAwait(false); - if (newAddon is null) + if (newAddons is null or []) { continue; } - if (newAddon is AutoloadMod && - addedAddons.TryGetValue(new(newAddon.Id, newAddon.Version), out var existingMod)) + foreach (var newAddon in newAddons) { - if (existingMod.Version is null && - newAddon.Version is not null) + try { - //replacing with addon that have version - addedAddons[new(newAddon.Id, newAddon.Version)] = newAddon; + if (newAddon is AutoloadMod && + addedAddons.TryGetValue(new(newAddon.Id, newAddon.Version), out var existingMod)) + { + if (existingMod.Version is null && + newAddon.Version is not null) + { + //replacing with addon that have version + addedAddons[new(newAddon.Id, newAddon.Version)] = newAddon; + } + else if (existingMod.Version is not null && + newAddon.Version is not null && + VersionComparer.Compare(newAddon.Version, existingMod.Version, ">")) + { + //replacing with addon that have higher version + addedAddons[new(newAddon.Id, newAddon.Version)] = newAddon; + } + } + else + { + _ = addedAddons.TryAdd(new(newAddon.Id, newAddon.Version), newAddon); + } } - else if (existingMod.Version is not null && - newAddon.Version is not null && - VersionComparer.Compare(newAddon.Version, existingMod.Version, ">")) + catch (Exception) { - //replacing with addon that have higher version - addedAddons[new(newAddon.Id, newAddon.Version)] = newAddon; + continue; } } - else - { - _ = addedAddons.TryAdd(new(newAddon.Id, newAddon.Version), newAddon); - } } catch (Exception) { @@ -427,39 +450,15 @@ newAddon.Version is not null && /// Get addon from a file /// /// Path to addon file - private async Task GetAddonFromFileAsync(string pathToFile) + private async Task?> GetAddonFromFileAsync(string pathToFile) { - var supportedGame = _game.GameEnum; - - string id; - string title; - AddonTypeEnum type; - string version; - bool isUnpacked; - - string? author; - string? description; - Stream? image; - Stream? preview; - string? gameVersion; - string? gameCrc; - HashSet? requiredFeatures; - string? mainCon; - HashSet? addCons; - string? mainDef; - HashSet? addDefs; - string? rts; - string? ini; - string? rff; - string? snd; - Dictionary? dependencies; - Dictionary? incompatibles; - IStartMap? startMap; - Dictionary? executables; + List carcasses = []; if (pathToFile.EndsWith(".json")) { - isUnpacked = true; + AddonCarcass carcass = new(); + + carcass.IsUnpacked = true; var jsonText = File.ReadAllText(pathToFile); @@ -481,65 +480,67 @@ newAddon.Version is not null && if (gridFile.Length > 0) { var stream = await File.ReadAllBytesAsync(gridFile[0]).ConfigureAwait(false); - image = new MemoryStream(stream); + carcass.Image = new MemoryStream(stream); } else { - image = null; + carcass.Image = null; } if (previewFile.Length > 0) { var stream = await File.ReadAllBytesAsync(previewFile[0]).ConfigureAwait(false); - preview = new MemoryStream(stream); + carcass.Preview = new MemoryStream(stream); } else { - preview = null; + carcass.Preview = null; } - type = manifest.AddonType; - id = manifest.Id; - title = manifest.Title; - author = manifest.Author; - image ??= preview; - version = manifest.Version; - description = manifest.Description; - supportedGame = manifest.SupportedGame.Game; - gameVersion = manifest.SupportedGame.Version; - gameCrc = manifest.SupportedGame.Crc; + carcass.Type = manifest.AddonType; + carcass.Id = manifest.Id; + carcass.Title = manifest.Title; + carcass.Author = manifest.Author; + carcass.Image ??= carcass.Preview; + carcass.Version = manifest.Version; + carcass.Description = manifest.Description; + carcass.SupportedGame = manifest.SupportedGame.Game; + carcass.GameVersion = manifest.SupportedGame.Version; + carcass.GameCrc = manifest.SupportedGame.Crc; - rts = manifest.Rts; - ini = manifest.Ini; - rff = manifest.MainRff; - snd = manifest.SoundRff; + carcass.Rts = manifest.Rts; + carcass.Ini = manifest.Ini; + carcass.Rff = manifest.MainRff; + carcass.Snd = manifest.SoundRff; - startMap = manifest.StartMap; + carcass.StartMap = manifest.StartMap; - requiredFeatures = manifest.Dependencies?.RequiredFeatures?.Select(static x => x).ToHashSet(); + carcass.RequiredFeatures = manifest.Dependencies?.RequiredFeatures?.Select(static x => x).ToHashSet(); - mainCon = manifest.MainCon; - addCons = manifest.AdditionalCons?.ToHashSet(); + carcass.MainCon = manifest.MainCon; + carcass.AddCons = manifest.AdditionalCons?.ToHashSet(); - mainDef = manifest.MainDef; - addDefs = manifest.AdditionalDefs?.ToHashSet(); + carcass.MainDef = manifest.MainDef; + carcass.AddDefs = manifest.AdditionalDefs?.ToHashSet(); - dependencies = manifest.Dependencies?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); - incompatibles = manifest.Incompatibles?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); + carcass.Dependencies = manifest.Dependencies?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); + carcass.Incompatibles = manifest.Incompatibles?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); if (manifest.Executables is not null) { - executables = []; + carcass.Executables = []; foreach (var exe in manifest.Executables) { - executables.Add(exe.Key, Path.Combine(Path.GetDirectoryName(pathToFile)!, exe.Value)); + carcass.Executables.Add(exe.Key, Path.Combine(Path.GetDirectoryName(pathToFile)!, exe.Value)); } } else { - executables = null; + carcass.Executables = null; } + + carcasses.Add(carcass); } else if (pathToFile.EndsWith(".map", StringComparison.OrdinalIgnoreCase)) { @@ -551,7 +552,7 @@ newAddon.Version is not null && Id = Path.GetFileName(pathToFile), Type = AddonTypeEnum.Map, Title = Path.GetFileName(pathToFile), - SupportedGame = new(supportedGame, null, null), + SupportedGame = new(_game.GameEnum, null, null), PathToFile = pathToFile, StartMap = new MapFileDto() { File = Path.GetFileName(pathToFile) }, BloodIni = iniExists ? bloodIni : null, @@ -569,18 +570,22 @@ newAddon.Version is not null && Executables = null }; - return addon; + return [addon]; } else if (ArchiveFactory.IsArchive(pathToFile, out _)) { using var archive = ArchiveFactory.Open(pathToFile); - var unpackedTo = UnpackIfNeededAndGetAddonDto(pathToFile, archive, out var manifest); + var unpackedTo = UnpackIfNeededAndGetAddonDto(pathToFile, archive, out var manifests); - if (manifest is null) + if (manifests is null or []) { return null; } + bool isUnpacked = false; + Stream? image; + Stream? preview; + if (unpackedTo is not null) { pathToFile = Path.Combine(unpackedTo, "addon.json"); @@ -619,47 +624,58 @@ newAddon.Version is not null && image = ImageHelper.GetCoverFromArchive(archive) ?? preview; } - type = manifest.AddonType; - id = manifest.Id; - title = manifest.Title; - author = manifest.Author; - image ??= preview; - version = manifest.Version; - description = manifest.Description; - supportedGame = manifest.SupportedGame.Game; - gameVersion = manifest.SupportedGame.Version; - gameCrc = manifest.SupportedGame.Crc; + foreach (var manifest in manifests) + { + AddonCarcass carcass = new(); - rts = manifest.Rts; - ini = manifest.Ini; - rff = manifest.MainRff; - snd = manifest.SoundRff; + carcass.IsUnpacked = isUnpacked; + carcass.Image = image; + carcass.Preview = preview; - startMap = manifest.StartMap; + carcass.Type = manifest.AddonType; + carcass.Id = manifest.Id; + carcass.Title = manifest.Title; + carcass.Author = manifest.Author; + carcass.Image ??= carcass.Preview; + carcass.Version = manifest.Version; + carcass.Description = manifest.Description; + carcass.SupportedGame = manifest.SupportedGame.Game; + carcass.GameVersion = manifest.SupportedGame.Version; + carcass.GameCrc = manifest.SupportedGame.Crc; - requiredFeatures = manifest.Dependencies?.RequiredFeatures?.Select(static x => x).ToHashSet(); + carcass.Rts = manifest.Rts; + carcass.Ini = manifest.Ini; + carcass.Rff = manifest.MainRff; + carcass.Snd = manifest.SoundRff; - mainCon = manifest.MainCon; - addCons = manifest.AdditionalCons?.ToHashSet(); + carcass.StartMap = manifest.StartMap; - mainDef = manifest.MainDef; - addDefs = manifest.AdditionalDefs?.ToHashSet(); + carcass.RequiredFeatures = manifest.Dependencies?.RequiredFeatures?.Select(static x => x).ToHashSet(); - dependencies = manifest.Dependencies?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); - incompatibles = manifest.Incompatibles?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); + carcass.MainCon = manifest.MainCon; + carcass.AddCons = manifest.AdditionalCons?.ToHashSet(); - if (manifest.Executables is not null) - { - executables = []; + carcass.MainDef = manifest.MainDef; + carcass.AddDefs = manifest.AdditionalDefs?.ToHashSet(); - foreach (var exe in manifest.Executables) + carcass.Dependencies = manifest.Dependencies?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); + carcass.Incompatibles = manifest.Incompatibles?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase); + + if (manifest.Executables is not null) { - executables.Add(exe.Key, Path.Combine(Path.GetDirectoryName(pathToFile)!, exe.Value)); + carcass.Executables = []; + + foreach (var exe in manifest.Executables) + { + carcass.Executables.Add(exe.Key, Path.Combine(Path.GetDirectoryName(pathToFile)!, exe.Value)); + } } - } - else - { - executables = null; + else + { + carcass.Executables = null; + } + + carcasses.Add(carcass); } } else if (pathToFile.EndsWith(".grp", StringComparison.OrdinalIgnoreCase)) @@ -671,191 +687,196 @@ newAddon.Version is not null && return null; } + List addons = []; - if (type is AddonTypeEnum.Mod) + foreach (var carcass in carcasses) { - var isEnabled = !_config.DisabledAutoloadMods.Contains(id); - - if (mainDef is not null) - { - ThrowHelper.ThrowArgumentException("Autoload mod can't have Main DEF"); - } - - var addon = new AutoloadMod() + if (carcass.Type is AddonTypeEnum.Mod) { - Id = id, - Type = AddonTypeEnum.Mod, - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, - IsEnabled = isEnabled, - PathToFile = pathToFile, - MainDef = null, - AdditionalDefs = addDefs, - AdditionalCons = addCons, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = null - }; + var isEnabled = !_config.DisabledAutoloadMods.Contains(carcass.Id); - return addon; - } - else - { - if (_game.GameEnum - is GameEnum.Duke3D - or GameEnum.Fury - or GameEnum.Redneck - or GameEnum.NAM - or GameEnum.WW2GI) - { - var addon = new DukeCampaign() + if (carcass.MainDef is not null) { - Id = id, - Type = type, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, - PathToFile = pathToFile, - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - MainCon = mainCon, - AdditionalCons = addCons, - MainDef = mainDef, - AdditionalDefs = addDefs, - RTS = rts, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = executables - }; + ThrowHelper.ThrowArgumentException("Autoload mod can't have Main DEF"); + } - return addon; - } - else if (_game.GameEnum is GameEnum.ShadowWarrior) - { - var addon = new WangCampaign() + var addon = new AutoloadMod() { - Id = id, - Type = type, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, + Id = carcass.Id, + Type = AddonTypeEnum.Mod, + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + IsEnabled = isEnabled, PathToFile = pathToFile, - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - MainDef = mainDef, - AdditionalDefs = addDefs, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = executables + MainDef = null, + AdditionalDefs = carcass.AddDefs, + AdditionalCons = carcass.AddCons, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = null }; - return addon; + addons.Add(addon); } - else if (_game.GameEnum is GameEnum.Blood) + else { - var addon = new BloodCampaign() + if (_game.GameEnum + is GameEnum.Duke3D + or GameEnum.Fury + or GameEnum.Redneck + or GameEnum.NAM + or GameEnum.WW2GI) { - Id = id, - Type = type, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, - PathToFile = pathToFile, - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - MainDef = mainDef, - AdditionalDefs = addDefs, - INI = ini, - RFF = rff, - SND = snd, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = executables - }; - - return addon; - } - else if (_game.GameEnum is GameEnum.Exhumed) - { - var addon = new SlaveCampaign() + var addon = new DukeCampaign() + { + Id = carcass.Id, + Type = carcass.Type, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + PathToFile = pathToFile, + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + MainCon = carcass.MainCon, + AdditionalCons = carcass.AddCons, + MainDef = carcass.MainDef, + AdditionalDefs = carcass.AddDefs, + RTS = carcass.Rts, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = carcass.Executables + }; + + addons.Add(addon); + } + else if (_game.GameEnum is GameEnum.ShadowWarrior) { - Id = id, - Type = type, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, - PathToFile = pathToFile, - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - MainDef = mainDef, - AdditionalDefs = addDefs, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = executables - }; - - return addon; - } - else if (_game.GameEnum is GameEnum.Standalone) - { - var addon = new StandaloneAddon() + var addon = new WangCampaign() + { + Id = carcass.Id, + Type = carcass.Type, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + PathToFile = pathToFile, + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + MainDef = carcass.MainDef, + AdditionalDefs = carcass.AddDefs, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = carcass.Executables + }; + + addons.Add(addon); + } + else if (_game.GameEnum is GameEnum.Blood) { - Id = id, - Type = type, - SupportedGame = new(supportedGame, gameVersion, gameCrc), - Title = title, - GridImage = image, - Description = description, - Version = version, - Author = author, - PathToFile = pathToFile, - DependentAddons = dependencies, - IncompatibleAddons = incompatibles, - StartMap = startMap, - MainDef = mainDef, - AdditionalDefs = addDefs, - RequiredFeatures = requiredFeatures, - PreviewImage = preview, - IsFolder = isUnpacked, - Executables = executables - }; - - return addon; - } - else - { - ThrowHelper.ThrowNotSupportedException(); - return null; + var addon = new BloodCampaign() + { + Id = carcass.Id, + Type = carcass.Type, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + PathToFile = pathToFile, + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + MainDef = carcass.MainDef, + AdditionalDefs = carcass.AddDefs, + INI = carcass.Ini, + RFF = carcass.Rff, + SND = carcass.Snd, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = carcass.Executables + }; + + addons.Add(addon); + } + else if (_game.GameEnum is GameEnum.Exhumed) + { + var addon = new SlaveCampaign() + { + Id = carcass.Id, + Type = carcass.Type, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + PathToFile = pathToFile, + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + MainDef = carcass.MainDef, + AdditionalDefs = carcass.AddDefs, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = carcass.Executables + }; + + addons.Add(addon); + } + else if (_game.GameEnum is GameEnum.Standalone) + { + var addon = new StandaloneAddon() + { + Id = carcass.Id, + Type = carcass.Type, + SupportedGame = new(carcass.SupportedGame, carcass.GameVersion, carcass.GameCrc), + Title = carcass.Title, + GridImage = carcass.Image, + Description = carcass.Description, + Version = carcass.Version, + Author = carcass.Author, + PathToFile = pathToFile, + DependentAddons = carcass.Dependencies, + IncompatibleAddons = carcass.Incompatibles, + StartMap = carcass.StartMap, + MainDef = carcass.MainDef, + AdditionalDefs = carcass.AddDefs, + RequiredFeatures = carcass.RequiredFeatures, + PreviewImage = carcass.Preview, + IsFolder = carcass.IsUnpacked, + Executables = carcass.Executables + }; + + addons.Add(addon); + } + else + { + ThrowHelper.ThrowNotSupportedException(); + } } } + + return addons; } /// @@ -863,63 +884,70 @@ or GameEnum.NAM /// /// Path to archive /// Archive - /// AddonDto - private string? UnpackIfNeededAndGetAddonDto(string pathToFile, IArchive archive, out AddonDto? addonDto) + /// AddonDto + private string? UnpackIfNeededAndGetAddonDto(string pathToFile, IArchive archive, out List? addonDtos) { - IArchiveEntry? addonJson = null; + string? unpackedTo = null; - foreach (var file in archive.Entries) + if (archive.Entries.Any(static x => x.Key!.Equals("addons.grpinfo", StringComparison.OrdinalIgnoreCase))) { - if (file.Key!.Equals("addons.grpinfo")) + //need to unpack archive with grpinfo + unpackedTo = Unpack(pathToFile, archive); + addonDtos = null; + return unpackedTo; + } + + var addonJsons = archive.Entries.Where(static x => x.Key!.StartsWith("addon") && x.Key!.EndsWith(".json")); + + if (addonJsons?.Any() is not true) + { + addonDtos = null; + return null; + } + + try + { + using var stream = addonJsons.First().OpenEntryStream(); + + var addonDto = JsonSerializer.Deserialize( + stream, + AddonManifestContext.Default.AddonDto + )!; + + if (addonDto.MainRff is not null || addonDto.SoundRff is not null) { - //need to unpack archive with grpinfo - var unpackedTo = Unpack(pathToFile, archive); - addonDto = null; - return unpackedTo; + //need to unpack addons that contain custom RFF files + unpackedTo = Unpack(pathToFile, archive); } - if (file.Key!.Equals("addon.json")) + if (addonDto.Executables is not null) { - addonJson = file; + //need to unpack addons with custom executables + unpackedTo = Unpack(pathToFile, archive); } } - - if (addonJson is not null) + catch { - try - { - using var stream = addonJson.OpenEntryStream(); + addonDtos = null; + return null; + } - addonDto = JsonSerializer.Deserialize( - stream, - AddonManifestContext.Default.AddonDto - )!; + List result = []; - if (addonDto.MainRff is not null || addonDto.SoundRff is not null) - { - //need to unpack addons that contain custom RFF files - var unpackedTo = Unpack(pathToFile, archive); - return unpackedTo; - } + foreach (var addonJson in addonJsons) + { + using var stream = addonJson.OpenEntryStream(); - if (addonDto.Executables is not null) - { - //need to unpack addons with custom executables - var unpackedTo = Unpack(pathToFile, archive); - return unpackedTo; - } + var addonDto = JsonSerializer.Deserialize( + stream, + AddonManifestContext.Default.AddonDto + )!; - return null; - } - catch - { - addonDto = null; - return null; - } + result.Add(addonDto); } - addonDto = null; - return null; + addonDtos = result.Count > 0 ? result : null; + return unpackedTo; } /// @@ -945,3 +973,32 @@ private string Unpack(string pathToFile, IArchive archive) return unpackTo; } } + +internal struct AddonCarcass +{ + public GameEnum SupportedGame { get; set; } + public string Id { get; set; } + public string Title { get; set; } + public AddonTypeEnum Type { get; set; } + public string Version { get; set; } + public bool IsUnpacked { get; set; } + public string? Author { get; set; } + public string? Description { get; set; } + public Stream? Image { get; set; } + public Stream? Preview { get; set; } + public string? GameVersion { get; set; } + public string? GameCrc { get; set; } + public HashSet? RequiredFeatures { get; set; } + public string? MainCon { get; set; } + public HashSet? AddCons { get; set; } + public string? MainDef { get; set; } + public HashSet? AddDefs { get; set; } + public string? Rts { get; set; } + public string? Ini { get; set; } + public string? Rff { get; set; } + public string? Snd { get; set; } + public Dictionary? Dependencies { get; set; } + public Dictionary? Incompatibles { get; set; } + public IStartMap? StartMap { get; set; } + public Dictionary? Executables { get; set; } +} diff --git a/src/Addons/Providers/InstalledAddonsProviderFactory.cs b/src/Addons/Providers/InstalledAddonsProviderFactory.cs index 9b8c74d..dc8e491 100644 --- a/src/Addons/Providers/InstalledAddonsProviderFactory.cs +++ b/src/Addons/Providers/InstalledAddonsProviderFactory.cs @@ -1,18 +1,23 @@ using Common.Client.Interfaces; using Common.Enums; using Common.Interfaces; +using Microsoft.Extensions.Logging; namespace Addons.Providers; public sealed class InstalledAddonsProviderFactory { private readonly Dictionary _list = []; - private readonly IConfigProvider _config; + private readonly ILogger _logger; - public InstalledAddonsProviderFactory(IConfigProvider config) + public InstalledAddonsProviderFactory( + IConfigProvider config, + ILogger logger + ) { _config = config; + _logger = logger; } /// @@ -27,7 +32,7 @@ public InstalledAddonsProvider GetSingleton(IGame game) } #pragma warning disable CS0618 // Type or member is obsolete - InstalledAddonsProvider newProvider = new(game, _config); + InstalledAddonsProvider newProvider = new(game, _config, _logger); #pragma warning restore CS0618 // Type or member is obsolete _list.Add(game.GameEnum, newProvider); diff --git a/src/Ports/Ports/BasePort.cs b/src/Ports/Ports/BasePort.cs index caf5287..3273ce9 100644 --- a/src/Ports/Ports/BasePort.cs +++ b/src/Ports/Ports/BasePort.cs @@ -472,6 +472,7 @@ protected virtual void GetAutoloadModsArgs(StringBuilder sb, IGame game, IAddon } var enabledModsCount = 0; + HashSet addedModsFiles = []; foreach (var mod in mods) { @@ -485,7 +486,11 @@ protected virtual void GetAutoloadModsArgs(StringBuilder sb, IGame game, IAddon continue; } - _ = sb.Append($@" {AddFileParam}""{aMod.FileName}"""); + if (!addedModsFiles.TryGetValue(mod.Value.FileName!, out _)) + { + _ = addedModsFiles.Add(mod.Value.FileName!); + _ = sb.Append($@" {AddFileParam}""{aMod.FileName}"""); + } if (aMod.AdditionalDefs is not null) { diff --git a/src/Tests/CmdArguments/AutoloadModsProvider.cs b/src/Tests/CmdArguments/AutoloadModsProvider.cs index 0e32af8..de4b003 100644 --- a/src/Tests/CmdArguments/AutoloadModsProvider.cs +++ b/src/Tests/CmdArguments/AutoloadModsProvider.cs @@ -107,7 +107,7 @@ public AutoloadModsProvider(GameEnum gameEnum) public AutoloadMod ModThatRequiresOfficialAddon => new() { - Id = "modThatRequiredOfficialAddon", + Id = "modThatRequiresOfficialAddon", Type = AddonTypeEnum.Mod, Title = "modThatRequiredOfficialAddon", GridImage = null, @@ -179,9 +179,9 @@ public AutoloadModsProvider(GameEnum gameEnum) public AutoloadMod IncompatibleModWithCompatibleVersion => new() { - Id = "incompatibleModWithIncompatibleVersion", + Id = "incompatibleModWithCompatibleVersion", Type = AddonTypeEnum.Mod, - Title = "incompatibleModWithIncompatibleVersion", + Title = "incompatibleModWithCompatibleVersion", GridImage = null, Author = null, Description = null, @@ -189,7 +189,7 @@ public AutoloadModsProvider(GameEnum gameEnum) SupportedGame = _game, RequiredFeatures = null, PathToFile = Path.Combine("D:", "Mods", "incompatible_mod_with_compatible_version.zip"), - DependentAddons = null, + DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", null } }, IncompatibleAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", "<=1.0" } }, AdditionalCons = null, MainDef = null, @@ -203,9 +203,9 @@ public AutoloadModsProvider(GameEnum gameEnum) public AutoloadMod IncompatibleModWithIncompatibleVersion => new() { - Id = "incompatibleModWithCompatibleVersion", + Id = "incompatibleModWithIncompatibleVersion", Type = AddonTypeEnum.Mod, - Title = "incompatibleModWithCompatibleVersion", + Title = "incompatibleModWithIncompatibleVersion", GridImage = null, Author = null, Description = null, @@ -213,7 +213,7 @@ public AutoloadModsProvider(GameEnum gameEnum) SupportedGame = _game, RequiredFeatures = null, PathToFile = Path.Combine("D:", "Mods", "!!!!!!!!!!NOPE!!!!!!!!!!"), - DependentAddons = null, + DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", null } }, IncompatibleAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", ">1.1" } }, AdditionalCons = null, MainDef = null, @@ -225,18 +225,18 @@ public AutoloadModsProvider(GameEnum gameEnum) Executables = null }; - public AutoloadMod DependantMod => new() + public AutoloadMod DependentMod => new() { - Id = "dependantMod", + Id = "dependentMod", Type = AddonTypeEnum.Mod, - Title = "dependantMod", + Title = "dependentMod", GridImage = null, Author = null, Description = null, Version = "1.0", SupportedGame = _game, RequiredFeatures = null, - PathToFile = Path.Combine("D:", "Mods", "dependant_mod.zip"), + PathToFile = Path.Combine("D:", "Mods", "dependent_mod.zip"), DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", null } }, IncompatibleAddons = null, AdditionalCons = null, @@ -248,12 +248,37 @@ public AutoloadModsProvider(GameEnum gameEnum) IsFolder = false, Executables = null }; + + + public AutoloadMod MultipleDependenciesMod => new() + { + Id = "multipleDependenciesMod", + Type = AddonTypeEnum.Mod, + Title = "multipleDependenciesMod", + GridImage = null, + Author = null, + Description = null, + Version = "1.0", + SupportedGame = _game, + RequiredFeatures = null, + PathToFile = Path.Combine("D:", "Mods", "!!!!!!!!!!NOPE!!!!!!!!!!"), + DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", null }, { "someMod", null } }, + IncompatibleAddons = null, + AdditionalCons = null, + MainDef = null, + AdditionalDefs = null, + StartMap = null, + PreviewImage = null, + IsEnabled = true, + IsFolder = false, + Executables = null + }; - public AutoloadMod DependantModWithIncompatibleVersion => new() + public AutoloadMod DependentModWithIncompatibleVersion => new() { - Id = "dependantModWithIncompatibleVersion", + Id = "dependentModWithIncompatibleVersion", Type = AddonTypeEnum.Mod, - Title = "dependantModWithIncompatibleVersion", + Title = "dependentModWithIncompatibleVersion", GridImage = null, Author = null, Description = null, @@ -273,18 +298,18 @@ public AutoloadModsProvider(GameEnum gameEnum) Executables = null }; - public AutoloadMod DependantModWithCompatibleVersion => new() + public AutoloadMod DependentModWithCompatibleVersion => new() { - Id = "dependantModWithCompatibleVersion", + Id = "dependentModWithCompatibleVersion", Type = AddonTypeEnum.Mod, - Title = "dependantModWithCompatibleVersion", + Title = "dependentModWithCompatibleVersion", GridImage = null, Author = null, Description = null, Version = "1.0", SupportedGame = _game, RequiredFeatures = null, - PathToFile = Path.Combine("D:", "Mods", "dependant_mod_with_compatible_version.zip"), + PathToFile = Path.Combine("D:", "Mods", "dependent_mod_with_compatible_version.zip"), DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { "enabledMod", ">1.1" } }, IncompatibleAddons = null, AdditionalCons = null, diff --git a/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs b/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs index f335798..7c0e1c3 100644 --- a/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs @@ -167,18 +167,19 @@ public void RazeTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, - _modsProvider.ModThatRequiredFeature + _modsProvider.ModThatRequiredFeature, + _modsProvider.MultipleDependenciesMod }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); Raze raze = new(); raze.BeforeStart(_bloodGame, _bloodCamp); var args = raze.GetStartGameArgs(_bloodGame, _bloodCamp, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\blood"" -def ""a"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\blood"" -def ""a"""; if (OperatingSystem.IsLinux()) { @@ -212,9 +213,9 @@ public void RazeCpTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -223,7 +224,7 @@ public void RazeCpTest() raze.BeforeStart(_bloodGame, _bloodCamp); var args = raze.GetStartGameArgs(_bloodGame, _bloodCpCamp, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_requires_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\bloodcp"" -def ""a"" -ini ""CRYPTIC.INI"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_requires_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\bloodcp"" -def ""a"" -ini ""CRYPTIC.INI"""; if (OperatingSystem.IsLinux()) { @@ -318,17 +319,18 @@ public void NBloodTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, - _modsProvider.ModThatRequiredFeature + _modsProvider.ModThatRequiredFeature, + _modsProvider.MultipleDependenciesMod }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _bloodCamp, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -350,9 +352,9 @@ public void NBloodCPTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -360,7 +362,7 @@ public void NBloodCPTest() NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _bloodCpCamp, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_requires_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""CRYPTIC.INI"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_requires_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""CRYPTIC.INI"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -377,7 +379,7 @@ public void NBloodTCTest() NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _bloodTc, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -g ""D:\Games\Blood\blood_tc.zip"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -g ""D:\Games\Blood\blood_tc.zip"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -394,7 +396,7 @@ public void NBloodTCFolderTest() NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _bloodTcFolder, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -game_dir ""D:\Games\Blood\blood_tc_folder"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -game_dir ""D:\Games\Blood\blood_tc_folder"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -411,7 +413,7 @@ public void NBloodTcExeOverride() NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _bloodTcExeOverride, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -433,9 +435,9 @@ public void NotBloodTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -443,7 +445,7 @@ public void NotBloodTest() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _bloodCamp, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -465,9 +467,9 @@ public void NotBloodCPTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -475,7 +477,7 @@ public void NotBloodCPTest() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _bloodCpCamp, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_requires_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""CRYPTIC.INI"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_requires_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""CRYPTIC.INI"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -492,7 +494,7 @@ public void NotBloodTCTest() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _bloodTc, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -g ""D:\Games\Blood\blood_tc.zip"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -g ""D:\Games\Blood\blood_tc.zip"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -509,7 +511,7 @@ public void NotBloodTCFolderTest() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _bloodTcFolder, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -game_dir ""D:\Games\Blood\blood_tc_folder"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -game_dir ""D:\Games\Blood\blood_tc_folder"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -526,7 +528,7 @@ public void NotBloodTcExeOverride() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _bloodTcExeOverride, [], true, true, 2); - var expected = @$" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; + var expected = @" -quick -nosetup -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""TC.INI"" -rff ""TC.RFF"" -snd ""TC.SND"" -s 2"; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/BloodLooseMapCmdArgumentsTests.cs b/src/Tests/CmdArguments/BloodLooseMapCmdArgumentsTests.cs index d800c04..6428a79 100644 --- a/src/Tests/CmdArguments/BloodLooseMapCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/BloodLooseMapCmdArgumentsTests.cs @@ -61,9 +61,9 @@ public void RazeTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -72,7 +72,7 @@ public void RazeTest() raze.BeforeStart(_bloodGame, _looseMap); var args = raze.GetStartGameArgs(_bloodGame, _looseMap, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\loose-map"" -def ""a"" -ini ""BLOOD.INI"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Blood\loose-map"" -def ""a"" -ini ""BLOOD.INI"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"""; if (OperatingSystem.IsLinux()) { @@ -106,9 +106,9 @@ public void NBloodTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -116,7 +116,7 @@ public void NBloodTest() NBlood nblood = new(); var args = nblood.GetStartGameArgs(_bloodGame, _looseMap, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""BLOOD.INI"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""BLOOD.INI"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"" -s 2"; if (OperatingSystem.IsLinux()) { @@ -138,9 +138,9 @@ public void NotBloodTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -148,7 +148,7 @@ public void NotBloodTest() NotBlood notblood = new(); var args = notblood.GetStartGameArgs(_bloodGame, _looseMap, mods, true, true, 2); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""BLOOD.INI"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"" -s 2"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Mods"" -usecwd -j ""D:\Games\Blood"" -h ""a"" -ini ""BLOOD.INI"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Blood\Maps"" -map ""LOOSE.MAP"" -s 2"; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs b/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs index 9731723..8436a46 100644 --- a/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs @@ -171,18 +171,19 @@ public void RazeTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, - _modsProvider.ModThatRequiredFeature + _modsProvider.ModThatRequiredFeature, + _modsProvider.MultipleDependenciesMod }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); Raze raze = new(); raze.BeforeStart(_dukeGame, _dukeCamp); var args = raze.GetStartGameArgs(_dukeGame, _dukeCamp, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -addcon ""ENABLED1.CON"" -addcon ""ENABLED2.CON"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Duke3D\duke3d"" -def ""a"" -addon 0"; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -addcon ""ENABLED1.CON"" -addcon ""ENABLED2.CON"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Duke3D\duke3d"" -def ""a"" -addon 0"; if (OperatingSystem.IsLinux()) { @@ -301,17 +302,18 @@ public void EDuke32Test() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, - _modsProvider.ModThatRequiredFeature + _modsProvider.ModThatRequiredFeature, + _modsProvider.MultipleDependenciesMod }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); EDuke32 eduke32 = new(); var args = eduke32.GetStartGameArgs(_dukeGame, _dukeCamp, mods, true, true, 3); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -cachesize 262144 -h ""a"" -j ""D:\Games\Duke3D"" -s3"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -cachesize 262144 -h ""a"" -j ""D:\Games\Duke3D"" -s3"; if (OperatingSystem.IsLinux()) { @@ -407,17 +409,18 @@ public void RedNukemTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, - _modsProvider.ModThatRequiredFeature + _modsProvider.ModThatRequiredFeature, + _modsProvider.MultipleDependenciesMod }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); RedNukem redNukem = new(); var args = redNukem.GetStartGameArgs(_dukeGame, _dukeCamp, mods, true, true); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -h ""a"" -j ""D:\Games\Duke3D"""; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -h ""a"" -j ""D:\Games\Duke3D"""; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/DukeLooseMapCmdArgumentsTests.cs b/src/Tests/CmdArguments/DukeLooseMapCmdArgumentsTests.cs index 11277e0..34302ba 100644 --- a/src/Tests/CmdArguments/DukeLooseMapCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/DukeLooseMapCmdArgumentsTests.cs @@ -64,9 +64,9 @@ public void RazeTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -75,7 +75,7 @@ public void RazeTest() raze.BeforeStart(_dukeGame, _dukeLooseMap); var args = raze.GetStartGameArgs(_dukeGame, _dukeLooseMap, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -addcon ""ENABLED1.CON"" -addcon ""ENABLED2.CON"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Duke3D\loose-map"" -def ""a"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -addcon ""ENABLED1.CON"" -addcon ""ENABLED2.CON"" -file ""mod_incompatible_with_addon.zip"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Duke3D\loose-map"" -def ""a"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"""; if (OperatingSystem.IsLinux()) { @@ -109,9 +109,9 @@ public void EDuke32Test() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -119,7 +119,7 @@ public void EDuke32Test() EDuke32 eduke32 = new(); var args = eduke32.GetStartGameArgs(_dukeGame, _dukeLooseMap, mods, true, true, 3); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -cachesize 262144 -h ""a"" -j ""D:\Games\Duke3D"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"" -s3"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -cachesize 262144 -h ""a"" -j ""D:\Games\Duke3D"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"" -s3"; if (OperatingSystem.IsLinux()) { @@ -141,9 +141,9 @@ public void RedNukemTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -151,7 +151,7 @@ public void RedNukemTest() RedNukem redNukem = new(); var args = redNukem.GetStartGameArgs(_dukeGame, _dukeLooseMap, mods, true, true); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -h ""a"" -j ""D:\Games\Duke3D"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"""; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Mods"" -usecwd -h ""a"" -j ""D:\Games\Duke3D"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Duke3D\Maps"" -map ""LOOSE.MAP"""; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs b/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs index 105e5c8..d442d2e 100644 --- a/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs @@ -62,9 +62,9 @@ public void FuryTest() _modsProvider.IncompatibleMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame, _modsProvider.ModThatRequiredFeature }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -72,7 +72,7 @@ public void FuryTest() Fury fury = new(new ConfigProviderFake()); var args = fury.GetStartGameArgs(_dukeGame, _dukeCamp, mods, true, true, 3); - var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependant_mod.zip"" -g ""dependant_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Fury\Mods"" -s3"; + var expected = @$" -quick -nosetup -g ""enabled_mod.zip"" -mh ""ENABLED1.DEF"" -mh ""ENABLED2.DEF"" -mx ""ENABLED1.CON"" -mx ""ENABLED2.CON"" -g ""mod_incompatible_with_addon.zip"" -g ""incompatible_mod_with_compatible_version.zip"" -g ""dependent_mod.zip"" -g ""dependent_mod_with_compatible_version.zip"" -g ""feature_mod.zip"" -j ""{Directory.GetCurrentDirectory()}\Data\Addons\Fury\Mods"" -s3"; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/WangCmdArgumentsTests.cs b/src/Tests/CmdArguments/WangCmdArgumentsTests.cs index 3312bd6..e5d1227 100644 --- a/src/Tests/CmdArguments/WangCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/WangCmdArgumentsTests.cs @@ -82,9 +82,9 @@ public void RazeTest() _modsProvider.DisabledMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -92,7 +92,7 @@ public void RazeTest() raze.BeforeStart(_wangGame, _wangCamp); var args = raze.GetStartGameArgs(_wangGame, _wangCamp, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Wang\shadowwarrior"" -def ""a"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Wang\shadowwarrior"" -def ""a"""; if (OperatingSystem.IsLinux()) { @@ -161,16 +161,16 @@ public void VoidSWTest() _modsProvider.DisabledMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); VoidSW voidSw = new(); var args = voidSw.GetStartGameArgs(_wangGame, _wangCamp, mods, true, true, 3); - var expected = @$" -quick -nosetup -g""enabled_mod.zip"" -mh""ENABLED1.DEF"" -mh""ENABLED2.DEF"" -g""incompatible_mod_with_compatible_version.zip"" -g""dependant_mod.zip"" -g""dependant_mod_with_compatible_version.zip"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Mods"" -usecwd -j""D:\Games\Wang"" -h""a"" -addon0 -s3"; + var expected = @$" -quick -nosetup -g""enabled_mod.zip"" -mh""ENABLED1.DEF"" -mh""ENABLED2.DEF"" -g""incompatible_mod_with_compatible_version.zip"" -g""dependent_mod.zip"" -g""dependent_mod_with_compatible_version.zip"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Mods"" -usecwd -j""D:\Games\Wang"" -h""a"" -addon0 -s3"; if (OperatingSystem.IsLinux()) { diff --git a/src/Tests/CmdArguments/WangLooseMapsCmdArgumentsTests.cs b/src/Tests/CmdArguments/WangLooseMapsCmdArgumentsTests.cs index d607f73..be2b2e8 100644 --- a/src/Tests/CmdArguments/WangLooseMapsCmdArgumentsTests.cs +++ b/src/Tests/CmdArguments/WangLooseMapsCmdArgumentsTests.cs @@ -60,9 +60,9 @@ public void RazeTest() _modsProvider.DisabledMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); @@ -70,7 +70,7 @@ public void RazeTest() raze.BeforeStart(_wangGame, _looseMap); var args = raze.GetStartGameArgs(_wangGame, _looseMap, mods, true, true); - var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependant_mod.zip"" -file ""dependant_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Wang\loose-map"" -def ""a"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Maps"" -map ""LOOSE.MAP"""; + var expected = @$" -quick -nosetup -file ""enabled_mod.zip"" -adddef ""ENABLED1.DEF"" -adddef ""ENABLED2.DEF"" -file ""incompatible_mod_with_compatible_version.zip"" -file ""dependent_mod.zip"" -file ""dependent_mod_with_compatible_version.zip"" -savedir ""{Directory.GetCurrentDirectory()}\Data\Saves\Raze\Wang\loose-map"" -def ""a"" -file ""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Maps"" -map ""LOOSE.MAP"""; if (OperatingSystem.IsLinux()) { @@ -103,16 +103,16 @@ public void VoidSWTest() _modsProvider.DisabledMod, _modsProvider.IncompatibleModWithIncompatibleVersion, _modsProvider.IncompatibleModWithCompatibleVersion, - _modsProvider.DependantMod, - _modsProvider.DependantModWithCompatibleVersion, - _modsProvider.DependantModWithIncompatibleVersion, + _modsProvider.DependentMod, + _modsProvider.DependentModWithCompatibleVersion, + _modsProvider.DependentModWithIncompatibleVersion, _modsProvider.ModForAnotherGame }.ToDictionary(x => new AddonVersion(x.Id, x.Version), x => (IAddon)x); VoidSW voidSw = new(); var args = voidSw.GetStartGameArgs(_wangGame, _looseMap, mods, true, true, 3); - var expected = @$" -quick -nosetup -g""enabled_mod.zip"" -mh""ENABLED1.DEF"" -mh""ENABLED2.DEF"" -g""incompatible_mod_with_compatible_version.zip"" -g""dependant_mod.zip"" -g""dependant_mod_with_compatible_version.zip"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Mods"" -usecwd -j""D:\Games\Wang"" -h""a"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Maps"" -map ""LOOSE.MAP"" -s3"; + var expected = @$" -quick -nosetup -g""enabled_mod.zip"" -mh""ENABLED1.DEF"" -mh""ENABLED2.DEF"" -g""incompatible_mod_with_compatible_version.zip"" -g""dependent_mod.zip"" -g""dependent_mod_with_compatible_version.zip"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Mods"" -usecwd -j""D:\Games\Wang"" -h""a"" -j""{Directory.GetCurrentDirectory()}\Data\Addons\Wang\Maps"" -map ""LOOSE.MAP"" -s3"; if (OperatingSystem.IsLinux()) {