fix: Cleans up FindItems and removes allocations (#1516)
This commit is contained in:
parent
a4cabe2fa4
commit
d77dac9516
17 changed files with 105 additions and 127 deletions
|
|
@ -202,7 +202,7 @@ public partial class SalvageBag : Bag
|
|||
var salvaged = 0;
|
||||
var notSalvaged = 0;
|
||||
|
||||
foreach (var item in FindItemsByType())
|
||||
foreach (var item in EnumerateItems())
|
||||
{
|
||||
if (item?.Deleted != false)
|
||||
{
|
||||
|
|
@ -271,11 +271,12 @@ public partial class SalvageBag : Bag
|
|||
// Salvaged: ~1_COUNT~/~2_NUM~ tailored items
|
||||
from.SendLocalizedMessage(1079974, $"{salvaged}\t{salvaged + notSalvaged}");
|
||||
|
||||
var items = FindItemsByType(_clothTypes);
|
||||
|
||||
for (var i = 0; i < items.Count; i++)
|
||||
foreach (var item in EnumerateItems())
|
||||
{
|
||||
from.AddToBackpack(items[i]);
|
||||
if (item.InTypeList(_clothTypes))
|
||||
{
|
||||
from.AddToBackpack(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
|
|
@ -74,9 +75,7 @@ public partial class Key : Item
|
|||
return;
|
||||
}
|
||||
|
||||
var items = cont.FindItemsByType(new[] { typeof(Key), typeof(KeyRing) });
|
||||
|
||||
foreach (var item in items)
|
||||
foreach (var item in cont.EnumerateItems())
|
||||
{
|
||||
if (item is Key key)
|
||||
{
|
||||
|
|
@ -85,10 +84,8 @@ public partial class Key : Item
|
|||
key.Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item is KeyRing keyRing)
|
||||
{
|
||||
var keyRing = (KeyRing)item;
|
||||
|
||||
keyRing.RemoveKey(keyValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -101,9 +98,7 @@ public partial class Key : Item
|
|||
return false;
|
||||
}
|
||||
|
||||
var items = cont.FindItemsByType(new[] { typeof(Key), typeof(KeyRing) });
|
||||
|
||||
foreach (var item in items)
|
||||
foreach (var item in cont.EnumerateItems())
|
||||
{
|
||||
if (item is Key key)
|
||||
{
|
||||
|
|
@ -112,10 +107,8 @@ public partial class Key : Item
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item is KeyRing keyRing)
|
||||
{
|
||||
var keyRing = (KeyRing)item;
|
||||
|
||||
if (keyRing.ContainsKey(keyValue))
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue