diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePacketTests.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePacketTests.cs index 01f551bdd..1a675e85d 100644 --- a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePacketTests.cs +++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePacketTests.cs @@ -477,5 +477,18 @@ namespace Server.Tests.Network var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } + + [Fact] + public void TestRemoveEntity() + { + Serial e = 0x1000; + var expected = new RemoveEntity(e).Compile(); + + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendRemoveEntity(e); + + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); + } } } diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePackets.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePackets.cs index d1e8bb3f8..932b241e3 100644 --- a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePackets.cs +++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/MobilePackets.cs @@ -635,4 +635,12 @@ namespace Server.Tests.Network Stream.Write(0); // terminate } } + + public sealed class RemoveEntity : Packet + { + public RemoveEntity(Serial entity) : base(0x1D, 5) + { + Stream.Write(entity); + } + } } diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPacketTests.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPacketTests.cs index b64789e66..90c5c3788 100644 --- a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPacketTests.cs +++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPacketTests.cs @@ -7,158 +7,124 @@ namespace Server.Tests.Network { public class PlayerPacketTests : IClassFixture { - [Fact] - public void TestStatLockInfo() + [Theory] + [InlineData(StatLockType.Down, StatLockType.Up, StatLockType.Locked)] + public void TestStatLockInfo(StatLockType str, StatLockType intel, StatLockType dex) { var m = new Mobile(0x1); m.DefaultMobileInit(); + m.StrLock = str; + m.IntLock = intel; + m.DexLock = dex; - var data = new StatLockInfo(m).Compile(); + var expected = new StatLockInfo(m).Compile(); - Span expectedData = stackalloc byte[12]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendStatLockInfo(m); - expectedData.Write(ref pos, (byte)0xBF); // Packet ID - expectedData.Write(ref pos, (ushort)12); // Length - expectedData.Write(ref pos, (ushort)0x19); // Sub-packet - expectedData.Write(ref pos, (byte)2); // Command - expectedData.Write(ref pos, m.Serial); - expectedData.Write(ref pos, (ushort)(((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock)); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Fact] - public void TestChangeUpdateRange() + [Theory] + [InlineData(0)] + [InlineData(10)] + [InlineData(200)] + public void TestChangeUpdateRange(int range) { - byte range = 10; - var data = new ChangeUpdateRange(range).Compile(); + var expected = new ChangeUpdateRange(range).Compile(); - Span expectedData = stackalloc byte[2]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendChangeUpdateRange((byte)range); - expectedData.Write(ref pos, (byte)0xC8); // Packet ID - expectedData.Write(ref pos, range); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Theory, InlineData(false), InlineData(true)] - public void TestDeathStatus(bool isDead) + [Theory] + [InlineData(false)] + [InlineData(true)] + public void TestDeathStatus(bool dead) { - var data = new DeathStatus(isDead).Compile(); + var expected = new DeathStatus(dead).Compile(); - Span expectedData = stackalloc byte[2]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendDeathStatus(dead); - const byte dead = 0; - const byte alive = 2; - expectedData.Write(ref pos, (byte)0x2C); // Packet ID - expectedData.Write(ref pos, isDead ? dead : alive); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Theory, InlineData(0, true), InlineData(0, false), InlineData(100, true), InlineData(1000, false)] + [Theory] + [InlineData(0, true)] + [InlineData(0, false)] + [InlineData(100, true)] + [InlineData(1000, false)] public void TestSpecialAbility(int abilityId, bool active) { - var data = new ToggleSpecialAbility(abilityId, active).Compile(); + var expected = new ToggleSpecialAbility(abilityId, active).Compile(); - Span expectedData = stackalloc byte[8]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendToggleSpecialAbility(abilityId, active); - expectedData.Write(ref pos, (byte)0xBF); // Packet ID - expectedData.Write(ref pos, (ushort)0x8); // Length - expectedData.Write(ref pos, (ushort)0x25); // Sub-packet - expectedData.Write(ref pos, (ushort)abilityId); - expectedData.Write(ref pos, active); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Theory, InlineData("This is a header", "This is a body", "This is a footer"), InlineData(null, null, null)] - public void TestDisplayProfile(string header, string body, string footer) + [Theory] + [InlineData(0x1000u, "This is a header", "This is a body", "This is a footer")] + [InlineData(0x1000u, null, null, null)] + public void TestDisplayProfile(uint serial, string header, string body, string footer) { - Serial m = 0x1000; + Serial m = serial; + var expected = new DisplayProfile(m, header, body, footer).Compile(); - var data = new DisplayProfile(m, header, body, footer).Compile(); + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendDisplayProfile(m, header, body, footer); - header ??= ""; - body ??= ""; - footer ??= ""; - - var length = 12 + header.Length + footer.Length * 2 + body.Length * 2; - - Span expectedData = stackalloc byte[length]; - var pos = 0; - - expectedData.Write(ref pos, (byte)0xB8); // Packet ID - expectedData.Write(ref pos, (ushort)length); // Length - expectedData.Write(ref pos, m); // Mobile Serial or Serial.Zero - expectedData.WriteAsciiNull(ref pos, header); - expectedData.WriteBigUniNull(ref pos, footer); - expectedData.WriteBigUniNull(ref pos, body); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Theory, InlineData(LRReason.CannotLift), InlineData(LRReason.TryToSteal)] + [Theory] + [InlineData(LRReason.CannotLift)] + [InlineData(LRReason.TryToSteal)] public void TestLiftRej(LRReason reason) { - var data = new LiftRej(reason).Compile(); + var expected = new LiftRej(reason).Compile(); - Span expectedData = stackalloc byte[2]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendLiftReject(reason); - expectedData.Write(ref pos, (byte)0x27); // Packet ID - expectedData.Write(ref pos, (byte)reason); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } [Fact] public void TestLogoutAck() { - var data = new LogoutAck().Compile(); + var expected = new LogoutAck().Compile(); - Span expectedData = stackalloc byte[2]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendLogoutAck(); - expectedData.Write(ref pos, (byte)0xD1); // Packet ID - expectedData.Write(ref pos, (byte)0x1); // 1 - Ack - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - [Theory, InlineData(1, 2, 3), InlineData(4, 5, 6)] + [Theory] + [InlineData(1, 2, 3)] + [InlineData(4, 5, 6)] + [InlineData(0x1234, 0x5678, 0x9ABC)] public void TestWeather(int type, int density, int temp) { - var data = new Weather(type, density, temp).Compile(); + var expected = new Weather(type, density, temp).Compile(); - Span expectedData = stackalloc byte[4]; - var pos = 0; + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendWeather((byte)type, (byte)density, (byte)temp); - expectedData.Write(ref pos, (byte)0x65); // Packet ID - expectedData.Write(ref pos, (byte)type); - expectedData.Write(ref pos, (byte)density); - expectedData.Write(ref pos, (byte)temp); - - AssertThat.Equal(data, expectedData); - } - - [Fact] - public void TestRemoveEntity() - { - Serial e = 0x1000; - var data = new RemoveEntity(e).Compile(); - - Span expectedData = stackalloc byte[5]; - var pos = 0; - - expectedData.Write(ref pos, (byte)0x1D); // Packet ID - expectedData.Write(ref pos, e); - - AssertThat.Equal(data, expectedData); + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } [Fact] diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPackets.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPackets.cs new file mode 100644 index 000000000..b078c9827 --- /dev/null +++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/PlayerPackets.cs @@ -0,0 +1,115 @@ +using System; +using Server.HuePickers; + +namespace Server.Network +{ + public sealed class StatLockInfo : Packet + { + public StatLockInfo(Mobile m) : base(0xBF) + { + EnsureCapacity(12); + + Stream.Write((short)0x19); + Stream.Write((byte)2); + Stream.Write(m.Serial); + Stream.Write((byte)0); + + var lockBits = ((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock; + + Stream.Write((byte)lockBits); + } + } + + public sealed class ChangeUpdateRange : Packet + { + private static readonly ChangeUpdateRange[] m_Cache = new ChangeUpdateRange[0x100]; + + public ChangeUpdateRange(int range) : base(0xC8, 2) + { + Stream.Write((byte)range); + } + + public static ChangeUpdateRange Instantiate(int range) + { + var idx = (byte)range; + var p = m_Cache[idx]; + + if (p == null) + { + m_Cache[idx] = p = new ChangeUpdateRange(range); + p.SetStatic(); + } + + return p; + } + } + + public sealed class DeathStatus : Packet + { + public static readonly Packet Dead = SetStatic(new DeathStatus(true)); + public static readonly Packet Alive = SetStatic(new DeathStatus(false)); + + public DeathStatus(bool dead) : base(0x2C, 2) + { + Stream.Write((byte)(dead ? 0 : 2)); + } + + public static Packet Instantiate(bool dead) => dead ? Dead : Alive; + } + + public sealed class ToggleSpecialAbility : Packet + { + public ToggleSpecialAbility(int abilityID, bool active) : base(0xBF) + { + EnsureCapacity(7); + + Stream.Write((short)0x25); + + Stream.Write((short)abilityID); + Stream.Write(active); + } + } + + public sealed class DisplayProfile : Packet + { + public DisplayProfile(Serial m, string header, string body, string footer) : base(0xB8) + { + header ??= ""; + body ??= ""; + footer ??= ""; + + EnsureCapacity(12 + header.Length + footer.Length * 2 + body.Length * 2); + + Stream.Write(m); + Stream.WriteAsciiNull(header); + Stream.WriteBigUniNull(footer); + Stream.WriteBigUniNull(body); + } + } + + public sealed class LiftRej : Packet + { + public LiftRej(LRReason reason) : base(0x27, 2) + { + Stream.Write((byte)reason); + } + } + + public sealed class LogoutAck : Packet + { + public LogoutAck() : base(0xD1, 2) + { + Stream.Write((byte)0x01); + } + } + + public sealed class Weather : Packet + { + public Weather(int type, int density, int temp) : base(0x65, 4) + { + Stream.Write((byte)type); + Stream.Write((byte)density); + Stream.Write((byte)temp); + } + } +} diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 80e475631..e8ca1ca8c 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -856,7 +856,7 @@ namespace Server { m_StrLock = value; - m_NetState?.Send(new StatLockInfo(this)); + m_NetState.SendStatLockInfo(this); } } } @@ -874,7 +874,7 @@ namespace Server { m_DexLock = value; - m_NetState?.Send(new StatLockInfo(this)); + m_NetState.SendStatLockInfo(this); } } } @@ -892,7 +892,7 @@ namespace Server { m_IntLock = value; - m_NetState?.Send(new StatLockInfo(this)); + m_NetState.SendStatLockInfo(this); } } } @@ -4752,8 +4752,6 @@ namespace Server SendIncomingPacket(); OnAfterResurrect(); - - // Send( new DeathStatus( false ) ); } } @@ -5060,7 +5058,7 @@ namespace Server } else { - Send(DeathStatus.Instantiate(true)); + m_NetState.SendDeathStatus(true); Warmode = false; @@ -5086,7 +5084,7 @@ namespace Server ProcessDeltaQueue(); - Send(DeathStatus.Instantiate(false)); + m_NetState.SendDeathStatus(false); CheckStatTimers(); } @@ -5355,7 +5353,7 @@ namespace Server if (rejected && state != null) { - state.Send(new LiftRej(reject)); + state.SendLiftReject(reject); if (item.Deleted) { @@ -8102,7 +8100,7 @@ namespace Server if (from == this) { - Send(new StatLockInfo(this)); + m_NetState.SendStatLockInfo(this); } if (Party is IParty ip) diff --git a/Projects/Server/Network/Packets/IncomingPlayerPackets.cs b/Projects/Server/Network/Packets/IncomingPlayerPackets.cs index 52f1c3b42..4fa23259f 100644 --- a/Projects/Server/Network/Packets/IncomingPlayerPackets.cs +++ b/Projects/Server/Network/Packets/IncomingPlayerPackets.cs @@ -321,7 +321,7 @@ namespace Server.Network public static void LogoutReq(NetState state, CircularBufferReader reader) { - state.Send(new LogoutAck()); + state.SendLogoutAck(); } public static void ChangeSkillLock(NetState state, CircularBufferReader reader) @@ -488,7 +488,7 @@ namespace Server.Network public static void SetUpdateRange(NetState state, CircularBufferReader reader) { - state.Send(ChangeUpdateRange.Instantiate(18)); + state.SendChangeUpdateRange(18); } public static void MobileQuery(NetState state, CircularBufferReader reader) diff --git a/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs b/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs new file mode 100644 index 000000000..07317c76d --- /dev/null +++ b/Projects/Server/Network/Packets/OutgoingPlayerPackets.cs @@ -0,0 +1,126 @@ +/************************************************************************* + * ModernUO * + * Copyright (C) 2019-2020 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: OutgoingPlayerPackets.cs * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +using System.Buffers; +using System.IO; +using System.Runtime.CompilerServices; + +namespace Server.Network +{ + public enum LRReason : byte + { + CannotLift, + OutOfRange, + OutOfSight, + TryToSteal, + AreHolding, + Inspecific + } + + public static class OutgoingPlayerPackets + { + public static void SendStatLockInfo(this NetState ns, Mobile m) + { + if (ns == null || !ns.GetSendBuffer(out var buffer)) + { + return; + } + + var writer = new CircularBufferWriter(buffer); + writer.Write((byte)0xBF); // Packet ID + writer.Write((ushort)12); + writer.Write((short)0x19); + writer.Write((byte)2); + writer.Write(m.Serial); + writer.Write((byte)0); + + var lockBits = ((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock; + + writer.Write((byte)lockBits); + + ns.Send(ref buffer, writer.Position); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void SendChangeUpdateRange(this NetState ns, byte range) + { + ns?.Send(stackalloc byte[] { 0xC8, range }); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void SendDeathStatus(this NetState ns, bool dead) + { + ns?.Send(stackalloc byte[] { 0x2C, dead ? 0 : 2 }); + } + + public static void SendToggleSpecialAbility(this NetState ns, int abilityId, bool active) + { + if (ns == null || !ns.GetSendBuffer(out var buffer)) + { + return; + } + + var writer = new CircularBufferWriter(buffer); + writer.Write((byte)0xBF); // Packet ID + writer.Write((ushort)8); + writer.Write((short)0x25); + writer.Write((short)abilityId); + writer.Write(active); + + ns.Send(ref buffer, writer.Position); + } + + public static void SendDisplayProfile(this NetState ns, Serial m, string header, string body, string footer) + { + if (ns == null || !ns.GetSendBuffer(out var buffer)) + { + return; + } + + header ??= ""; + body ??= ""; + footer ??= ""; + + var writer = new CircularBufferWriter(buffer); + writer.Write((byte)0xB8); // Packet ID + writer.Seek(2, SeekOrigin.Current); + writer.Write(m); + writer.WriteAsciiNull(header); + writer.WriteBigUniNull(footer); + writer.WriteBigUniNull(body); + + writer.WritePacketLength(); + ns.Send(ref buffer, writer.Position); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void SendLiftReject(this NetState ns, LRReason reason) + { + ns?.Send(stackalloc byte[] { 0x27, (byte)reason }); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void SendLogoutAck(this NetState ns) + { + ns?.Send(stackalloc byte[] { 0xD1, 0x01 }); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void SendWeather(this NetState ns, byte type, byte density, byte temp) + { + ns?.Send(stackalloc byte[] { 0x65, type, density, temp }); + } + } +} diff --git a/Projects/Server/Network/Packets/PlayerPackets.cs b/Projects/Server/Network/Packets/PlayerPackets.cs index 8511ff5ef..e7ec0f628 100644 --- a/Projects/Server/Network/Packets/PlayerPackets.cs +++ b/Projects/Server/Network/Packets/PlayerPackets.cs @@ -1,151 +1,8 @@ -/************************************************************************* - * ModernUO * - * Copyright 2019-2020 - ModernUO Development Team * - * Email: hi@modernuo.com * - * File: PlayerPackets.cs * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *************************************************************************/ - using System; using Server.HuePickers; namespace Server.Network { - public enum LRReason : byte - { - CannotLift = 0, - OutOfRange = 1, - OutOfSight = 2, - TryToSteal = 3, - AreHolding = 4, - Inspecific = 5 - } - - public sealed class StatLockInfo : Packet - { - public StatLockInfo(Mobile m) : base(0xBF) - { - EnsureCapacity(12); - - Stream.Write((short)0x19); - Stream.Write((byte)2); - Stream.Write(m.Serial); - Stream.Write((byte)0); - - var lockBits = ((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock; - - Stream.Write((byte)lockBits); - } - } - - public sealed class ChangeUpdateRange : Packet - { - private static readonly ChangeUpdateRange[] m_Cache = new ChangeUpdateRange[0x100]; - - public ChangeUpdateRange(int range) : base(0xC8, 2) - { - Stream.Write((byte)range); - } - - public static ChangeUpdateRange Instantiate(int range) - { - var idx = (byte)range; - var p = m_Cache[idx]; - - if (p == null) - { - m_Cache[idx] = p = new ChangeUpdateRange(range); - p.SetStatic(); - } - - return p; - } - } - - public sealed class DeathStatus : Packet - { - public static readonly Packet Dead = SetStatic(new DeathStatus(true)); - public static readonly Packet Alive = SetStatic(new DeathStatus(false)); - - public DeathStatus(bool dead) : base(0x2C, 2) - { - Stream.Write((byte)(dead ? 0 : 2)); - } - - public static Packet Instantiate(bool dead) => dead ? Dead : Alive; - } - - public sealed class ToggleSpecialAbility : Packet - { - public ToggleSpecialAbility(int abilityID, bool active) : base(0xBF) - { - EnsureCapacity(7); - - Stream.Write((short)0x25); - - Stream.Write((short)abilityID); - Stream.Write(active); - } - } - - public sealed class DisplayProfile : Packet - { - public DisplayProfile(Serial m, string header, string body, string footer) : base(0xB8) - { - header ??= ""; - body ??= ""; - footer ??= ""; - - EnsureCapacity(12 + header.Length + footer.Length * 2 + body.Length * 2); - - Stream.Write(m); - Stream.WriteAsciiNull(header); - Stream.WriteBigUniNull(footer); - Stream.WriteBigUniNull(body); - } - } - - public sealed class LiftRej : Packet - { - public LiftRej(LRReason reason) : base(0x27, 2) - { - Stream.Write((byte)reason); - } - } - - public sealed class LogoutAck : Packet - { - public LogoutAck() : base(0xD1, 2) - { - Stream.Write((byte)0x01); - } - } - - public sealed class Weather : Packet - { - public Weather(int type, int density, int temp) : base(0x65, 4) - { - Stream.Write((byte)type); - Stream.Write((byte)density); - Stream.Write((byte)temp); - } - } - - public sealed class RemoveEntity : Packet - { - public RemoveEntity(Serial entity) : base(0x1D, 5) - { - Stream.Write(entity); - } - } - public sealed class ServerChange : Packet { public ServerChange(Point3D p, Map map) : base(0x76, 16) diff --git a/Projects/UOContent/Misc/Profile.cs b/Projects/UOContent/Misc/Profile.cs index a86a2bb07..23ff42cb9 100644 --- a/Projects/UOContent/Misc/Profile.cs +++ b/Projects/UOContent/Misc/Profile.cs @@ -60,7 +60,7 @@ namespace Server.Misc var body = beheld.Profile ?? ""; var serial = beholder != beheld || !beheld.ProfileLocked ? beheld.Serial : Serial.Zero; - beholder.Send(new DisplayProfile(serial, header, body, footer)); + beholder.NetState.SendDisplayProfile(serial, header, body, footer); } private static string GetAccountDuration(Mobile m) diff --git a/Projects/UOContent/Misc/Weather.cs b/Projects/UOContent/Misc/Weather.cs index 97fd9c53d..3f93ff3fc 100644 --- a/Projects/UOContent/Misc/Weather.cs +++ b/Projects/UOContent/Misc/Weather.cs @@ -354,8 +354,6 @@ namespace Server.Misc type = 2; } - Packet weatherPacket = null; - foreach (var ns in TcpServer.Instances) { var mob = ns.Mobile; @@ -377,15 +375,8 @@ namespace Server.Misc continue; } - if (weatherPacket == null) - { - weatherPacket = Packet.Acquire(new Network.Weather(type, density, temperature)); - } - - ns.Send(weatherPacket); + ns.SendWeather((byte)type, (byte)density, (byte)temperature); } - - Packet.Release(weatherPacket); } m_Stage++; diff --git a/Projects/UOContent/Spells/Base/SpecialMove.cs b/Projects/UOContent/Spells/Base/SpecialMove.cs index 86db6cec1..9e36a638c 100644 --- a/Projects/UOContent/Spells/Base/SpecialMove.cs +++ b/Projects/UOContent/Spells/Base/SpecialMove.cs @@ -216,7 +216,7 @@ namespace Server.Spells if (moveID != -1) { - m.Send(new ToggleSpecialAbility(moveID + 1, false)); + m.NetState.SendToggleSpecialAbility(moveID + 1, false); } } } @@ -278,7 +278,7 @@ namespace Server.Spells if (moveID > 0) { - m.Send(new ToggleSpecialAbility(moveID + 1, true)); + m.NetState.SendToggleSpecialAbility(moveID + 1, true); } TextDefinition.SendMessageTo(m, move.AbilityMessage); @@ -297,7 +297,7 @@ namespace Server.Spells if (moveID > 0) { - m.Send(new ToggleSpecialAbility(moveID + 1, false)); + m.NetState.SendToggleSpecialAbility(moveID + 1, false); } } } diff --git a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs index 6d72a6e41..9c1b44b8e 100644 --- a/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs +++ b/Projects/UOContent/Spells/Bushido/SamuraiSpell.cs @@ -126,7 +126,7 @@ namespace Server.Spells.Bushido if (spellID > 0) { - caster.Send(new ToggleSpecialAbility(spellID + 1, true)); + caster.NetState.SendToggleSpecialAbility(spellID + 1, true); } } @@ -136,7 +136,7 @@ namespace Server.Spells.Bushido if (spellID > 0) { - caster.Send(new ToggleSpecialAbility(spellID + 1, false)); + caster.NetState.SendToggleSpecialAbility(spellID + 1, false); } } }