Updates Combat Packets & Moves Tracking to Content (#298)

- [X] Changes outgoing combat packets
- [X] Moves quest arrow to PlayerMobile and moves quest arrow packets to content.

Bumps release version
This commit is contained in:
Kamron Batman 2020-11-01 21:33:01 -08:00 committed by GitHub
parent 55935d30b4
commit 6f5cb00cdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 373 additions and 319 deletions

View file

@ -1,90 +0,0 @@
using System;
using System.Buffers;
using Server.Network;
using Xunit;
namespace Server.Tests.Network
{
public class ArrowPacketTests
{
[Fact]
public void TestCancelArrow()
{
var data = new CancelArrow().Compile();
Span<byte> expectedData = stackalloc byte[6];
var pos = 0;
expectedData.Write(ref pos, (byte)0xBA); // Packet ID
expectedData.Write(ref pos, (byte)0); // Command
expectedData.Write(ref pos, 0xFFFFFFFF); // X, Y
AssertThat.Equal(data, expectedData);
}
[Theory]
[InlineData(0, 0)]
[InlineData(100, 10)]
[InlineData(100000, 100000)]
public void TestSetArrow(int x, int y)
{
var data = new SetArrow(x, y).Compile();
Span<byte> expectedData = stackalloc byte[6];
var pos = 0;
expectedData.Write(ref pos, (byte)0xBA); // Packet ID
expectedData.Write(ref pos, (byte)0x01); // Command
expectedData.Write(ref pos, (ushort)x);
expectedData.Write(ref pos, (ushort)y);
AssertThat.Equal(data, expectedData);
}
[Theory]
[InlineData(0, 0)]
[InlineData(100, 10)]
[InlineData(100000, 100000)]
public void TestCancelArrowHS(int x, int y)
{
Serial serial = 0x01;
var data = new CancelArrowHS(x, y, serial).Compile();
Span<byte> expectedData = stackalloc byte[10];
var pos = 0;
expectedData.Write(ref pos, (byte)0xBA); // Packet ID
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0); // Command
#else
pos++;
#endif
expectedData.Write(ref pos, (ushort)x);
expectedData.Write(ref pos, (ushort)y);
expectedData.Write(ref pos, serial);
AssertThat.Equal(data, expectedData);
}
[Theory]
[InlineData(0, 0)]
[InlineData(100, 10)]
[InlineData(100000, 100000)]
public void TestSetArrowHS(int x, int y)
{
Serial serial = 0x01;
var data = new SetArrowHS(x, y, serial).Compile();
Span<byte> expectedData = stackalloc byte[10];
var pos = 0;
expectedData.Write(ref pos, (byte)0xBA); // Packet ID
expectedData.Write(ref pos, (byte)0x01); // Command
expectedData.Write(ref pos, (ushort)x);
expectedData.Write(ref pos, (ushort)y);
expectedData.Write(ref pos, serial);
AssertThat.Equal(data, expectedData);
}
}
}

View file

@ -13,22 +13,13 @@ namespace Server.Tests.Network
Serial attacker = 0x1000;
Serial defender = 0x2000;
var data = new Swing(attacker, defender).Compile();
var expected = new Swing(attacker, defender).Compile();
Span<byte> expectedData = stackalloc byte[10];
var pos = 0;
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendSwing(attacker, defender);
expectedData.Write(ref pos, (byte)0x2F); // Packet ID
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
expectedData.Write(ref pos, attacker);
expectedData.Write(ref pos, defender);
AssertThat.Equal(data, expectedData);
var result = ns.SendPipe.Reader.TryRead();
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
}
[Theory]
@ -36,45 +27,27 @@ namespace Server.Tests.Network
[InlineData(false)]
public void TestSetWarMode(bool warmode)
{
var data = new SetWarMode(warmode).Compile();
var expected = new SetWarMode(warmode).Compile();
Span<byte> expectedData = stackalloc byte[5];
var pos = 0;
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendSetWarMode(warmode);
expectedData.Write(ref pos, (byte)0x72); // Packet ID
expectedData.Write(ref pos, warmode);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
expectedData.Write(ref pos, (byte)0x32);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (byte)0);
#else
pos++;
#endif
AssertThat.Equal(data, expectedData);
var result = ns.SendPipe.Reader.TryRead();
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
}
[Fact]
public void TestChangeCombatant()
{
Serial combatant = 0x1000;
Serial serial = 0x1024;
var data = new ChangeCombatant(combatant).Compile();
var expected = new ChangeCombatant(serial).Compile();
Span<byte> expectedData = stackalloc byte[5];
var pos = 0;
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendChangeCombatant(serial);
expectedData.Write(ref pos, (byte)0xAA); // Packet ID
expectedData.Write(ref pos, combatant);
AssertThat.Equal(data, expectedData);
var result = ns.SendPipe.Reader.TryRead();
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
}
}
}

View file

@ -0,0 +1,46 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2020 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: CombatPackets.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 <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server.Network
{
public sealed class Swing : Packet
{
public Swing(Serial attacker, Serial defender) : base(0x2F, 10)
{
Stream.Write((byte)0);
Stream.Write(attacker);
Stream.Write(defender);
}
}
public sealed class SetWarMode : Packet
{
public SetWarMode(bool mode) : base(0x72, 5)
{
Stream.Write(mode);
Stream.Write((byte)0x00);
Stream.Write((byte)0x32);
Stream.Write((byte)0x00);
}
}
public sealed class ChangeCombatant : Packet
{
public ChangeCombatant(Serial combatant) : base(0xAA, 5)
{
Stream.Write(combatant);
}
}
}