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;
|
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)
|
public void Serialize(IGenericWriter writer)
|
||||||
|
|
|
||||||
|
|
@ -350,28 +350,8 @@ public abstract class Town : IComparable<Town>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UnregisterGuard(BaseFactionGuard guard)
|
public bool UnregisterGuard(BaseFactionGuard guard) =>
|
||||||
{
|
guard != null && FindGuardList(guard.GetType())?.Guards.Remove(guard) == true;
|
||||||
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 RegisterVendor(BaseFactionVendor vendor)
|
public bool RegisterVendor(BaseFactionVendor vendor)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -252,11 +252,7 @@ public abstract class BaseFactionTrap : BaseTrap
|
||||||
|
|
||||||
public override void OnDelete()
|
public override void OnDelete()
|
||||||
{
|
{
|
||||||
if (Faction?.Traps.Contains(this) == true)
|
Faction?.Traps.Remove(this);
|
||||||
{
|
|
||||||
Faction.Traps.Remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnDelete();
|
base.OnDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,4 +282,4 @@ public abstract class BaseFactionTrap : BaseTrap
|
||||||
|
|
||||||
return faction != Faction;
|
return faction != Faction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,9 +123,8 @@ namespace Server.Engines.PartySystem
|
||||||
{
|
{
|
||||||
from.SendMessage("They are not in a party.");
|
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.");
|
from.SendMessage("You are no longer listening to that party.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Server.Engines.PartySystem
|
||||||
from.SendLocalizedMessage(1005455); // Who would you like to remove from your party?
|
from.SendLocalizedMessage(1005455); // Who would you like to remove from your party?
|
||||||
from.Target = new RemovePartyTarget();
|
from.Target = new RemovePartyTarget();
|
||||||
}
|
}
|
||||||
else if ((p.Leader == from || from == target) && p.Contains(target))
|
else if (p.Leader == from || from == target)
|
||||||
{
|
{
|
||||||
p.Remove(target);
|
p.Remove(target);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1865,17 +1865,14 @@ namespace Server.Gumps
|
||||||
{
|
{
|
||||||
var acct = (Account)m_List[v];
|
var acct = (Account)m_List[v];
|
||||||
|
|
||||||
if (info.IsSwitched(v))
|
if (!info.IsSwitched(v))
|
||||||
{
|
|
||||||
if (!rads.Contains(acct))
|
|
||||||
{
|
|
||||||
rads.Add(acct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (rads.Contains(acct))
|
|
||||||
{
|
{
|
||||||
rads.Remove(acct);
|
rads.Remove(acct);
|
||||||
}
|
}
|
||||||
|
else if (!rads.Contains(acct))
|
||||||
|
{
|
||||||
|
rads.Add(acct);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,13 +226,10 @@ public class Gump : BaseGump
|
||||||
|
|
||||||
public void Remove(GumpEntry g)
|
public void Remove(GumpEntry g)
|
||||||
{
|
{
|
||||||
if (g == null || !Entries.Contains(g))
|
if (g != null && Entries.Remove(g))
|
||||||
{
|
{
|
||||||
return;
|
g.Parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entries.Remove(g);
|
|
||||||
g.Parent = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Intern(string value)
|
public int Intern(string value)
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,13 @@ public partial class Guildstone : Item, IAddon, IChoppable
|
||||||
|
|
||||||
var house = BaseHouse.FindHouseAt(this);
|
var house = BaseHouse.FindHouseAt(this);
|
||||||
|
|
||||||
if (house?.IsOwner(from) == true && house.Addons.Contains(this))
|
if (house?.IsOwner(from) == true && house.Addons.Remove(this))
|
||||||
{
|
{
|
||||||
Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
|
Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
|
||||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||||
|
|
||||||
Delete();
|
Delete();
|
||||||
|
|
||||||
house.Addons.Remove(this);
|
|
||||||
|
|
||||||
var deed = Deed;
|
var deed = Deed;
|
||||||
|
|
||||||
if (deed != null)
|
if (deed != null)
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ namespace Server.Guilds
|
||||||
|
|
||||||
public void TurnToMember(Guild g)
|
public void TurnToMember(Guild g)
|
||||||
{
|
{
|
||||||
if (g.Alliance != this || !m_PendingMembers.Contains(g) || m_Members.Contains(g))
|
if (g.Alliance != this || m_Members.Contains(g) || !m_PendingMembers.Remove(g))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -199,21 +199,16 @@ namespace Server.Guilds
|
||||||
g.GuildMessage(1070760, Name); // Your Guild has joined the ~1_ALLIANCENAME~ Alliance.
|
g.GuildMessage(1070760, Name); // Your Guild has joined the ~1_ALLIANCENAME~ Alliance.
|
||||||
AllianceMessage(1070761, g.Name); // A new Guild has joined your Alliance: ~1_GUILDNAME~
|
AllianceMessage(1070761, g.Name); // A new Guild has joined your Alliance: ~1_GUILDNAME~
|
||||||
|
|
||||||
m_PendingMembers.Remove(g);
|
|
||||||
m_Members.Add(g);
|
m_Members.Add(g);
|
||||||
g.Alliance.InvalidateMemberProperties();
|
g.Alliance.InvalidateMemberProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveGuild(Guild g)
|
public void RemoveGuild(Guild g)
|
||||||
{
|
{
|
||||||
if (m_PendingMembers.Contains(g))
|
m_PendingMembers.Remove(g);
|
||||||
{
|
|
||||||
m_PendingMembers.Remove(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Members.Contains(g)) // Sanity, just incase someone with a custom script adds a character to BOTH arrays
|
if (m_Members.Remove(g)) // Sanity, just incase someone with a custom script adds a character to BOTH arrays
|
||||||
{
|
{
|
||||||
m_Members.Remove(g);
|
|
||||||
g.InvalidateMemberProperties();
|
g.InvalidateMemberProperties();
|
||||||
|
|
||||||
g.GuildMessage(1070763, Name); // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance.
|
g.GuildMessage(1070763, Name); // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance.
|
||||||
|
|
|
||||||
|
|
@ -477,17 +477,8 @@ namespace Server.Misc
|
||||||
return Notoriety.Enemy;
|
return Notoriety.Enemy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Stealing.ClassicMode && pmTarg?.PermaFlags.Contains(source) == true)
|
if (Stealing.ClassicMode && pmTarg?.PermaFlags.Contains(source) == true ||
|
||||||
{
|
bcTarg?.AlwaysAttackable == true || CheckHouseFlag(source, target, target.Location, target.Map))
|
||||||
return Notoriety.CanBeAttacked;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bcTarg?.AlwaysAttackable == true)
|
|
||||||
{
|
|
||||||
return Notoriety.CanBeAttacked;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CheckHouseFlag(source, target, target.Location, target.Map))
|
|
||||||
{
|
{
|
||||||
return Notoriety.CanBeAttacked;
|
return Notoriety.CanBeAttacked;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,8 @@ namespace Server.Mobiles
|
||||||
|
|
||||||
public void EndClaimList(Mobile from, BaseCreature pet)
|
public void EndClaimList(Mobile from, BaseCreature pet)
|
||||||
{
|
{
|
||||||
if (pet?.Deleted != false || from.Map != Map || from is not PlayerMobile pm || pm.Stabled?.Contains(pet) != true || !from.CheckAlive())
|
if (pet?.Deleted != false || from.Map != Map || from is not PlayerMobile pm
|
||||||
|
|| pm.Stabled?.Contains(pet) != true || !from.CheckAlive())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2642,10 +2642,8 @@ namespace Server.Multis
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Access.Contains(targ))
|
if (Access.Remove(targ))
|
||||||
{
|
{
|
||||||
Access.Remove(targ);
|
|
||||||
|
|
||||||
if (!HasAccess(targ) && IsInside(targ))
|
if (!HasAccess(targ) && IsInside(targ))
|
||||||
{
|
{
|
||||||
targ.Location = BanLocation;
|
targ.Location = BanLocation;
|
||||||
|
|
@ -2800,10 +2798,8 @@ namespace Server.Multis
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CoOwners.Contains(targ))
|
if (CoOwners.Remove(targ))
|
||||||
{
|
{
|
||||||
CoOwners.Remove(targ);
|
|
||||||
|
|
||||||
targ.Delta(MobileDelta.Noto);
|
targ.Delta(MobileDelta.Noto);
|
||||||
|
|
||||||
from.SendLocalizedMessage(501299); // Co-owner removed from list.
|
from.SendLocalizedMessage(501299); // Co-owner removed from list.
|
||||||
|
|
@ -2872,10 +2868,8 @@ namespace Server.Multis
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Friends.Contains(targ))
|
if (Friends.Remove(targ))
|
||||||
{
|
{
|
||||||
Friends.Remove(targ);
|
|
||||||
|
|
||||||
targ.Delta(MobileDelta.Noto);
|
targ.Delta(MobileDelta.Noto);
|
||||||
|
|
||||||
from.SendLocalizedMessage(501298); // Friend removed from list.
|
from.SendLocalizedMessage(501298); // Friend removed from list.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue