RynthSuite as of 2026-11-08 (internal 6ec9b64): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:47 -05:00
commit f8fa62b64c
196 changed files with 24980 additions and 633 deletions

View file

@ -37,11 +37,23 @@
// After a death or a login RynthAi's stream of rebuffs kept the count moving,
// so it never read "steady" and a press waited until it gave up.
//
// RynthDefective never resets the client's count itself (ForceResetBusyCount):
// the count is the engine's (its reconciler and watchdogs own it), RynthAi
// stopped resetting it on 2026-10-06 because a reset zeroes actions the server
// hasn't answered yet (each later answer then drives it negative), and nothing
// here needs it at zero: ignoring a leftover is enough to send.
// RynthDefective doesn't reset the client's count itself (ForceResetBusyCount)
// unless the player asks: the count is the engine's (its reconciler and
// watchdogs own it), RynthAi stopped resetting it on 2026-10-06 because a reset
// zeroes actions the server hasn't answered yet (each later answer then drives
// it negative), and nothing here needs it at zero: ignoring a leftover is
// enough to send.
//
// "Shortcuts clear a stuck busy state" (DefSettings.ClearStuckBusy, 2026-11-04,
// off by default; a player's ask): a press held ONLY by the count (BusyHold.Busy
// with nothing of ours in flight or unanswered, no gesture, RynthAi with no
// action of its own, no "You're too busy" from the server in ServerBusyRecentMs)
// sends the reset RynthAi's /ra clearbusy sends (the engine's
// ForceResetBusyCount: the count to 0, the cursor re-read, every plugin's
// mirror told), once per press, then the press goes (BusyClearRule; the use
// controller waits ClearSettleMs for the reset to land on the game's tick,
// then takes what is left as a leftover). Not /ra clearbusy's StopCompletely:
// a press must not stop a run. Never with a real action in flight.
// ============================================================================
using System;
@ -128,6 +140,34 @@ internal static class BusyRule
}
}
/// <summary>
/// Whether a press held by the busy count clears it first (DefSettings.ClearStuckBusy, off by default).
/// Pure: the use controller asks, the tests check every case.
/// </summary>
internal static class BusyClearRule
{
/// <summary>The server answered "You're too busy" this recently: it really is busy, nothing is cleared.</summary>
public const long ServerBusyRecentMs = 5000;
/// <param name="enabled">The player's option.</param>
/// <param name="hold">What <see cref="BusyRule"/> says holds the press.</param>
/// <param name="f">The readings it said it from.</param>
/// <param name="ownInFlight">A use or cast of ours is in flight (sent, not answered or let go).</param>
/// <param name="ownAnswered">Our own last use or cast was answered (UseDone, the item in hand, a refusal); false while one went unanswered.</param>
/// <param name="sinceServerBusyMs">Since the server last answered "You're too busy".</param>
public static bool ShouldClear(bool enabled, BusyHold hold, in BusyFacts f, bool ownInFlight, bool ownAnswered, long sinceServerBusyMs)
{
if (!enabled || hold != BusyHold.Busy || f.Count <= 0) return false; // only the count, and only when it holds
if (ownInFlight) return false; // ours, under way
if (f.SinceOwnSendMs < BusyRule.OwnTrustMs && !ownAnswered) return false; // ours, never answered: it may still be
if (f.Animating) return false; // a gesture: the character is acting
if (f.BotPaced == true) return false; // RynthAi's own action, unanswered
// A RynthAi that doesn't say what it has in flight: its "waiting on the server" bit while fresh.
if (f.BotPaced == null && f.BotWaiting == true && f.BotSteadyMs < BusyRule.BotTrustMs) return false;
return sinceServerBusyMs >= ServerBusyRecentMs; // the server said busy just now
}
}
/// <summary>
/// The clocks behind <see cref="BusyRule"/>: how long each reading has read the same, our own last
/// send, and the leftover count. <see cref="Observe"/> every tick (in or out of the world: a count
@ -194,6 +234,15 @@ internal sealed class BusyGate
/// <summary>Our own use or cast went out now.</summary>
public void NoteOwnSend(long now) => _ownSendMs = now;
/// <summary>
/// The count as it reads now is a leftover (after the player's clear: what the reset didn't take holds
/// this press no more). Only a count above it holds again.
/// </summary>
public void AcceptLeftover()
{
if (_count > _leftover) _leftover = _count;
}
public BusyFacts Facts(long now) => Facts(now, false);
/// <param name="pacedKnown">RynthAi holds for the press (its PacedAction bit is meaningful).</param>

View file

@ -44,6 +44,14 @@ internal sealed unsafe class HostDefWorld : IDefWorld
public bool HoldBot(uint ms) => BotYield.Hold(_host, ms);
public void ReleaseBot() => BotYield.Release(_host);
/// <summary>The busy-count reset of /ra clearbusy (ForceResetBusyCount; the engine runs it on the game's thread).</summary>
public bool ClearBusyCount()
{
if (!_host.HasForceResetBusyCount) return false;
_host.ForceResetBusyCount();
return true;
}
public int RefusalSeq => _host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0;
public bool RefusalNamed(uint objectId) =>

View file

@ -39,6 +39,12 @@ internal interface IDefWorld
bool HoldBot(uint ms);
/// <summary>Ends the player's turn.</summary>
void ReleaseBot();
/// <summary>
/// Resets the client's busy count as RynthAi's /ra clearbusy does (the engine's ForceResetBusyCount:
/// the count to 0 and the cursor re-read, on the game's next tick; every plugin's copy of the count is
/// told). False when this engine can't. Only for "Shortcuts clear a stuck busy state" (BusyClearRule).
/// </summary>
bool ClearBusyCount();
/// <summary>Count of the server's UseDone events; 0 when the engine can't report them.</summary>
int UseDoneSeq { get; }
/// <summary>The error of the server's first UseDone after <paramref name="seqAtSend"/> (0x1D: "You're too busy"); 0 = none or unknown.</summary>
@ -155,6 +161,10 @@ internal static class Stance
/// behind that stream until it gave up. While RynthAi holds, it also says exactly what it has in
/// flight, so only that and our own last use hold a press: the busy count beyond them is a leftover.
///
/// Shortcuts clear a stuck busy state (2026-11-04, Settings.ClearStuckBusy, off by default): a press held
/// only by the busy count, with nothing real in flight (<see cref="BusyClearRule"/>), resets the count as
/// /ra clearbusy does, once per press, then goes (<see cref="ClearSettleMs"/> for the reset to read; logged).
///
/// After a portal (2026-10-29): the engine takes no game action until 5 s after portal space ends
/// (its world-transition gate: AC is still loading the new place), so a press then was refused and
/// reported as "the client didn't take the request". Within <see cref="PortalRetryWindowMs"/> of
@ -188,6 +198,11 @@ internal sealed class UseController
public const long PortalRetryWindowMs = 6000;
/// <summary>How often a refused use or cast is tried again after a portal.</summary>
public const long RefusedRetryMs = 250;
/// <summary>
/// After "Shortcuts clear a stuck busy state" cleared the count for a press: it waits this long for the
/// engine's reset (on the game's next tick) to read, then goes, what is left taken as a leftover.
/// </summary>
public const long ClearSettleMs = 500;
private enum Stage { Sent, WaitWield, Stance, Magic }
@ -227,6 +242,14 @@ internal sealed class UseController
private long _worldBackMs = long.MinValue / 4;
private long _refusedRetryAtMs = long.MinValue / 4;
private UseRequest? _refusedSaid;
// "Shortcuts clear a stuck busy state" (Settings.ClearStuckBusy): the press a clear was sent (or tried)
// for, once per press; when; whether the engine took it. Our own last send answered; the server's last
// "You're too busy".
private UseRequest? _clearedFor;
private long _clearedAtMs;
private bool _clearSent;
private bool _ownAnswered = true;
private long _tooBusyAtMs = long.MinValue / 4;
/// <summary>The engine refused sends this soon after the character came out of portal space: they are tried again.</summary>
private bool JustArrived(long now) => now - _worldBackMs < PortalRetryWindowMs;
@ -277,6 +300,7 @@ internal sealed class UseController
_lastWait = string.Empty;
_retryNotBeforeMs = long.MinValue / 4;
_refusedRetryAtMs = long.MinValue / 4;
_clearedFor = null;
}
/// <summary>
@ -288,6 +312,8 @@ internal sealed class UseController
{
Reset();
_busy.Reset();
_ownAnswered = true;
_tooBusyAtMs = long.MinValue / 4;
}
public void Tick(IDefWorld w)
@ -340,7 +366,7 @@ internal sealed class UseController
if (_pending == null) return;
UseRequest req = _pending;
string? wait = WaitReason(w, now);
string? wait = WaitReason(w, req, now);
if (wait != null)
{
_lastWait = wait;
@ -355,12 +381,18 @@ internal sealed class UseController
Send(w, req, now);
}
private string? WaitReason(IDefWorld w, long now)
private string? WaitReason(IDefWorld w, UseRequest req, long now)
{
if (now - _lastDoneMs < MinGapMs) return "the last action just finished";
if (now < _retryNotBeforeMs) return "the server said the character was busy";
if (now < _refusedRetryAtMs) return "the game is still loading after the portal";
return Hold(now) switch
BusyHold hold = Hold(now);
if (hold == BusyHold.Busy && Settings.ClearStuckBusy)
{
if (ClearStuckBusy(w, req, now) is { } clearing) return clearing;
hold = Hold(now);
}
return hold switch
{
BusyHold.Busy => "the character is busy",
BusyHold.Animation => "an animation is playing",
@ -369,6 +401,40 @@ internal sealed class UseController
};
}
/// <summary>
/// "Shortcuts clear a stuck busy state": <paramref name="req"/> is held by the busy count. When nothing
/// real is in flight (BusyClearRule) the count is reset as /ra clearbusy does, once for this press, and
/// the press waits <see cref="ClearSettleMs"/> for the reset to read; then what is left is a leftover
/// and it goes. Returns the wait while the clear settles, null for the usual rules (nothing cleared, or
/// the clear has settled).
/// </summary>
private string? ClearStuckBusy(IDefWorld w, UseRequest req, long now)
{
const string Clearing = "a stuck busy state is being cleared";
if (ReferenceEquals(_clearedFor, req))
{
if (!_clearSent) return null; // the engine couldn't: the usual rules
if (now - _clearedAtMs < ClearSettleMs) return Clearing;
_busy.AcceptLeftover();
return null;
}
BusyFacts f = _busy.Facts(now, _botHeld);
if (!BusyClearRule.ShouldClear(true, BusyHold.Busy, f, _flight != null, _ownAnswered, now - _tooBusyAtMs)) return null;
_clearedFor = req;
_clearedAtMs = now;
_clearSent = w.ClearBusyCount();
if (!_clearSent)
{
Log?.Invoke($"[RynthDefective] {req.Source}: held only by the client's busy count ({f.Count}), but this RynthCore can't reset it "
+ "(ForceResetBusyCount): waiting as usual");
return null;
}
Log?.Invoke($"[RynthDefective] {req.Source}: held only by the client's busy count ({f.Count}; nothing of ours or RynthAi's in flight, "
+ "no gesture, no 'too busy' from the server): reset it as /ra clearbusy does (Shortcuts clear a stuck busy state), then the use");
Say?.Invoke($"{req.Label}: clearing a stuck busy state...");
return Clearing;
}
/// <summary>The busy gate's verdict now; a leftover it ignores for the first time is logged.</summary>
private BusyHold Hold(long now)
{
@ -444,6 +510,7 @@ internal sealed class UseController
return;
}
_busy.NoteOwnSend(now);
_ownAnswered = false;
_flight = new Flight
{
@ -602,6 +669,7 @@ internal sealed class UseController
return true;
}
_busy.NoteOwnSend(now);
_ownAnswered = false;
f.Stage = Stage.Sent;
f.SentMs = now;
f.StageMs = now;
@ -627,7 +695,12 @@ internal sealed class UseController
{
if (!answered && age >= UseTimeoutMs) Log?.Invoke($"[RynthDefective] no UseDone for {f.What} after {age} ms; carrying on");
Finish(now);
if (answered && w.UseDoneError(f.UseDoneAtSend) == TooBusyError) RetryTooBusy(f, now);
if (answered) _ownAnswered = true;
if (answered && w.UseDoneError(f.UseDoneAtSend) == TooBusyError)
{
_tooBusyAtMs = now; // the server really is busy: nothing is cleared for a while (BusyClearRule)
RetryTooBusy(f, now);
}
return true;
}
return false;
@ -638,6 +711,7 @@ internal sealed class UseController
if (live != null && live.Wielded)
{
Wielded?.Invoke(live);
_ownAnswered = true; // a wield's answer is the item in hand
f.Item = live;
f.Stage = Stage.Stance;
f.StageMs = now;
@ -645,6 +719,7 @@ internal sealed class UseController
}
if (w.RefusalSeq != f.RefusalAtSend && w.RefusalNamed(f.Item.Id))
{
_ownAnswered = true;
Warn?.Invoke($"{f.Item.FullName}: the server wouldn't let you wield it (a skill, level or slot requirement?).");
Finish(now);
return true;