Snapshot for release 2026.10.28.3 (internal db7f094)

This commit is contained in:
Tom Bohar 2026-10-28 23:23:42 -04:00
commit e6642d0e10
102 changed files with 4821 additions and 782 deletions

View file

@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace RynthCore.Plugin.RynthNav;
/// <summary>
/// /rnav's lines for the words that used to answer nothing (2026-10-28: every command answers,
/// Plugins/Shared/CommandReply.cs): "recent" without "clear", "arrive" with no or a wrong number,
/// a word /rnav doesn't know. Pure, so RynthNav.RouteTests checks them.
/// </summary>
internal static class NavReplies
{
public const double ArriveMin = 2, ArriveMax = 200;
/// <summary>"/rnav arrive &lt;yards&gt;": the distance when it is one the arrow takes.</summary>
public static bool TryArrive(string rest, out double yards) =>
double.TryParse(rest, NumberStyles.Float, CultureInfo.InvariantCulture, out yards) && yards >= ArriveMin && yards <= ArriveMax;
public static string Arrived(double yards) => $"the arrow counts you as arrived within {yards:F0} yd";
/// <summary>"/rnav arrive" alone or with a wrong number: the value now and the usage.</summary>
public static string ArriveUsage(string rest, double now) =>
(rest.Trim().Length == 0 ? "" : $"'{rest.Trim()}' isn't {ArriveMin:F0}-{ArriveMax:F0} yd. ")
+ $"{Arrived(now)} — /rnav arrive <yards {ArriveMin:F0}-{ArriveMax:F0}>";
/// <summary>"/rnav recent": the recent places, newest first.</summary>
public static string Recent(IReadOnlyList<SavedPlace> recent) => recent.Count == 0
? "no recent places (arrow, route and go targets land here)"
: $"recent places ({recent.Count}): {string.Join(", ", recent.Select(p => p.Name))} — /rnav recent clear forgets them";
/// <summary>A word /rnav doesn't know.</summary>
public static string Unknown(string word) => $"unknown '{word}' — /rnav help";
}

View file

@ -46,6 +46,8 @@
<Compile Include="..\Shared\Nav3DText.cs" Link="Shared\Nav3DText.cs" />
<!-- Install folders (RynthAi's NavProfiles, where "save as nav route" writes). Read only. -->
<Compile Include="..\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
<!-- How a chat command answers (2026-10-28): the shared reply queue and colours. -->
<Compile Include="..\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
<!-- RynthAi's own nav file reader/writer (uTank2 NAV 1.2), so a saved route is written exactly
the way RynthAi writes its own. Self-contained (System.IO only). -->
<Compile Include="..\RynthCore.Plugin.RynthAi\LegacyUi\NavRouteParser.cs" Link="Shared\NavRouteParser.cs" />

View file

@ -1051,6 +1051,7 @@ public sealed partial class RynthNavPlugin
case "fav": CmdFav(rest); break;
case "recent":
if (rest.Equals("clear", StringComparison.OrdinalIgnoreCase)) { _store.ClearRecent(); Say("recent places cleared"); }
else Say(NavReplies.Recent(_store.Recent));
break;
case "recalls": CmdRecalls(rest); break;
case "tie": CmdTie(rest); break;
@ -1058,10 +1059,11 @@ public sealed partial class RynthNavPlugin
case "mesh": CmdMesh(rest); break;
case "saveroute": CmdSaveRoute(rest); break;
case "arrive":
if (double.TryParse(rest, NumberStyles.Float, CultureInfo.InvariantCulture, out double yd) && yd >= 2 && yd <= 200)
{ _arrow.ArriveUnits = yd; Say($"the arrow counts you as arrived within {yd:F0} yd"); }
if (NavReplies.TryArrive(rest, out double yd)) { _arrow.ArriveUnits = yd; Say(NavReplies.Arrived(yd)); }
else if (rest.Length == 0) Say(NavReplies.ArriveUsage(rest, _arrow.ArriveUnits));
else SayFail(NavReplies.ArriveUsage(rest, _arrow.ArriveUnits));
break;
default: Say($"unknown '{cmd}' — /rnav help"); break;
default: SayFail(NavReplies.Unknown(cmd)); break;
}
}

View file

@ -136,6 +136,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
public override int Initialize()
{
_ = Reply;
_status = "initialized";
// Every use logged (Plugins/Shared/UseAudit.cs). No macro here: no door/corpse guard.
RynthCore.Plugin.Shared.UseAudit.Reset("RynthNav", null);
@ -183,7 +184,7 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
lock (_gotoGate) { _gotoPath = null; _gotoIdx = 0; }
_badTiles.Clear();
_tileRegions.Clear(); _tilePrints.Clear(); ResetCoarse();
_chatOut.Clear();
Reply.Clear();
_goNote = "";
HideMarkers("logged out");
_meshView.Clear(); _meshDunLb = 0;
@ -216,15 +217,15 @@ public sealed partial class RynthNavPlugin : RynthPluginBase
// Chat from the tick thread. The engine drops an off-thread WriteToChat that comes
// within 100 ms of any other plugin's (RynthAi writes often), so a line said here is
// queued and retried on later ticks until it goes through (one line per tick; a line
// that still can't be written after ~3 s is dropped so the queue never jams).
private readonly System.Collections.Concurrent.ConcurrentQueue<string> _chatOut = new();
private int _chatTries;
private void Say(string text) { if (_chatOut.Count < 64) _chatOut.Enqueue("[RynthNav] " + text); }
private void FlushChat()
{
if (!_chatOut.TryPeek(out string? line)) return;
if (Host.WriteToChat(line, 1) || ++_chatTries > 90) { _chatOut.TryDequeue(out _); _chatTries = 0; }
}
// that still can't be written after ~1.5 s goes to the log so the queue never jams).
// The queue is the shared one every plugin answers commands through (Plugins/Shared/CommandReply.cs).
private RynthCore.Plugin.Shared.CommandReply? _reply;
private RynthCore.Plugin.Shared.CommandReply Reply =>
_reply ??= new RynthCore.Plugin.Shared.CommandReply("[RynthNav]", (t, c) => Host.WriteToChat(t, c), t => Host.Log(t));
private void Say(string text) => Reply.Ok(text);
/// <summary>A command that didn't work: why, and the usage (the failure colour).</summary>
private void SayFail(string text) => Reply.Fail(text);
private void FlushChat() => Reply.Flush();
private uint CurrentLandblock => (_cellId >> 16) & 0xFFFF;