Fix mod content installers.

In 4312a4d3f4 MiniYaml merging was adjusted. One effect of this change was that duplicate keys in files that did not previously require merging was previously allowed, but was now an error. (Test case `TestMergeConflictsNoMerge`)

The installer files were relying on the previous behaviour to allow multiple `ContentPackage` keys. The above change caused a regression where attempting to manage mod content would crash due to now erroring on the duplicate keys.

We fix the issue by applying a unique ID suffix, as is a common pattern elsewhere in our yaml files, and teach InstallFromSourceLogic to recognise and strip it.
This commit is contained in:
RoosterDragon
2024-07-30 19:15:37 +01:00
committed by Gustas
parent ebaed9966b
commit 578a9fe457
22 changed files with 198 additions and 193 deletions

View File

@@ -253,7 +253,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
foreach (var sourceActionNode in sourceActionListYaml.Value.Nodes)
{
var sourceAction = modSource.ObjectCreator.CreateObject<ISourceAction>($"{sourceActionNode.Key}SourceAction");
var key = sourceActionNode.Key;
var split = key.IndexOf('@');
if (split != -1)
key = key[..split];
var sourceAction = modSource.ObjectCreator.CreateObject<ISourceAction>($"{key}SourceAction");
sourceAction.RunActionOnSource(sourceActionNode.Value, path, modData, extracted, m => message = m);
}
}
@@ -262,7 +266,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (beforeInstall != null)
RunSourceActions(beforeInstall);
foreach (var packageInstallationNode in modSource.Install.Where(x => x.Key == "ContentPackage"))
foreach (var packageInstallationNode in modSource.Install.Where(
x => x.Key == "ContentPackage" || x.Key.StartsWith("ContentPackage@", StringComparison.Ordinal)))
{
var packageName = packageInstallationNode.Value.NodeWithKeyOrDefault("Name")?.Value.Value;
if (!string.IsNullOrEmpty(packageName) && selectedPackages.TryGetValue(packageName, out var required) && required)