feat: Adds a movement throttle system. Removes Fastwalk system. (#1511)

### 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.
This commit is contained in:
Kamron Batman 2023-09-27 20:53:22 -07:00 • committed by GitHub
parent 27df6344d9
commit 146abad36e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 106 additions and 322 deletions

View file

@ -1,67 +0,0 @@
using System.Collections.Generic;
using Server.Commands.Generic;
namespace Server.Network;
public static class FastwalkDetection
{
private static readonly HashSet<Mobile> _debugFastwalk = new();
public static void Initialize()
{
TargetCommands.Register(new DebugFastwalk());
EventSink.FastWalk += OnFastwalk;
}
private static void OnFastwalk(FastWalkEventArgs e)
{
var from = e.NetState.Mobile;
if (from == null)
{
return;
}
if (!_debugFastwalk.Contains(from))
{
return;
}
from.PublicOverheadMessage(MessageType.Emote, from.EmoteHue, false, "Fastwalk Detected", accessLevel: AccessLevel.GameMaster);
}
public class DebugFastwalk : BaseCommand
{
public DebugFastwalk()
{
AccessLevel = AccessLevel.GameMaster;
Supports = CommandSupport.AllMobiles;
Commands = new[] { "DebugFastwalk" };
ObjectTypes = ObjectTypes.Mobiles;
ListOptimized = true;
Usage = "DebugFastwalk <on|off>";
Description = "Enables fastwalk debug messages";
}
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
var on = e.Arguments.Length == 0 || e.GetBoolean(0);
foreach (var o in list)
{
if (o is not Mobile m)
{
continue;
}
if (on)
{
_debugFastwalk.Add(m);
}
else
{
_debugFastwalk.Remove(m);
}
}
}
}
}