fix: Eliminates double lookup with Contains->Remove (#2539)
This commit is contained in:
parent
e12cc5dd83
commit
8d88ef70fd
12 changed files with 25 additions and 80 deletions
|
|
@ -87,10 +87,7 @@ public class FactionItem
|
|||
item.FactionItemState = null;
|
||||
}
|
||||
|
||||
if (Faction?.State.FactionItems.Contains(this) == true)
|
||||
{
|
||||
Faction.State.FactionItems.Remove(this);
|
||||
}
|
||||
Faction?.State.FactionItems.Remove(this);
|
||||
}
|
||||
|
||||
public void Serialize(IGenericWriter writer)
|
||||
|
|
|
|||
|
|
@ -350,28 +350,8 @@ public abstract class Town : IComparable<Town>
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool UnregisterGuard(BaseFactionGuard guard)
|
||||
{
|
||||
if (guard == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var guardList = FindGuardList(guard.GetType());
|
||||
|
||||
if (guardList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!guardList.Guards.Contains(guard))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
guardList.Guards.Remove(guard);
|
||||
return true;
|
||||
}
|
||||
public bool UnregisterGuard(BaseFactionGuard guard) =>
|
||||
guard != null && FindGuardList(guard.GetType())?.Guards.Remove(guard) == true;
|
||||
|
||||
public bool RegisterVendor(BaseFactionVendor vendor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -252,11 +252,7 @@ public abstract class BaseFactionTrap : BaseTrap
|
|||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (Faction?.Traps.Contains(this) == true)
|
||||
{
|
||||
Faction.Traps.Remove(this);
|
||||
}
|
||||
|
||||
Faction?.Traps.Remove(this);
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
|
|
@ -286,4 +282,4 @@ public abstract class BaseFactionTrap : BaseTrap
|
|||
|
||||
return faction != Faction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,9 +123,8 @@ namespace Server.Engines.PartySystem
|
|||
{
|
||||
from.SendMessage("They are not in a party.");
|
||||
}
|
||||
else if (p.m_Listeners.Contains(from))
|
||||
else if (p.m_Listeners.Remove(from))
|
||||
{
|
||||
p.m_Listeners.Remove(from);
|
||||
from.SendMessage("You are no longer listening to that party.");
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Server.Engines.PartySystem
|
|||
from.SendLocalizedMessage(1005455); // Who would you like to remove from your party?
|
||||
from.Target = new RemovePartyTarget();
|
||||
}
|
||||
else if ((p.Leader == from || from == target) && p.Contains(target))
|
||||
else if (p.Leader == from || from == target)
|
||||
{
|
||||
p.Remove(target);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue