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

@ -60,43 +60,6 @@ public static class OutgoingMovementPackets
ns.Send(writer.Span);
}
public static void SendInitialFastwalkStack(this NetState ns, uint[] keys)
{
if (ns.CannotSendPackets())
{
return;
}
var writer = new SpanWriter(stackalloc byte[29]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)29);
writer.Write((ushort)0x1); // Subpacket
writer.Write(keys[0]);
writer.Write(keys[1]);
writer.Write(keys[2]);
writer.Write(keys[3]);
writer.Write(keys[4]);
writer.Write(keys[5]);
ns.Send(writer.Span);
}
public static void SendFastwalkStackKey(this NetState ns, uint key = 0)
{
if (ns.CannotSendPackets())
{
return;
}
var writer = new SpanWriter(stackalloc byte[9]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)9);
writer.Write((ushort)0x2); // Subpacket
writer.Write(key);
ns.Send(writer.Span);
}
public static void SendTimeSyncResponse(this NetState ns)
{
if (ns.CannotSendPackets())