This reverts commit 179cb50557.
This commit is contained in:
parent
179cb50557
commit
c2ecc76457
588 changed files with 16260 additions and 10926 deletions
|
|
@ -14,7 +14,7 @@
|
|||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.1
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ namespace Server
|
|||
Spawner = 0x100
|
||||
}
|
||||
|
||||
public class Item : IHued, IComparable<Item>, ISerializable, ISpawnable, ITile
|
||||
public class Item : IHued, IComparable<Item>, ISerializable, ISpawnable, IPropertyListObject
|
||||
{
|
||||
public const int QuestItemHue = 0x4EA; // Hmmmm... "for EA"?
|
||||
public static readonly List<Item> EmptyItems = new List<Item>();
|
||||
|
|
@ -340,22 +340,20 @@ namespace Server
|
|||
set => SetFlag(ImplFlag.Stackable, value);
|
||||
}
|
||||
|
||||
private ObjectPropertyList m_PropertyList;
|
||||
public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this);
|
||||
public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this);
|
||||
public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this);
|
||||
|
||||
public ObjectPropertyList PropertyList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PropertyList == null)
|
||||
{
|
||||
m_PropertyList = new ObjectPropertyList(this);
|
||||
GetProperties(m_PropertyList);
|
||||
AppendChildProperties(m_PropertyList);
|
||||
}
|
||||
|
||||
return m_PropertyList;
|
||||
}
|
||||
}
|
||||
// World packets need to be invalidated when any of the following changes:
|
||||
// - ItemID
|
||||
// - Amount
|
||||
// - Location
|
||||
// - Hue
|
||||
// - Packet Flags
|
||||
// - Direction
|
||||
public Packet WorldPacket => StaticPacketHandlers.GetWorldItemPacket(this);
|
||||
public Packet WorldPacketSA => StaticPacketHandlers.GetWorldItemSAPacket(this);
|
||||
public Packet WorldPacketHS => StaticPacketHandlers.GetWorldItemHSPacket(this);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Visible
|
||||
|
|
@ -366,6 +364,7 @@ namespace Server
|
|||
if (GetFlag(ImplFlag.Visible) != value)
|
||||
{
|
||||
SetFlag(ImplFlag.Visible, value);
|
||||
ReleaseWorldPackets();
|
||||
|
||||
if (m_Map != null)
|
||||
{
|
||||
|
|
@ -378,7 +377,7 @@ namespace Server
|
|||
Mobile m = state.Mobile;
|
||||
|
||||
if (!m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
Packets.SendRemoveEntity(state, Serial);
|
||||
state.Send(RemovePacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -398,6 +397,7 @@ namespace Server
|
|||
if (GetFlag(ImplFlag.Movable) != value)
|
||||
{
|
||||
SetFlag(ImplFlag.Movable, value);
|
||||
ReleaseWorldPackets();
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
}
|
||||
|
|
@ -433,7 +433,16 @@ namespace Server
|
|||
|
||||
public virtual bool IsVirtualItem => false;
|
||||
|
||||
public virtual int LabelNumber => m_ItemID < 0x4000 ? 1020000 + m_ItemID : 1078872 + m_ItemID;
|
||||
public virtual int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_ItemID < 0x4000)
|
||||
return 1020000 + m_ItemID;
|
||||
|
||||
return 1078872 + m_ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int TotalGold => GetTotal(TotalType.Gold);
|
||||
|
|
@ -504,6 +513,8 @@ namespace Server
|
|||
if (m_Hue != value)
|
||||
{
|
||||
m_Hue = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
}
|
||||
|
|
@ -565,6 +576,7 @@ namespace Server
|
|||
int oldPileWeight = PileWeight;
|
||||
|
||||
m_ItemID = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
int newPileWeight = PileWeight;
|
||||
|
||||
|
|
@ -630,6 +642,8 @@ namespace Server
|
|||
if ((LightType)m_Direction != value)
|
||||
{
|
||||
m_Direction = (Direction)value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
}
|
||||
|
|
@ -644,6 +658,8 @@ namespace Server
|
|||
if (m_Direction != value)
|
||||
{
|
||||
m_Direction = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
}
|
||||
|
|
@ -662,6 +678,7 @@ namespace Server
|
|||
int oldPileWeight = PileWeight;
|
||||
|
||||
m_Amount = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
int newPileWeight = PileWeight;
|
||||
|
||||
|
|
@ -689,8 +706,6 @@ namespace Server
|
|||
|
||||
public ItemData ItemData => TileData.ItemTable[m_ItemID & TileData.MaxItemValue];
|
||||
|
||||
int ITile.ID => ItemData.Value;
|
||||
|
||||
public virtual bool CanTarget => true;
|
||||
public virtual bool DisplayLootType => true;
|
||||
|
||||
|
|
@ -706,6 +721,8 @@ namespace Server
|
|||
|
||||
InvalidateProperties();
|
||||
|
||||
ReleaseWorldPackets();
|
||||
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
}
|
||||
|
|
@ -781,7 +798,7 @@ namespace Server
|
|||
Mobile m = state.Mobile;
|
||||
|
||||
if (m.InRange(oldLocation, GetUpdateRange(m)))
|
||||
Packets.SendRemoveEntity(state, Serial);
|
||||
state.Send(RemovePacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -791,6 +808,8 @@ namespace Server
|
|||
m_Location = location;
|
||||
OnLocationChange(oldRealLocation);
|
||||
|
||||
ReleaseWorldPackets();
|
||||
|
||||
List<Item> items = LookupItems();
|
||||
|
||||
if (items != null)
|
||||
|
|
@ -834,8 +853,7 @@ namespace Server
|
|||
{
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if (!m.InRange(location, GetUpdateRange(m)))
|
||||
Packets.SendRemoveEntity(state, Serial);
|
||||
if (!m.InRange(location, GetUpdateRange(m))) state.Send(RemovePacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -846,6 +864,8 @@ namespace Server
|
|||
m_Location = location;
|
||||
OnLocationChange(oldRealLocation);
|
||||
|
||||
ReleaseWorldPackets();
|
||||
|
||||
eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange());
|
||||
|
||||
foreach (NetState state in eable)
|
||||
|
|
@ -935,13 +955,17 @@ namespace Server
|
|||
{
|
||||
NetState ns = rootParent.NetState;
|
||||
|
||||
if (ns != null && rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent)))
|
||||
{
|
||||
Packets.SendContainerContentUpdate(ns, this);
|
||||
if (ns != null)
|
||||
if (rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent)))
|
||||
{
|
||||
if (ns.ContainerGridLines)
|
||||
ns.Send(new ContainerContentUpdate6017(this));
|
||||
else
|
||||
ns.Send(new ContainerContentUpdate(this));
|
||||
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PropertyList.Send(ns);
|
||||
}
|
||||
if (ObjectPropertyList.Enabled)
|
||||
ns.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
|
||||
SecureTrade st = GetSecureTradeCont()?.Trade;
|
||||
|
|
@ -962,16 +986,19 @@ namespace Server
|
|||
|
||||
if (ns != null && tradeRecip.CanSee(this) && tradeRecip.InRange(worldLoc, GetUpdateRange(tradeRecip)))
|
||||
{
|
||||
Packets.SendContainerContentUpdate(ns, this);
|
||||
if (ns.ContainerGridLines)
|
||||
ns.Send(new ContainerContentUpdate6017(this));
|
||||
else
|
||||
ns.Send(new ContainerContentUpdate(this));
|
||||
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PropertyList.Send(ns);
|
||||
ns.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
|
||||
List<Mobile> openers = contParent.Openers;
|
||||
|
||||
if (openers?.Count > 0)
|
||||
if (openers != null)
|
||||
lock (openers)
|
||||
{
|
||||
for (int i = 0; i < openers.Count; ++i)
|
||||
|
|
@ -981,7 +1008,9 @@ namespace Server
|
|||
int range = GetUpdateRange(mob);
|
||||
|
||||
if (mob.Map != map || !mob.InRange(worldLoc, range))
|
||||
{
|
||||
openers.RemoveAt(i--);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mob == rootParent || mob == tradeRecip)
|
||||
|
|
@ -991,10 +1020,13 @@ namespace Server
|
|||
|
||||
if (ns != null && mob.CanSee(this))
|
||||
{
|
||||
Packets.SendContainerContentUpdate(ns, this);
|
||||
if (ns.ContainerGridLines)
|
||||
ns.Send(new ContainerContentUpdate6017(this));
|
||||
else
|
||||
ns.Send(new ContainerContentUpdate(this));
|
||||
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PropertyList.Send(ns);
|
||||
ns.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1006,6 +1038,8 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
Packet p = null;
|
||||
|
||||
IPooledEnumerable<NetState> eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
||||
foreach (NetState state in eable)
|
||||
|
|
@ -1020,26 +1054,39 @@ namespace Server
|
|||
SendInfoTo(state, ObjectPropertyList.Enabled);
|
||||
else
|
||||
{
|
||||
if (m_Parent is Item)
|
||||
Packets.SendContainerContentUpdate(state, this);
|
||||
if (p != null)
|
||||
state.Send(p);
|
||||
else if (m_Parent is Item)
|
||||
{
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new ContainerContentUpdate6017(this));
|
||||
else
|
||||
state.Send(new ContainerContentUpdate(this));
|
||||
}
|
||||
else if (m_Parent is Mobile)
|
||||
Packets.SendEquipUpdate(state, this);
|
||||
{
|
||||
p = new EquipUpdate(this);
|
||||
p.Acquire();
|
||||
|
||||
state.Send(p);
|
||||
}
|
||||
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PropertyList.Send(state);
|
||||
state.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
else if ((flags & ItemDelta.EquipOnly) != 0 && m_Parent is Mobile)
|
||||
{
|
||||
Packets.SendEquipUpdate(state, this);
|
||||
state.Send(p ?? (p = Packet.Acquire(new EquipUpdate(this))));
|
||||
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PropertyList.Send(state);
|
||||
state.Send(OPLPacket);
|
||||
} else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0)
|
||||
PropertyList.Send(state);
|
||||
state.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
|
||||
Packet.Release(p);
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
|
|
@ -1079,7 +1126,7 @@ namespace Server
|
|||
|
||||
OnAfterDelete();
|
||||
|
||||
ClearProperties();
|
||||
FreeCache();
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
|
|
@ -1190,7 +1237,17 @@ namespace Server
|
|||
long ticks = LastMoved.Ticks;
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
|
||||
TimeSpan d = new TimeSpan(ticks - now);
|
||||
TimeSpan d;
|
||||
|
||||
try
|
||||
{
|
||||
d = new TimeSpan(ticks - now);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (ticks < now) d = TimeSpan.MaxValue;
|
||||
else d = TimeSpan.MaxValue;
|
||||
}
|
||||
|
||||
double minutes = -d.TotalMinutes;
|
||||
|
||||
|
|
@ -1249,7 +1306,13 @@ namespace Server
|
|||
if (GetSaveFlag(flags, SaveFlag.Name))
|
||||
writer.Write(info.m_Name);
|
||||
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent)) writer.Write(m_Parent?.Deleted == false ? m_Parent.Serial : Serial.MinusOne);
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent))
|
||||
{
|
||||
if (m_Parent?.Deleted == false)
|
||||
writer.Write(m_Parent.Serial);
|
||||
else
|
||||
writer.Write(Serial.MinusOne);
|
||||
}
|
||||
|
||||
if (GetSaveFlag(flags, SaveFlag.Items))
|
||||
writer.Write(items, false);
|
||||
|
|
@ -1380,10 +1443,10 @@ namespace Server
|
|||
public List<Item> AcquireItems()
|
||||
{
|
||||
if (this is Container cont)
|
||||
return cont.m_Items ??= new List<Item>();
|
||||
return cont.m_Items ?? (cont.m_Items = new List<Item>());
|
||||
|
||||
CompactInfo info = AcquireCompactInfo();
|
||||
return info.m_Items ??= new List<Item>();
|
||||
return info.m_Items ?? (info.m_Items = new List<Item>());
|
||||
}
|
||||
|
||||
private void SetFlag(ImplFlag flag, bool value)
|
||||
|
|
@ -1475,7 +1538,7 @@ namespace Server
|
|||
/// </summary>
|
||||
public virtual void SendPropertiesTo(Mobile from)
|
||||
{
|
||||
PropertyList.Send(from?.NetState);
|
||||
from.Send(PropertyList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1624,23 +1687,23 @@ namespace Server
|
|||
list.Add(1062203, "{0}", m.Name); // Blessed for ~1_NAME~
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Fills an <see cref="ObjectPropertyList" /> with everything applicable. By default, this invokes
|
||||
/// <see cref="AddNameProperties" />, then <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>. This method should be overridden to add any custom
|
||||
/// properties.
|
||||
/// </summary>
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
/// <summary>
|
||||
/// Overridable. Fills an <see cref="ObjectPropertyList" /> with everything applicable. By default, this invokes
|
||||
/// <see cref="AddNameProperties" />, then <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>. This method should be overridden to add any custom
|
||||
/// properties.
|
||||
/// </summary>
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
AddNameProperties(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's <see cref="ObjectPropertyList" />.
|
||||
/// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildProperties(ObjectPropertyList list, Item item)
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's <see cref="ObjectPropertyList" />.
|
||||
/// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildProperties(ObjectPropertyList list, Item item)
|
||||
{
|
||||
if (m_Parent is Item parentItem)
|
||||
parentItem.GetChildProperties(list, item);
|
||||
|
|
@ -1648,12 +1711,12 @@ namespace Server
|
|||
parentMobile.GetChildProperties(list, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's Name <see cref="ObjectPropertyList" />
|
||||
/// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item)
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's Name <see cref="ObjectPropertyList" />
|
||||
/// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item)
|
||||
{
|
||||
if (m_Parent is Item parentItem)
|
||||
parentItem.GetChildNameProperties(list, item);
|
||||
|
|
@ -1679,7 +1742,9 @@ namespace Server
|
|||
IEntity parent = bounce.m_Parent;
|
||||
|
||||
if (parent?.Deleted != false)
|
||||
{
|
||||
MoveToWorld(bounce.m_WorldLoc, bounce.m_Map);
|
||||
}
|
||||
else if (parent is Item p)
|
||||
{
|
||||
IEntity root = p.RootParent;
|
||||
|
|
@ -1691,7 +1756,9 @@ namespace Server
|
|||
p.AddItem(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveToWorld(from.Location, from.Map);
|
||||
}
|
||||
}
|
||||
else if (parent is Mobile parentMobile)
|
||||
{
|
||||
|
|
@ -1699,7 +1766,9 @@ namespace Server
|
|||
MoveToWorld(bounce.m_WorldLoc, bounce.m_Map);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveToWorld(bounce.m_WorldLoc, bounce.m_Map);
|
||||
}
|
||||
|
||||
ClearBounce();
|
||||
}
|
||||
|
|
@ -1790,14 +1859,19 @@ namespace Server
|
|||
MoveToWorld(location, m_Map);
|
||||
}
|
||||
|
||||
public void LabelTo(Mobile to, int number, string args = "")
|
||||
public void LabelTo(Mobile to, int number)
|
||||
{
|
||||
Packets.SendMessageLocalized(to?.NetState, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", args);
|
||||
to.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", ""));
|
||||
}
|
||||
|
||||
public void LabelTo(Mobile to, int number, string args)
|
||||
{
|
||||
to.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", args));
|
||||
}
|
||||
|
||||
public void LabelTo(Mobile to, string text)
|
||||
{
|
||||
Packets.SendUnicodeMessage(to?.NetState, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", text);
|
||||
to.Send(new UnicodeMessage(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", text));
|
||||
}
|
||||
|
||||
public void LabelTo(Mobile to, string format, params object[] args)
|
||||
|
|
@ -1805,9 +1879,14 @@ namespace Server
|
|||
LabelTo(to, string.Format(format, args));
|
||||
}
|
||||
|
||||
public void LabelToAffix(Mobile to, int number, AffixType type, string affix, string args = "")
|
||||
public void LabelToAffix(Mobile to, int number, AffixType type, string affix)
|
||||
{
|
||||
Packets.SendMessageLocalizedAffix(to?.NetState, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, args);
|
||||
to.Send(new MessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, ""));
|
||||
}
|
||||
|
||||
public void LabelToAffix(Mobile to, int number, AffixType type, string affix, string args)
|
||||
{
|
||||
to.Send(new MessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, number, "", type, affix, args));
|
||||
}
|
||||
|
||||
public virtual void LabelLootTypeTo(Mobile to)
|
||||
|
|
@ -1921,7 +2000,8 @@ namespace Server
|
|||
|
||||
public void ClearProperties()
|
||||
{
|
||||
m_PropertyList = null;
|
||||
StaticPacketHandlers.FreeOPLPacket(this);
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
}
|
||||
|
||||
public void InvalidateProperties()
|
||||
|
|
@ -1931,14 +2011,23 @@ namespace Server
|
|||
|
||||
if (m_Map != null && m_Map != Map.Internal && !World.Loading)
|
||||
{
|
||||
ObjectPropertyList oldList = m_PropertyList;
|
||||
m_PropertyList = null;
|
||||
ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this);
|
||||
|
||||
if (oldList?.Hash != PropertyList.Hash)
|
||||
{
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
Delta(ItemDelta.Properties);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseWorldPackets()
|
||||
{
|
||||
StaticPacketHandlers.FreeWorldItemPackets(this);
|
||||
}
|
||||
|
||||
public virtual int GetPacketFlags()
|
||||
|
|
@ -1987,17 +2076,18 @@ namespace Server
|
|||
|
||||
private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0;
|
||||
|
||||
public IPooledEnumerable<IEntity> GetObjectsInRange(int range) =>
|
||||
m_Map?.GetObjectsInRange(m_Parent == null ? m_Location : GetWorldLocation(), range) ?? Map.NullEnumerable<IEntity>.Instance;
|
||||
public IPooledEnumerable<IEntity> GetObjectsInRange(int range)
|
||||
{
|
||||
Map map = m_Map;
|
||||
|
||||
public IPooledEnumerable<Item> GetItemsInRange(int range) =>
|
||||
m_Map?.GetItemsInRange(m_Parent == null ? m_Location : GetWorldLocation(), range) ?? Map.NullEnumerable<Item>.Instance;
|
||||
if (map == null)
|
||||
return Map.NullEnumerable<IEntity>.Instance;
|
||||
|
||||
public IPooledEnumerable<Mobile> GetMobilesInRange(int range) =>
|
||||
m_Map?.GetMobilesInRange(m_Parent == null ? m_Location : GetWorldLocation(), range) ?? Map.NullEnumerable<Mobile>.Instance;
|
||||
if (m_Parent == null)
|
||||
return map.GetObjectsInRange(m_Location, range);
|
||||
|
||||
public IPooledEnumerable<NetState> GetClientsInRange(int range) =>
|
||||
m_Map?.GetClientsInRange(m_Parent == null ? m_Location : GetWorldLocation(), range) ?? Map.NullEnumerable<NetState>.Instance;
|
||||
return map.GetObjectsInRange(GetWorldLocation(), range);
|
||||
}
|
||||
|
||||
public IPooledEnumerable<Item> GetItemsInRange(int range)
|
||||
{
|
||||
|
|
@ -2448,7 +2538,9 @@ namespace Server
|
|||
if (heldBy != null)
|
||||
{
|
||||
if (GetBounce() != null)
|
||||
{
|
||||
Bounce(heldBy);
|
||||
}
|
||||
else
|
||||
{
|
||||
heldBy.Holding = null;
|
||||
|
|
@ -2469,22 +2561,18 @@ namespace Server
|
|||
|
||||
public virtual void SendInfoTo(NetState state, bool sendOplPacket)
|
||||
{
|
||||
SendWorldPacketFor(state);
|
||||
state.Send(GetWorldPacketFor(state));
|
||||
|
||||
if (sendOplPacket)
|
||||
PropertyList.Send(state);
|
||||
if (sendOplPacket) state.Send(OPLPacket);
|
||||
}
|
||||
|
||||
// World packets need to be invalidated when any of the following changes:
|
||||
// - ItemID
|
||||
// - Amount
|
||||
// - Location
|
||||
// - Hue
|
||||
// - Packet Flags
|
||||
// - Direction
|
||||
protected virtual void SendWorldPacketFor(NetState state)
|
||||
protected virtual Packet GetWorldPacketFor(NetState state)
|
||||
{
|
||||
Packets.SendWorldItem(state, this);
|
||||
if (state.HighSeas)
|
||||
return WorldPacketHS;
|
||||
if (state.StygianAbyss)
|
||||
return WorldPacketSA;
|
||||
return WorldPacket;
|
||||
}
|
||||
|
||||
public virtual int GetTotal(TotalType type) => 0;
|
||||
|
|
@ -2664,7 +2752,10 @@ namespace Server
|
|||
|
||||
public virtual void FreeCache()
|
||||
{
|
||||
m_PropertyList = null;
|
||||
ReleaseWorldPackets();
|
||||
StaticPacketHandlers.FreeRemoveItemPacket(this);
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
StaticPacketHandlers.FreeOPLPacket(this);
|
||||
}
|
||||
|
||||
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text)
|
||||
|
|
@ -2672,6 +2763,7 @@ namespace Server
|
|||
if (m_Map == null)
|
||||
return;
|
||||
|
||||
Packet p = null;
|
||||
Point3D worldLoc = GetWorldLocation();
|
||||
|
||||
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
|
@ -2682,21 +2774,36 @@ namespace Server
|
|||
|
||||
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (ascii)
|
||||
Packets.SendAsciiMessage(state, Serial, m_ItemID, type, hue, 3, Name, text);
|
||||
else
|
||||
Packets.SendUnicodeMessage(state, Serial, m_ItemID, type, hue, 3, "ENU", Name, text);
|
||||
if (p == null)
|
||||
{
|
||||
if (ascii)
|
||||
p = new AsciiMessage(Serial, m_ItemID, type, hue, 3, Name, text);
|
||||
else
|
||||
p = new UnicodeMessage(Serial, m_ItemID, type, hue, 3, "ENU", Name, text);
|
||||
|
||||
p.Acquire();
|
||||
}
|
||||
|
||||
state.Send(p);
|
||||
}
|
||||
}
|
||||
|
||||
Packet.Release(p);
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
public void PublicOverheadMessage(MessageType type, int hue, int number, string args = "")
|
||||
public void PublicOverheadMessage(MessageType type, int hue, int number)
|
||||
{
|
||||
PublicOverheadMessage(type, hue, number, "");
|
||||
}
|
||||
|
||||
public void PublicOverheadMessage(MessageType type, int hue, int number, string args)
|
||||
{
|
||||
if (m_Map == null)
|
||||
return;
|
||||
|
||||
Packet p = null;
|
||||
Point3D worldLoc = GetWorldLocation();
|
||||
|
||||
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
|
||||
|
|
@ -2706,9 +2813,16 @@ namespace Server
|
|||
Mobile m = state.Mobile;
|
||||
|
||||
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
Packets.SendMessageLocalized(state, Serial, m_ItemID, type, hue, 3, number, Name, args);
|
||||
{
|
||||
if (p == null)
|
||||
p = Packet.Acquire(new MessageLocalized(Serial, m_ItemID, type, hue, 3, number, Name, args));
|
||||
|
||||
state.Send(p);
|
||||
}
|
||||
}
|
||||
|
||||
Packet.Release(p);
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
|
|
@ -3073,8 +3187,7 @@ namespace Server
|
|||
{
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if (m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
Packets.SendRemoveEntity(state, Serial);
|
||||
if (m.InRange(worldLoc, GetUpdateRange(m))) state.Send(RemovePacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -3114,21 +3227,21 @@ namespace Server
|
|||
to.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", ""));
|
||||
}
|
||||
|
||||
public void SendLocalizedMessageTo(Mobile to, int number, string args = "")
|
||||
public void SendLocalizedMessageTo(Mobile to, int number, string args)
|
||||
{
|
||||
if (Deleted || !to.CanSee(this))
|
||||
return;
|
||||
|
||||
Packets.SendMessageLocalized(to.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", args);
|
||||
to.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", args));
|
||||
}
|
||||
|
||||
public void SendLocalizedMessageTo(Mobile to, int number, AffixType affixType, string affix = "", string args = "")
|
||||
public void SendLocalizedMessageTo(Mobile to, int number, AffixType affixType, string affix, string args)
|
||||
{
|
||||
if (Deleted || !to.CanSee(this))
|
||||
return;
|
||||
|
||||
Packets.SendMessageLocalizedAffix(to.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", affixType, affix,
|
||||
args);
|
||||
to.Send(new MessageLocalizedAffix(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", affixType, affix,
|
||||
args));
|
||||
}
|
||||
|
||||
public virtual void OnSnoop(Mobile from)
|
||||
|
|
@ -3280,7 +3393,7 @@ namespace Server
|
|||
|
||||
public bool CheckLift(Mobile from)
|
||||
{
|
||||
LRReason reject = LRReason.Unspecific;
|
||||
LRReason reject = LRReason.Inspecific;
|
||||
|
||||
return CheckLift(from, this, ref reject);
|
||||
}
|
||||
|
|
@ -3307,8 +3420,8 @@ namespace Server
|
|||
ObjectPropertyList opl = PropertyList;
|
||||
|
||||
if (opl.Header > 0)
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, opl.Header, Name,
|
||||
opl.HeaderArgs);
|
||||
from.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, opl.Header, Name,
|
||||
opl.HeaderArgs));
|
||||
}
|
||||
|
||||
public virtual void OnSingleClick(Mobile from)
|
||||
|
|
@ -3327,10 +3440,11 @@ namespace Server
|
|||
if (Name == null)
|
||||
{
|
||||
if (m_Amount <= 1)
|
||||
Packets.SendMessageLocalized(ns, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber);
|
||||
ns.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", ""));
|
||||
else
|
||||
Packets.SendMessageLocalizedAffix(ns, Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "",
|
||||
AffixType.Append, $" : {m_Amount}");
|
||||
ns.Send(new MessageLocalizedAffix(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "",
|
||||
AffixType.Append,
|
||||
$" : {m_Amount}", ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3420,8 +3534,8 @@ namespace Server
|
|||
if (BlessedFor != null)
|
||||
return false;
|
||||
|
||||
public virtual bool IsStandardLoot() =>
|
||||
!(Mobile.InsuranceEnabled && Insured) && BlessedFor == null && m_LootType == LootType.Regular;
|
||||
return m_LootType == LootType.Regular;
|
||||
}
|
||||
|
||||
public override string ToString() => $"0x{Serial.Value:X} \"{GetType().Name}\"";
|
||||
|
||||
|
|
@ -3509,9 +3623,11 @@ namespace Server
|
|||
private Map m_Map;
|
||||
private LootType m_LootType;
|
||||
private Direction m_Direction;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Location Location Location!
|
||||
|
||||
public virtual void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
}
|
||||
|
|
@ -3540,8 +3656,7 @@ namespace Server
|
|||
{
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if (!m.InRange(value, GetUpdateRange(m)))
|
||||
Packets.SendRemoveEntity(state, Serial);
|
||||
if (!m.InRange(value, GetUpdateRange(m))) state.Send(RemovePacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
|
@ -3549,6 +3664,7 @@ namespace Server
|
|||
|
||||
Point3D oldLoc = m_Location;
|
||||
m_Location = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
SetLastMoved();
|
||||
|
||||
|
|
@ -3571,17 +3687,24 @@ namespace Server
|
|||
else if (m_Parent is Item)
|
||||
{
|
||||
m_Location = value;
|
||||
ReleaseWorldPackets();
|
||||
|
||||
Delta(ItemDelta.Update);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Location = value;
|
||||
ReleaseWorldPackets();
|
||||
}
|
||||
|
||||
if (m_Parent == null)
|
||||
m_Map.OnMove(oldLocation, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Location = value;
|
||||
ReleaseWorldPackets();
|
||||
}
|
||||
|
||||
OnLocationChange(oldLocation);
|
||||
}
|
||||
|
|
@ -3607,9 +3730,11 @@ namespace Server
|
|||
get => m_Location.m_Z;
|
||||
set => Location = new Point3D(m_Location.m_X, m_Location.m_Y, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnDoubleClick[...]
|
||||
|
||||
public virtual void OnDoubleClick(Mobile from)
|
||||
{
|
||||
}
|
||||
|
|
@ -3636,6 +3761,7 @@ namespace Server
|
|||
{
|
||||
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue