Buff chain: no fast-path buff right after a movement call
With FastBuffChain on, a buff went out 50 ms after a nav StopCompletelyBy: the fast path skips the animation gate, and the motion the stop starts was still playing on the client. MoveAudit now counts every movement call routed through it that reaches the client (MovementSends: a start, a stop, a turn, or a held stop sent by FlushPendingStops). Jumps and movement other plugins send on their own (RynthNav, RynthLua) do not go through MoveAudit and are not counted. BuffCastChain records the count when a buff goes out, and Eligible refuses the fast path when it has changed since. While a held stop is still waiting to be sent (MoveAudit.HasPendingStop) the fast path is refused too: CastSpellFor would flush that stop inside the fast-path cast itself, after the count the chain compares. The next buff then takes the normal path, which waits on the animation gate (GestureHolds) as every buff did before the chain. Nothing else reads the count, so no other MayStart caller changes. MovementWaits (counted once per buff) is in the chain's Describe line. Tests: 50 ms after a nav stop, and after a nav turn, the next buff waits for the animation and goes once it is over, not on the fast path; stops held while the buff was unanswered keep the next buff off the fast path; the same sequence with no movement takes the fast path (control). The stop, turn and held-stop checks fail with their guard disabled. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
88502d4efa
commit
bbc000f10b
4 changed files with 99 additions and 15 deletions
|
|
@ -45,6 +45,14 @@ internal static class MoveAudit
|
|||
private static string _lastKey = "";
|
||||
private static long _lastWrittenMs = long.MinValue;
|
||||
private static int _repeats;
|
||||
|
||||
// Every movement call that reached the client (a start, a stop, a turn, a held stop sent later).
|
||||
private static long _movementSends;
|
||||
|
||||
/// <summary>Movement calls that reached the client so far: a start, a stop, a turn, or a held stop
|
||||
/// sent by FlushPendingStops. Only ever grows (Reset aside); a reader compares two values to know
|
||||
/// whether anything moved in between (BuffCastChain: no fast-path buff right after a movement change).</summary>
|
||||
internal static long MovementSends { get { lock (Gate) return _movementSends; } }
|
||||
private static string _repeatLastArg = "";
|
||||
private static long _repeatFirstMs;
|
||||
|
||||
|
|
@ -54,7 +62,7 @@ internal static class MoveAudit
|
|||
if (HeldForAction(host, who, on ? "SetAutoRun(True)" : "SetAutoRun(False)", isStop: !on, deferAs: on ? null : PendingStop.AutoRunOff())) return false;
|
||||
if (on) FlushPendingStops(host, "before a start");
|
||||
Note(host, who, "SetAutoRun", on ? "True" : "False", collapseByKindOnly: false);
|
||||
lock (Gate) { _autoRunOn = on; if (on) _lastStartMs = NowMs(); else _pendingAutoRunOff = null; }
|
||||
lock (Gate) { _autoRunOn = on; if (on) _lastStartMs = NowMs(); else _pendingAutoRunOff = null; _movementSends++; }
|
||||
return host.SetAutoRun(on);
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +70,7 @@ internal static class MoveAudit
|
|||
{
|
||||
if (HeldForAction(host, who, "StopCompletely()", isStop: true, deferAs: PendingStop.Complete())) return false;
|
||||
Note(host, who, "StopCompletely", "", collapseByKindOnly: false);
|
||||
lock (Gate) { _autoRunOn = false; _motionsOn.Clear(); ClearPendingLocked(); } // clears everything AC has on
|
||||
lock (Gate) { _autoRunOn = false; _motionsOn.Clear(); ClearPendingLocked(); _movementSends++; } // clears everything AC has on
|
||||
return host.StopCompletely();
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +80,7 @@ internal static class MoveAudit
|
|||
if (HeldForAction(host, who, $"SetMotion(0x{motion:X8}, {(on ? "True" : "False")})", isStop: !on, motion, on ? null : PendingStop.MotionOff(motion))) return false;
|
||||
if (on) FlushPendingStops(host, "before a start");
|
||||
Note(host, who, "SetMotion", $"0x{motion:X8}, {(on ? "True" : "False")}", collapseByKindOnly: false);
|
||||
lock (Gate) { if (on) { _motionsOn.Add(motion); _lastStartMs = NowMs(); } else { _motionsOn.Remove(motion); _pendingMotionOff.Remove(motion); } }
|
||||
lock (Gate) { if (on) { _motionsOn.Add(motion); _lastStartMs = NowMs(); } else { _motionsOn.Remove(motion); _pendingMotionOff.Remove(motion); } _movementSends++; }
|
||||
return host.SetMotion(motion, on);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +90,7 @@ internal static class MoveAudit
|
|||
if (HeldForAction(host, who, $"DoMovement(0x{motion:X8})", isStop: false)) return false;
|
||||
FlushPendingStops(host, "before a start");
|
||||
Note(host, who, "DoMovement", $"0x{motion:X8}, {speed:0.##}, {holdKey}", collapseByKindOnly: false);
|
||||
lock (Gate) { _motionsOn.Add(motion); _lastStartMs = NowMs(); }
|
||||
lock (Gate) { _motionsOn.Add(motion); _lastStartMs = NowMs(); _movementSends++; }
|
||||
return host.DoMovement(motion, speed, holdKey);
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +264,7 @@ internal static class MoveAudit
|
|||
if (host.HasStopCompletely)
|
||||
{
|
||||
host.StopCompletely();
|
||||
lock (Gate) { _autoRunOn = false; _motionsOn.Clear(); _deferredStopsSent++; }
|
||||
lock (Gate) { _autoRunOn = false; _motionsOn.Clear(); _deferredStopsSent++; _movementSends++; }
|
||||
sent.Add($"StopCompletely() for {complete}");
|
||||
}
|
||||
else
|
||||
|
|
@ -269,21 +277,21 @@ internal static class MoveAudit
|
|||
if (autoRunOff != null)
|
||||
{
|
||||
host.SetAutoRun(false);
|
||||
lock (Gate) { _autoRunOn = false; _deferredStopsSent++; }
|
||||
lock (Gate) { _autoRunOn = false; _deferredStopsSent++; _movementSends++; }
|
||||
sent.Add($"SetAutoRun(False) for {autoRunOff}");
|
||||
}
|
||||
foreach (var m in motionOff)
|
||||
{
|
||||
if (!host.HasSetMotion) break;
|
||||
host.SetMotion(m.Key, false);
|
||||
lock (Gate) { _motionsOn.Remove(m.Key); _deferredStopsSent++; }
|
||||
lock (Gate) { _motionsOn.Remove(m.Key); _deferredStopsSent++; _movementSends++; }
|
||||
sent.Add($"SetMotion(0x{m.Key:X8}, False) for {m.Value}");
|
||||
}
|
||||
foreach (var s in stopMovement)
|
||||
{
|
||||
if (!host.HasStopMovement) break;
|
||||
host.StopMovement(s.Key, s.Value.holdKey);
|
||||
lock (Gate) { _motionsOn.Remove(s.Key); _deferredStopsSent++; }
|
||||
lock (Gate) { _motionsOn.Remove(s.Key); _deferredStopsSent++; _movementSends++; }
|
||||
sent.Add($"StopMovement(0x{s.Key:X8}) for {s.Value.who}");
|
||||
}
|
||||
}
|
||||
|
|
@ -331,7 +339,7 @@ internal static class MoveAudit
|
|||
{
|
||||
if (HeldForAction(host, who, $"StopMovement(0x{motion:X8})", isStop: true, motion, PendingStop.StopMovement(motion, holdKey))) return false;
|
||||
Note(host, who, "StopMovement", $"0x{motion:X8}, {holdKey}", collapseByKindOnly: false);
|
||||
lock (Gate) { _motionsOn.Remove(motion); _pendingStopMovement.Remove(motion); }
|
||||
lock (Gate) { _motionsOn.Remove(motion); _pendingStopMovement.Remove(motion); _movementSends++; }
|
||||
return host.StopMovement(motion, holdKey);
|
||||
}
|
||||
|
||||
|
|
@ -341,6 +349,7 @@ internal static class MoveAudit
|
|||
if (HeldForUse(host, who, "TurnToHeading")) return false;
|
||||
if (HeldForAction(host, who, "TurnToHeading", isStop: false)) return false;
|
||||
Note(host, who, "TurnToHeading", headingDegrees.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture), collapseByKindOnly: true);
|
||||
lock (Gate) _movementSends++;
|
||||
return host.TurnToHeading(headingDegrees);
|
||||
}
|
||||
|
||||
|
|
@ -400,6 +409,7 @@ internal static class MoveAudit
|
|||
ClearPendingLocked();
|
||||
_pendingSinceMs = 0;
|
||||
_deferredStopsSent = 0;
|
||||
_movementSends = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue