Fixed ConfigService not filtering out configs that it shouldn't be loading.

This commit is contained in:
MapleWheels
2026-03-24 10:36:46 -04:00
parent b70b6bf326
commit c1fdedf955

View File

@@ -291,8 +291,7 @@ public sealed partial class ConfigService : IConfigService
ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray()
}, false);
}
public void RegisterSettingTypeInitializer<T>(string typeIdentifier, Func<(IConfigService ConfigService, IConfigInfo Info), T> settingFactory) where T : class, ISettingBase
{
Guard.IsNotNullOrWhiteSpace(typeIdentifier, nameof(typeIdentifier));
@@ -307,6 +306,16 @@ public sealed partial class ConfigService : IConfigService
_instanceFactory[typeIdentifier] = settingFactory;
}
private static ImmutableArray<T> SelectCompatible<T>(ImmutableArray<T> resources) where T : IBaseResourceInfo
{
return resources
.Where(r => r.SupportedPlatforms.HasFlag(ModUtils.Environment.CurrentPlatform))
.Where(r => r.SupportedTargets.HasFlag(ModUtils.Environment.CurrentTarget))
.OrderBy(r => r.Optional ? 1 : 0) // optional content last
.ThenBy(r => r.LoadPriority)
.ToImmutableArray();
}
public async Task<FluentResults.Result> LoadConfigsAsync(ImmutableArray<IConfigResourceInfo> configResources)
{
@@ -320,7 +329,7 @@ public sealed partial class ConfigService : IConfigService
var taskBuilder = ImmutableArray.CreateBuilder<Task<ImmutableArray<IConfigInfo>>>();
var toProcessErrors = new ConcurrentStack<IError>();
foreach (var resource in configResources)
foreach (var resource in SelectCompatible(configResources))
{
taskBuilder.Add(await Task.Factory.StartNew<Task<ImmutableArray<IConfigInfo>>>(async Task<ImmutableArray<IConfigInfo>> () =>
{
@@ -408,7 +417,7 @@ public sealed partial class ConfigService : IConfigService
var result = new FluentResults.Result();
foreach (var resource in configProfileResources)
foreach (var resource in SelectCompatible(configProfileResources))
{
var r = await _configProfileInfoParserService.TryParseResourcesAsync(resource);
if (r.IsFailed)