Moves Item/Mobile locks to a handler. (#34)
This commit is contained in:
parent
cf90a58bea
commit
de50bc9e43
10 changed files with 876 additions and 1055 deletions
|
|
@ -177,21 +177,20 @@ namespace Server.Engines.Quests.Doom
|
|||
|
||||
Party p = PartySystem.Party.Get(from);
|
||||
|
||||
if (p != null)
|
||||
for (int i = 0; i < p.Members.Count; ++i)
|
||||
for (int i = 0; i < p?.Members.Count; ++i)
|
||||
{
|
||||
PartyMemberInfo pmi = p.Members[i];
|
||||
Mobile member = pmi.Mobile;
|
||||
|
||||
if (member != from && member.Map == Map.Malas && member.Region.IsPartOf("Doom"))
|
||||
{
|
||||
PartyMemberInfo pmi = p.Members[i];
|
||||
Mobile member = pmi.Mobile;
|
||||
if (AngryAt == member)
|
||||
AngryAt = null;
|
||||
|
||||
if (member != from && member.Map == Map.Malas && member.Region.IsPartOf("Doom"))
|
||||
{
|
||||
if (AngryAt == member)
|
||||
AngryAt = null;
|
||||
|
||||
member.CloseGump<ChylothPartyGump>();
|
||||
member.SendGump(new ChylothPartyGump(from, member));
|
||||
}
|
||||
member.CloseGump<ChylothPartyGump>();
|
||||
member.SendGump(new ChylothPartyGump(from, member));
|
||||
}
|
||||
}
|
||||
|
||||
if (AngryAt == from)
|
||||
AngryAt = null;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@ namespace Server.Items
|
|||
{
|
||||
From = from;
|
||||
|
||||
if (From.NetState != null)
|
||||
Address = From.NetState.Address;
|
||||
else
|
||||
Address = IPAddress.None;
|
||||
Address = From.NetState?.Address ?? IPAddress.None;
|
||||
|
||||
Date = DateTime.UtcNow;
|
||||
}
|
||||
|
|
@ -367,9 +364,7 @@ namespace Server.Items
|
|||
|
||||
public string FormatPrice()
|
||||
{
|
||||
if (m_TicketPrice == 0)
|
||||
return "FREE";
|
||||
return $"{m_TicketPrice} gold";
|
||||
return m_TicketPrice == 0 ? "FREE" : $"{m_TicketPrice} gold";
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
|
|
|
|||
949
Server/Item.cs
949
Server/Item.cs
File diff suppressed because it is too large
Load diff
173
Server/Layer.cs
Normal file
173
Server/Layer.cs
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
namespace Server
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of item layer values.
|
||||
/// </summary>
|
||||
public enum Layer : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid layer.
|
||||
/// </summary>
|
||||
Invalid = 0x00,
|
||||
|
||||
/// <summary>
|
||||
/// First valid layer. Equivalent to <c>Layer.OneHanded</c>.
|
||||
/// </summary>
|
||||
FirstValid = 0x01,
|
||||
|
||||
/// <summary>
|
||||
/// One handed weapon.
|
||||
/// </summary>
|
||||
OneHanded = 0x01,
|
||||
|
||||
/// <summary>
|
||||
/// Two handed weapon or shield.
|
||||
/// </summary>
|
||||
TwoHanded = 0x02,
|
||||
|
||||
/// <summary>
|
||||
/// Shoes.
|
||||
/// </summary>
|
||||
Shoes = 0x03,
|
||||
|
||||
/// <summary>
|
||||
/// Pants.
|
||||
/// </summary>
|
||||
Pants = 0x04,
|
||||
|
||||
/// <summary>
|
||||
/// Shirts.
|
||||
/// </summary>
|
||||
Shirt = 0x05,
|
||||
|
||||
/// <summary>
|
||||
/// Helmets, hats, and masks.
|
||||
/// </summary>
|
||||
Helm = 0x06,
|
||||
|
||||
/// <summary>
|
||||
/// Gloves.
|
||||
/// </summary>
|
||||
Gloves = 0x07,
|
||||
|
||||
/// <summary>
|
||||
/// Rings.
|
||||
/// </summary>
|
||||
Ring = 0x08,
|
||||
|
||||
/// <summary>
|
||||
/// Talismans.
|
||||
/// </summary>
|
||||
Talisman = 0x09,
|
||||
|
||||
/// <summary>
|
||||
/// Gorgets and necklaces.
|
||||
/// </summary>
|
||||
Neck = 0x0A,
|
||||
|
||||
/// <summary>
|
||||
/// Hair.
|
||||
/// </summary>
|
||||
Hair = 0x0B,
|
||||
|
||||
/// <summary>
|
||||
/// Half aprons.
|
||||
/// </summary>
|
||||
Waist = 0x0C,
|
||||
|
||||
/// <summary>
|
||||
/// Torso, inner layer.
|
||||
/// </summary>
|
||||
InnerTorso = 0x0D,
|
||||
|
||||
/// <summary>
|
||||
/// Bracelets.
|
||||
/// </summary>
|
||||
Bracelet = 0x0E,
|
||||
|
||||
/// <summary>
|
||||
/// Unused.
|
||||
/// </summary>
|
||||
Unused_xF = 0x0F,
|
||||
|
||||
/// <summary>
|
||||
/// Beards and mustaches.
|
||||
/// </summary>
|
||||
FacialHair = 0x10,
|
||||
|
||||
/// <summary>
|
||||
/// Torso, outer layer.
|
||||
/// </summary>
|
||||
MiddleTorso = 0x11,
|
||||
|
||||
/// <summary>
|
||||
/// Earings.
|
||||
/// </summary>
|
||||
Earrings = 0x12,
|
||||
|
||||
/// <summary>
|
||||
/// Arms and sleeves.
|
||||
/// </summary>
|
||||
Arms = 0x13,
|
||||
|
||||
/// <summary>
|
||||
/// Cloaks.
|
||||
/// </summary>
|
||||
Cloak = 0x14,
|
||||
|
||||
/// <summary>
|
||||
/// Backpacks.
|
||||
/// </summary>
|
||||
Backpack = 0x15,
|
||||
|
||||
/// <summary>
|
||||
/// Torso, outer layer.
|
||||
/// </summary>
|
||||
OuterTorso = 0x16,
|
||||
|
||||
/// <summary>
|
||||
/// Leggings, outer layer.
|
||||
/// </summary>
|
||||
OuterLegs = 0x17,
|
||||
|
||||
/// <summary>
|
||||
/// Leggings, inner layer.
|
||||
/// </summary>
|
||||
InnerLegs = 0x18,
|
||||
|
||||
/// <summary>
|
||||
/// Last valid non-internal layer. Equivalent to <c>Layer.InnerLegs</c>.
|
||||
/// </summary>
|
||||
LastUserValid = 0x18,
|
||||
|
||||
/// <summary>
|
||||
/// Mount item layer.
|
||||
/// </summary>
|
||||
Mount = 0x19,
|
||||
|
||||
/// <summary>
|
||||
/// Vendor 'buy pack' layer.
|
||||
/// </summary>
|
||||
ShopBuy = 0x1A,
|
||||
|
||||
/// <summary>
|
||||
/// Vendor 'resale pack' layer.
|
||||
/// </summary>
|
||||
ShopResale = 0x1B,
|
||||
|
||||
/// <summary>
|
||||
/// Vendor 'sell pack' layer.
|
||||
/// </summary>
|
||||
ShopSell = 0x1C,
|
||||
|
||||
/// <summary>
|
||||
/// Bank box layer.
|
||||
/// </summary>
|
||||
Bank = 0x1D,
|
||||
|
||||
/// <summary>
|
||||
/// Last valid layer. Equivalent to <c>Layer.Bank</c>.
|
||||
/// </summary>
|
||||
LastValid = 0x1D
|
||||
}
|
||||
}
|
||||
287
Server/LightType.cs
Normal file
287
Server/LightType.cs
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
namespace Server
|
||||
{
|
||||
public enum LightType
|
||||
{
|
||||
/// <summary>
|
||||
/// Window shape, arched, ray shining east.
|
||||
/// </summary>
|
||||
ArchedWindowEast,
|
||||
|
||||
/// <summary>
|
||||
/// Medium circular shape.
|
||||
/// </summary>
|
||||
Circle225,
|
||||
|
||||
/// <summary>
|
||||
/// Small circular shape.
|
||||
/// </summary>
|
||||
Circle150,
|
||||
|
||||
/// <summary>
|
||||
/// Door shape, shining south.
|
||||
/// </summary>
|
||||
DoorSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Door shape, shining east.
|
||||
/// </summary>
|
||||
DoorEast,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), north wall.
|
||||
/// </summary>
|
||||
NorthBig,
|
||||
|
||||
/// <summary>
|
||||
/// Large pie shape (90 degrees), north-east corner.
|
||||
/// </summary>
|
||||
NorthEastBig,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), east wall.
|
||||
/// </summary>
|
||||
EastBig,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), west wall.
|
||||
/// </summary>
|
||||
WestBig,
|
||||
|
||||
/// <summary>
|
||||
/// Large pie shape (90 degrees), south-west corner.
|
||||
/// </summary>
|
||||
SouthWestBig,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), south wall.
|
||||
/// </summary>
|
||||
SouthBig,
|
||||
|
||||
/// <summary>
|
||||
/// Medium semicircular shape (180 degrees), north wall.
|
||||
/// </summary>
|
||||
NorthSmall,
|
||||
|
||||
/// <summary>
|
||||
/// Medium pie shape (90 degrees), north-east corner.
|
||||
/// </summary>
|
||||
NorthEastSmall,
|
||||
|
||||
/// <summary>
|
||||
/// Medium semicircular shape (180 degrees), east wall.
|
||||
/// </summary>
|
||||
EastSmall,
|
||||
|
||||
/// <summary>
|
||||
/// Medium semicircular shape (180 degrees), west wall.
|
||||
/// </summary>
|
||||
WestSmall,
|
||||
|
||||
/// <summary>
|
||||
/// Medium semicircular shape (180 degrees), south wall.
|
||||
/// </summary>
|
||||
SouthSmall,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a wall decoration, north wall.
|
||||
/// </summary>
|
||||
DecorationNorth,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a wall decoration, north-east corner.
|
||||
/// </summary>
|
||||
DecorationNorthEast,
|
||||
|
||||
/// <summary>
|
||||
/// Small semicircular shape (180 degrees), east wall.
|
||||
/// </summary>
|
||||
EastTiny,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a wall decoration, west wall.
|
||||
/// </summary>
|
||||
DecorationWest,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a wall decoration, south-west corner.
|
||||
/// </summary>
|
||||
DecorationSouthWest,
|
||||
|
||||
/// <summary>
|
||||
/// Small semicircular shape (180 degrees), south wall.
|
||||
/// </summary>
|
||||
SouthTiny,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, rectangular, no ray, shining south.
|
||||
/// </summary>
|
||||
RectWindowSouthNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, rectangular, no ray, shining east.
|
||||
/// </summary>
|
||||
RectWindowEastNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, rectangular, ray shining south.
|
||||
/// </summary>
|
||||
RectWindowSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, rectangular, ray shining east.
|
||||
/// </summary>
|
||||
RectWindowEast,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, arched, no ray, shining south.
|
||||
/// </summary>
|
||||
ArchedWindowSouthNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, arched, no ray, shining east.
|
||||
/// </summary>
|
||||
ArchedWindowEastNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, arched, ray shining south.
|
||||
/// </summary>
|
||||
ArchedWindowSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Large circular shape.
|
||||
/// </summary>
|
||||
Circle300,
|
||||
|
||||
/// <summary>
|
||||
/// Large pie shape (90 degrees), north-west corner.
|
||||
/// </summary>
|
||||
NorthWestBig,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Medium pie shape (90 degrees), south-east corner.
|
||||
/// </summary>
|
||||
DarkSouthEast,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Medium semicircular shape (180 degrees), south wall.
|
||||
/// </summary>
|
||||
DarkSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Medium pie shape (90 degrees), north-west corner.
|
||||
/// </summary>
|
||||
DarkNorthWest,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Medium pie shape (90 degrees), south-east corner. Equivalent to <c>LightType.SouthEast</c>.
|
||||
/// </summary>
|
||||
DarkSouthEast2,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Medium circular shape (180 degrees), east wall.
|
||||
/// </summary>
|
||||
DarkEast,
|
||||
|
||||
/// <summary>
|
||||
/// Negative light. Large circular shape.
|
||||
/// </summary>
|
||||
DarkCircle300,
|
||||
|
||||
/// <summary>
|
||||
/// Opened door shape, shining south.
|
||||
/// </summary>
|
||||
DoorOpenSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Opened door shape, shining east.
|
||||
/// </summary>
|
||||
DoorOpenEast,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, square, ray shining east.
|
||||
/// </summary>
|
||||
SquareWindowEast,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, square, no ray, shining east.
|
||||
/// </summary>
|
||||
SquareWindowEastNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, square, ray shining south.
|
||||
/// </summary>
|
||||
SquareWindowSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, square, no ray, shining south.
|
||||
/// </summary>
|
||||
SquareWindowSouthNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Empty.
|
||||
/// </summary>
|
||||
Empty,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, skinny, no ray, shining south.
|
||||
/// </summary>
|
||||
SkinnyWindowSouthNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, skinny, ray shining east.
|
||||
/// </summary>
|
||||
SkinnyWindowEast,
|
||||
|
||||
/// <summary>
|
||||
/// Window shape, skinny, no ray, shining east.
|
||||
/// </summary>
|
||||
SkinnyWindowEastNoRay,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a hole, shining south.
|
||||
/// </summary>
|
||||
HoleSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a hole, shining south.
|
||||
/// </summary>
|
||||
HoleEast,
|
||||
|
||||
/// <summary>
|
||||
/// Large circular shape with a moongate graphic embedded.
|
||||
/// </summary>
|
||||
Moongate,
|
||||
|
||||
/// <summary>
|
||||
/// Unknown usage. Many rows of slightly angled lines.
|
||||
/// </summary>
|
||||
Strips,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a small hole, shining south.
|
||||
/// </summary>
|
||||
SmallHoleSouth,
|
||||
|
||||
/// <summary>
|
||||
/// Shaped like a small hole, shining east.
|
||||
/// </summary>
|
||||
SmallHoleEast,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), north wall. Identical graphic as <c>LightType.NorthBig</c>, but slightly different
|
||||
/// positioning.
|
||||
/// </summary>
|
||||
NorthBig2,
|
||||
|
||||
/// <summary>
|
||||
/// Large semicircular shape (180 degrees), west wall. Identical graphic as <c>LightType.WestBig</c>, but slightly different
|
||||
/// positioning.
|
||||
/// </summary>
|
||||
WestBig2,
|
||||
|
||||
/// <summary>
|
||||
/// Large pie shape (90 degrees), north-west corner. Equivalent to <c>LightType.NorthWestBig</c>.
|
||||
/// </summary>
|
||||
NorthWestBig2
|
||||
}
|
||||
}
|
||||
312
Server/Mobile.cs
312
Server/Mobile.cs
|
|
@ -457,7 +457,7 @@ namespace Server
|
|||
/// <summary>
|
||||
/// Base class representing players, npcs, and creatures.
|
||||
/// </summary>
|
||||
public class Mobile : IHued, IComparable<Mobile>, ISerializable, ISpawnable
|
||||
public class Mobile : IHued, IComparable<Mobile>, ISerializable, ISpawnable, IPropertyListObject
|
||||
{
|
||||
private const int
|
||||
WarmodeCatchCount = 4; // Allow four warmode changes in 0.5 seconds, any more will be delay for two seconds
|
||||
|
|
@ -551,14 +551,8 @@ namespace Server
|
|||
|
||||
private string m_NameMod;
|
||||
|
||||
private Packet m_OPLPacket;
|
||||
|
||||
private ObjectPropertyList m_PropertyList;
|
||||
|
||||
private QuestArrow m_QuestArrow;
|
||||
|
||||
private Packet m_RemovePacket;
|
||||
|
||||
private int m_SolidHueOverride = -1;
|
||||
|
||||
private StatLockType m_StrLock, m_DexLock, m_IntLock;
|
||||
|
|
@ -1783,59 +1777,9 @@ namespace Server
|
|||
|
||||
public Region Region => m_Region ?? (Map == null ? Map.Internal.DefaultRegion : Map.DefaultRegion);
|
||||
|
||||
public Packet RemovePacket
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_RemovePacket == null)
|
||||
lock (rpLock)
|
||||
{
|
||||
if (m_RemovePacket == null)
|
||||
{
|
||||
m_RemovePacket = new RemoveMobile(this);
|
||||
m_RemovePacket.SetStatic();
|
||||
}
|
||||
}
|
||||
|
||||
return m_RemovePacket;
|
||||
}
|
||||
}
|
||||
|
||||
public Packet OPLPacket
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_OPLPacket == null)
|
||||
lock (oplLock)
|
||||
{
|
||||
if (m_OPLPacket == null)
|
||||
{
|
||||
m_OPLPacket = new OPLInfo(PropertyList);
|
||||
m_OPLPacket.SetStatic();
|
||||
}
|
||||
}
|
||||
|
||||
return m_OPLPacket;
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectPropertyList PropertyList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PropertyList == null)
|
||||
{
|
||||
m_PropertyList = new ObjectPropertyList(this);
|
||||
|
||||
GetProperties(m_PropertyList);
|
||||
|
||||
m_PropertyList.Terminate();
|
||||
m_PropertyList.SetStatic();
|
||||
}
|
||||
|
||||
return m_PropertyList;
|
||||
}
|
||||
}
|
||||
public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this);
|
||||
public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this);
|
||||
public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int SolidHueOverride
|
||||
|
|
@ -6765,17 +6709,17 @@ namespace Server
|
|||
return delta != 0 ? body : 0;
|
||||
}
|
||||
|
||||
public void FreeCache()
|
||||
public virtual void FreeCache()
|
||||
{
|
||||
Packet.Release(ref m_RemovePacket);
|
||||
Packet.Release(ref m_PropertyList);
|
||||
Packet.Release(ref m_OPLPacket);
|
||||
StaticPacketHandlers.FreeRemoveItemPacket(this);
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
StaticPacketHandlers.FreeOPLPacket(this);
|
||||
}
|
||||
|
||||
public void ClearProperties()
|
||||
{
|
||||
Packet.Release(ref m_PropertyList);
|
||||
Packet.Release(ref m_OPLPacket);
|
||||
StaticPacketHandlers.FreeOPLPacket(this);
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
}
|
||||
|
||||
public void InvalidateProperties()
|
||||
|
|
@ -6785,13 +6729,11 @@ namespace Server
|
|||
|
||||
if (m_Map != null && m_Map != Map.Internal && !World.Loading)
|
||||
{
|
||||
ObjectPropertyList oldList = m_PropertyList;
|
||||
Packet.Release(ref m_PropertyList);
|
||||
ObjectPropertyList newList = PropertyList;
|
||||
ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this);
|
||||
|
||||
if (oldList == null || oldList.Hash != newList.Hash)
|
||||
if (oldList?.Hash != PropertyList.Hash)
|
||||
{
|
||||
Packet.Release(ref m_OPLPacket);
|
||||
StaticPacketHandlers.FreeOPLInfoPacket(this);
|
||||
Delta(MobileDelta.Properties);
|
||||
}
|
||||
}
|
||||
|
|
@ -6808,148 +6750,148 @@ namespace Server
|
|||
|
||||
Point3D oldLocation = m_Location;
|
||||
|
||||
if (oldLocation != newLocation)
|
||||
if (oldLocation == newLocation)
|
||||
return;
|
||||
|
||||
m_Location = newLocation;
|
||||
UpdateRegion();
|
||||
|
||||
BankBox box = FindBankNoCreate();
|
||||
|
||||
if (box?.Opened == true)
|
||||
box.Close();
|
||||
|
||||
m_NetState?.ValidateAllTrades();
|
||||
|
||||
m_Map?.OnMove(oldLocation, this);
|
||||
|
||||
if (isTeleport && m_NetState != null && (!m_NetState.HighSeas || !NoMoveHS))
|
||||
{
|
||||
m_Location = newLocation;
|
||||
UpdateRegion();
|
||||
m_NetState.Sequence = 0;
|
||||
|
||||
BankBox box = FindBankNoCreate();
|
||||
if (m_NetState.StygianAbyss)
|
||||
m_NetState.Send(new MobileUpdate(this));
|
||||
else
|
||||
m_NetState.Send(new MobileUpdateOld(this));
|
||||
|
||||
if (box?.Opened == true)
|
||||
box.Close();
|
||||
ClearFastwalkStack();
|
||||
}
|
||||
|
||||
m_NetState?.ValidateAllTrades();
|
||||
Map map = m_Map;
|
||||
|
||||
m_Map?.OnMove(oldLocation, this);
|
||||
if (map != null)
|
||||
{
|
||||
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
|
||||
|
||||
if (isTeleport && m_NetState != null && (!m_NetState.HighSeas || !NoMoveHS))
|
||||
IPooledEnumerable<NetState> eable = map.GetClientsInRange(oldLocation);
|
||||
|
||||
foreach (NetState ns in eable)
|
||||
if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location))
|
||||
ns.Send(RemovePacket);
|
||||
|
||||
eable.Free();
|
||||
|
||||
NetState ourState = m_NetState;
|
||||
|
||||
// Check to see if we are attached to a client
|
||||
if (ourState != null)
|
||||
{
|
||||
m_NetState.Sequence = 0;
|
||||
IPooledEnumerable<IEntity> eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange);
|
||||
|
||||
if (m_NetState.StygianAbyss)
|
||||
m_NetState.Send(new MobileUpdate(this));
|
||||
else
|
||||
m_NetState.Send(new MobileUpdateOld(this));
|
||||
// We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
|
||||
|
||||
ClearFastwalkStack();
|
||||
}
|
||||
foreach (IEntity o in eeable)
|
||||
if (o is Item item)
|
||||
{
|
||||
int range = item.GetUpdateRange(this);
|
||||
Point3D loc = item.Location;
|
||||
|
||||
Map map = m_Map;
|
||||
if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) &&
|
||||
CanSee(item))
|
||||
item.SendInfoTo(ourState);
|
||||
}
|
||||
else if (o != this && o is Mobile m)
|
||||
{
|
||||
if (!Utility.InUpdateRange(newLocation, m.m_Location))
|
||||
continue;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
|
||||
bool inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location);
|
||||
|
||||
IPooledEnumerable<NetState> eable = map.GetClientsInRange(oldLocation);
|
||||
|
||||
foreach (NetState ns in eable)
|
||||
if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location))
|
||||
ns.Send(RemovePacket);
|
||||
|
||||
eable.Free();
|
||||
|
||||
NetState ourState = m_NetState;
|
||||
|
||||
// Check to see if we are attached to a client
|
||||
if (ourState != null)
|
||||
{
|
||||
IPooledEnumerable<IEntity> eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange);
|
||||
|
||||
// We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
|
||||
|
||||
foreach (IEntity o in eeable)
|
||||
if (o is Item item)
|
||||
if (m.m_NetState != null &&
|
||||
(isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this))
|
||||
{
|
||||
int range = item.GetUpdateRange(this);
|
||||
Point3D loc = item.Location;
|
||||
m.m_NetState.Send(MobileIncoming.Create(m.m_NetState, m, this));
|
||||
|
||||
if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) &&
|
||||
CanSee(item))
|
||||
item.SendInfoTo(ourState);
|
||||
}
|
||||
else if (o != this && o is Mobile m)
|
||||
{
|
||||
if (!Utility.InUpdateRange(newLocation, m.m_Location))
|
||||
continue;
|
||||
|
||||
bool inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location);
|
||||
|
||||
if (m.m_NetState != null &&
|
||||
(isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this))
|
||||
{
|
||||
m.m_NetState.Send(MobileIncoming.Create(m.m_NetState, m, this));
|
||||
|
||||
if (m.m_NetState.StygianAbyss)
|
||||
{
|
||||
//if ( m_Poison != null )
|
||||
m.m_NetState.Send(new HealthbarPoison(this));
|
||||
|
||||
//if ( m_Blessed || m_YellowHealthbar )
|
||||
m.m_NetState.Send(new HealthbarYellow(this));
|
||||
}
|
||||
|
||||
if (IsDeadBondedPet)
|
||||
m.m_NetState.Send(new BondedStatus(0, Serial, 1));
|
||||
|
||||
if (ObjectPropertyList.Enabled) m.m_NetState.Send(OPLPacket);
|
||||
}
|
||||
|
||||
if (inOldRange || !CanSee(m))
|
||||
continue;
|
||||
|
||||
ourState.Send(MobileIncoming.Create(ourState, this, m));
|
||||
|
||||
if (ourState.StygianAbyss)
|
||||
{
|
||||
//if ( m.Poisoned )
|
||||
ourState.Send(new HealthbarPoison(m));
|
||||
|
||||
//if ( m.Blessed || m.YellowHealthbar )
|
||||
ourState.Send(new HealthbarYellow(m));
|
||||
}
|
||||
|
||||
if (m.IsDeadBondedPet)
|
||||
ourState.Send(new BondedStatus(0, m.Serial, 1));
|
||||
|
||||
if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket);
|
||||
}
|
||||
|
||||
eeable.Free();
|
||||
}
|
||||
else
|
||||
{
|
||||
eable = map.GetClientsInRange(newLocation);
|
||||
|
||||
// We're not attached to a client, so simply send an Incoming
|
||||
foreach (NetState ns in eable)
|
||||
if ((isTeleport && (!ns.HighSeas || !NoMoveHS) ||
|
||||
!Utility.InUpdateRange(oldLocation, ns.Mobile.Location)) && ns.Mobile.CanSee(this))
|
||||
{
|
||||
ns.Send(MobileIncoming.Create(ns, ns.Mobile, this));
|
||||
|
||||
if (ns.StygianAbyss)
|
||||
if (m.m_NetState.StygianAbyss)
|
||||
{
|
||||
//if ( m_Poison != null )
|
||||
ns.Send(new HealthbarPoison(this));
|
||||
m.m_NetState.Send(new HealthbarPoison(this));
|
||||
|
||||
//if ( m_Blessed || m_YellowHealthbar )
|
||||
ns.Send(new HealthbarYellow(this));
|
||||
m.m_NetState.Send(new HealthbarYellow(this));
|
||||
}
|
||||
|
||||
if (IsDeadBondedPet)
|
||||
ns.Send(new BondedStatus(0, Serial, 1));
|
||||
m.m_NetState.Send(new BondedStatus(0, Serial, 1));
|
||||
|
||||
if (ObjectPropertyList.Enabled) ns.Send(OPLPacket);
|
||||
if (ObjectPropertyList.Enabled) m.m_NetState.Send(OPLPacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
if (inOldRange || !CanSee(m))
|
||||
continue;
|
||||
|
||||
ourState.Send(MobileIncoming.Create(ourState, this, m));
|
||||
|
||||
if (ourState.StygianAbyss)
|
||||
{
|
||||
//if ( m.Poisoned )
|
||||
ourState.Send(new HealthbarPoison(m));
|
||||
|
||||
//if ( m.Blessed || m.YellowHealthbar )
|
||||
ourState.Send(new HealthbarYellow(m));
|
||||
}
|
||||
|
||||
if (m.IsDeadBondedPet)
|
||||
ourState.Send(new BondedStatus(0, m.Serial, 1));
|
||||
|
||||
if (ObjectPropertyList.Enabled) ourState.Send(m.OPLPacket);
|
||||
}
|
||||
|
||||
eeable.Free();
|
||||
}
|
||||
else
|
||||
{
|
||||
eable = map.GetClientsInRange(newLocation);
|
||||
|
||||
OnLocationChange(oldLocation);
|
||||
// We're not attached to a client, so simply send an Incoming
|
||||
foreach (NetState ns in eable)
|
||||
if ((isTeleport && (!ns.HighSeas || !NoMoveHS) ||
|
||||
!Utility.InUpdateRange(oldLocation, ns.Mobile.Location)) && ns.Mobile.CanSee(this))
|
||||
{
|
||||
ns.Send(MobileIncoming.Create(ns, ns.Mobile, this));
|
||||
|
||||
Region.OnLocationChanged(this, oldLocation);
|
||||
if (ns.StygianAbyss)
|
||||
{
|
||||
//if ( m_Poison != null )
|
||||
ns.Send(new HealthbarPoison(this));
|
||||
|
||||
//if ( m_Blessed || m_YellowHealthbar )
|
||||
ns.Send(new HealthbarYellow(this));
|
||||
}
|
||||
|
||||
if (IsDeadBondedPet)
|
||||
ns.Send(new BondedStatus(0, Serial, 1));
|
||||
|
||||
if (ObjectPropertyList.Enabled) ns.Send(OPLPacket);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
}
|
||||
|
||||
OnLocationChange(oldLocation);
|
||||
|
||||
Region.OnLocationChanged(this, oldLocation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1035,9 +1035,8 @@ namespace Server.Network
|
|||
|
||||
int hue = item.Hue;
|
||||
|
||||
if (parent != null)
|
||||
if (parent.SolidHueOverride >= 0)
|
||||
hue = parent.SolidHueOverride;
|
||||
if (parent?.SolidHueOverride >= 0)
|
||||
hue = parent.SolidHueOverride;
|
||||
|
||||
m_Stream.Write(item.Serial);
|
||||
m_Stream.Write((short)item.ItemID);
|
||||
|
|
@ -2019,19 +2018,11 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveItem : Packet
|
||||
public sealed class RemoveEntity : Packet
|
||||
{
|
||||
public RemoveItem(Item item) : base(0x1D, 5)
|
||||
public RemoveEntity(IEntity entity) : base(0x1D, 5)
|
||||
{
|
||||
m_Stream.Write(item.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveMobile : Packet
|
||||
{
|
||||
public RemoveMobile(Mobile m) : base(0x1D, 5)
|
||||
{
|
||||
m_Stream.Write(m.Serial);
|
||||
m_Stream.Write(entity.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4363,38 +4354,9 @@ namespace Server.Network
|
|||
return p;
|
||||
}
|
||||
|
||||
public static void Release(ref ObjectPropertyList p)
|
||||
{
|
||||
p?.Release();
|
||||
|
||||
p = null;
|
||||
}
|
||||
|
||||
public static void Release(ref RemoveItem p)
|
||||
{
|
||||
p?.Release();
|
||||
|
||||
p = null;
|
||||
}
|
||||
|
||||
public static void Release(ref RemoveMobile p)
|
||||
{
|
||||
p?.Release();
|
||||
|
||||
p = null;
|
||||
}
|
||||
|
||||
public static void Release(ref OPLInfo p)
|
||||
{
|
||||
p?.Release();
|
||||
|
||||
p = null;
|
||||
}
|
||||
|
||||
public static void Release(ref Packet p)
|
||||
{
|
||||
p?.Release();
|
||||
|
||||
p = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
115
Server/Network/StaticPacketHandlers.cs
Normal file
115
Server/Network/StaticPacketHandlers.cs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class StaticPacketHandlers
|
||||
{
|
||||
private static ConcurrentDictionary<IPropertyListObject,OPLInfo> OPLInfoPackets = new ConcurrentDictionary<IPropertyListObject,OPLInfo>();
|
||||
private static ConcurrentDictionary<IPropertyListObject,ObjectPropertyList> ObjectPropertyListPackets = new ConcurrentDictionary<IPropertyListObject,ObjectPropertyList>();
|
||||
private static ConcurrentDictionary<IEntity,RemoveEntity> RemoveEntityPackets = new ConcurrentDictionary<IEntity,RemoveEntity>();
|
||||
|
||||
private static ConcurrentDictionary<Item,WorldItem> WorldItemPackets = new ConcurrentDictionary<Item,WorldItem>();
|
||||
private static ConcurrentDictionary<Item,WorldItemSA> WorldItemSAPackets = new ConcurrentDictionary<Item,WorldItemSA>();
|
||||
private static ConcurrentDictionary<Item,WorldItemHS> WorldItemHSPackets = new ConcurrentDictionary<Item,WorldItemHS>();
|
||||
|
||||
public static OPLInfo GetOPLInfoPacket(IPropertyListObject obj)
|
||||
{
|
||||
return OPLInfoPackets.GetOrAdd(obj, value =>
|
||||
{
|
||||
OPLInfo packet = new OPLInfo(value.PropertyList);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
public static OPLInfo FreeOPLInfoPacket(IPropertyListObject obj)
|
||||
{
|
||||
if (OPLInfoPackets.TryRemove(obj, out OPLInfo p))
|
||||
Packet.Release(p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public static ObjectPropertyList GetOPLPacket(IPropertyListObject obj)
|
||||
{
|
||||
return ObjectPropertyListPackets.GetOrAdd(obj, value =>
|
||||
{
|
||||
ObjectPropertyList list = new ObjectPropertyList(value);
|
||||
|
||||
value.GetProperties(list);
|
||||
if (value is Item item)
|
||||
item.AppendChildProperties(list);
|
||||
|
||||
list.Terminate();
|
||||
list.SetStatic();
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public static ObjectPropertyList FreeOPLPacket(IPropertyListObject obj)
|
||||
{
|
||||
if (ObjectPropertyListPackets.TryRemove(obj, out ObjectPropertyList list))
|
||||
Packet.Release(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static RemoveEntity GetRemoveEntityPacket(IEntity entity)
|
||||
{
|
||||
return RemoveEntityPackets.GetOrAdd(entity, value =>
|
||||
{
|
||||
RemoveEntity packet = new RemoveEntity(value);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
public static void FreeRemoveItemPacket(IEntity entity)
|
||||
{
|
||||
if (RemoveEntityPackets.TryRemove(entity, out RemoveEntity p))
|
||||
Packet.Release(p);
|
||||
}
|
||||
|
||||
public static WorldItem GetWorldItemPacket(Item item)
|
||||
{
|
||||
return WorldItemPackets.GetOrAdd(item, value =>
|
||||
{
|
||||
WorldItem packet = new WorldItem(value);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
public static WorldItemSA GetWorldItemSAPacket(Item item)
|
||||
{
|
||||
return WorldItemSAPackets.GetOrAdd(item, value =>
|
||||
{
|
||||
WorldItemSA packet = new WorldItemSA(value);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
public static WorldItemHS GetWorldItemHSPacket(Item item)
|
||||
{
|
||||
return WorldItemHSPackets.GetOrAdd(item, value =>
|
||||
{
|
||||
WorldItemHS packet = new WorldItemHS(value);
|
||||
packet.SetStatic();
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
public static void FreeWorldItemPackets(Item item)
|
||||
{
|
||||
if (WorldItemPackets.TryRemove(item, out WorldItem wi))
|
||||
Packet.Release(wi);
|
||||
|
||||
if (WorldItemSAPackets.TryRemove(item, out WorldItemSA wisa))
|
||||
Packet.Release(wisa);
|
||||
|
||||
if (WorldItemHSPackets.TryRemove(item, out WorldItemHS wihs))
|
||||
Packet.Release(wihs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,14 @@ using Server.Network;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public interface IPropertyListObject : IEntity
|
||||
{
|
||||
ObjectPropertyList PropertyList{ get; }
|
||||
OPLInfo OPLPacket{ get; }
|
||||
|
||||
void GetProperties(ObjectPropertyList list);
|
||||
}
|
||||
|
||||
public sealed class ObjectPropertyList : Packet
|
||||
{
|
||||
private static byte[] m_Buffer = new byte[1024];
|
||||
|
|
@ -191,4 +199,4 @@ namespace Server
|
|||
m_Stream.Write(list.Hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@
|
|||
<Compile Include="Items\VirtualCheck.cs" />
|
||||
<Compile Include="Items\VirtualHair.cs" />
|
||||
<Compile Include="KeywordList.cs" />
|
||||
<Compile Include="Layer.cs" />
|
||||
<Compile Include="LightType.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Map.cs" />
|
||||
<Compile Include="Menus\IMenu.cs" />
|
||||
|
|
@ -169,6 +171,7 @@
|
|||
<Compile Include="Network\Compression.cs" />
|
||||
<Compile Include="Network\EncodedPacketHandler.cs" />
|
||||
<Compile Include="Network\EncodedReader.cs" />
|
||||
<Compile Include="Network\StaticPacketHandlers.cs" />
|
||||
<Compile Include="Network\Listener.cs" />
|
||||
<Compile Include="Network\MessagePump.cs" />
|
||||
<Compile Include="Network\NetState.cs" />
|
||||
|
|
@ -260,4 +263,4 @@
|
|||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue