From c1fdedf955afa04cd37bfc2203882b6e3f397754 Mon Sep 17 00:00:00 2001 From: MapleWheels Date: Tue, 24 Mar 2026 10:36:46 -0400 Subject: [PATCH] Fixed ConfigService not filtering out configs that it shouldn't be loading. --- .../LuaCs/_Services/ConfigService.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/ConfigService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/ConfigService.cs index 8357d31b9..5685571b4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/ConfigService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/ConfigService.cs @@ -291,8 +291,7 @@ public sealed partial class ConfigService : IConfigService ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray() }, false); } - - + public void RegisterSettingTypeInitializer(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 SelectCompatible(ImmutableArray 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 LoadConfigsAsync(ImmutableArray configResources) { @@ -320,7 +329,7 @@ public sealed partial class ConfigService : IConfigService var taskBuilder = ImmutableArray.CreateBuilder>>(); var toProcessErrors = new ConcurrentStack(); - foreach (var resource in configResources) + foreach (var resource in SelectCompatible(configResources)) { taskBuilder.Add(await Task.Factory.StartNew>>(async Task> () => { @@ -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)