Snapshot for release 2026.10.20.1 (internal 7116fab)

This commit is contained in:
Tom Bohar 2026-10-20 21:28:18 -04:00
commit bfcd48950d
215 changed files with 16200 additions and 2838 deletions

View file

@ -0,0 +1,76 @@
using System;
namespace RynthCore.Plugin.RynthNav;
// Autorun and stops sent when they change, not every tick (2026-10-19). The goto sent
// SetAutoRun(False) every tick while it settled after a teleport, turned in place or stood at a
// portal, SetAutoRun(True) every tick while it ran, and SetAutoRun(False) + StopCompletely every
// tick while it held in the Town Network: about 55 calls a second. The plugin tick isn't AC's main
// thread, so every call takes a slot in the engine's action ring (256), and the ring is held
// through portal space. On a recall + Town Network trip (Matron Hive East, 10-19 16:38-16:40) it
// filled: 1,204 queued actions refused (anyone's, not only ours), 256 stale stops run 12 s late.
// Now a change goes out at once, "on" is sent again every ReassertMs (a cast, a stance change or a
// server stop turns autorun off without telling us; RynthAi's nav re-asserts the same way), and
// "off" and a halt go out once. A call the engine refuses isn't taken as sent: it is tried again
// after RetryMs, not every tick. Stop() is for a goto's start and end and a teleport: it always sends.
internal sealed class AutoRunGate
{
public const long ReassertMs = 500;
public const long RetryMs = 250;
private readonly Func<bool, bool> _setAutoRun;
private readonly Func<bool> _stopCompletely;
private readonly Func<long> _now;
private int _run = -1; // the last SetAutoRun that went through: 1 on, 0 off, -1 not known
private long _runMs; // when it went through
private bool _halted; // a StopCompletely went through and nothing has started since
private long _retryAtMs; // a call was refused: nothing but Stop() before this
public AutoRunGate(Func<bool, bool> setAutoRun, Func<bool> stopCompletely, Func<long> now)
{
_setAutoRun = setAutoRun;
_stopCompletely = stopCompletely;
_now = now;
}
/// <summary>Autorun on or off: sent when it's a change, and "on" again every ReassertMs.</summary>
public void Run(bool on)
{
long now = _now();
int want = on ? 1 : 0;
if (want == _run && !(on && now - _runMs >= ReassertMs)) return;
if (now < _retryAtMs) return;
bool ok = _setAutoRun(on);
_run = ok ? want : -1;
_runMs = now;
if (ok && on) _halted = false;
_retryAtMs = ok ? 0 : now + RetryMs;
}
/// <summary>Autorun off and StopCompletely, unless that's what was sent last.</summary>
public void Halt()
{
if (_halted) return;
if (_now() < _retryAtMs) return;
Stop();
}
/// <summary>Autorun off and StopCompletely, always (a goto's start and end, a teleport).</summary>
public void Stop()
{
long now = _now();
bool off = _setAutoRun(false);
bool stopped = _stopCompletely();
_run = off ? 0 : -1;
_runMs = now;
_halted = off && stopped;
_retryAtMs = _halted ? 0 : now + RetryMs;
}
/// <summary>What the client has on isn't known any more (a new goto: the d-pad or another plugin may have moved it).</summary>
public void Forget()
{
_run = -1; _runMs = 0; _halted = false; _retryAtMs = 0;
}
}

View file

@ -106,7 +106,7 @@ public sealed partial class RynthNavPlugin
// 20:42). Within PortalUseUnits with the live portal seen: stand still and use it every 3 s.
if (_portalLiveId != 0 && Host.HasUseObject && d <= PortalUseUnits)
{
Host.SetAutoRun(false);
AutoRun.Run(false);
if (now - _portalLastUseMs > 3000)
{
_portalLastUseMs = now;

View file

@ -22,7 +22,7 @@ public sealed partial class RynthNavPlugin
_settleJumpMs = NowMs;
_settleQuietSince = 0;
_settleSawPortal = Host.HasIsPortaling && Host.IsPortaling();
Host.SetAutoRun(false);
AutoRun.Run(false);
lock (_gate) _status = "arriving…";
}
@ -30,7 +30,7 @@ public sealed partial class RynthNavPlugin
{
long now = NowMs;
bool portaling = Host.HasIsPortaling && Host.IsPortaling();
Host.SetAutoRun(false);
AutoRun.Run(false);
if (portaling)
{
_settleSawPortal = true;

View file

@ -110,11 +110,7 @@ public sealed partial class RynthNavPlugin
private double LocalX => _wx - ((_cellId >> 24) & 0xFF) * 192.0;
private double LocalY => _wy - ((_cellId >> 16) & 0xFF) * 192.0;
private void HubHalt()
{
Host.SetAutoRun(false);
Host.StopCompletely();
}
private void HubHalt() => AutoRun.Halt();
/// <summary>One tick of a hub step: wait for the landing inside, walk to the exit, take it.</summary>
private void StepHub()

View file

@ -726,7 +726,7 @@ public sealed partial class RynthNavPlugin
_recallWandTried = false; _recallChangedStance = false; _recallSent = false; _recallWasPortaling = false;
_recallPreLb = CurrentLandblock; _recallPreWx = _wx; _recallPreWy = _wy;
BeginWand();
Host.SetAutoRun(false); Host.StopCompletely();
AutoRun.Stop();
RecallOption? o = CurrentRecallOption();
lock (_gate) _status = o == null ? "recall step: unknown recall" : $"recalling: {o.Name}";
Host.Log($"[RynthNav] recall step: {o?.Name ?? "?"}");
@ -758,7 +758,7 @@ public sealed partial class RynthNavPlugin
Host.Log($"[RynthNav] recall {o.Name}: teleported (moved {moved:F0}u)");
_lastLandMs = NowMs;
EndRecall();
Host.SetAutoRun(false); Host.StopCompletely();
AutoRun.Stop();
RefreshTiles(CurrentLandblock);
BeginSettle();
return;

View file

@ -42,9 +42,13 @@ public sealed partial class RynthNavPlugin
double next = current + Math.Clamp(error, -maxStep, maxStep);
Host.TurnToHeading((float)(((next % 360.0) + 360.0) % 360.0));
}
Host.SetAutoRun(!_turnInPlace);
AutoRun.Run(!_turnInPlace);
}
// SetAutoRun/StopCompletely for the goto, sent when they change (AutoRunGate.cs).
private AutoRunGate? _autoRun;
private AutoRunGate AutoRun => _autoRun ??= new AutoRunGate(on => Host.SetAutoRun(on), () => Host.StopCompletely(), () => NowMs);
/// <summary>A fresh start for the turn servo (a new goto, a teleport).</summary>
private void ResetTurn() { _turnInPlace = false; _lastTurnMs = 0; }
}

View file

@ -440,7 +440,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
// A new goto (not the re-plan after "no route over land") may re-plan once again.
if (!landReplan) { _landReplanned = false; _enterPortal = enter.Length > 0 ? _nextEnterPortal : ""; _nextEnterPortal = ""; }
// Whatever was running stops first: a refused goto must not leave the old one half-changed.
if (_gotoActive) { _gotoActive = false; _route = null; _portalWait = false; ResetHub(); Host.SetAutoRun(false); Host.StopCompletely(); HideMarkers("a new goto"); }
if (_gotoActive) { _gotoActive = false; _route = null; _portalWait = false; ResetHub(); AutoRun.Stop(); HideMarkers("a new goto"); }
double twx = NavCoords.WorldX(tew), twy = NavCoords.WorldY(tns);
int gLbX = (int)Math.Floor(twx / 192.0), gLbY = (int)Math.Floor(twy / 192.0);
if (double.IsNaN(twx) || double.IsNaN(twy) || gLbX < 0 || gLbX > 255 || gLbY < 0 || gLbY > 255)
@ -524,6 +524,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
Say($"goto: the target's landblock 0x{goalLb:X4} has no tile; walking as far as the navmesh goes");
SetTrip(_route, name, tns, tew, recalls, enter, live: true);
AutoRun.Forget(); // the d-pad or another plugin may have moved since: the first call goes out
_gotoActive = true;
_gotoName = name; _gotoType = type;
_walkHaveLast = false;
@ -624,14 +625,14 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
// A teleport on a walking leg is never planned: a portal we touched by accident. Stop.
bool portalingNow = Host.HasIsPortaling && Host.IsPortaling();
double jump = _walkHaveLast ? Math.Sqrt((_wx - _walkLastWx) * (_wx - _walkLastWx) + (_wy - _walkLastWy) * (_wy - _walkLastWy)) : 0;
if (portalingNow && !_walkHaveLast) { Host.SetAutoRun(false); return; } // still arriving from the last step's teleport
if (portalingNow && !_walkHaveLast) { AutoRun.Run(false); return; } // still arriving from the last step's teleport
// The client can show portal space a second or more AFTER the position jump that ended a
// recall or portal step (seen live: @lifestone jumped at 19:45:11, portal space began at
// 19:45:12). That portal space is the step's own: wait it out, and count the landing from
// its end, rather than calling it a stray portal.
if (portalingNow && NowMs - _lastLandMs < SettleAfterTeleportMs)
{
Host.SetAutoRun(false);
AutoRun.Run(false);
_walkHaveLast = false;
_lastLandMs = NowMs;
return;
@ -701,7 +702,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
if (_coarseHoldTicks > 0 && _coarse == null && _gotoActive)
{
_coarseHoldTicks--;
Host.SetAutoRun(false);
AutoRun.Run(false);
lock (_gate) _status = "planning the way…";
return;
}
@ -740,7 +741,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
}
else if (_blindTicks++ == BlindPushTicks)
{
Host.SetAutoRun(false);
AutoRun.Run(false);
}
return;
}
@ -818,7 +819,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
ResetHub();
_avoid.Clear(); _coarseHoldTicks = 0;
ResetBlocked();
Host.SetAutoRun(false); Host.StopCompletely();
AutoRun.Stop();
lock (_gate) _status = status;
Host.Log($"[RynthNav] goto: {status}");
Say(status == "arrived" && _gotoName.Length > 0 ? $"goto: arrived at {_gotoName}" : $"goto: {status}");
@ -841,7 +842,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
if (teleported)
{
Host.SetAutoRun(false); Host.StopCompletely();
AutoRun.Stop();
_portalWait = false;
_lastLandMs = NowMs;
Host.Log($"[RynthNav] teleport detected (lb 0x{_prePortalLb:X4}->0x{CurrentLandblock:X4}, moved {moved:F0}u) — next leg");
@ -871,7 +872,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
double away = Math.Atan2(-dew, -dns) * 180.0 / Math.PI;
DriveTo(away);
}
else { Host.SetAutoRun(false); Host.StopCompletely(); }
else AutoRun.Halt();
_portalWaitTicks = 0;
_portalTryStartMs = NowMs; // the cooldown isn't a failed try
if (!_cooldownSaid) { _cooldownSaid = true; Host.Log($"[RynthNav] waiting {(PortalCooldownMs - sinceTeleport) / 1000.0:F1} s before the portal (teleported {sinceTeleport} ms ago)"); }