Snapshot for release 2026.10.29.3 (internal f81a090)

This commit is contained in:
Tom Bohar 2026-10-29 15:22:43 -04:00
commit aa8bf65897
27 changed files with 1821 additions and 61 deletions

View file

@ -27,6 +27,16 @@
// After that the use is sent: if the server really is busy it answers
// "You're too busy" (UseDone 0x1D) and the use controller tries once more.
//
// With RynthAi holding for the press (RynthAi.Yield, 2026-10-29), RynthAi says
// exactly what it has in flight (its pacer's one outstanding action), so the
// rule is simpler and doesn't wait seconds for the count to sit still:
// * RynthAi's own unanswered action holds, for at most BotTrustMs;
// * the count holds only right after our own use (OwnTrustMs);
// * anything else in the count is a leftover (a death, a login, a corpse
// open's +1) or a click in the game's own windows: the use goes.
// 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
@ -54,9 +64,15 @@ internal enum BusyStale { None = 0, Count = 1, Animation = 2, Bot = 4 }
/// <param name="AnimatingMs">How long it has animated without a break.</param>
/// <param name="BotWaiting">RynthAi is waiting on the server (null = RynthAi isn't there).</param>
/// <param name="BotSteadyMs">How long that bit has read its current value.</param>
/// <param name="BotPaced">
/// RynthAi holds for the press and reports its own unanswered action (RynthAi.Yield); null = it
/// doesn't (absent, from before, its pacing off): the rules above apply.
/// </param>
/// <param name="BotPacedMs">How long RynthAi's own action has been unanswered (0 when none).</param>
internal readonly record struct BusyFacts(
int Count, long CountSteadyMs, int Leftover, long SinceOwnSendMs,
bool Animating, long AnimatingMs, bool? BotWaiting, long BotSteadyMs);
bool Animating, long AnimatingMs, bool? BotWaiting, long BotSteadyMs,
bool? BotPaced = null, long BotPacedMs = 0);
internal static class BusyRule
{
@ -78,6 +94,23 @@ internal static class BusyRule
if (f.AnimatingMs < AnimationMaxMs) return BusyHold.Animation;
stale |= BusyStale.Animation;
}
if (f.BotPaced is bool paced)
{
// RynthAi holds for the press and says what it has in flight: that, and our own last use,
// are all that hold it. The rest of the count is a leftover or a click in the game's own
// windows; a really busy server answers "You're too busy" (one more try).
if (paced)
{
if (f.BotPacedMs < BotTrustMs) return BusyHold.Bot;
stale |= BusyStale.Bot;
}
if (f.Count > 0)
{
if (f.Count > f.Leftover && f.SinceOwnSendMs < OwnTrustMs) return BusyHold.Busy;
stale |= BusyStale.Count;
}
return BusyHold.None;
}
if (f.Count > 0)
{
bool fresh = f.CountSteadyMs < CountTrustMs || f.SinceOwnSendMs < OwnTrustMs;
@ -110,14 +143,22 @@ internal sealed class BusyGate
private long _animatingSinceMs;
private bool? _bot;
private long _botSinceMs;
private bool _paced;
private long _pacedSinceMs;
private long _ownSendMs = long.MinValue / 4;
private BusyStale _logged;
/// <summary>The count judged a leftover (0 = none).</summary>
public int Leftover => _leftover;
public void Observe(int count, bool animating, bool? botWaiting, long now)
public void Observe(int count, bool animating, bool? botWaiting, long now) => Observe(count, animating, botWaiting, null, now);
/// <param name="botPaced">RynthAi's own action is unanswered (null = it can't say).</param>
public void Observe(int count, bool animating, bool? botWaiting, bool? botPaced, long now)
{
bool paced = botPaced == true;
if (paced && !_paced) _pacedSinceMs = now;
_paced = paced;
if (count < 0) count = 0;
if (!_started)
{
@ -153,17 +194,24 @@ internal sealed class BusyGate
/// <summary>Our own use or cast went out now.</summary>
public void NoteOwnSend(long now) => _ownSendMs = now;
public BusyFacts Facts(long now) => new(
public BusyFacts Facts(long now) => Facts(now, false);
/// <param name="pacedKnown">RynthAi holds for the press (its PacedAction bit is meaningful).</param>
public BusyFacts Facts(long now, bool pacedKnown) => new(
_count, now - _countSinceMs, _leftover, now - _ownSendMs,
_animating, _animating ? now - _animatingSinceMs : 0, _bot, now - _botSinceMs);
_animating, _animating ? now - _animatingSinceMs : 0, _bot, now - _botSinceMs,
pacedKnown ? _paced : null, pacedKnown && _paced ? now - _pacedSinceMs : 0);
/// <summary>
/// What holds a use back now. A count found to be a leftover becomes the new leftover;
/// <paramref name="newlyIgnored"/> names the leftovers not reported before (log them once).
/// </summary>
public BusyHold Judge(long now, out BusyStale newlyIgnored)
public BusyHold Judge(long now, out BusyStale newlyIgnored) => Judge(now, false, out newlyIgnored);
/// <param name="pacedKnown">RynthAi holds for the press (RynthAi.Yield): its own action is what it says.</param>
public BusyHold Judge(long now, bool pacedKnown, out BusyStale newlyIgnored)
{
BusyHold hold = BusyRule.Decide(Facts(now), out BusyStale stale);
BusyHold hold = BusyRule.Decide(Facts(now, pacedKnown), out BusyStale stale);
if ((stale & BusyStale.Count) != 0 && _count > _leftover)
{
_leftover = _count;
@ -175,15 +223,21 @@ internal sealed class BusyGate
}
/// <summary>The words for the log line when a leftover is first ignored.</summary>
public string Describe(BusyStale what, long now)
public string Describe(BusyStale what, long now) => Describe(what, now, false);
public string Describe(BusyStale what, long now, bool pacedKnown)
{
BusyFacts f = Facts(now);
BusyFacts f = Facts(now, pacedKnown);
var parts = new System.Collections.Generic.List<string>(3);
if ((what & BusyStale.Count) != 0)
parts.Add($"the client's busy count has read {f.Count} for {f.CountSteadyMs / 1000.0:0.0} s with nothing of ours in flight");
parts.Add(f.BotPaced != null
? $"the client's busy count reads {f.Count} with nothing of ours or RynthAi's in flight"
: $"the client's busy count has read {f.Count} for {f.CountSteadyMs / 1000.0:0.0} s with nothing of ours in flight");
if ((what & BusyStale.Animation) != 0)
parts.Add($"the character has read 'animating' for {f.AnimatingMs / 1000.0:0.0} s");
if ((what & BusyStale.Bot) != 0)
if ((what & BusyStale.Bot) != 0 && f.BotPaced != null)
parts.Add($"RynthAi's own action has had no answer for {f.BotPacedMs / 1000.0:0.0} s");
else if ((what & BusyStale.Bot) != 0)
parts.Add($"RynthAi has read 'waiting on the server' for {f.BotSteadyMs / 1000.0:0.0} s"
+ ((what & BusyStale.Count) != 0 || (_logged & BusyStale.Count) != 0 ? " (its copy of the same count)" : ""));
return "[RynthDefective] " + string.Join("; ", parts)
@ -194,6 +248,7 @@ internal sealed class BusyGate
{
_started = false;
_leftover = 0;
_paced = false;
_logged = BusyStale.None;
_ownSendMs = long.MinValue / 4;
}

View file

@ -40,6 +40,9 @@ internal sealed unsafe class HostDefWorld : IDefWorld
public bool? BotWaitingOnServer => BotActivity.Read(_host) is { } a ? (a & RynthAiActivity.ServerAction) != 0 : null;
public bool? BotMacroRunning => BotActivity.Read(_host) is { } a ? (a & RynthAiActivity.MacroRunning) != 0 : null;
public bool? BotPaced => BotYield.Available(_host) && BotActivity.Read(_host) is { } a ? (a & RynthAiActivity.PacedAction) != 0 : null;
public bool HoldBot(uint ms) => BotYield.Hold(_host, ms);
public void ReleaseBot() => BotYield.Release(_host);
public int RefusalSeq => _host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0;
@ -149,6 +152,47 @@ internal sealed unsafe class HostDefWorld : IDefWorld
}
}
/// <summary>
/// RynthAi's "RynthAi.Yield" interface (2026-10-29): the player's key press takes RynthAi's turn, so
/// RynthAi starts nothing new until the press has gone. Resolved again every call (a RynthAi reload
/// frees the table). Absent on a RynthAi from before it: nothing is held then.
/// </summary>
internal static unsafe class BotYield
{
private static RynthAiYieldApiV1* Table(RynthCoreHost host)
{
if (!host.HasGetPluginInterface) return null;
try
{
var t = (RynthAiYieldApiV1*)host.GetPluginInterface("RynthAi", RynthAiYieldApiV1.InterfaceName, RynthAiYieldApiV1.InterfaceVersion);
return t != null && t->Version >= 1 && t->StructSize >= (uint)sizeof(RynthAiYieldApiV1) ? t : null;
}
catch
{
return null; // a RynthAi mid-reload
}
}
public static bool Available(RynthCoreHost host) => Table(host) != null;
/// <summary>Asks for the player's turn for <paramref name="ms"/>; true when RynthAi holds (its pacing is on).</summary>
public static bool Hold(RynthCoreHost host, uint ms)
{
var t = Table(host);
if (t == null || t->HoldForPlayer == null) return false;
try { return t->HoldForPlayer(ms) != 0; }
catch { return false; }
}
public static void Release(RynthCoreHost host)
{
var t = Table(host);
if (t == null || t->ReleaseHold == null) return;
try { t->ReleaseHold(); }
catch { }
}
}
/// <summary>
/// RynthAi's activity bits: its "RynthAi.Activity" interface; on an older RynthAi without it, the
/// macro bit from "RynthAi.Status"; null when RynthAi isn't loaded or not ready. Resolved again every

View file

@ -27,6 +27,18 @@ internal interface IDefWorld
bool? BotWaitingOnServer { get; }
/// <summary>RynthAi's macro is running (null = RynthAi isn't there).</summary>
bool? BotMacroRunning { get; }
/// <summary>
/// A use, cast or stance change RynthAi sent has no answer yet (its pacer's; not the busy count).
/// Null = can't tell: RynthAi isn't there or is from before RynthAi.Yield.
/// </summary>
bool? BotPaced { get; }
/// <summary>
/// The player's turn: RynthAi starts nothing new for <paramref name="ms"/> (RynthAi.Yield). True when
/// it holds; false when it can't (not there, from before, its pacing off): BotPaced means nothing then.
/// </summary>
bool HoldBot(uint ms);
/// <summary>Ends the player's turn.</summary>
void ReleaseBot();
/// <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>
@ -136,6 +148,18 @@ internal static class Stance
/// holds nothing (<see cref="BusyGate"/>, logged once); if the server really is busy it answers
/// "You're too busy" and the use is tried once more after <see cref="RetryAfterMs"/>. Weapon swaps
/// also wait out a running RynthAi macro unless the player allowed them (it would swap straight back).
///
/// The player's turn (2026-10-29): while a request waits, and for the first <see cref="FlightHoldMs"/>
/// of its flight, RynthAi is asked to start nothing new (RynthAi.Yield, renewed every tick, let go
/// when done). After a death or a login RynthAi rebuffs and re-wields, and a press used to wait
/// 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.
///
/// 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
/// coming out of portal space a refused use or cast waits instead and is tried again every
/// <see cref="RefusedRetryMs"/>; it goes the moment the engine takes it.
/// </summary>
internal sealed class UseController
{
@ -156,6 +180,14 @@ internal sealed class UseController
public const long RetryAfterMs = 1000;
/// <summary>ACE's YoureTooBusy, as a UseDone error.</summary>
public const uint TooBusyError = 0x1D;
/// <summary>Each ask for the player's turn lasts this long (asked again every tick while it is wanted).</summary>
public const uint BotHoldAskMs = 1500;
/// <summary>RynthAi is held this long into our use's flight (a stance change of its own would cancel the use on the server).</summary>
public const long FlightHoldMs = 3000;
/// <summary>A use or cast the client refuses this soon after portal space ends waits and is tried again (the engine's gate holds 5 s).</summary>
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;
private enum Stage { Sent, WaitWield, Stance, Magic }
@ -175,6 +207,9 @@ internal sealed class UseController
// A cast: the spell, its target, and the Magic stance it waits for.
public uint SpellId, Target;
public bool ModeAsked;
/// <summary>A cast the client refused after a portal is tried again from this time.</summary>
public long CastRetryAtMs;
public bool CastWaitSaid;
public long MagicSeenMs;
}
@ -184,6 +219,20 @@ internal sealed class UseController
private long _retryNotBeforeMs = long.MinValue / 4;
private string _lastWait = string.Empty;
private readonly BusyGate _busy = new();
/// <summary>RynthAi holds for us (the last ask was taken): its PacedAction bit is what it has in flight.</summary>
private bool _botHeld;
// When the character last came out of portal space (or logged in): a refused send soon after waits.
// Starts "in the world" so a plugin load in the world doesn't count as an arrival.
private bool _wasInWorld = true;
private long _worldBackMs = long.MinValue / 4;
private long _refusedRetryAtMs = long.MinValue / 4;
private UseRequest? _refusedSaid;
/// <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;
/// <summary>RynthAi holds its next action for the press now (tests).</summary>
internal bool BotHeld => _botHeld;
/// <summary>The busy readings' clocks (tests look at the leftover).</summary>
internal BusyGate Busy => _busy;
@ -227,6 +276,7 @@ internal sealed class UseController
_flight = null;
_lastWait = string.Empty;
_retryNotBeforeMs = long.MinValue / 4;
_refusedRetryAtMs = long.MinValue / 4;
}
/// <summary>
@ -243,8 +293,41 @@ internal sealed class UseController
public void Tick(IDefWorld w)
{
long now = w.NowMs;
_busy.Observe(w.BusyCount, w.Animating, w.BotWaitingOnServer, now);
if (!w.InWorld)
_busy.Observe(w.BusyCount, w.Animating, w.BotWaitingOnServer, w.BotPaced, now);
try
{
TickInner(w, now);
}
finally
{
KeepBotHeld(w, now, ask: false); // let RynthAi go the tick the press is done
}
}
/// <summary>
/// The player's turn: asked for while a request waits or its flight is young (ask), let go when
/// neither. RynthAi's hold ends by itself within <see cref="BotHoldAskMs"/> if we stop asking.
/// </summary>
private void KeepBotHeld(IDefWorld w, long now, bool ask)
{
bool want = _pending != null || (_flight != null && now - _flight.SentMs < FlightHoldMs);
if (want)
{
if (ask) _botHeld = w.HoldBot(BotHoldAskMs);
}
else if (_botHeld)
{
w.ReleaseBot();
_botHeld = false;
}
}
private void TickInner(IDefWorld w, long now)
{
bool inWorld = w.InWorld;
if (inWorld && !_wasInWorld) _worldBackMs = now;
_wasInWorld = inWorld;
if (!inWorld)
{
// Portal space (a death's too): what was waiting is dropped, and said so (a key pressed in the
// portal did nothing). A use in flight is the server's now; nothing to say about it.
@ -252,6 +335,7 @@ internal sealed class UseController
if (_pending != null || _flight != null) Reset();
return;
}
KeepBotHeld(w, now, ask: true);
if (_flight != null && !AdvanceFlight(w, now)) return; // still in flight: nothing new goes out
if (_pending == null) return;
@ -275,6 +359,7 @@ internal sealed class UseController
{
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.Busy => "the character is busy",
@ -287,8 +372,8 @@ internal sealed class UseController
/// <summary>The busy gate's verdict now; a leftover it ignores for the first time is logged.</summary>
private BusyHold Hold(long now)
{
BusyHold hold = _busy.Judge(now, out BusyStale ignored);
if (ignored != BusyStale.None) Log?.Invoke(_busy.Describe(ignored, now));
BusyHold hold = _busy.Judge(now, _botHeld, out BusyStale ignored);
if (ignored != BusyStale.None) Log?.Invoke(_busy.Describe(ignored, now, _botHeld));
return hold;
}
@ -354,6 +439,7 @@ internal sealed class UseController
bool sent = target != 0 ? w.UseObjectOn(item.Id, target) : w.UseObject(item.Id);
if (!sent)
{
if (WaitOutRefusal(req, name, now)) return;
Warn?.Invoke($"{name}: the client didn't take the request (nothing was sent).");
return;
}
@ -378,6 +464,25 @@ internal sealed class UseController
Say?.Invoke(action == UseAction.Equip ? $"Wielding {name}..." : $"Using {name}...");
}
/// <summary>
/// The client refused to send <paramref name="req"/>: just after a portal the engine takes no game
/// action yet, so the request waits and is tried again (its wait limit still counts from the press).
/// Said once per request. False when it isn't just after a portal: a refusal is reported as before.
/// </summary>
private bool WaitOutRefusal(UseRequest req, string name, long now)
{
if (!JustArrived(now) || _pending != null) return false; // a newer press waits already: the newest wish wins
_pending = req;
_refusedRetryAtMs = now + RefusedRetryMs;
if (!ReferenceEquals(_refusedSaid, req))
{
_refusedSaid = req;
Log?.Invoke($"[RynthDefective] {req.Source}: the client doesn't take {name} yet ({now - _worldBackMs} ms after the portal); trying again");
Say?.Invoke($"{name}: waiting for the game to finish the portal...");
}
return true;
}
/// <summary>
/// The server answered "You're too busy" (UseDone 0x1D) to <paramref name="f"/>'s use: it is tried
/// once more after <see cref="RetryAfterMs"/>, unless a newer request is waiting (the newest wish
@ -475,10 +580,23 @@ internal sealed class UseController
private bool Cast(IDefWorld w, Flight f, long now)
{
if (now < f.CastRetryAtMs) return false;
f.UseDoneAtSend = w.UseDoneSeq;
f.RefusalAtSend = w.RefusalSeq;
if (!w.CastSpell(f.Target, f.SpellId))
{
// Just after a portal the engine takes no game action yet: the cast is tried again.
if (JustArrived(now) && now - f.Request.AtMs < WaitLimitMs)
{
f.CastRetryAtMs = now + RefusedRetryMs;
if (!f.CastWaitSaid)
{
f.CastWaitSaid = true;
Log?.Invoke($"[RynthDefective] {f.Request.Source}: the client doesn't take the cast of {f.What} yet ({now - _worldBackMs} ms after the portal); trying again");
Say?.Invoke($"{f.Name}: waiting for the game to finish the portal...");
}
return false;
}
Warn?.Invoke($"{f.Name}: the client didn't take the cast (nothing was sent).");
Finish(now);
return true;