fix(core): Removes implicit cast between Serial and uint (#728)
* Fixes spellbooks using serial ctor * Fixes misc items where someone thought they had an amount and it didn't * Fixes all `Food` types.
This commit is contained in:
parent
17521c9cd7
commit
0dc4acc164
74 changed files with 319 additions and 248 deletions
|
|
@ -27,7 +27,7 @@ namespace Benchmarks
|
|||
var writer = new CircularBufferWriter(buffer);
|
||||
writer.Write((byte)0xAE);
|
||||
writer.Write((ushort)(50 + text.Length * 2));
|
||||
writer.Write(serial);
|
||||
writer.Write(serial.Value);
|
||||
writer.Write((short)graphic);
|
||||
writer.Write((byte)type);
|
||||
writer.Write((short)hue);
|
||||
|
|
|
|||
|
|
@ -137,6 +137,8 @@ namespace Server.Network
|
|||
UnderlyingStream.Write(m_Buffer, 0, 4);
|
||||
}
|
||||
|
||||
public void Write(Serial serial) => Write(serial.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sequence of bytes to the underlying stream
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestChangeCharacter()
|
||||
{
|
||||
var firstMobile = new Mobile(0x1);
|
||||
var firstMobile = new Mobile((Serial)0x1);
|
||||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.RawName = "Test Mobile";
|
||||
|
||||
var secondMobile = new Mobile(0x2);
|
||||
var secondMobile = new Mobile((Serial)0x2);
|
||||
secondMobile.DefaultMobileInit();
|
||||
secondMobile.RawName = null;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ namespace Server.Tests.Network
|
|||
[Theory, InlineData(ProtocolChanges.Version70610), InlineData(ProtocolChanges.Version6000)]
|
||||
public void TestSupportedFeatures(ProtocolChanges protocolChanges)
|
||||
{
|
||||
var firstMobile = new Mobile(0x1);
|
||||
var firstMobile = new Mobile((Serial)0x1);
|
||||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestLoginConfirm()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Body = 0x100;
|
||||
m.X = 100;
|
||||
|
|
@ -156,7 +156,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestCharacterListUpdate()
|
||||
{
|
||||
var firstMobile = new Mobile(0x1);
|
||||
var firstMobile = new Mobile((Serial)0x1);
|
||||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.RawName = "Test Mobile";
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestCharacterList70130()
|
||||
{
|
||||
var firstMobile = new Mobile(0x1);
|
||||
var firstMobile = new Mobile((Serial)0x1);
|
||||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestCharacterListOld()
|
||||
{
|
||||
var firstMobile = new Mobile(0x1);
|
||||
var firstMobile = new Mobile((Serial)0x1);
|
||||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSwing()
|
||||
{
|
||||
Serial attacker = 0x1000;
|
||||
Serial defender = 0x2000;
|
||||
Serial attacker = (Serial)0x1024;
|
||||
Serial defender = (Serial)0x2048;
|
||||
|
||||
var expected = new Swing(attacker, defender).Compile();
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestChangeCombatant()
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new ChangeCombatant(serial).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerDisplay()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplay(serial, gumpId).Compile();
|
||||
|
|
@ -27,7 +27,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerDisplayHS()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplayHS(serial, gumpId).Compile();
|
||||
|
|
@ -43,7 +43,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDisplaySpellbook()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbook(serial).Compile();
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDisplaySpellbookHS()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbookHS(serial).Compile();
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestNewSpellbookContent()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort graphic = 100;
|
||||
ushort offset = 10;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
|
@ -93,7 +93,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSpellbookContent()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort offset = 10;
|
||||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
|
@ -110,7 +110,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSpellbookContent6017()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort offset = 10;
|
||||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
|
@ -128,7 +128,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerContentUpdate()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate(item).Compile();
|
||||
|
|
@ -143,7 +143,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestContainerContentUpdate6017()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate6017(item).Compile();
|
||||
|
|
@ -163,7 +163,7 @@ namespace Server.Tests.Network
|
|||
cont.AddItem(new Item(World.NewItem));
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
|
@ -184,7 +184,7 @@ namespace Server.Tests.Network
|
|||
cont.AddItem(new Item(World.NewItem));
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Server.Tests.Network
|
|||
[Theory, InlineData(10), InlineData(-5), InlineData(1024)]
|
||||
public void TestDamagePacketOld(int inputAmount)
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacketOld(serial, inputAmount).Compile();
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ namespace Server.Tests.Network
|
|||
[Theory, InlineData(10), InlineData(-5), InlineData(1024), InlineData(100000)]
|
||||
public void TestDamage(int inputAmount)
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacket(serial, inputAmount).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ namespace Server.Tests.Network
|
|||
public void TestParticleEffect()
|
||||
{
|
||||
var effectType = EffectType.Moving;
|
||||
Serial serial = 0x4000;
|
||||
Serial from = 0x1000;
|
||||
Serial to = 0x2000;
|
||||
Serial serial = (Serial)0x4000;
|
||||
Serial from = (Serial)0x1000;
|
||||
Serial to = (Serial)0x2000;
|
||||
var itemId = 0x100;
|
||||
var fromPoint = new Point3D(1000, 100, -10);
|
||||
var toPoint = new Point3D(1500, 500, 0);
|
||||
|
|
@ -63,8 +63,8 @@ namespace Server.Tests.Network
|
|||
public void TestHuedEffect()
|
||||
{
|
||||
var effectType = EffectType.Moving;
|
||||
Serial from = 0x1000;
|
||||
Serial to = 0x2000;
|
||||
Serial from = (Serial)0x1000;
|
||||
Serial to = (Serial)0x2000;
|
||||
var itemId = 0x100;
|
||||
var fromPoint = new Point3D(1000, 100, -10);
|
||||
var toPoint = new Point3D(1500, 500, 0);
|
||||
|
|
@ -105,7 +105,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestBoltEffect()
|
||||
{
|
||||
IEntity entity = new Entity(0x1000, new Point3D(1000, 100, -10), Map.Felucca);
|
||||
IEntity entity = new Entity((Serial)0x1000, new Point3D(1000, 100, -10), Map.Felucca);
|
||||
var hue = 0x1024;
|
||||
var expected = new BoltEffect(entity, hue).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Tests.Network
|
|||
[InlineData("", true)]
|
||||
public void TestDisplayEquipmentInfo(string name, bool unidentified)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.RawName = name;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestEquipUpdate()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var item = new Item(World.NewItem) { Parent = m };
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDisplaySignGump()
|
||||
{
|
||||
Serial gumpSerial = 0x1000;
|
||||
Serial gumpSerial = (Serial)0x1000;
|
||||
var gumpId = 100;
|
||||
var unknownString = "This is an unknown string";
|
||||
var caption = "This is a caption";
|
||||
|
|
@ -60,7 +60,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.Unpack)]
|
||||
public void TestGumpPacketAdmin(ProtocolChanges changes)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.RawName = "Test Mobile";
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace Server.Tests
|
|||
void AppendLayout(bool val);
|
||||
void AppendLayout(int val);
|
||||
void AppendLayout(uint val);
|
||||
void AppendLayout(Serial serial);
|
||||
void AppendLayoutNS(int val);
|
||||
void AppendLayout(string text);
|
||||
void AppendLayoutNS(string text);
|
||||
|
|
@ -89,6 +90,8 @@ namespace Server.Tests
|
|||
m_Layout.Write(m_Buffer, 0, bytes);
|
||||
}
|
||||
|
||||
public void AppendLayout(Serial serial) => AppendLayout(serial.Value);
|
||||
|
||||
public void AppendLayoutNS(int val)
|
||||
{
|
||||
var toString = val.ToString();
|
||||
|
|
@ -232,6 +235,8 @@ namespace Server.Tests
|
|||
m_LayoutLength += bytes;
|
||||
}
|
||||
|
||||
public void AppendLayout(Serial serial) => AppendLayout(serial.Value);
|
||||
|
||||
public void AppendLayoutNS(int val)
|
||||
{
|
||||
var toString = val.ToString();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestWorldItemPacket()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
@ -45,7 +45,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestWorldItemSAPacket()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
ushort itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
@ -81,7 +81,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestWorldItemHSPacket()
|
||||
{
|
||||
Serial serial = 0x1000;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestPersonalLightLevel()
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
byte lightLevel = 5;
|
||||
var expected = new PersonalLightLevel(serial, lightLevel).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(true, true)]
|
||||
public void TestDisplayContextMenu(bool newHaven, bool newPacket)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var item = new ContextMenuItem(World.NewItem, newPacket);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMessageLocalized()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -49,7 +49,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMessageLocalizedAffix()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -94,7 +94,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestAsciiMessage()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -132,7 +132,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestUnicodeMessage()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial = (Serial)0x1024;
|
||||
var graphic = 0x100;
|
||||
var messageType = MessageType.Label;
|
||||
var hue = 1024;
|
||||
|
|
@ -172,8 +172,8 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestFollowMessage()
|
||||
{
|
||||
Serial serial = 0x1;
|
||||
Serial serial2 = 0x2;
|
||||
Serial serial = (Serial)0x1024;
|
||||
Serial serial2 = (Serial)0x2;
|
||||
|
||||
var expected = new FollowMessage(serial, serial2).Compile();
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestObjectHelpResponse()
|
||||
{
|
||||
Serial s = 0x100;
|
||||
Serial s = (Serial)0x100;
|
||||
var text = "This is some testing text";
|
||||
|
||||
var expected = new ObjectHelpResponse(s, text).Compile();
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestDeathAnimation()
|
||||
{
|
||||
Serial killed = 0x1;
|
||||
Serial corpse = 0x1000;
|
||||
Serial killed = (Serial)0x1;
|
||||
Serial corpse = (Serial)0x1000;
|
||||
|
||||
var expected = new DeathAnimation(killed, corpse).Compile();
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestBondStatus()
|
||||
{
|
||||
Serial petSerial = 0x1;
|
||||
Serial petSerial = (Serial)0x1;
|
||||
const bool bonded = true;
|
||||
|
||||
var expected = new BondedStatus(petSerial, bonded).Compile();
|
||||
|
|
@ -42,7 +42,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.None)]
|
||||
public void TestMobileMoving(ProtocolChanges protocolChanges)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var noto = 10;
|
||||
|
|
@ -63,7 +63,7 @@ namespace Server.Tests.Network
|
|||
[InlineData("Some Really Long Mobile Name That Gets Cut off")]
|
||||
public void TestMobileName(string name)
|
||||
{
|
||||
var m = new Mobile(0x1) { Name = name };
|
||||
var m = new Mobile((Serial)0x1) { Name = name };
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var expected = new MobileName(m).Compile();
|
||||
|
|
@ -80,7 +80,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(10, 100, 25, true, false, 0)]
|
||||
public void TestMobileAnimation(int action, int frameCount, int repeatCount, bool reverse, bool repeat, byte delay)
|
||||
{
|
||||
Serial mobile = 0x1;
|
||||
Serial mobile = (Serial)0x1;
|
||||
|
||||
var expected = new MobileAnimation(
|
||||
mobile,
|
||||
|
|
@ -112,7 +112,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(10, 100, 20)]
|
||||
public void TestNewMobileAnimation(int action, int frameCount, byte delay)
|
||||
{
|
||||
Serial mobile = 0x1;
|
||||
Serial mobile = (Serial)0x1;
|
||||
|
||||
var expected = new NewMobileAnimation(
|
||||
mobile,
|
||||
|
|
@ -140,7 +140,7 @@ namespace Server.Tests.Network
|
|||
public void TestHealthbarPoison(string pName)
|
||||
{
|
||||
var p = Poison.GetPoison(pName);
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Poison = p;
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(true, true)]
|
||||
public void TestYellowBar(bool isBlessed, bool isYellowHealth)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Blessed = isBlessed;
|
||||
m.YellowHealthbar = isYellowHealth;
|
||||
|
|
@ -179,7 +179,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(false)]
|
||||
public void TestMobileStatusCompact(bool canBeRenamed)
|
||||
{
|
||||
var m = new Mobile(0x1) { Name = "Random Mobile 1" };
|
||||
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
|
|
@ -203,7 +203,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.Version502b)]
|
||||
public void TestMobileStatus(ProtocolChanges changes)
|
||||
{
|
||||
var beholder = new Mobile(0x1) { Name = "Random Mobile 1" };
|
||||
var beholder = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
beholder.DefaultMobileInit();
|
||||
beholder.Str = 50;
|
||||
beholder.Hits = 100;
|
||||
|
|
@ -212,7 +212,7 @@ namespace Server.Tests.Network
|
|||
beholder.Dex = 25;
|
||||
beholder.Stam = 100;
|
||||
|
||||
var beheld = new Mobile(0x2) { Name = "Random Mobile 2" };
|
||||
var beheld = new Mobile((Serial)0x2) { Name = "Random Mobile 2" };
|
||||
beheld.DefaultMobileInit();
|
||||
beheld.Str = 50;
|
||||
beheld.Hits = 100;
|
||||
|
|
@ -237,7 +237,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.Version502b)]
|
||||
public void TestMobileStatusExtendedSelf(ProtocolChanges changes)
|
||||
{
|
||||
var m = new Mobile(0x1) { Name = "Random Mobile 1" };
|
||||
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
|
|
@ -261,7 +261,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.StygianAbyss, 100)]
|
||||
public void TestMobileUpdate(ProtocolChanges changes, int solidHueOverride)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.SolidHueOverride = solidHueOverride;
|
||||
|
||||
|
|
@ -289,13 +289,13 @@ namespace Server.Tests.Network
|
|||
ProtocolChanges changes, int hairItemId, int hairHue, int facialHairItemId, int facialHairHue
|
||||
)
|
||||
{
|
||||
var beholder = new Mobile(0x1)
|
||||
var beholder = new Mobile((Serial)0x1)
|
||||
{
|
||||
Name = "Random Mobile 1"
|
||||
};
|
||||
beholder.DefaultMobileInit();
|
||||
|
||||
var beheld = new Mobile(0x2)
|
||||
var beheld = new Mobile((Serial)0x2)
|
||||
{
|
||||
Name = "Random Mobile 2"
|
||||
};
|
||||
|
|
@ -333,7 +333,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileHits()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 100;
|
||||
m.Hits = 100;
|
||||
|
|
@ -350,7 +350,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileHitsN()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 100;
|
||||
m.Hits = 100;
|
||||
|
|
@ -367,7 +367,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileMana()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
|
|
@ -384,7 +384,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileManaN()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
|
|
@ -401,7 +401,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileStam()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Dex = 75;
|
||||
m.Stam = 100;
|
||||
|
|
@ -418,7 +418,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileStamN()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Dex = 75;
|
||||
m.Stam = 100;
|
||||
|
|
@ -435,7 +435,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileAttributes()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
|
|
@ -456,7 +456,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMobileAttributesN()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
|
|
@ -477,7 +477,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestRemoveEntity()
|
||||
{
|
||||
Serial e = 0x1000;
|
||||
Serial e = (Serial)0x1000;
|
||||
var expected = new RemoveEntity(e).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMovementRej()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
const byte seq = 100;
|
||||
|
|
@ -54,7 +54,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestMovementAck()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
const byte seq = 100;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(StatLockType.Down, StatLockType.Up, StatLockType.Locked)]
|
||||
public void TestStatLockInfo(StatLockType str, StatLockType intel, StatLockType dex)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.StrLock = str;
|
||||
m.IntLock = intel;
|
||||
|
|
@ -77,11 +77,10 @@ namespace Server.Tests.Network
|
|||
[InlineData(0x1000u, null, null, null)]
|
||||
public void TestDisplayProfile(uint serial, string header, string body, string footer)
|
||||
{
|
||||
Serial m = serial;
|
||||
var expected = new DisplayProfile(m, header, body, footer).Compile();
|
||||
var expected = new DisplayProfile((Serial)serial, header, body, footer).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayProfile(m, header, body, footer);
|
||||
ns.SendDisplayProfile((Serial)serial, header, body, footer);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
@ -146,7 +145,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSkillsUpdate()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var skills = m.Skills;
|
||||
|
|
@ -182,7 +181,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(SkillName.Begging, 100000, 1000)]
|
||||
public void TestSkillChange(SkillName skillName, int baseFixedPoint, int capFixedPoint)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var skill = m.Skills[skillName];
|
||||
|
|
@ -222,8 +221,8 @@ namespace Server.Tests.Network
|
|||
int itemId, int hue, int amount
|
||||
)
|
||||
{
|
||||
var src = new Entity(srcSerial, new Point3D(srcX, srcY, srcZ), null);
|
||||
var targ = new Entity(trgSerial, new Point3D(trgX, trgY, trgZ), null);
|
||||
var src = new Entity((Serial)srcSerial, new Point3D(srcX, srcY, srcZ), null);
|
||||
var targ = new Entity((Serial)trgSerial, new Point3D(trgX, trgY, trgZ), null);
|
||||
|
||||
var expected = new DragEffect(src, targ, itemId, hue, amount).Compile();
|
||||
|
||||
|
|
@ -258,10 +257,10 @@ namespace Server.Tests.Network
|
|||
[InlineData(0x1024u, "Test Title", true, false)]
|
||||
public void TestDisplayPaperdoll(uint m, string title, bool warmode, bool canLift)
|
||||
{
|
||||
var expected = new DisplayPaperdoll(m, title, warmode, canLift).Compile();
|
||||
var expected = new DisplayPaperdoll((Serial)m, title, warmode, canLift).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayPaperdoll(m, title, warmode, canLift);
|
||||
ns.SendDisplayPaperdoll((Serial)m, title, warmode, canLift);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Tests.Network
|
|||
[InlineData("this is a really long name that is more than 30 characters, probably")]
|
||||
public void TestDisplaySecureTrade(string name)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var firstCont = new Container(World.NewItem);
|
||||
|
|
@ -77,7 +77,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSecureTradeEquip()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var cont = new Container(World.NewItem);
|
||||
|
|
@ -95,7 +95,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestSecureTradeEquip6017()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var cont = new Container(World.NewItem);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(ProtocolChanges.HighSeas)]
|
||||
public void TestDisplayBuyList(ProtocolChanges protocolChanges)
|
||||
{
|
||||
var vendor = new Mobile(0x1);
|
||||
var vendor = new Mobile((Serial)0x1);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
|
@ -56,7 +56,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestVendorBuyList()
|
||||
{
|
||||
var vendor = new Mobile(0x1);
|
||||
var vendor = new Mobile((Serial)0x1);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var cont = new Container(World.NewItem);
|
||||
|
|
@ -80,7 +80,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestEndVendorBuy()
|
||||
{
|
||||
var vendor = new Mobile(0x1);
|
||||
var vendor = new Mobile((Serial)0x1);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var expected = new EndVendorBuy(vendor.Serial).Compile();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestVendorSellList()
|
||||
{
|
||||
var vendor = new Mobile(0x1024u);
|
||||
var vendor = new Mobile((Serial)0x1024u);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var item1 = new Item(World.NewItem);
|
||||
|
|
@ -37,7 +37,7 @@ namespace Server.Tests.Network
|
|||
[Fact]
|
||||
public void TestEndVendorSell()
|
||||
{
|
||||
var vendor = new Mobile(0x1024u);
|
||||
var vendor = new Mobile((Serial)0x1024u);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var expected = new EndVendorBuy(vendor.Serial).Compile();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server.Tests
|
|||
[Fact]
|
||||
public void TestSendVirtualHairUpdate()
|
||||
{
|
||||
var m = new Mobile(0x1024u);
|
||||
var m = new Mobile((Serial)0x1024u);
|
||||
m.DefaultMobileInit();
|
||||
m.HairHue = 0x1000;
|
||||
m.HairItemID = 0x2000;
|
||||
|
|
@ -27,7 +27,7 @@ namespace Server.Tests
|
|||
[Fact]
|
||||
public void TestSendRemoveVirtualHair()
|
||||
{
|
||||
var m = new Mobile(0x1024u);
|
||||
var m = new Mobile((Serial)0x1024u);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var expected = new RemoveHair(m).Compile();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ using System.Runtime.CompilerServices;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Microsoft.Toolkit.HighPerformance;
|
||||
using Server;
|
||||
using Server.Text;
|
||||
|
||||
namespace System.Buffers
|
||||
|
|
@ -234,6 +235,9 @@ namespace System.Buffers
|
|||
Position += 4;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Write(Serial serial) => Write(serial.Value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void WriteLE(uint value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Gumps
|
|||
{
|
||||
public class Gump
|
||||
{
|
||||
private static uint m_NextSerial = 1;
|
||||
private static Serial _nextSerial = (Serial)1;
|
||||
|
||||
public static readonly byte[] NoMove = StringToBuffer("{ nomove }");
|
||||
public static readonly byte[] NoClose = StringToBuffer("{ noclose }");
|
||||
|
|
@ -20,7 +20,7 @@ namespace Server.Gumps
|
|||
{
|
||||
do
|
||||
{
|
||||
Serial = m_NextSerial++;
|
||||
Serial = _nextSerial++;
|
||||
} while (Serial == 0); // standard client apparently doesn't send a gump response packet if serial == 0
|
||||
|
||||
X = x;
|
||||
|
|
@ -186,7 +186,7 @@ namespace Server.Gumps
|
|||
Add(new GumpTextEntryLimited(x, y, width, height, hue, entryID, initialText, size));
|
||||
}
|
||||
|
||||
public void AddItemProperty(uint serial)
|
||||
public void AddItemProperty(Serial serial)
|
||||
{
|
||||
Add(new GumpItemProperty(serial));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,18 +22,18 @@ namespace Server.Gumps
|
|||
{
|
||||
public static readonly byte[] LayoutName = Gump.StringToBuffer("itemproperty");
|
||||
|
||||
public GumpItemProperty(uint serial) => Serial = serial;
|
||||
public GumpItemProperty(Serial serial) => Serial = serial;
|
||||
|
||||
public uint Serial { get; set; }
|
||||
public Serial Serial { get; set; }
|
||||
|
||||
public override string Compile(OrderedHashSet<string> strings) => $"{{ itemproperty {Serial} }}";
|
||||
public override string Compile(OrderedHashSet<string> strings) => $"{{ itemproperty {Serial.Value} }}";
|
||||
|
||||
public override void AppendTo(ref SpanWriter writer, OrderedHashSet<string> strings, ref int entries, ref int switches)
|
||||
{
|
||||
writer.Write((ushort)0x7B20); // "{ "
|
||||
writer.Write(LayoutName);
|
||||
writer.WriteAscii(' ');
|
||||
writer.WriteAscii(Serial.ToString());
|
||||
writer.WriteAscii(Serial.Value.ToString());
|
||||
writer.Write((ushort)0x207D); // " }"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ namespace Server.HuePickers
|
|||
{
|
||||
public class HuePicker
|
||||
{
|
||||
private static Serial m_NextSerial = 1;
|
||||
private static Serial _nextSerial = (Serial)1;
|
||||
|
||||
public HuePicker(int itemID)
|
||||
{
|
||||
do
|
||||
{
|
||||
Serial = m_NextSerial++;
|
||||
Serial = _nextSerial++;
|
||||
} while (Serial == 0);
|
||||
|
||||
ItemID = itemID;
|
||||
|
|
|
|||
|
|
@ -114,22 +114,7 @@ namespace Server
|
|||
var loc = reader.ReadPoint3D();
|
||||
var worldLoc = reader.ReadPoint3D();
|
||||
|
||||
IEntity parent;
|
||||
|
||||
Serial serial = reader.ReadUInt();
|
||||
|
||||
if (serial.IsItem)
|
||||
{
|
||||
parent = World.FindItem(serial);
|
||||
}
|
||||
else if (serial.IsMobile)
|
||||
{
|
||||
parent = World.FindMobile(serial);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = null;
|
||||
}
|
||||
IEntity parent = reader.ReadEntity<IEntity>();
|
||||
|
||||
return new BounceInfo(map, loc, worldLoc, parent);
|
||||
}
|
||||
|
|
@ -2651,7 +2636,7 @@ namespace Server
|
|||
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent))
|
||||
{
|
||||
Serial parent = reader.ReadUInt();
|
||||
Serial parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
@ -2812,7 +2797,7 @@ namespace Server
|
|||
|
||||
if (GetSaveFlag(flags, SaveFlag.Parent))
|
||||
{
|
||||
Serial parent = reader.ReadUInt();
|
||||
Serial parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
@ -2930,7 +2915,7 @@ namespace Server
|
|||
AcquireCompactInfo().m_Name = name;
|
||||
}
|
||||
|
||||
Serial parent = reader.ReadUInt();
|
||||
Serial parent = reader.ReadSerial();
|
||||
|
||||
if (parent.IsMobile)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server
|
|||
public const int EquipUpdatePacketLength = 15;
|
||||
public const int RemovePacketLength = 5;
|
||||
|
||||
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, Serial hairSerial, int itemId, int hue, Layer layer)
|
||||
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
|
|
@ -22,7 +22,7 @@ namespace Server
|
|||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, Serial hairSerial, int itemId, int hue, Layer layer)
|
||||
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, uint hairSerial, int itemId, int hue, Layer layer)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ namespace Server
|
|||
writer.Write((short)(m.SolidHueOverride >= 0 ? m.SolidHueOverride : hue));
|
||||
}
|
||||
|
||||
public static void SendRemoveHairPacket(this NetState ns, Serial hairSerial)
|
||||
public static void SendRemoveHairPacket(this NetState ns, uint hairSerial)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
|
|
@ -52,7 +52,7 @@ namespace Server
|
|||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
public static void CreateRemoveHairPacket(Span<byte> buffer, Serial hairSerial)
|
||||
public static void CreateRemoveHairPacket(Span<byte> buffer, uint hairSerial)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ namespace Server
|
|||
|
||||
// TODO: Can we make this higher for newer clients?
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - m * 4;
|
||||
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - m.Value * 4;
|
||||
}
|
||||
|
||||
public class FacialHairInfo : BaseHairInfo
|
||||
|
|
@ -143,6 +143,6 @@ namespace Server
|
|||
|
||||
// TODO: Can we make this higher for newer clients?
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - 1 - m * 4;
|
||||
public static uint FakeSerial(Serial m) => 0x7FFFFFFF - 0x400 - 1 - m.Value* 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,12 +350,12 @@ namespace Server.Network
|
|||
var oldestID = 0;
|
||||
var oldest = DateTime.MaxValue;
|
||||
|
||||
foreach (var kvp in m_AuthIDWindow)
|
||||
foreach (var (key, authId) in m_AuthIDWindow)
|
||||
{
|
||||
if (kvp.Value.Age < oldest)
|
||||
if (authId.Age < oldest)
|
||||
{
|
||||
oldestID = kvp.Key;
|
||||
oldest = kvp.Value.Age;
|
||||
oldestID = key;
|
||||
oldest = authId.Age;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Server.Network
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
int unk = reader.ReadByte();
|
||||
var lang = reader.ReadAscii(3);
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ namespace Server.Network
|
|||
}
|
||||
else
|
||||
{
|
||||
Serial s = value;
|
||||
Serial s = (Serial)value;
|
||||
|
||||
if (s.IsMobile)
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ namespace Server.Network
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
Serial s = reader.ReadUInt32();
|
||||
Serial s = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (s.IsMobile)
|
||||
{
|
||||
|
|
@ -167,7 +167,7 @@ namespace Server.Network
|
|||
|
||||
while (reader.Remaining > 0)
|
||||
{
|
||||
Serial s = reader.ReadUInt32();
|
||||
Serial s = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (s.IsMobile)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -184,14 +184,14 @@ namespace Server.Network
|
|||
|
||||
public static void PartyMessage_RemoveMember(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnRemove(state.Mobile, World.FindMobile(reader.ReadUInt32()));
|
||||
PartyCommands.Handler?.OnRemove(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void PartyMessage_PrivateMessage(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnPrivateMessage(
|
||||
state.Mobile,
|
||||
World.FindMobile(reader.ReadUInt32()),
|
||||
World.FindMobile((Serial)reader.ReadUInt32()),
|
||||
reader.ReadBigUniSafe()
|
||||
);
|
||||
}
|
||||
|
|
@ -208,12 +208,12 @@ namespace Server.Network
|
|||
|
||||
public static void PartyMessage_Accept(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnAccept(state.Mobile, World.FindMobile(reader.ReadUInt32()));
|
||||
PartyCommands.Handler?.OnAccept(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void PartyMessage_Decline(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnDecline(state.Mobile, World.FindMobile(reader.ReadUInt32()));
|
||||
PartyCommands.Handler?.OnDecline(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void Animate(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
|
|
@ -249,7 +249,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Item spellbook = reader.ReadInt16() == 1 ? World.FindItem(reader.ReadUInt32()) : null;
|
||||
Item spellbook = reader.ReadInt16() == 1 ? World.FindItem((Serial)reader.ReadUInt32()) : null;
|
||||
|
||||
var spellID = reader.ReadInt16() - 1;
|
||||
EventSink.InvokeCastSpellRequest(from, spellID, spellbook);
|
||||
|
|
@ -317,7 +317,7 @@ namespace Server.Network
|
|||
|
||||
public static void CloseStatus(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
}
|
||||
|
||||
public static void Language(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
|
|
@ -341,7 +341,7 @@ namespace Server.Network
|
|||
|
||||
var from = state.Mobile;
|
||||
|
||||
Serial s = reader.ReadUInt32();
|
||||
Serial s = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (s.IsMobile)
|
||||
{
|
||||
|
|
@ -379,7 +379,7 @@ namespace Server.Network
|
|||
|
||||
if (menu != null && from == menu.From)
|
||||
{
|
||||
var entity = World.FindEntity(reader.ReadUInt32());
|
||||
var entity = World.FindEntity((Serial)reader.ReadUInt32());
|
||||
|
||||
if (entity != null && entity == menu.Target && from.CanSee(entity))
|
||||
{
|
||||
|
|
@ -423,7 +423,7 @@ namespace Server.Network
|
|||
public static void ContextMenuRequest(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
var target = World.FindEntity(reader.ReadUInt32());
|
||||
var target = World.FindEntity((Serial)reader.ReadUInt32());
|
||||
|
||||
if (from != null && target != null && from.Map == target.Map && from.CanSee(target))
|
||||
{
|
||||
|
|
@ -466,14 +466,14 @@ namespace Server.Network
|
|||
|
||||
if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0)
|
||||
{
|
||||
var bandage = World.FindItem(reader.ReadUInt32());
|
||||
var bandage = World.FindItem((Serial)reader.ReadUInt32());
|
||||
|
||||
if (bandage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var target = World.FindMobile(reader.ReadUInt32());
|
||||
var target = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
|
|
@ -494,19 +494,19 @@ namespace Server.Network
|
|||
{
|
||||
var spellId = (short)(reader.ReadInt16() - 1); // zero based;
|
||||
|
||||
EventSink.InvokeTargetedSpell(state.Mobile, World.FindEntity(reader.ReadUInt32()), spellId);
|
||||
EventSink.InvokeTargetedSpell(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), spellId);
|
||||
}
|
||||
|
||||
public static void TargetedSkillUse(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var skillId = reader.ReadInt16();
|
||||
|
||||
EventSink.InvokeTargetedSkillUse(state.Mobile, World.FindEntity(reader.ReadUInt32()), skillId);
|
||||
EventSink.InvokeTargetedSkillUse(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), skillId);
|
||||
}
|
||||
|
||||
public static void TargetByResourceMacro(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (serial.IsItem)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Server.Network
|
|||
|
||||
public static void LiftReq(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
int amount = reader.ReadUInt16();
|
||||
var item = World.FindItem(serial);
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
reader.Seek(5, SeekOrigin.Current);
|
||||
var to = World.FindMobile(reader.ReadUInt32()) ?? from;
|
||||
var to = World.FindMobile((Serial)reader.ReadUInt32()) ?? from;
|
||||
|
||||
if (!to.AllowEquipFrom(from) || !to.EquipItem(item))
|
||||
{
|
||||
|
|
@ -79,7 +79,7 @@ namespace Server.Network
|
|||
packetLength -= 1;
|
||||
}
|
||||
|
||||
Serial dest = reader.ReadUInt32();
|
||||
Serial dest = (Serial)reader.ReadUInt32();
|
||||
|
||||
var loc = new Point3D(x, y, z);
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ namespace Server.Network
|
|||
int y = reader.ReadInt16();
|
||||
int z = reader.ReadSByte();
|
||||
reader.ReadByte(); // Grid Location?
|
||||
Serial dest = reader.ReadUInt32();
|
||||
Serial dest = (Serial)reader.ReadUInt32();
|
||||
|
||||
var loc = new Point3D(x, y, z);
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ namespace Server.Network
|
|||
var serialList = new List<Serial>(count);
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
serialList.Add(reader.ReadUInt32());
|
||||
serialList.Add((Serial)reader.ReadUInt32());
|
||||
}
|
||||
|
||||
EventSink.InvokeEquipMacro(state.Mobile, serialList);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Server.Network
|
|||
public static void RenameRequest(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
var targ = World.FindMobile(reader.ReadUInt32());
|
||||
var targ = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (targ != null)
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ namespace Server.Network
|
|||
|
||||
public static void MobileNameRequest(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var m = World.FindMobile(reader.ReadUInt32());
|
||||
var m = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (m != null && Utility.InUpdateRange(state.Mobile.Location, m.Location) && state.Mobile.CanSee(m))
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ namespace Server.Network
|
|||
public static void ProfileReq(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
int type = reader.ReadByte();
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
var beholder = state.Mobile;
|
||||
var beheld = World.FindMobile(serial);
|
||||
|
|
@ -94,7 +94,7 @@ namespace Server.Network
|
|||
{
|
||||
case 1: // Cancel
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (World.FindItem(serial) is SecureTradeContainer cont && cont.Trade != null &&
|
||||
(cont.Trade.From.Mobile == state.Mobile || cont.Trade.To.Mobile == state.Mobile))
|
||||
|
|
@ -106,7 +106,7 @@ namespace Server.Network
|
|||
}
|
||||
case 2: // Check
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (World.FindItem(serial) is SecureTradeContainer cont)
|
||||
{
|
||||
|
|
@ -133,7 +133,7 @@ namespace Server.Network
|
|||
}
|
||||
case 3: // Update Gold
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
if (World.FindItem(serial) is SecureTradeContainer cont)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
var m = World.FindMobile(reader.ReadUInt32());
|
||||
var m = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@ namespace Server.Network
|
|||
{
|
||||
var tokenizer = command.Tokenize(' ');
|
||||
var spellID = (tokenizer.MoveNext() ? Utility.ToInt32(tokenizer.Current) : 0) - 1;
|
||||
var serial = tokenizer.MoveNext() ? Utility.ToUInt32(tokenizer.Current) : (uint)Serial.MinusOne;
|
||||
var serial = tokenizer.MoveNext() ? (Serial)Utility.ToUInt32(tokenizer.Current) : Serial.MinusOne;
|
||||
|
||||
EventSink.InvokeCastSpellRequest(from, spellID, World.FindItem(serial));
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ namespace Server.Network
|
|||
|
||||
public static void DisplayGumpResponse(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
var typeID = reader.ReadInt32();
|
||||
var buttonID = reader.ReadInt32();
|
||||
|
||||
|
|
@ -461,7 +461,7 @@ namespace Server.Network
|
|||
|
||||
if (buttonID == 1 && switchCount > 0)
|
||||
{
|
||||
var beheld = World.FindMobile(reader.ReadUInt32());
|
||||
var beheld = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (beheld != null)
|
||||
{
|
||||
|
|
@ -523,7 +523,7 @@ namespace Server.Network
|
|||
|
||||
reader.ReadInt32(); // 0xEDEDEDED
|
||||
int type = reader.ReadByte();
|
||||
var m = World.FindMobile(reader.ReadUInt32());
|
||||
var m = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (m == null)
|
||||
{
|
||||
|
|
@ -601,7 +601,7 @@ namespace Server.Network
|
|||
|
||||
public static void EncodedCommand(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var e = World.FindEntity(reader.ReadUInt32());
|
||||
var e = World.FindEntity((Serial)reader.ReadUInt32());
|
||||
int packetId = reader.ReadUInt16();
|
||||
|
||||
var ph = IncomingPackets.GetEncodedHandler(packetId);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Server.Network
|
|||
int type = reader.ReadByte();
|
||||
var targetID = reader.ReadInt32();
|
||||
int flags = reader.ReadByte();
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
int x = reader.ReadInt16();
|
||||
int y = reader.ReadInt16();
|
||||
reader.ReadByte();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Server.Network
|
|||
|
||||
public static void VendorBuyReply(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var vendor = World.FindMobile(reader.ReadUInt32());
|
||||
var vendor = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
if (vendor == null)
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ namespace Server.Network
|
|||
while (msgSize > 0)
|
||||
{
|
||||
var layer = reader.ReadByte();
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
int amount = reader.ReadInt16();
|
||||
|
||||
buyList.Add(new BuyItemResponse(serial, amount));
|
||||
|
|
@ -67,7 +67,7 @@ namespace Server.Network
|
|||
|
||||
public static void VendorSellReply(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
Serial serial = reader.ReadUInt32();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
var vendor = World.FindMobile(serial);
|
||||
|
||||
if (vendor == null)
|
||||
|
|
@ -92,7 +92,7 @@ namespace Server.Network
|
|||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = World.FindItem(reader.ReadUInt32());
|
||||
var item = World.FindItem((Serial)reader.ReadUInt32());
|
||||
int amount = reader.ReadInt16();
|
||||
|
||||
if (item != null && amount > 0)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Server.Network
|
|||
var itemID = item is BaseMulti ? item.ItemID | 0x4000 : item.ItemID & 0x3FFF;
|
||||
var amount = item.Amount;
|
||||
var hasAmount = amount != 0;
|
||||
var serial = hasAmount ? item.Serial | 0x80000000 : item.Serial & 0x7FFFFFFF;
|
||||
var serial = hasAmount ? item.Serial.Value | 0x80000000 : item.Serial.Value & 0x7FFFFFFF;
|
||||
var loc = item.Location;
|
||||
var hue = item.Hue;
|
||||
var flags = item.GetPacketFlags();
|
||||
|
|
|
|||
|
|
@ -66,29 +66,65 @@ namespace Server
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Serial l, Serial r) => l.Value == r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Serial l, uint r) => l.Value == r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Serial l, Serial r) => l.Value != r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Serial l, uint r) => l.Value != r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator >(Serial l, Serial r) => l.Value > r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator >(Serial l, uint r) => l.Value > r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator <(Serial l, Serial r) => l.Value < r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator <(Serial l, uint r) => l.Value < r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator >=(Serial l, Serial r) => l.Value >= r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator >=(Serial l, uint r) => l.Value >= r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator <=(Serial l, Serial r) => l.Value <= r.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator <=(Serial l, uint r) => l.Value <= r;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator +(Serial l, Serial r) => (Serial)(l.Value + r.Value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator +(Serial l, uint r) => (Serial)(l.Value + r);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator ++(Serial l) => (Serial)(l.Value + 1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator -(Serial l, Serial r) => (Serial)(l.Value - r.Value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator -(Serial l, uint r) => (Serial)(l.Value - r);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Serial operator --(Serial l) => (Serial)(l.Value - 1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override string ToString() => $"0x{Value:X8}";
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator uint(Serial a) => a.Value;
|
||||
public static explicit operator uint(Serial a) => a.Value;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator Serial(uint a) => new(a);
|
||||
public static explicit operator Serial(uint a) => new(a);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Equals(Serial other) => Value == other.Value;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -26,40 +27,59 @@ namespace Server
|
|||
|
||||
public BinaryFileReader(Stream stream) => _reader = new BinaryReader(stream);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Close() => _reader.Close();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string ReadString(bool intern = false)
|
||||
{
|
||||
var str = _reader.ReadString();
|
||||
return intern ? Utility.Intern(str) : str;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long ReadLong() => _reader.ReadInt64();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ulong ReadULong() => _reader.ReadUInt64();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int ReadInt() => _reader.ReadInt32();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint ReadUInt() => _reader.ReadUInt32();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short ReadShort() => _reader.ReadInt16();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort ReadUShort() => _reader.ReadUInt16();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double ReadDouble() => _reader.ReadDouble();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float ReadFloat() => _reader.ReadSingle();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte ReadByte() => _reader.ReadByte();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public sbyte ReadSByte() => _reader.ReadSByte();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool ReadBool() => _reader.ReadBoolean();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Serial ReadSerial() => (Serial)_reader.ReadUInt32();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Read(Span<byte> buffer) => _reader.Read(buffer);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long Seek(long offset, SeekOrigin origin) => _reader.BaseStream.Seek(offset, origin);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose() => Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System;
|
|||
using System.Buffers.Binary;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Server.Text;
|
||||
|
||||
|
|
@ -62,6 +63,7 @@ namespace Server
|
|||
return intern ? Utility.Intern(str) : str;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long ReadLong()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadInt64LittleEndian(_buffer.AsSpan(_position, 8));
|
||||
|
|
@ -69,6 +71,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ulong ReadULong()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadUInt64LittleEndian(_buffer.AsSpan(_position, 8));
|
||||
|
|
@ -76,6 +79,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int ReadInt()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadInt32LittleEndian(_buffer.AsSpan(_position, 4));
|
||||
|
|
@ -83,6 +87,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint ReadUInt()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadUInt32LittleEndian(_buffer.AsSpan(_position, 4));
|
||||
|
|
@ -90,6 +95,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short ReadShort()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadInt16LittleEndian(_buffer.AsSpan(_position, 2));
|
||||
|
|
@ -97,6 +103,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort ReadUShort()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadUInt16LittleEndian(_buffer.AsSpan(_position, 2));
|
||||
|
|
@ -104,6 +111,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double ReadDouble()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadDoubleLittleEndian(_buffer.AsSpan(_position, 8));
|
||||
|
|
@ -111,6 +119,7 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float ReadFloat()
|
||||
{
|
||||
var v = BinaryPrimitives.ReadSingleLittleEndian(_buffer.AsSpan(_position, 4));
|
||||
|
|
@ -118,12 +127,18 @@ namespace Server
|
|||
return v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte ReadByte() => _buffer[_position++];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public sbyte ReadSByte() => (sbyte)_buffer[_position++];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool ReadBool() => _buffer[_position++] != 0;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Serial ReadSerial() => (Serial)ReadUInt();
|
||||
|
||||
public int Read(Span<byte> buffer)
|
||||
{
|
||||
var length = buffer.Length;
|
||||
|
|
|
|||
|
|
@ -286,6 +286,9 @@ namespace Server
|
|||
_buffer[Index++] = *(byte*)&value; // up to 30% faster to dereference the raw value on the stack
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Write(Serial serial) => Write(serial.Value);
|
||||
|
||||
internal void InternalWriteString(string value)
|
||||
{
|
||||
var remaining = m_Encoding.GetByteCount(value);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace Server
|
|||
byte ReadByte();
|
||||
sbyte ReadSByte();
|
||||
bool ReadBool();
|
||||
Serial ReadSerial();
|
||||
|
||||
DateTime ReadDateTime() => new(ReadLong(), DateTimeKind.Utc);
|
||||
TimeSpan ReadTimeSpan() => new(ReadLong());
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace Server
|
|||
void Write(byte value);
|
||||
void Write(sbyte value);
|
||||
void Write(bool value);
|
||||
void Write(Serial serial);
|
||||
|
||||
void Write(DateTime value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ namespace Server
|
|||
|
||||
public EntityTypeIndex(string typeName) => TypeName = typeName;
|
||||
|
||||
public Serial CreateIndex(uint num) => num;
|
||||
public Serial CreateIndex(uint num) => (Serial)num;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,22 +55,23 @@ namespace Server
|
|||
private const uint _maxItems = MaxItemSerial - ItemOffset + 1;
|
||||
|
||||
private static Serial _lastMobile = Serial.Zero;
|
||||
private static Serial _lastItem = ItemOffset;
|
||||
private static Serial _lastItem = (Serial)ItemOffset;
|
||||
private static Serial _lastGuild = Serial.Zero;
|
||||
|
||||
public static Serial NewMobile
|
||||
{
|
||||
get
|
||||
{
|
||||
uint last = _lastMobile;
|
||||
var last = _lastMobile;
|
||||
var maxMobile = (Serial)MaxMobileSerial;
|
||||
|
||||
for (int i = 0; i < MaxMobileSerial; i++)
|
||||
{
|
||||
last++;
|
||||
|
||||
if (last > MaxMobileSerial)
|
||||
if (last > maxMobile)
|
||||
{
|
||||
last = 1;
|
||||
last = (Serial)1;
|
||||
}
|
||||
|
||||
if (FindMobile(last) == null)
|
||||
|
|
@ -88,7 +89,7 @@ namespace Server
|
|||
{
|
||||
get
|
||||
{
|
||||
uint last = _lastItem;
|
||||
var last = _lastItem;
|
||||
|
||||
for (int i = 0; i < _maxItems; i++)
|
||||
{
|
||||
|
|
@ -96,7 +97,7 @@ namespace Server
|
|||
|
||||
if (last > MaxItemSerial)
|
||||
{
|
||||
last = ItemOffset;
|
||||
last = (Serial)ItemOffset;
|
||||
}
|
||||
|
||||
if (FindItem(last) == null)
|
||||
|
|
@ -648,7 +649,7 @@ namespace Server
|
|||
|
||||
public static T ReadEntity<T>(this IGenericReader reader) where T : class, ISerializable
|
||||
{
|
||||
Serial serial = reader.ReadUInt();
|
||||
Serial serial = reader.ReadSerial();
|
||||
var typeT = typeof(T);
|
||||
|
||||
// Add to this list when creating new serializable types
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestPartyEmptyList()
|
||||
{
|
||||
Serial m = 0x1024u;
|
||||
Serial m = (Serial)0x1024u;
|
||||
|
||||
var expected = new PartyEmptyList(m).Compile();
|
||||
|
||||
|
|
@ -26,10 +26,10 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestPartyRemoveMember()
|
||||
{
|
||||
var leader = new Mobile(0x1024u);
|
||||
var leader = new Mobile((Serial)0x1024u);
|
||||
leader.DefaultMobileInit();
|
||||
|
||||
var member = new Mobile(0x2048u);
|
||||
var member = new Mobile((Serial)0x2048u);
|
||||
member.DefaultMobileInit();
|
||||
|
||||
var p = new Party(leader);
|
||||
|
|
@ -47,10 +47,10 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestPartyMemberList()
|
||||
{
|
||||
var leader = new Mobile(0x1024u);
|
||||
var leader = new Mobile((Serial)0x1024u);
|
||||
leader.DefaultMobileInit();
|
||||
|
||||
var member = new Mobile(0x2048u);
|
||||
var member = new Mobile((Serial)0x2048u);
|
||||
member.DefaultMobileInit();
|
||||
|
||||
var p = new Party(leader);
|
||||
|
|
@ -70,7 +70,7 @@ namespace UOContent.Tests
|
|||
[InlineData(false)]
|
||||
public void TestPartyTextMessage(bool toAll)
|
||||
{
|
||||
Serial serial = 0x1024u;
|
||||
Serial serial = (Serial)0x1024u;
|
||||
var text = "[Party] Stuff Happens";
|
||||
|
||||
var expected = new PartyTextMessage(toAll, serial, text).Compile();
|
||||
|
|
@ -85,7 +85,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestPartyInvitation()
|
||||
{
|
||||
Serial m = 0x1024u;
|
||||
Serial m = (Serial)0x1024u;
|
||||
|
||||
var expected = new PartyInvitation(m).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,10 @@ namespace UOContent.Tests
|
|||
[InlineData(0x1024u, 1, 100, 200)]
|
||||
public void TestSendStatueAnimation(uint s, int status, int anim, int frame)
|
||||
{
|
||||
Serial serial = s;
|
||||
var expected = new UpdateStatueAnimation(serial, status, anim, frame).Compile();
|
||||
var expected = new UpdateStatueAnimation((Serial)s, status, anim, frame).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendStatueAnimation(serial, status, anim, frame);
|
||||
ns.SendStatueAnimation((Serial)s, status, anim, frame);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ namespace UOContent.Tests
|
|||
[InlineData("🅵🅰🅽🅲🆈 🆃🅴🆇🆃 Author", "🅵🅰🅽🅲🆈 🆃🅴🆇🆃 Title")]
|
||||
public void TestBookCover(string author, string title)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
Serial serial = 0x1001;
|
||||
Serial serial = (Serial)0x1001;
|
||||
var book = new TestBook(serial) { Author = author, Title = title };
|
||||
|
||||
var expected = new BookHeader(m, book).Compile();
|
||||
|
|
@ -57,10 +57,10 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestBookContent()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
Serial serial = 0x1001;
|
||||
Serial serial = (Serial)0x1001;
|
||||
var book = new TestBook(serial) { Author = "Some Author", Title = "Some Title" };
|
||||
book.Pages[0].Lines = new[]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace UOContent.Tests
|
|||
[InlineData("🅵🅰🅽🅲🆈 🆃🅴🆇🆃", true, "First Line", "Second Line")]
|
||||
public void TestSendBBHeaderMessage(string subject, bool content, params string[] lines)
|
||||
{
|
||||
var poster = new Mobile(0x1024u) { Name = "Kamron" };
|
||||
var poster = new Mobile((Serial)0x1024u) { Name = "Kamron" };
|
||||
poster.DefaultMobileInit();
|
||||
|
||||
var bb = new TestBulletinBoard(0x234);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestMahjongJoinGame()
|
||||
{
|
||||
Serial game = 0x1024u;
|
||||
Serial game = (Serial)0x1024u;
|
||||
|
||||
var expected = new MahjongJoinGame(game).Compile();
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ namespace UOContent.Tests
|
|||
[InlineData(false)]
|
||||
public void TestMahjongPlayersInfo(bool showScores)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var game = new MahjongGame { ShowScores = showScores };
|
||||
|
|
@ -67,7 +67,7 @@ namespace UOContent.Tests
|
|||
[InlineData(false)]
|
||||
public void TestMahjongTilesInfo(bool spectatorVision)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var game = new MahjongGame { SpectatorVision = spectatorVision };
|
||||
|
|
@ -87,7 +87,7 @@ namespace UOContent.Tests
|
|||
[InlineData(false)]
|
||||
public void TestMahjongTileInfo(bool spectatorVision)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var game = new MahjongGame { SpectatorVision = spectatorVision };
|
||||
|
|
@ -105,7 +105,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestMahjongRelieve()
|
||||
{
|
||||
Serial game = 0x1024u;
|
||||
Serial game = (Serial)0x1024u;
|
||||
|
||||
var expected = new MahjongRelieve(game).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestCorpseEquipPacket()
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var weapon = new VikingSword();
|
||||
|
|
@ -36,7 +36,7 @@ namespace UOContent.Tests
|
|||
[InlineData(ProtocolChanges.ContainerGridLines)]
|
||||
public void TestCorpseContainerPacket(ProtocolChanges changes)
|
||||
{
|
||||
var m = new Mobile(0x1);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var weapon = new VikingSword();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace UOContent.Tests
|
|||
|
||||
var list = new List<IEntity> { item1, beholder.Object };
|
||||
var notContained = new List<IEntity> { item2 };
|
||||
var boat = new TestBoat(0x3000, list, notContained)
|
||||
var boat = new TestBoat((Serial)0x3000, list, notContained)
|
||||
{
|
||||
Location = new Point3D(10, 20, 15),
|
||||
Facing = Direction.Right,
|
||||
|
|
@ -87,7 +87,7 @@ namespace UOContent.Tests
|
|||
|
||||
var list = new List<IEntity> { item1, beholder.Object };
|
||||
var notContained = new List<IEntity> { item2 };
|
||||
var boat = new TestBoat(0x3000, list, notContained)
|
||||
var boat = new TestBoat((Serial)0x3000, list, notContained)
|
||||
{
|
||||
Location = new Point3D(10, 20, 15),
|
||||
Facing = Direction.Right
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ namespace UOContent.Tests
|
|||
[InlineData(0x1001u)]
|
||||
public void TestBeginHouseCustomization(uint serial)
|
||||
{
|
||||
var expected = new BeginHouseCustomization(serial).Compile();
|
||||
var expected = new BeginHouseCustomization((Serial)serial).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendBeginHouseCustomization(serial);
|
||||
ns.SendBeginHouseCustomization((Serial)serial);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
@ -28,10 +28,10 @@ namespace UOContent.Tests
|
|||
[InlineData(0x1001u)]
|
||||
public void TestEndHouseCustomization(uint serial)
|
||||
{
|
||||
var expected = new EndHouseCustomization(serial).Compile();
|
||||
var expected = new EndHouseCustomization((Serial)serial).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendEndHouseCustomization(serial);
|
||||
ns.SendEndHouseCustomization((Serial)serial);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
@ -42,10 +42,10 @@ namespace UOContent.Tests
|
|||
[InlineData(0x1001u, 100)]
|
||||
public void TestDesignStateGeneral(uint serial, int revision)
|
||||
{
|
||||
var expected = new DesignStateGeneral(serial, revision).Compile();
|
||||
var expected = new DesignStateGeneral((Serial)serial, revision).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDesignStateGeneral(serial, revision);
|
||||
ns.SendDesignStateGeneral((Serial)serial, revision);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
@ -54,7 +54,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestHouseDesignStateDetailed()
|
||||
{
|
||||
Serial serial = 0x40000001;
|
||||
Serial serial = (Serial)0x40000001;
|
||||
var revision = 10;
|
||||
var tiles = new MultiTileEntry[250];
|
||||
for (var i = 0; i < tiles.Length; i++)
|
||||
|
|
|
|||
|
|
@ -56,14 +56,14 @@ namespace Server.Network
|
|||
private readonly bool[] m_PlaneUsed = new bool[9];
|
||||
private readonly byte[] m_PrimBuffer = new byte[4];
|
||||
|
||||
public DesignStateDetailed(uint serial, int revision, int xMin, int yMin, int xMax, int yMax, MultiTileEntry[] tiles)
|
||||
public DesignStateDetailed(Serial serial, int revision, int xMin, int yMin, int xMax, int yMax, MultiTileEntry[] tiles)
|
||||
: base(0xD8)
|
||||
{
|
||||
EnsureCapacity(17 + tiles.Length * 5);
|
||||
|
||||
Write((byte)0x03); // Compression Type
|
||||
Write((byte)0x00); // Unknown
|
||||
Write(serial);
|
||||
Write(serial.Value);
|
||||
Write(revision);
|
||||
Write((short)tiles.Length);
|
||||
Write((short)0); // Buffer length : reserved
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(100000, 100000)]
|
||||
public void TestCancelArrowHS(int x, int y)
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new CancelArrowHS(x, y, serial).Compile();
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ namespace Server.Tests.Network
|
|||
[InlineData(100000, 100000)]
|
||||
public void TestSetArrowHS(int x, int y)
|
||||
{
|
||||
Serial serial = 0x1024;
|
||||
Serial serial = (Serial)0x1024;
|
||||
|
||||
var expected = new SetArrowHS(x, y, serial).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ namespace UOContent.Tests
|
|||
{
|
||||
var timeSpan = new TimeSpan(ts);
|
||||
var expected = new AddBuffPacket(
|
||||
mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan
|
||||
(Serial)mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan
|
||||
).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
BuffInfo.SendAddBuffPacket(ns, mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
|
||||
BuffInfo.SendAddBuffPacket(ns, (Serial)mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
@ -29,7 +29,7 @@ namespace UOContent.Tests
|
|||
[Fact]
|
||||
public void TestRemoveBuffIcon()
|
||||
{
|
||||
Serial m = 0x1024;
|
||||
Serial m = (Serial)0x1024;
|
||||
var buffIcon = BuffIcon.Disguised;
|
||||
var expected = new RemoveBuffPacket(m, buffIcon).Compile();
|
||||
|
||||
|
|
|
|||
|
|
@ -1029,7 +1029,7 @@ namespace Server.Accounting
|
|||
try
|
||||
{
|
||||
var index = Utility.GetXMLInt32(Utility.GetAttribute(ele, "index", "0"), 0);
|
||||
var serial = Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0);
|
||||
var serial = (Serial)Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0);
|
||||
|
||||
if (index >= 0 && index < list.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Server.Accounting
|
|||
{
|
||||
get
|
||||
{
|
||||
uint last = _lastAccount;
|
||||
var last = _lastAccount;
|
||||
|
||||
for (uint i = 0; i < uint.MaxValue; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Server.Commands.Generic
|
|||
{
|
||||
if (e.Length >= 2)
|
||||
{
|
||||
Serial serial = e.GetUInt32(0);
|
||||
Serial serial = (Serial)e.GetUInt32(0);
|
||||
|
||||
object obj = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ namespace Server.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
var ser = e.GetUInt32(0);
|
||||
var ser = (Serial)e.GetUInt32(0);
|
||||
|
||||
var ent = World.FindEntity(ser);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Server.Commands
|
|||
{
|
||||
if (e.Length == 1)
|
||||
{
|
||||
var ent = World.FindEntity(e.GetUInt32(0));
|
||||
var ent = World.FindEntity((Serial)e.GetUInt32(0));
|
||||
|
||||
if (ent == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
2 => new Hinge(3),
|
||||
3 => new Key(),
|
||||
4 => new Scissors(),
|
||||
5 => new BarrelTap(3),
|
||||
5 => new BarrelTap(),
|
||||
6 => new BarrelHoops(),
|
||||
7 => new Gears(3),
|
||||
8 => new Lockpick(3),
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ namespace Server.Engines.MLQuests
|
|||
var quest = MLQuestSystem.ReadQuestRef(reader);
|
||||
|
||||
// TODO: Serialize quester TYPE too, the quest giver reference then becomes optional (only for escorts)
|
||||
var quester = World.FindEntity(reader.ReadUInt()) as IQuestGiver;
|
||||
var quester = reader.ReadEntity<IEntity>() as IQuestGiver;
|
||||
|
||||
var claimReward = reader.ReadBool();
|
||||
var objectives = reader.ReadInt();
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace Server.Gumps
|
|||
{
|
||||
try
|
||||
{
|
||||
var serial = Utility.ToUInt32(text);
|
||||
var serial = (Serial)Utility.ToUInt32(text);
|
||||
|
||||
var toSet = World.FindEntity(serial);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
@ -52,7 +52,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
@ -88,7 +88,7 @@ namespace Server.Items
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
|
||||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Server.Network
|
|||
|
||||
int packetID = reader.ReadByte();
|
||||
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BaseBulletinBoard board || !board.CheckRange(from))
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBulletinBoard board || !board.CheckRange(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRequestContent(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
var thread = World.FindItem(reader.ReadUInt32()) as BulletinMessage;
|
||||
var thread = World.FindItem((Serial)reader.ReadUInt32()) as BulletinMessage;
|
||||
|
||||
if (thread != null && thread.Parent != board)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ namespace Server.Network
|
|||
|
||||
public static void BBRemoveMessage(Mobile from, BaseBulletinBoard board, CircularBufferReader reader)
|
||||
{
|
||||
if (World.FindItem(reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BulletinMessage msg || msg.Parent != board)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Server.Items
|
|||
{
|
||||
public abstract class Food : Item
|
||||
{
|
||||
public Food(int itemID, int amount) : base(itemID)
|
||||
public Food(int itemID, int amount = 1) : base(itemID)
|
||||
{
|
||||
Stackable = true;
|
||||
Amount = amount;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
public static void OnPacket(NetState state, CircularBufferReader reader, ref int packetLength)
|
||||
{
|
||||
var game = World.FindItem(reader.ReadUInt32()) as MahjongGame;
|
||||
var game = World.FindItem((Serial)reader.ReadUInt32()) as MahjongGame;
|
||||
|
||||
game?.Players.CheckPlayers();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Server.Network
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (!(World.FindItem(reader.ReadUInt32()) is MapItem map))
|
||||
if (!(World.FindItem((Serial)reader.ReadUInt32()) is MapItem map))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ namespace Server.Items
|
|||
writer.WriteEncodedInt(TriggerRange);
|
||||
}
|
||||
|
||||
private IEntity ReadEntity(IGenericReader reader) => World.FindEntity(reader.ReadUInt());
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
|
@ -243,8 +241,8 @@ namespace Server.Items
|
|||
TriggerDelay = reader.ReadTimeSpan();
|
||||
SoundDelay = reader.ReadTimeSpan();
|
||||
|
||||
m_Source = ReadEntity(reader);
|
||||
m_Target = ReadEntity(reader);
|
||||
m_Source = reader.ReadEntity<IEntity>();
|
||||
m_Target = reader.ReadEntity<IEntity>();
|
||||
Sequence = reader.ReadEntity<EffectController>();
|
||||
|
||||
FixedDirection = reader.ReadBool();
|
||||
|
|
|
|||
|
|
@ -928,7 +928,7 @@ namespace Server.Guilds
|
|||
else
|
||||
{
|
||||
var g = uint.TryParse(arg, out var id)
|
||||
? World.FindGuild(id) as Guild
|
||||
? World.FindGuild((Serial)id) as Guild
|
||||
: FindByAbbrev(arg) as Guild ?? FindByName(arg) as Guild;
|
||||
|
||||
if (g != null)
|
||||
|
|
|
|||
|
|
@ -845,6 +845,8 @@ namespace Server.Mobiles
|
|||
PackGold(100, 200);
|
||||
}
|
||||
|
||||
private static readonly Serial _COFFEE = (Serial)0x7FC0FFEE;
|
||||
|
||||
public virtual void VendorBuy(Mobile from)
|
||||
{
|
||||
if (!IsActiveSeller)
|
||||
|
|
@ -898,7 +900,7 @@ namespace Server.Mobiles
|
|||
new BuyItemState(
|
||||
buyItem.Name,
|
||||
cont.Serial,
|
||||
disp?.Serial ?? 0x7FC0FFEE,
|
||||
disp?.Serial ?? _COFFEE,
|
||||
buyItem.Price,
|
||||
buyItem.Amount,
|
||||
buyItem.ItemID,
|
||||
|
|
|
|||
|
|
@ -3002,7 +3002,7 @@ namespace Server.Multis
|
|||
for (var i = 0; i < relocatedCount; i++)
|
||||
{
|
||||
var relLocation = reader.ReadPoint3D();
|
||||
var entity = World.FindEntity(reader.ReadUInt());
|
||||
var entity = reader.ReadEntity<IEntity>();
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1770,7 +1770,7 @@ namespace Server.Multis
|
|||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
if (World.FindItem(reader.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map &&
|
||||
if (World.FindItem((Serial)reader.ReadUInt32()) is HouseFoundation foundation && from.Map == foundation.Map &&
|
||||
from.InRange(foundation.GetWorldLocation(), 24) &&
|
||||
from.CanSee(foundation))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server.Multis
|
|||
private const int maxPerPlaneOffsetBuffer = 750;
|
||||
private static readonly int maxPackedPlaneOffsetBuffer = Zlib.MaxPackSize(maxPerPlaneOffsetBuffer * 5);
|
||||
|
||||
public static byte[] CreateHouseDesignStateDetailed(uint serial, int revision, MultiComponentList components)
|
||||
public static byte[] CreateHouseDesignStateDetailed(Serial serial, int revision, MultiComponentList components)
|
||||
{
|
||||
var xMin = components.Min.X;
|
||||
var yMin = components.Min.Y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue