### Summary
- Removes Fastwalk system
- Removed the following settings:
- `movement.enableFastWalkPrevention`
- `movement.fastwalkExemptionLevel`
- Adds movement throttle system.
- Adds the following settings:
- `movement.throttleReset` - Default value is `1000` (1 second).
- `movement.throttleThreshold` - Default value is `400` (400ms).
### Movement Throttling
This new system will trigger if a player requests 400ms (configurable) worth of movements quicker than wall clock time. When this happens, the player is throttled (all incoming packets to the server are halted) until wall clock time catches up with the requests. Upon each throttle, the player receives enough credit to handle up to 400ms of "lag" as a grace/catch-up.
### Developer Notes
We use two throttle queues to prevent an infinite loop.
71 lines
2 KiB
C#
71 lines
2 KiB
C#
using System;
|
|
using Server.Network;
|
|
using Xunit;
|
|
|
|
namespace Server.Tests.Network
|
|
{
|
|
public class MovementPacketTests : IClassFixture<ServerFixture>
|
|
{
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(1)]
|
|
[InlineData(2)]
|
|
public void TestSpeedControl(byte speedControl)
|
|
{
|
|
var expected = new SpeedControl(speedControl).Compile();
|
|
|
|
var ns = PacketTestUtilities.CreateTestNetState();
|
|
ns.SendSpeedControl((SpeedControlSetting)speedControl);
|
|
|
|
var result = ns.SendPipe.Reader.TryRead();
|
|
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestMovePlayer()
|
|
{
|
|
const Direction d = Direction.Left;
|
|
var expected = new MovePlayer(d).Compile();
|
|
|
|
var ns = PacketTestUtilities.CreateTestNetState();
|
|
ns.SendMovePlayer(d);
|
|
|
|
var result = ns.SendPipe.Reader.TryRead();
|
|
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestMovementRej()
|
|
{
|
|
var m = new Mobile((Serial)0x1);
|
|
m.DefaultMobileInit();
|
|
|
|
const byte seq = 100;
|
|
|
|
var expected = new MovementRej(seq, m).Compile();
|
|
|
|
var ns = PacketTestUtilities.CreateTestNetState();
|
|
ns.SendMovementRej(seq, m);
|
|
|
|
var result = ns.SendPipe.Reader.TryRead();
|
|
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestMovementAck()
|
|
{
|
|
var m = new Mobile((Serial)0x1);
|
|
m.DefaultMobileInit();
|
|
|
|
const byte seq = 100;
|
|
|
|
var expected = MovementAck.Instantiate(seq, m).Compile();
|
|
|
|
var ns = PacketTestUtilities.CreateTestNetState();
|
|
ns.SendMovementAck(seq, m);
|
|
|
|
var result = ns.SendPipe.Reader.TryRead();
|
|
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
|
}
|
|
}
|
|
}
|