fix: Fixes container enumeration not recycling pooled arrays (#2341)
### Summary Updates all calls to container.EnumerateItems() to properly dispose of the underlying PooledRefQueue so that we are properly recycling pooled arrays.
This commit is contained in:
parent
1780edf0be
commit
c494fb4cc3
15 changed files with 388 additions and 365 deletions
|
|
@ -1599,15 +1599,19 @@ public sealed class BRGame : EventGame
|
|||
|
||||
var hadBomb = false;
|
||||
|
||||
foreach (var bomb in corpse.EnumerateItemsByType<BRBomb>(false))
|
||||
using (var queue = corpse.EnumerateItemsByType<BRBomb>(false))
|
||||
{
|
||||
hadBomb = true;
|
||||
bomb.DropTo(mob, killer);
|
||||
foreach (var bomb in queue)
|
||||
{
|
||||
hadBomb = true;
|
||||
bomb.DropTo(mob, killer);
|
||||
}
|
||||
}
|
||||
|
||||
if (mob.Backpack != null)
|
||||
{
|
||||
foreach (var bomb in mob.Backpack.EnumerateItemsByType<BRBomb>(false))
|
||||
using var queue = mob.Backpack.EnumerateItemsByType<BRBomb>(false);
|
||||
foreach (var bomb in queue)
|
||||
{
|
||||
hadBomb = true;
|
||||
bomb.DropTo(mob, killer);
|
||||
|
|
|
|||
|
|
@ -947,15 +947,19 @@ public sealed class CTFGame : EventGame
|
|||
|
||||
var hadFlag = false;
|
||||
|
||||
foreach (var flag in corpse.EnumerateItemsByType<CTFFlag>(false))
|
||||
using (var queue = corpse.EnumerateItemsByType<CTFFlag>(false))
|
||||
{
|
||||
hadFlag = true;
|
||||
flag.DropTo(mob, killer);
|
||||
foreach (var flag in queue)
|
||||
{
|
||||
hadFlag = true;
|
||||
flag.DropTo(mob, killer);
|
||||
}
|
||||
}
|
||||
|
||||
if (mob.Backpack != null)
|
||||
{
|
||||
foreach (var flag in mob.Backpack.EnumerateItemsByType<CTFFlag>(false))
|
||||
using var queue = mob.Backpack.EnumerateItemsByType<CTFFlag>(false);
|
||||
foreach (var flag in queue)
|
||||
{
|
||||
hadFlag = true;
|
||||
flag.DropTo(mob, killer);
|
||||
|
|
|
|||
|
|
@ -410,7 +410,8 @@ public abstract class Faction : IComparable<Faction>
|
|||
|
||||
if (mob.Backpack != null)
|
||||
{
|
||||
foreach (var sigil in mob.Backpack.EnumerateItemsByType<Sigil>())
|
||||
using var queue = mob.Backpack.EnumerateItemsByType<Sigil>();
|
||||
foreach (var sigil in queue)
|
||||
{
|
||||
sigil.ReturnHome();
|
||||
}
|
||||
|
|
@ -1073,7 +1074,8 @@ public abstract class Faction : IComparable<Faction>
|
|||
|
||||
if (victim.Backpack != null)
|
||||
{
|
||||
foreach (var sigil in victim.Backpack.EnumerateItemsByType<Sigil>())
|
||||
using var queue = victim.Backpack.EnumerateItemsByType<Sigil>();
|
||||
foreach (var sigil in queue)
|
||||
{
|
||||
if (killerState == null || killerPack == null)
|
||||
{
|
||||
|
|
@ -1254,7 +1256,8 @@ public abstract class Faction : IComparable<Faction>
|
|||
{
|
||||
if (m.Backpack != null)
|
||||
{
|
||||
foreach (var sigil in m.Backpack.EnumerateItemsByType<Sigil>())
|
||||
using var queue = m.Backpack.EnumerateItemsByType<Sigil>();
|
||||
foreach (var sigil in queue)
|
||||
{
|
||||
sigil.ReturnHome();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
var left = Objective.DesiredAmount;
|
||||
|
||||
foreach (var item in pack.EnumerateItemsByType<Item>(false, ClaimTypePredicate))
|
||||
using var queue = pack.EnumerateItemsByType<Item>(false, ClaimTypePredicate);
|
||||
foreach (var item in queue)
|
||||
{
|
||||
if (item.QuestItem && Objective.CheckItem(item))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -192,7 +192,8 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
var left = Objective.Amount;
|
||||
|
||||
foreach (var item in pack.EnumerateItems(false, ClaimTypePredicate))
|
||||
using var queue = pack.EnumerateItems(false, ClaimTypePredicate);
|
||||
foreach (var item in queue)
|
||||
{
|
||||
if (left == 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue