fix: Cleans up core code (#1187)

**Only one functional change**
* Fixes a bug in LogFactory where `Warning` is being logged as `Information`

Non-functional changes:
* Updates/Fixes copyright headers
* Removes namespace scopes for core files.

View with [whitespace off](https://github.com/modernuo/ModernUO/pull/1187/files?w=1).
This commit is contained in:
Kamron Batman 2022-10-10 21:47:08 -07:00 committed by GitHub
parent 0138d40bda
commit f268d5d4e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
262 changed files with 28527 additions and 28646 deletions

View file

@ -1,125 +1,124 @@
using System;
using System.Runtime.CompilerServices;
namespace Server.Items
namespace Server.Items;
public abstract class BaseMulti : Item
{
public abstract class BaseMulti : Item
public BaseMulti(int itemID) : base(itemID) => Movable = false;
public BaseMulti(Serial serial) : base(serial)
{
public BaseMulti(int itemID) : base(itemID) => Movable = false;
}
public BaseMulti(Serial serial) : base(serial)
[CommandProperty(AccessLevel.GameMaster)]
public override int ItemID
{
get => base.ItemID;
set
{
}
[CommandProperty(AccessLevel.GameMaster)]
public override int ItemID
{
get => base.ItemID;
set
if (base.ItemID != value)
{
if (base.ItemID != value)
{
var facet = Parent == null ? Map : null;
var facet = Parent == null ? Map : null;
facet?.OnLeave(this);
facet?.OnLeave(this);
base.ItemID = value;
base.ItemID = value;
facet?.OnEnter(this);
}
facet?.OnEnter(this);
}
}
}
public override int LabelNumber
{
get
{
var mcl = Components;
if (mcl.List.Length > 0)
{
int id = mcl.List[0].ItemId;
if (id < 0x4000)
{
return 1020000 + id;
}
return 1078872 + id;
}
return base.LabelNumber;
}
}
public virtual bool AllowsRelativeDrop => false;
public virtual MultiComponentList Components => MultiData.GetComponents(ItemID);
[Obsolete("Replace with calls to OnLeave and OnEnter surrounding component invalidation.", true)]
public virtual void RefreshComponents()
{
if (Parent == null)
{
var facet = Map;
if (facet != null)
{
facet.OnLeave(this);
facet.OnEnter(this);
}
}
}
public override int GetMaxUpdateRange() => 22;
public override int GetUpdateRange(Mobile m) => 22;
public virtual bool Contains(Point2D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(Point3D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(IPoint3D p) => Contains(p.X, p.Y);
public virtual bool Contains(int x, int y)
public override int LabelNumber
{
get
{
var mcl = Components;
x -= X + mcl.Min.m_X;
y -= Y + mcl.Min.m_Y;
return x >= 0
&& x < mcl.Width
&& y >= 0
&& y < mcl.Height
&& mcl.Tiles[x][y].Length > 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(Mobile m) => m.Map == Map && Contains(m.X, m.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(Item item) => item.Map == Map && Contains(item.X, item.Y);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0)
if (mcl.List.Length > 0)
{
if (ItemID >= 0x4000)
int id = mcl.List[0].ItemId;
if (id < 0x4000)
{
ItemID -= 0x4000;
return 1020000 + id;
}
return 1078872 + id;
}
return base.LabelNumber;
}
}
public virtual bool AllowsRelativeDrop => false;
public virtual MultiComponentList Components => MultiData.GetComponents(ItemID);
[Obsolete("Replace with calls to OnLeave and OnEnter surrounding component invalidation.", true)]
public virtual void RefreshComponents()
{
if (Parent == null)
{
var facet = Map;
if (facet != null)
{
facet.OnLeave(this);
facet.OnEnter(this);
}
}
}
public override int GetMaxUpdateRange() => 22;
public override int GetUpdateRange(Mobile m) => 22;
public virtual bool Contains(Point2D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(Point3D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(IPoint3D p) => Contains(p.X, p.Y);
public virtual bool Contains(int x, int y)
{
var mcl = Components;
x -= X + mcl.Min.m_X;
y -= Y + mcl.Min.m_Y;
return x >= 0
&& x < mcl.Width
&& y >= 0
&& y < mcl.Height
&& mcl.Tiles[x][y].Length > 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(Mobile m) => m.Map == Map && Contains(m.X, m.Y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(Item item) => item.Map == Map && Contains(item.X, item.Y);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0)
{
if (ItemID >= 0x4000)
{
ItemID -= 0x4000;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,126 +1,125 @@
using Server.Accounting;
using Server.Network;
namespace Server.Items
namespace Server.Items;
public class BankBox : Container
{
public class BankBox : Container
public BankBox(Serial serial) : base(serial)
{
public BankBox(Serial serial) : base(serial)
}
public BankBox(Mobile owner) : base(0xE7C)
{
Layer = Layer.Bank;
Movable = false;
Owner = owner;
}
public override int DefaultMaxWeight => 0;
public override bool IsVirtualItem => true;
public Mobile Owner { get; private set; }
public bool Opened { get; private set; }
public static bool SendDeleteOnClose { get; set; }
public void Open()
{
Opened = true;
if (Owner != null)
{
}
Owner.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
true,
$"Bank container has {TotalItems} items, {TotalWeight} stones",
Owner.NetState
);
public BankBox(Mobile owner) : base(0xE7C)
{
Layer = Layer.Bank;
Movable = false;
Owner = owner;
}
public override int DefaultMaxWeight => 0;
public override bool IsVirtualItem => true;
public Mobile Owner { get; private set; }
public bool Opened { get; private set; }
public static bool SendDeleteOnClose { get; set; }
public void Open()
{
Opened = true;
if (Owner != null)
{
Owner.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
true,
$"Bank container has {TotalItems} items, {TotalWeight} stones",
Owner.NetState
);
Owner.NetState?.SendEquipUpdate(this);
DisplayTo(Owner);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Owner);
writer.Write(Opened);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
Owner = reader.ReadEntity<Mobile>();
Opened = reader.ReadBool();
if (Owner == null)
{
Delete();
}
break;
}
}
if (ItemID == 0xE41)
{
ItemID = 0xE7C;
}
}
public void Close()
{
Opened = false;
if (SendDeleteOnClose)
{
Owner?.NetState.SendRemoveEntity(Serial);
}
}
public override void OnSingleClick(Mobile from)
{
}
public override void OnDoubleClick(Mobile from)
{
}
public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped;
public override bool IsAccessibleTo(Mobile check) =>
(check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check);
public override bool OnDragDrop(Mobile from, Item dropped) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped);
public override bool OnDragDropInto(Mobile from, Item item, Point3D p) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) &&
base.OnDragDropInto(from, item, p);
public override int GetTotal(TotalType type)
{
if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold)
{
return Owner.Account.TotalGold;
}
return base.GetTotal(type);
Owner.NetState?.SendEquipUpdate(this);
DisplayTo(Owner);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Owner);
writer.Write(Opened);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
Owner = reader.ReadEntity<Mobile>();
Opened = reader.ReadBool();
if (Owner == null)
{
Delete();
}
break;
}
}
if (ItemID == 0xE41)
{
ItemID = 0xE7C;
}
}
public void Close()
{
Opened = false;
if (SendDeleteOnClose)
{
Owner?.NetState.SendRemoveEntity(Serial);
}
}
public override void OnSingleClick(Mobile from)
{
}
public override void OnDoubleClick(Mobile from)
{
}
public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped;
public override bool IsAccessibleTo(Mobile check) =>
(check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check);
public override bool OnDragDrop(Mobile from, Item dropped) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped);
public override bool OnDragDropInto(Mobile from, Item item, Point3D p) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) &&
base.OnDragDropInto(from, item, p);
public override int GetTotal(TotalType type)
{
if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold)
{
return Owner.Account.TotalGold;
}
return base.GetTotal(type);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2020 - ModernUO Development Team *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Layer.cs *
* *
@ -13,176 +13,175 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server
namespace Server;
/// <summary>
/// Enumeration of item layer values.
/// </summary>
public enum Layer : byte
{
/// <summary>
/// Enumeration of item layer values.
/// Invalid layer.
/// </summary>
public enum Layer : byte
{
/// <summary>
/// Invalid layer.
/// </summary>
Invalid = 0x00,
Invalid = 0x00,
/// <summary>
/// First valid layer. Equivalent to <c>Layer.OneHanded</c>.
/// </summary>
FirstValid = 0x01,
/// <summary>
/// First valid layer. Equivalent to <c>Layer.OneHanded</c>.
/// </summary>
FirstValid = 0x01,
/// <summary>
/// One handed weapon.
/// </summary>
OneHanded = 0x01,
/// <summary>
/// One handed weapon.
/// </summary>
OneHanded = 0x01,
/// <summary>
/// Two handed weapon or shield.
/// </summary>
TwoHanded = 0x02,
/// <summary>
/// Two handed weapon or shield.
/// </summary>
TwoHanded = 0x02,
/// <summary>
/// Shoes.
/// </summary>
Shoes = 0x03,
/// <summary>
/// Shoes.
/// </summary>
Shoes = 0x03,
/// <summary>
/// Pants.
/// </summary>
Pants = 0x04,
/// <summary>
/// Pants.
/// </summary>
Pants = 0x04,
/// <summary>
/// Shirts.
/// </summary>
Shirt = 0x05,
/// <summary>
/// Shirts.
/// </summary>
Shirt = 0x05,
/// <summary>
/// Helmets, hats, and masks.
/// </summary>
Helm = 0x06,
/// <summary>
/// Helmets, hats, and masks.
/// </summary>
Helm = 0x06,
/// <summary>
/// Gloves.
/// </summary>
Gloves = 0x07,
/// <summary>
/// Gloves.
/// </summary>
Gloves = 0x07,
/// <summary>
/// Rings.
/// </summary>
Ring = 0x08,
/// <summary>
/// Rings.
/// </summary>
Ring = 0x08,
/// <summary>
/// Talismans.
/// </summary>
Talisman = 0x09,
/// <summary>
/// Talismans.
/// </summary>
Talisman = 0x09,
/// <summary>
/// Gorgets and necklaces.
/// </summary>
Neck = 0x0A,
/// <summary>
/// Gorgets and necklaces.
/// </summary>
Neck = 0x0A,
/// <summary>
/// Hair.
/// </summary>
Hair = 0x0B,
/// <summary>
/// Hair.
/// </summary>
Hair = 0x0B,
/// <summary>
/// Half aprons.
/// </summary>
Waist = 0x0C,
/// <summary>
/// Half aprons.
/// </summary>
Waist = 0x0C,
/// <summary>
/// Torso, inner layer.
/// </summary>
InnerTorso = 0x0D,
/// <summary>
/// Torso, inner layer.
/// </summary>
InnerTorso = 0x0D,
/// <summary>
/// Bracelets.
/// </summary>
Bracelet = 0x0E,
/// <summary>
/// Bracelets.
/// </summary>
Bracelet = 0x0E,
/// <summary>
/// Unused.
/// </summary>
Unused_xF = 0x0F,
/// <summary>
/// Unused.
/// </summary>
Unused_xF = 0x0F,
/// <summary>
/// Beards and mustaches.
/// </summary>
FacialHair = 0x10,
/// <summary>
/// Beards and mustaches.
/// </summary>
FacialHair = 0x10,
/// <summary>
/// Torso, outer layer.
/// </summary>
MiddleTorso = 0x11,
/// <summary>
/// Torso, outer layer.
/// </summary>
MiddleTorso = 0x11,
/// <summary>
/// Earings.
/// </summary>
Earrings = 0x12,
/// <summary>
/// Earings.
/// </summary>
Earrings = 0x12,
/// <summary>
/// Arms and sleeves.
/// </summary>
Arms = 0x13,
/// <summary>
/// Arms and sleeves.
/// </summary>
Arms = 0x13,
/// <summary>
/// Cloaks.
/// </summary>
Cloak = 0x14,
/// <summary>
/// Cloaks.
/// </summary>
Cloak = 0x14,
/// <summary>
/// Backpacks.
/// </summary>
Backpack = 0x15,
/// <summary>
/// Backpacks.
/// </summary>
Backpack = 0x15,
/// <summary>
/// Torso, outer layer.
/// </summary>
OuterTorso = 0x16,
/// <summary>
/// Torso, outer layer.
/// </summary>
OuterTorso = 0x16,
/// <summary>
/// Leggings, outer layer.
/// </summary>
OuterLegs = 0x17,
/// <summary>
/// Leggings, outer layer.
/// </summary>
OuterLegs = 0x17,
/// <summary>
/// Leggings, inner layer.
/// </summary>
InnerLegs = 0x18,
/// <summary>
/// Leggings, inner layer.
/// </summary>
InnerLegs = 0x18,
/// <summary>
/// Last valid non-internal layer. Equivalent to <c>Layer.InnerLegs</c>.
/// </summary>
LastUserValid = 0x18,
/// <summary>
/// Last valid non-internal layer. Equivalent to <c>Layer.InnerLegs</c>.
/// </summary>
LastUserValid = 0x18,
/// <summary>
/// Mount item layer.
/// </summary>
Mount = 0x19,
/// <summary>
/// Mount item layer.
/// </summary>
Mount = 0x19,
/// <summary>
/// Vendor 'buy pack' layer.
/// </summary>
ShopBuy = 0x1A,
/// <summary>
/// Vendor 'buy pack' layer.
/// </summary>
ShopBuy = 0x1A,
/// <summary>
/// Vendor 'resale pack' layer.
/// </summary>
ShopResale = 0x1B,
/// <summary>
/// Vendor 'resale pack' layer.
/// </summary>
ShopResale = 0x1B,
/// <summary>
/// Vendor 'sell pack' layer.
/// </summary>
ShopSell = 0x1C,
/// <summary>
/// Vendor 'sell pack' layer.
/// </summary>
ShopSell = 0x1C,
/// <summary>
/// Bank box layer.
/// </summary>
Bank = 0x1D,
/// <summary>
/// Bank box layer.
/// </summary>
Bank = 0x1D,
/// <summary>
/// Last valid layer. Equivalent to <c>Layer.Bank</c>.
/// </summary>
LastValid = 0x1D
}
/// <summary>
/// Last valid layer. Equivalent to <c>Layer.Bank</c>.
/// </summary>
LastValid = 0x1D
}

View file

@ -1,6 +1,6 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2020 - ModernUO Development Team *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: LightType.cs *
* *
@ -13,291 +13,290 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server
namespace Server;
public enum LightType
{
public enum LightType
{
/// <summary>
/// Window shape, arched, ray shining east.
/// </summary>
ArchedWindowEast,
/// <summary>
/// Window shape, arched, ray shining east.
/// </summary>
ArchedWindowEast,
/// <summary>
/// Medium circular shape.
/// </summary>
Circle225,
/// <summary>
/// Medium circular shape.
/// </summary>
Circle225,
/// <summary>
/// Small circular shape.
/// </summary>
Circle150,
/// <summary>
/// Small circular shape.
/// </summary>
Circle150,
/// <summary>
/// Door shape, shining south.
/// </summary>
DoorSouth,
/// <summary>
/// Door shape, shining south.
/// </summary>
DoorSouth,
/// <summary>
/// Door shape, shining east.
/// </summary>
DoorEast,
/// <summary>
/// Door shape, shining east.
/// </summary>
DoorEast,
/// <summary>
/// Large semicircular shape (180 degrees), north wall.
/// </summary>
NorthBig,
/// <summary>
/// Large semicircular shape (180 degrees), north wall.
/// </summary>
NorthBig,
/// <summary>
/// Large pie shape (90 degrees), north-east corner.
/// </summary>
NorthEastBig,
/// <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), east wall.
/// </summary>
EastBig,
/// <summary>
/// Large semicircular shape (180 degrees), west wall.
/// </summary>
WestBig,
/// <summary>
/// Large semicircular shape (180 degrees), west wall.
/// </summary>
WestBig,
/// <summary>
/// Large pie shape (90 degrees), south-west corner.
/// </summary>
SouthWestBig,
/// <summary>
/// Large pie shape (90 degrees), south-west corner.
/// </summary>
SouthWestBig,
/// <summary>
/// Large semicircular shape (180 degrees), south wall.
/// </summary>
SouthBig,
/// <summary>
/// Large semicircular shape (180 degrees), south wall.
/// </summary>
SouthBig,
/// <summary>
/// Medium semicircular shape (180 degrees), north wall.
/// </summary>
NorthSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), north wall.
/// </summary>
NorthSmall,
/// <summary>
/// Medium pie shape (90 degrees), north-east corner.
/// </summary>
NorthEastSmall,
/// <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), east wall.
/// </summary>
EastSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), west wall.
/// </summary>
WestSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), west wall.
/// </summary>
WestSmall,
/// <summary>
/// Medium semicircular shape (180 degrees), south wall.
/// </summary>
SouthSmall,
/// <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 wall.
/// </summary>
DecorationNorth,
/// <summary>
/// Shaped like a wall decoration, north-east corner.
/// </summary>
DecorationNorthEast,
/// <summary>
/// Shaped like a wall decoration, north-east corner.
/// </summary>
DecorationNorthEast,
/// <summary>
/// Small semicircular shape (180 degrees), east wall.
/// </summary>
EastTiny,
/// <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, west wall.
/// </summary>
DecorationWest,
/// <summary>
/// Shaped like a wall decoration, south-west corner.
/// </summary>
DecorationSouthWest,
/// <summary>
/// Shaped like a wall decoration, south-west corner.
/// </summary>
DecorationSouthWest,
/// <summary>
/// Small semicircular shape (180 degrees), south wall.
/// </summary>
SouthTiny,
/// <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 south.
/// </summary>
RectWindowSouthNoRay,
/// <summary>
/// Window shape, rectangular, no ray, shining east.
/// </summary>
RectWindowEastNoRay,
/// <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 south.
/// </summary>
RectWindowSouth,
/// <summary>
/// Window shape, rectangular, ray shining east.
/// </summary>
RectWindowEast,
/// <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 south.
/// </summary>
ArchedWindowSouthNoRay,
/// <summary>
/// Window shape, arched, no ray, shining east.
/// </summary>
ArchedWindowEastNoRay,
/// <summary>
/// Window shape, arched, no ray, shining east.
/// </summary>
ArchedWindowEastNoRay,
/// <summary>
/// Window shape, arched, ray shining south.
/// </summary>
ArchedWindowSouth,
/// <summary>
/// Window shape, arched, ray shining south.
/// </summary>
ArchedWindowSouth,
/// <summary>
/// Large circular shape.
/// </summary>
Circle300,
/// <summary>
/// Large circular shape.
/// </summary>
Circle300,
/// <summary>
/// Large pie shape (90 degrees), north-west corner.
/// </summary>
NorthWestBig,
/// <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 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 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), 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 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. Medium circular shape (180 degrees), east wall.
/// </summary>
DarkEast,
/// <summary>
/// Negative light. Large circular shape.
/// </summary>
DarkCircle300,
/// <summary>
/// Negative light. Large circular shape.
/// </summary>
DarkCircle300,
/// <summary>
/// Opened door shape, shining south.
/// </summary>
DoorOpenSouth,
/// <summary>
/// Opened door shape, shining south.
/// </summary>
DoorOpenSouth,
/// <summary>
/// Opened door shape, shining east.
/// </summary>
DoorOpenEast,
/// <summary>
/// Opened door shape, shining east.
/// </summary>
DoorOpenEast,
/// <summary>
/// Window shape, square, ray shining east.
/// </summary>
SquareWindowEast,
/// <summary>
/// Window shape, square, ray shining east.
/// </summary>
SquareWindowEast,
/// <summary>
/// Window shape, square, no ray, shining east.
/// </summary>
SquareWindowEastNoRay,
/// <summary>
/// Window shape, square, no ray, shining east.
/// </summary>
SquareWindowEastNoRay,
/// <summary>
/// Window shape, square, ray shining south.
/// </summary>
SquareWindowSouth,
/// <summary>
/// Window shape, square, ray shining south.
/// </summary>
SquareWindowSouth,
/// <summary>
/// Window shape, square, no ray, shining south.
/// </summary>
SquareWindowSouthNoRay,
/// <summary>
/// Window shape, square, no ray, shining south.
/// </summary>
SquareWindowSouthNoRay,
/// <summary>
/// Empty.
/// </summary>
Empty,
/// <summary>
/// Empty.
/// </summary>
Empty,
/// <summary>
/// Window shape, skinny, no ray, shining south.
/// </summary>
SkinnyWindowSouthNoRay,
/// <summary>
/// Window shape, skinny, no ray, shining south.
/// </summary>
SkinnyWindowSouthNoRay,
/// <summary>
/// Window shape, skinny, ray shining east.
/// </summary>
SkinnyWindowEast,
/// <summary>
/// Window shape, skinny, ray shining east.
/// </summary>
SkinnyWindowEast,
/// <summary>
/// Window shape, skinny, no ray, shining east.
/// </summary>
SkinnyWindowEastNoRay,
/// <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>
HoleSouth,
/// <summary>
/// Shaped like a hole, shining south.
/// </summary>
HoleEast,
/// <summary>
/// Shaped like a hole, shining south.
/// </summary>
HoleEast,
/// <summary>
/// Large circular shape with a moongate graphic embedded.
/// </summary>
Moongate,
/// <summary>
/// Large circular shape with a moongate graphic embedded.
/// </summary>
Moongate,
/// <summary>
/// Unknown usage. Many rows of slightly angled lines.
/// </summary>
Strips,
/// <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 south.
/// </summary>
SmallHoleSouth,
/// <summary>
/// Shaped like a small hole, shining east.
/// </summary>
SmallHoleEast,
/// <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), 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 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
}
/// <summary>
/// Large pie shape (90 degrees), north-west corner. Equivalent to <c>LightType.NorthWestBig</c>.
/// </summary>
NorthWestBig2
}

View file

@ -1,113 +1,112 @@
using Server.Accounting;
using Server.Network;
namespace Server.Items
namespace Server.Items;
public class SecureTradeContainer : Container
{
public class SecureTradeContainer : Container
public SecureTradeContainer(SecureTrade trade) : base(0x1E5E)
{
public SecureTradeContainer(SecureTrade trade) : base(0x1E5E)
{
Trade = trade;
Trade = trade;
Movable = false;
Movable = false;
}
public SecureTradeContainer(Serial serial) : base(serial)
{
}
public SecureTrade Trade { get; }
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck)
{
return true;
}
public SecureTradeContainer(Serial serial) : base(serial)
var to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile;
return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight);
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
reject = LRReason.CannotLift;
return false;
}
public override bool IsAccessibleTo(Mobile check) =>
IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check);
public override void OnItemAdded(Item item)
{
if (item is not VirtualCheck)
{
}
public SecureTrade Trade { get; }
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck)
{
return true;
}
var to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile;
return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight);
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
reject = LRReason.CannotLift;
return false;
}
public override bool IsAccessibleTo(Mobile check) =>
IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check);
public override void OnItemAdded(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public override void OnItemRemoved(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public override void OnSubItemAdded(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public override void OnSubItemRemoved(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public void ClearChecks()
{
if (Trade == null)
{
return;
}
if (Trade.From?.IsDisposed == false)
{
Trade.From.Accepted = false;
}
if (Trade.To?.IsDisposed == false)
{
Trade.To.Accepted = false;
}
Trade.Update();
}
public override bool IsChildVisibleTo(Mobile m, Item child) =>
child is VirtualCheck
? AccountGold.Enabled && m.NetState is not { NewSecureTrading: true }
: base.IsChildVisibleTo(m, child);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
ClearChecks();
}
}
public override void OnItemRemoved(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public override void OnSubItemAdded(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public override void OnSubItemRemoved(Item item)
{
if (item is not VirtualCheck)
{
ClearChecks();
}
}
public void ClearChecks()
{
if (Trade == null)
{
return;
}
if (Trade.From?.IsDisposed == false)
{
Trade.From.Accepted = false;
}
if (Trade.To?.IsDisposed == false)
{
Trade.To.Accepted = false;
}
Trade.Update();
}
public override bool IsChildVisibleTo(Mobile m, Item child) =>
child is VirtualCheck
? AccountGold.Enabled && m.NetState is not { NewSecureTrading: true }
: base.IsChildVisibleTo(m, child);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}

View file

@ -1,6 +1,6 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2020 - ModernUO Development Team *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: VirtualCheck.cs *
* *
@ -16,382 +16,381 @@
using Server.Gumps;
using Server.Network;
namespace Server.Items
namespace Server.Items;
public sealed class VirtualCheck : Item
{
public sealed class VirtualCheck : Item
public static bool UseEditGump { get; private set; }
public static void Configure()
{
public static bool UseEditGump { get; private set; }
UseEditGump = ServerConfiguration.GetSetting("virtualChecks.useEditGump", Core.TOL);
}
public static void Configure()
private int m_Gold;
private int m_Plat;
public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0)
{
Plat = plat;
Gold = gold;
Movable = false;
}
public VirtualCheck(Serial serial)
: base(serial)
{
}
public override bool IsVirtualItem => true;
public override bool DisplayWeight => false;
public override bool DisplayLootType => false;
public override double DefaultWeight => 0;
public override string DefaultName => "Offer Of Currency";
public EditGump Editor { get; private set; }
[CommandProperty(AccessLevel.Administrator)]
public int Plat
{
get => m_Plat;
set
{
UseEditGump = ServerConfiguration.GetSetting("virtualChecks.useEditGump", Core.TOL);
m_Plat = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.Administrator)]
public int Gold
{
get => m_Gold;
set
{
m_Gold = value;
InvalidateProperties();
}
}
public override bool IsAccessibleTo(Mobile check)
{
var c = GetSecureTradeCont();
if (check == null || c == null)
{
return base.IsAccessibleTo(check);
}
private int m_Gold;
return c.RootParent == check && IsChildOf(c);
}
private int m_Plat;
public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0)
public override void OnDoubleClickSecureTrade(Mobile from)
{
if (UseEditGump && IsAccessibleTo(from))
{
Plat = plat;
Gold = gold;
Movable = false;
}
public VirtualCheck(Serial serial)
: base(serial)
{
}
public override bool IsVirtualItem => true;
public override bool DisplayWeight => false;
public override bool DisplayLootType => false;
public override double DefaultWeight => 0;
public override string DefaultName => "Offer Of Currency";
public EditGump Editor { get; private set; }
[CommandProperty(AccessLevel.Administrator)]
public int Plat
{
get => m_Plat;
set
if (Editor?.Check?.Deleted != false)
{
m_Plat = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.Administrator)]
public int Gold
{
get => m_Gold;
set
{
m_Gold = value;
InvalidateProperties();
}
}
public override bool IsAccessibleTo(Mobile check)
{
var c = GetSecureTradeCont();
if (check == null || c == null)
{
return base.IsAccessibleTo(check);
}
return c.RootParent == check && IsChildOf(c);
}
public override void OnDoubleClickSecureTrade(Mobile from)
{
if (UseEditGump && IsAccessibleTo(from))
{
if (Editor?.Check?.Deleted != false)
{
Editor = new EditGump(from, this);
Editor.Send();
}
else
{
Editor.Refresh(true);
}
Editor = new EditGump(from, this);
Editor.Send();
}
else
{
if (Editor != null)
{
Editor.Close();
Editor = null;
}
base.OnDoubleClickSecureTrade(from);
Editor.Refresh(true);
}
}
public override void OnSingleClick(Mobile from)
else
{
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
list.Add(1060738, $"{Plat:#,0} platinum, {Gold:#,0} gold"); // value: ~1_val~
}
public void UpdateTrade(Mobile user)
{
var c = GetSecureTradeCont();
if (c?.Trade == null)
{
return;
}
if (user == c.Trade.From.Mobile)
{
c.Trade.UpdateFromCurrency();
}
else if (user == c.Trade.To.Mobile)
{
c.Trade.UpdateToCurrency();
}
c.ClearChecks();
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
if (Editor != null)
{
Editor.Close();
Editor = null;
}
base.OnDoubleClickSecureTrade(from);
}
}
public override void OnSingleClick(Mobile from)
{
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
}
public override void GetProperties(IPropertyList list)
{
base.GetProperties(list);
list.Add(1060738, $"{Plat:#,0} platinum, {Gold:#,0} gold"); // value: ~1_val~
}
public void UpdateTrade(Mobile user)
{
var c = GetSecureTradeCont();
if (c?.Trade == null)
{
return;
}
public override void Serialize(IGenericWriter writer)
if (user == c.Trade.From.Mobile)
{
c.Trade.UpdateFromCurrency();
}
else if (user == c.Trade.To.Mobile)
{
c.Trade.UpdateToCurrency();
}
public override void Deserialize(IGenericReader reader)
c.ClearChecks();
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
if (Editor != null)
{
Delete();
Editor.Close();
Editor = null;
}
}
public override void Serialize(IGenericWriter writer)
{
}
public override void Deserialize(IGenericReader reader)
{
Delete();
}
public class EditGump : Gump
{
public enum Buttons
{
Close,
Clear,
Accept,
AllPlat,
AllGold
}
public class EditGump : Gump
private int m_Plat, m_Gold;
public EditGump(Mobile user, VirtualCheck check) : base(50, 50)
{
public enum Buttons
User = user;
Check = check;
m_Plat = Check.Plat;
m_Gold = Check.Gold;
Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
User.CloseGump<EditGump>();
CompileLayout();
}
public Mobile User { get; }
public VirtualCheck Check { get; private set; }
public override void OnServerClose(NetState owner)
{
base.OnServerClose(owner);
if (Check?.Deleted == false)
{
Close,
Clear,
Accept,
AllPlat,
AllGold
Check.UpdateTrade(User);
}
}
public void Close()
{
User.CloseGump<EditGump>();
if (Check?.Deleted == false)
{
Check.UpdateTrade(User);
}
else
{
Check = null;
}
}
public void Send()
{
if (Check?.Deleted == false)
{
User.SendGump(this);
}
else
{
Close();
}
}
public void Refresh(bool recompile)
{
if (Check?.Deleted != false)
{
Close();
return;
}
private int m_Plat, m_Gold;
public EditGump(Mobile user, VirtualCheck check) : base(50, 50)
if (recompile)
{
User = user;
Check = check;
m_Plat = Check.Plat;
m_Gold = Check.Gold;
Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
User.CloseGump<EditGump>();
CompileLayout();
}
public Mobile User { get; }
public VirtualCheck Check { get; private set; }
Close();
Send();
}
public override void OnServerClose(NetState owner)
private void CompileLayout()
{
if (Check?.Deleted != false)
{
base.OnServerClose(owner);
if (Check?.Deleted == false)
{
Check.UpdateTrade(User);
}
return;
}
public void Close()
Entries.ForEach(e => e.Parent = null);
Entries.Clear();
AddPage(0);
AddBackground(0, 0, 400, 160, 3500);
// Title
AddImageTiled(25, 35, 350, 3, 96);
AddImage(10, 8, 113);
AddImage(360, 8, 113);
var title =
$"<BASEFONT COLOR=#FF2F4F4F><CENTER>BANK OF {User.RawName.ToUpper()}</CENTER>";
AddHtml(40, 15, 320, 20, title);
// Platinum Row
AddBackground(15, 60, 175, 20, 9300);
AddBackground(20, 45, 165, 30, 9350);
AddItem(20, 45, 3826); // Plat
AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0"));
AddButton(195, 50, 95, 95, (int)Buttons.AllPlat); // ->
AddBackground(210, 60, 175, 20, 9300);
AddBackground(215, 45, 165, 30, 9350);
AddTextEntry(225, 50, 145, 20, 0, 0, m_Plat.ToString(), User.Account.TotalPlat.ToString().Length);
// Gold Row
AddBackground(15, 100, 175, 20, 9300);
AddBackground(20, 85, 165, 30, 9350);
AddItem(20, 85, 3823); // Gold
AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0"));
AddButton(195, 90, 95, 95, (int)Buttons.AllGold); // ->
AddBackground(210, 100, 175, 20, 9300);
AddBackground(215, 85, 165, 30, 9350);
AddTextEntry(225, 90, 145, 20, 0, 1, m_Gold.ToString(), User.Account.TotalGold.ToString().Length);
// Buttons
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
AddButton(215, 128, 12003, 12004, (int)Buttons.Clear);
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (Check?.Deleted != false || sender.Mobile != User)
{
User.CloseGump<EditGump>();
if (Check?.Deleted == false)
{
Check.UpdateTrade(User);
}
else
{
Check = null;
}
}
public void Send()
{
if (Check?.Deleted == false)
{
User.SendGump(this);
}
else
{
Close();
}
}
public void Refresh(bool recompile)
{
if (Check?.Deleted != false)
{
Close();
return;
}
if (recompile)
{
CompileLayout();
}
Close();
Send();
return;
}
private void CompileLayout()
bool refresh = false, updated = false;
switch ((Buttons)info.ButtonID)
{
if (Check?.Deleted != false)
{
return;
}
case Buttons.Close:
break;
case Buttons.Clear:
{
m_Plat = m_Gold = 0;
refresh = true;
}
break;
case Buttons.Accept:
{
var platText = info.GetTextEntry(0).Text;
var goldText = info.GetTextEntry(1).Text;
Entries.ForEach(e => e.Parent = null);
Entries.Clear();
AddPage(0);
AddBackground(0, 0, 400, 160, 3500);
// Title
AddImageTiled(25, 35, 350, 3, 96);
AddImage(10, 8, 113);
AddImage(360, 8, 113);
var title =
$"<BASEFONT COLOR=#FF2F4F4F><CENTER>BANK OF {User.RawName.ToUpper()}</CENTER>";
AddHtml(40, 15, 320, 20, title);
// Platinum Row
AddBackground(15, 60, 175, 20, 9300);
AddBackground(20, 45, 165, 30, 9350);
AddItem(20, 45, 3826); // Plat
AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0"));
AddButton(195, 50, 95, 95, (int)Buttons.AllPlat); // ->
AddBackground(210, 60, 175, 20, 9300);
AddBackground(215, 45, 165, 30, 9350);
AddTextEntry(225, 50, 145, 20, 0, 0, m_Plat.ToString(), User.Account.TotalPlat.ToString().Length);
// Gold Row
AddBackground(15, 100, 175, 20, 9300);
AddBackground(20, 85, 165, 30, 9350);
AddItem(20, 85, 3823); // Gold
AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0"));
AddButton(195, 90, 95, 95, (int)Buttons.AllGold); // ->
AddBackground(210, 100, 175, 20, 9300);
AddBackground(215, 85, 165, 30, 9350);
AddTextEntry(225, 90, 145, 20, 0, 1, m_Gold.ToString(), User.Account.TotalGold.ToString().Length);
// Buttons
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
AddButton(215, 128, 12003, 12004, (int)Buttons.Clear);
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (Check?.Deleted != false || sender.Mobile != User)
{
Close();
return;
}
bool refresh = false, updated = false;
switch ((Buttons)info.ButtonID)
{
case Buttons.Close:
break;
case Buttons.Clear:
if (!int.TryParse(platText, out m_Plat))
{
m_Plat = m_Gold = 0;
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
break;
case Buttons.Accept:
else if (!int.TryParse(goldText, out m_Gold))
{
var platText = info.GetTextEntry(0).Text;
var goldText = info.GetTextEntry(1).Text;
User.SendMessage("That is not a valid amount of gold.");
refresh = true;
}
else
{
var totalPlat = User.Account.TotalPlat;
var totalGold = User.Account.TotalGold;
if (!int.TryParse(platText, out m_Plat))
if (totalPlat < m_Plat || totalGold < m_Gold)
{
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
else if (!int.TryParse(goldText, out m_Gold))
{
User.SendMessage("That is not a valid amount of gold.");
m_Plat = User.Account.TotalPlat;
m_Gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
var totalPlat = User.Account.TotalPlat;
var totalGold = User.Account.TotalGold;
if (totalPlat < m_Plat || totalGold < m_Gold)
{
m_Plat = User.Account.TotalPlat;
m_Gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
Check.Plat = m_Plat;
Check.Gold = m_Gold;
updated = true;
}
Check.Plat = m_Plat;
Check.Gold = m_Gold;
updated = true;
}
}
break;
case Buttons.AllPlat:
{
m_Plat = User.Account.TotalPlat;
refresh = true;
}
break;
case Buttons.AllGold:
{
m_Gold = User.Account.TotalGold;
refresh = true;
}
break;
}
if (updated)
{
User.SendMessage("Your offer has been updated.");
}
if (refresh && Check?.Deleted == false)
{
Refresh(true);
return;
}
Close();
}
break;
case Buttons.AllPlat:
{
m_Plat = User.Account.TotalPlat;
refresh = true;
}
break;
case Buttons.AllGold:
{
m_Gold = User.Account.TotalGold;
refresh = true;
}
break;
}
if (updated)
{
User.SendMessage("Your offer has been updated.");
}
if (refresh && Check?.Deleted == false)
{
Refresh(true);
return;
}
Close();
}
}
}

View file

@ -3,146 +3,145 @@ using System.Buffers;
using System.Runtime.CompilerServices;
using Server.Network;
namespace Server
namespace Server;
public static class OutgoingVirtualHairPackets
{
public static class OutgoingVirtualHairPackets
public const int EquipUpdatePacketLength = 15;
public const int RemovePacketLength = 5;
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
{
public const int EquipUpdatePacketLength = 15;
public const int RemovePacketLength = 5;
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
if (ns.CannotSendPackets())
{
if (ns.CannotSendPackets())
{
return;
}
Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength];
CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer);
ns.Send(buffer);
return;
}
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
{
if (buffer[0] != 0)
{
return;
}
var writer = new SpanWriter(buffer);
writer.Write((byte)0x2E); // Packet ID
writer.Write(hairSerial);
writer.Write((short)itemId);
writer.Write((byte)0);
writer.Write((byte)layer);
writer.Write(m.Serial);
writer.Write((short)(m.SolidHueOverride >= 0 ? m.SolidHueOverride : hue));
}
public static void SendRemoveHairPacket(this NetState ns, uint hairSerial)
{
if (ns.CannotSendPackets())
{
return;
}
Span<byte> buffer = stackalloc byte[RemovePacketLength];
CreateRemoveHairPacket(buffer, hairSerial);
ns.Send(buffer);
}
public static void CreateRemoveHairPacket(Span<byte> buffer, uint hairSerial)
{
if (buffer[0] != 0)
{
return;
}
var writer = new SpanWriter(buffer);
writer.Write((byte)0x1D); // Packet ID
writer.Write(hairSerial);
}
Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength];
CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer);
ns.Send(buffer);
}
public abstract class BaseHairInfo
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
{
protected BaseHairInfo(int itemid, int hue = 0)
if (buffer[0] != 0)
{
ItemID = itemid;
Hue = hue;
return;
}
protected BaseHairInfo(IGenericReader reader)
{
var version = reader.ReadInt();
var writer = new SpanWriter(buffer);
writer.Write((byte)0x2E); // Packet ID
switch (version)
{
case 0:
{
ItemID = reader.ReadInt();
Hue = reader.ReadInt();
break;
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int ItemID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Hue { get; set; }
public virtual void Serialize(IGenericWriter writer)
{
writer.Write(0); // version
writer.Write(ItemID);
writer.Write(Hue);
}
writer.Write(hairSerial);
writer.Write((short)itemId);
writer.Write((byte)0);
writer.Write((byte)layer);
writer.Write(m.Serial);
writer.Write((short)(m.SolidHueOverride >= 0 ? m.SolidHueOverride : hue));
}
public class HairInfo : BaseHairInfo
public static void SendRemoveHairPacket(this NetState ns, uint hairSerial)
{
public HairInfo(int itemid)
: base(itemid)
if (ns.CannotSendPackets())
{
return;
}
public HairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public HairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - m.Value * 4;
Span<byte> buffer = stackalloc byte[RemovePacketLength];
CreateRemoveHairPacket(buffer, hairSerial);
ns.Send(buffer);
}
public class FacialHairInfo : BaseHairInfo
public static void CreateRemoveHairPacket(Span<byte> buffer, uint hairSerial)
{
public FacialHairInfo(int itemid)
: base(itemid)
if (buffer[0] != 0)
{
return;
}
public FacialHairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public FacialHairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - 1 - m.Value* 4;
var writer = new SpanWriter(buffer);
writer.Write((byte)0x1D); // Packet ID
writer.Write(hairSerial);
}
}
public abstract class BaseHairInfo
{
protected BaseHairInfo(int itemid, int hue = 0)
{
ItemID = itemid;
Hue = hue;
}
protected BaseHairInfo(IGenericReader reader)
{
var version = reader.ReadInt();
switch (version)
{
case 0:
{
ItemID = reader.ReadInt();
Hue = reader.ReadInt();
break;
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int ItemID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Hue { get; set; }
public virtual void Serialize(IGenericWriter writer)
{
writer.Write(0); // version
writer.Write(ItemID);
writer.Write(Hue);
}
}
public class HairInfo : BaseHairInfo
{
public HairInfo(int itemid)
: base(itemid)
{
}
public HairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public HairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - m.Value * 4;
}
public class FacialHairInfo : BaseHairInfo
{
public FacialHairInfo(int itemid)
: base(itemid)
{
}
public FacialHairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public FacialHairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - 1 - m.Value* 4;
}