Apply RoleLoadout MinLimit fix to EnsureValid too (#29358)
Apply MinLimit fix to EnsureValid too
This commit is contained in:
@@ -124,9 +124,12 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
|||||||
// If you put invalid ones first but that's your fault for not using sensible defaults
|
// If you put invalid ones first but that's your fault for not using sensible defaults
|
||||||
if (loadouts.Count < groupProto.MinLimit)
|
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;
|
continue;
|
||||||
|
|
||||||
var defaultLoadout = new Loadout()
|
var defaultLoadout = new Loadout()
|
||||||
@@ -193,11 +196,10 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
|||||||
if (groupProto.MinLimit > 0)
|
if (groupProto.MinLimit > 0)
|
||||||
{
|
{
|
||||||
// Apply any loadouts we can.
|
// Apply any loadouts we can.
|
||||||
var addedCount = 0;
|
|
||||||
foreach (var protoId in groupProto.Loadouts)
|
foreach (var protoId in groupProto.Loadouts)
|
||||||
{
|
{
|
||||||
// Reached the limit, time to stop
|
// Reached the limit, time to stop
|
||||||
if (addedCount >= groupProto.MinLimit)
|
if (loadouts.Count >= groupProto.MinLimit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!protoManager.TryIndex(protoId, out var loadoutProto))
|
if (!protoManager.TryIndex(protoId, out var loadoutProto))
|
||||||
@@ -214,7 +216,6 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
|||||||
|
|
||||||
loadouts.Add(defaultLoadout);
|
loadouts.Add(defaultLoadout);
|
||||||
Apply(loadoutProto);
|
Apply(loadoutProto);
|
||||||
addedCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user