Some cleanup of contains keys and try get values (#246)

This commit is contained in:
Kamron Batman 2020-09-13 20:20:44 -07:00 committed by GitHub
parent 9cbb0cfd23
commit a236617ad9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 3508 additions and 350 deletions

View file

@ -31,11 +31,11 @@ namespace Server.ContextMenus
if (target is Mobile mobile)
{
mobile.GetContextMenuEntries(@from, list);
mobile.GetContextMenuEntries(from, list);
}
else if (target is Item item)
{
item.GetContextMenuEntries(@from, list);
item.GetContextMenuEntries(from, list);
}
Entries = list.ToArray();

View file

@ -570,7 +570,7 @@ namespace Server.Items
for (var i = 0; i < stackItems.Count; i++)
{
stackItems[i].m_StackItem.StackWith(@from, stackItems[i].m_DropItem, false);
stackItems[i].m_StackItem.StackWith(from, stackItems[i].m_DropItem, false);
}
return true;
@ -674,7 +674,7 @@ namespace Server.Items
if (CheckContentDisplay(from))
{
LabelTo(@from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty);
LabelTo(from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty);
}
// LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) );
@ -824,11 +824,11 @@ namespace Server.Items
{
if (from.AccessLevel > AccessLevel.Player || from.InRange(GetWorldLocation(), 2))
{
DisplayTo(@from);
DisplayTo(from);
}
else
{
@from.SendLocalizedMessage(500446); // That is too far away.
from.SendLocalizedMessage(500446); // That is too far away.
}
}

View file

@ -2254,11 +2254,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
parentItem.GetChildContextMenuEntries(@from, list, item);
parentItem.GetChildContextMenuEntries(from, list, item);
}
else if (m_Parent is Mobile parentMobile)
{
parentMobile.GetChildContextMenuEntries(@from, list, item);
parentMobile.GetChildContextMenuEntries(from, list, item);
}
}
@ -2266,11 +2266,11 @@ namespace Server
{
if (m_Parent is Item item)
{
item.GetChildContextMenuEntries(@from, list, this);
item.GetChildContextMenuEntries(from, list, this);
}
else if (m_Parent is Mobile mobile)
{
mobile.GetChildContextMenuEntries(@from, list, this);
mobile.GetChildContextMenuEntries(from, list, this);
}
}
@ -3241,7 +3241,7 @@ namespace Server
// OSI sends 1074769, bug!
if (QuestItem)
{
@from.SendLocalizedMessage(
from.SendLocalizedMessage(
1049343
); // You can only drop quest items into the top-most level of your backpack while you still need them for your quest.
}
@ -3667,7 +3667,7 @@ namespace Server
if (target is Container container && p.m_X != -1 && p.m_Y != -1)
{
return OnDroppedInto(@from, container, p);
return OnDroppedInto(from, container, p);
}
return OnDroppedOnto(from, target);
@ -4212,11 +4212,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
parentItem.OnItemUsed(@from, item);
parentItem.OnItemUsed(from, item);
}
else if (m_Parent is Mobile parentMobile)
{
parentMobile.OnItemUsed(@from, item);
parentMobile.OnItemUsed(from, item);
}
}
@ -4234,11 +4234,11 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
parentItem.OnItemLifted(@from, item);
parentItem.OnItemLifted(from, item);
}
else if (m_Parent is Mobile parentMobile)
{
parentMobile.OnItemLifted(@from, item);
parentMobile.OnItemLifted(from, item);
}
}
@ -4261,7 +4261,7 @@ namespace Server
{
if (m_Parent is Item parentItem)
{
parentItem.OnSingleClickContained(@from, item);
parentItem.OnSingleClickContained(from, item);
}
}
@ -4271,7 +4271,7 @@ namespace Server
if (opl.Header > 0)
{
@from.Send(
from.Send(
new MessageLocalized(
Serial,
m_ItemID,
@ -4295,7 +4295,7 @@ namespace Server
if (DisplayLootType)
{
LabelLootTypeTo(@from);
LabelLootTypeTo(from);
}
var ns = from.NetState;

View file

@ -3758,7 +3758,7 @@ namespace Server
}
else
{
hue = Notoriety.GetHue(Notoriety.Compute(@from, this));
hue = Notoriety.GetHue(Notoriety.Compute(from, this));
}
from.Send(new MessageLocalized(Serial, Body, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs));
@ -5571,7 +5571,7 @@ namespace Server
{
if (item.QuestItem)
{
@from.SendLocalizedMessage(1074868); // Stacks of quest items cannot be unstacked.
from.SendLocalizedMessage(1074868); // Stacks of quest items cannot be unstacked.
}
reject = LRReason.CannotLift;
@ -5634,7 +5634,7 @@ namespace Server
foreach (var ns in eable)
{
if (ns.Mobile != @from && ns.Mobile.CanSee(@from) && ns.Mobile.InLOS(@from) &&
if (ns.Mobile != from && ns.Mobile.CanSee(from) && ns.Mobile.InLOS(from) &&
ns.Mobile.CanSee(root))
{
if (p == null)
@ -5645,7 +5645,7 @@ namespace Server
map
);
p = Packet.Acquire(new DragEffect(src, @from, item.ItemID, item.Hue, amount));
p = Packet.Acquire(new DragEffect(src, from, item.ItemID, item.Hue, amount));
}
ns.Send(p);
@ -5671,7 +5671,7 @@ namespace Server
if (liftSound != -1)
{
@from.Send(new PlaySound(liftSound, @from));
from.Send(new PlaySound(liftSound, from));
}
from.NextActionTime = Core.TickCount + ActionDelay;
@ -5845,7 +5845,7 @@ namespace Server
if (to == null || !item.DropToItem(from, to, loc))
{
item.Bounce(@from);
item.Bounce(from);
}
else
{
@ -5882,7 +5882,7 @@ namespace Server
if (!item.DropToWorld(from, loc))
{
item.Bounce(@from);
item.Bounce(from);
}
else
{
@ -5919,7 +5919,7 @@ namespace Server
if (to == null || !item.DropToMobile(from, to, loc))
{
item.Bounce(@from);
item.Bounce(from);
}
else
{
@ -6443,7 +6443,7 @@ namespace Server
if (from != null)
{
RegisterDamage(amount, @from);
RegisterDamage(amount, from);
}
DisruptiveAction();
@ -6473,7 +6473,7 @@ namespace Server
if (informMount)
{
Mount?.OnRiderDamaged(amount, @from, newHits < 0);
Mount?.OnRiderDamaged(amount, from, newHits < 0);
}
if (newHits < 0)
@ -8624,7 +8624,7 @@ namespace Server
{
if (from.Map == Map && Utility.InUpdateRange(this, from) && from.CanSee(this))
{
@from.Send(new MobileStatus(@from, this, m_NetState));
from.Send(new MobileStatus(from, this, m_NetState));
}
if (from == this)
@ -8634,7 +8634,7 @@ namespace Server
if (Party is IParty ip)
{
ip.OnStatsQuery(@from, this);
ip.OnStatsQuery(from, this);
}
}
@ -8708,7 +8708,7 @@ namespace Server
}
else
{
hue = Notoriety.GetHue(Notoriety.Compute(@from, this));
hue = Notoriety.GetHue(Notoriety.Compute(from, this));
}
var name = Name ?? string.Empty;
@ -10143,7 +10143,7 @@ namespace Server
if (CanPaperdollBeOpenedBy(from))
{
DisplayPaperdollTo(@from);
DisplayPaperdollTo(from);
}
}
@ -10175,7 +10175,7 @@ namespace Server
{
if (CanPaperdollBeOpenedBy(from))
{
DisplayPaperdollTo(@from);
DisplayPaperdollTo(from);
}
}
@ -10590,11 +10590,11 @@ namespace Server
{
if (m_CallbackHandlesCancel && m_Callback != null)
{
m_Callback(@from, "");
m_Callback(from, "");
}
else
{
m_CancelCallback?.Invoke(@from, "");
m_CancelCallback?.Invoke(from, "");
}
}
}

View file

@ -433,7 +433,7 @@ namespace Server.Network
if (targ != null)
{
EventSink.InvokeRenameRequest(@from, targ, pvSrc.ReadStringSafe());
EventSink.InvokeRenameRequest(from, targ, pvSrc.ReadStringSafe());
}
}
@ -631,7 +631,7 @@ namespace Server.Network
if (item != null && from.Map == item.Map && Utility.InUpdateRange(item.GetWorldLocation(), from.Location) &&
from.CanSee(item))
{
item.OnHelpRequest(@from);
item.OnHelpRequest(from);
}
}
else if (serial.IsMobile)
@ -668,7 +668,7 @@ namespace Server.Network
if (m != null)
{
@from.Attack(m);
from.Attack(m);
}
}
@ -827,11 +827,11 @@ namespace Server.Network
if (type == 0)
{
p.OnCancel(@from);
p.OnCancel(from);
}
else
{
p.OnResponse(@from, text);
p.OnResponse(from, text);
}
}
}
@ -858,11 +858,11 @@ namespace Server.Network
if (type == 0)
{
p.OnCancel(@from);
p.OnCancel(from);
}
else
{
p.OnResponse(@from, text);
p.OnResponse(from, text);
}
}
}
@ -970,7 +970,7 @@ namespace Server.Network
if (!to.AllowEquipFrom(from) || !to.EquipItem(item))
{
item.Bounce(@from);
item.Bounce(from);
}
item.ClearBounce();
@ -1458,7 +1458,7 @@ namespace Server.Network
if (m?.Deleted == false)
{
@from.Use(m);
from.Use(m);
}
}
else if (s.IsItem)
@ -1467,7 +1467,7 @@ namespace Server.Network
if (item?.Deleted == false)
{
@from.Use(item);
from.Use(item);
}
}
}
@ -1500,7 +1500,7 @@ namespace Server.Network
{
if (from.Region.OnSingleClick(from, m))
{
m.OnSingleClick(@from);
m.OnSingleClick(from);
}
}
}
@ -1520,7 +1520,7 @@ namespace Server.Network
{
if (item.Parent is Item parentItem)
{
parentItem.OnSingleClickContained(@from, item);
parentItem.OnSingleClickContained(from, item);
}
item.OnSingleClick(from);
@ -1581,7 +1581,7 @@ namespace Server.Network
if (from != null && ok && from.Alive && from.Body.IsHuman && !from.Mounted)
{
@from.Animate(action, 7, 1, true, false, 0);
from.Animate(action, 7, 1, true, false, 0);
}
}
@ -1711,7 +1711,7 @@ namespace Server.Network
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
{
m.SendPropertiesTo(@from);
m.SendPropertiesTo(from);
}
}
else if (s.IsItem)
@ -1721,7 +1721,7 @@ namespace Server.Network
if (item?.Deleted == false && from.CanSee(item) &&
Utility.InUpdateRange(from.Location, item.GetWorldLocation()))
{
item.SendPropertiesTo(@from);
item.SendPropertiesTo(from);
}
}
}
@ -1744,7 +1744,7 @@ namespace Server.Network
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
{
m.SendPropertiesTo(@from);
m.SendPropertiesTo(from);
}
}
else if (s.IsItem)
@ -1754,7 +1754,7 @@ namespace Server.Network
if (item?.Deleted == false && from.CanSee(item) &&
Utility.InUpdateRange(from.Location, item.GetWorldLocation()))
{
item.SendPropertiesTo(@from);
item.SendPropertiesTo(from);
}
}
}
@ -2031,12 +2031,12 @@ namespace Server.Network
{
case 0x04: // Stats
{
m.OnStatsQuery(@from);
m.OnStatsQuery(from);
break;
}
case 0x05:
{
m.OnSkillsQuery(@from);
m.OnSkillsQuery(from);
break;
}
default:

View file

@ -25,22 +25,22 @@ namespace Server
if (from6017)
{
@from.Send(new SecureTradeEquip6017(To.Container, to));
from.Send(new SecureTradeEquip6017(To.Container, to));
}
else
{
@from.Send(new SecureTradeEquip(To.Container, to));
from.Send(new SecureTradeEquip(To.Container, to));
}
from.Send(new UpdateSecureTrade(From.Container, false, false));
if (from6017)
{
@from.Send(new SecureTradeEquip6017(From.Container, @from));
from.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
@from.Send(new SecureTradeEquip(From.Container, @from));
from.Send(new SecureTradeEquip(From.Container, from));
}
from.Send(new DisplaySecureTrade(to, From.Container, To.Container, to.Name));
@ -48,12 +48,12 @@ namespace Server
if (from.Account != null && from704565)
{
@from.Send(
from.Send(
new UpdateSecureTrade(
From.Container,
TradeFlag.UpdateLedger,
@from.Account.TotalGold,
@from.Account.TotalPlat
from.Account.TotalGold,
from.Account.TotalPlat
)
);
}
@ -63,11 +63,11 @@ namespace Server
if (to6017)
{
to.Send(new SecureTradeEquip6017(From.Container, @from));
to.Send(new SecureTradeEquip6017(From.Container, from));
}
else
{
to.Send(new SecureTradeEquip(From.Container, @from));
to.Send(new SecureTradeEquip(From.Container, from));
}
to.Send(new UpdateSecureTrade(To.Container, false, false));

View file

@ -168,31 +168,31 @@ namespace Server.Targeting
{
if (!from.CanSee(targeted))
{
OnCantSeeTarget(@from, targeted);
OnCantSeeTarget(from, targeted);
}
else if (CheckLOS && !from.InLOS(targeted))
{
OnTargetOutOfLOS(@from, targeted);
OnTargetOutOfLOS(from, targeted);
}
else if (item?.InSecureTrade == true)
{
OnTargetInSecureTrade(@from, targeted);
OnTargetInSecureTrade(from, targeted);
}
else if (item?.IsAccessibleTo(from) == false)
{
OnTargetNotAccessible(@from, targeted);
OnTargetNotAccessible(from, targeted);
}
else if (item?.CheckTarget(from, this, targeted) == false)
{
OnTargetUntargetable(@from, targeted);
OnTargetUntargetable(from, targeted);
}
else if (mobile?.CheckTarget(from, this, mobile) == false)
{
OnTargetUntargetable(@from, mobile);
OnTargetUntargetable(from, mobile);
}
else if (from.Region.OnTarget(from, this, targeted))
{
OnTarget(@from, targeted);
OnTarget(from, targeted);
}
}