From c2f8984e6cbb2c71b73a839ae577350760395fdc Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Sat, 22 Jun 2024 22:17:28 -0400 Subject: [PATCH] Apply RoleLoadout MinLimit fix to EnsureValid too (#29358) Apply MinLimit fix to EnsureValid too --- Content.Shared/Preferences/Loadouts/RoleLoadout.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Preferences/Loadouts/RoleLoadout.cs b/Content.Shared/Preferences/Loadouts/RoleLoadout.cs index ca6d841616..f943c9ea8a 100644 --- a/Content.Shared/Preferences/Loadouts/RoleLoadout.cs +++ b/Content.Shared/Preferences/Loadouts/RoleLoadout.cs @@ -124,9 +124,12 @@ public sealed partial class RoleLoadout : IEquatable // If you put invalid ones first but that's your fault for not using sensible defaults if (loadouts.Count < groupProto.MinLimit) { - for (var i = 0; i < Math.Min(groupProto.MinLimit, groupProto.Loadouts.Count); i++) + foreach (var protoId in groupProto.Loadouts) { - if (!protoManager.TryIndex(groupProto.Loadouts[i], out var loadoutProto)) + if (loadouts.Count >= groupProto.MinLimit) + break; + + if (!protoManager.TryIndex(protoId, out var loadoutProto)) continue; var defaultLoadout = new Loadout() @@ -193,11 +196,10 @@ public sealed partial class RoleLoadout : IEquatable if (groupProto.MinLimit > 0) { // Apply any loadouts we can. - var addedCount = 0; foreach (var protoId in groupProto.Loadouts) { // Reached the limit, time to stop - if (addedCount >= groupProto.MinLimit) + if (loadouts.Count >= groupProto.MinLimit) break; if (!protoManager.TryIndex(protoId, out var loadoutProto)) @@ -214,7 +216,6 @@ public sealed partial class RoleLoadout : IEquatable loadouts.Add(defaultLoadout); Apply(loadoutProto); - addedCount++; } } } -- 2.51.2