feat: SK backlog from test through 2026.11.22.48 (Trade Shop, Oracle, quests, loot, nav)
Squash of test/main-merge-2026-10-25 onto aelrynth main 2026.11.19.1 for the standing sk PR. Includes Trade Shop, Oracle wiki/ILT tracker, quest runs, loot checklist, RynthNav, VTank import. HandWrittenVersion remains 0.5.0-legacy-ui. See Changelog/2026-11-22-sk-backlog-test-merge.md.
This commit is contained in:
parent
660e6b5b1c
commit
dc08e1abba
521 changed files with 47247 additions and 795 deletions
|
|
@ -15,6 +15,8 @@ namespace RynthCore.Plugin.RynthChat;
|
|||
///
|
||||
/// JSON per line: {"seq":N,"ts":"HH:mm:ss","chan":"Chat","type":3,"sender":"Bob"|null,"text":"..."}.
|
||||
/// "type" (AC's ChatMessageType) was added in 0.2.0; engines before it ignore it.
|
||||
/// ,"auto":true (0.3.4) marks automated system text (ChatLine.Auto); absent otherwise,
|
||||
/// and engines before 2026.10.18.30 ignore it.
|
||||
/// Every non-ASCII character is written as a \uXXXX escape, so the export is
|
||||
/// pure ASCII and survives the ANSI marshalling on both sides (before 0.2.0 an
|
||||
/// accented name or the "→" of an outgoing tell arrived as "?").
|
||||
|
|
@ -32,6 +34,19 @@ internal sealed class ChatBuffer
|
|||
private int _count; // lines stored (<= _ring.Length)
|
||||
private ulong _nextSeq = 1;
|
||||
|
||||
// Quest lists (2026-10-25): the /myquests and /qb list replies plugins ask for by themselves
|
||||
// are hidden; one the player asked for in chat (RynthChat's input, NoteTypedQuestCommand)
|
||||
// shows, under All. The window opens on the command and stays open while its lines keep coming.
|
||||
private const long TypedQuestFirstLineMs = 15_000; // the command -> its first line
|
||||
private const long QuestListIdleMs = 4_000; // between two lines of one list
|
||||
private long _questShowUntilMs;
|
||||
// The same for the /bank balance dump: hidden unless the player typed /bank (RynthILT's and
|
||||
// ub-Rythai's own reads stay out of every tab, whether or not a plugin ate them).
|
||||
private long _bankShowUntilMs;
|
||||
// When the last quest-list line arrived: the eaten lines of a /qb list (its quest names
|
||||
// match no fixed format) that follow it belong to the same hidden list.
|
||||
private long _lastQuestListLineMs = long.MinValue / 2;
|
||||
|
||||
internal ChatBuffer(int capacity = DefaultCapacity)
|
||||
{
|
||||
_ring = new ChatLine?[Math.Clamp(capacity, MinCapacity, MaxCapacity)];
|
||||
|
|
@ -70,7 +85,8 @@ internal sealed class ChatBuffer
|
|||
}
|
||||
}
|
||||
|
||||
internal void Add(string? text, int chatType)
|
||||
/// <param name="loginBurst">The character is entering the world: its system text is automated.</param>
|
||||
internal void Add(string? text, int chatType, bool loginBurst = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
string channel = ChatClassifier.IsItemInfo(text) ? ChatClassifier.Items
|
||||
|
|
@ -78,9 +94,37 @@ internal sealed class ChatBuffer
|
|||
: ChatClassifier.ChannelFor(text, chatType);
|
||||
string? sender = ChatClassifier.SenderFor(text, chatType);
|
||||
string ts = DateTime.Now.ToString("HH:mm:ss");
|
||||
bool auto = ChatClassifier.IsAutomatedText(text, chatType)
|
||||
|| ChatClassifier.IsLoginBurst(channel, chatType, loginBurst);
|
||||
bool questList = ChatClassifier.IsQuestListText(text, chatType);
|
||||
bool bankDump = ChatClassifier.IsBankBalanceDump(text);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
bool hidden = false;
|
||||
if (questList)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
_lastQuestListLineMs = now;
|
||||
if (now < _questShowUntilMs)
|
||||
{
|
||||
auto = false; // the player asked for it: under All like any reply
|
||||
_questShowUntilMs = now + QuestListIdleMs;
|
||||
}
|
||||
else
|
||||
hidden = true;
|
||||
}
|
||||
else if (bankDump)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
if (now < _bankShowUntilMs)
|
||||
{
|
||||
auto = false;
|
||||
_bankShowUntilMs = now + QuestListIdleMs;
|
||||
}
|
||||
else
|
||||
hidden = true;
|
||||
}
|
||||
// Numbered under the lock, so the ring is always in seq order (the
|
||||
// engine skips anything at or below the last seq it has seen).
|
||||
_ring[_head] = new ChatLine
|
||||
|
|
@ -91,12 +135,53 @@ internal sealed class ChatBuffer
|
|||
ChatType = chatType,
|
||||
Sender = sender,
|
||||
Text = text,
|
||||
Auto = auto,
|
||||
Hidden = hidden,
|
||||
};
|
||||
_head = (_head + 1) % _ring.Length;
|
||||
if (_count < _ring.Length) _count++;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A plugin ate the line just dispatched (the engine calls this after every plugin has seen
|
||||
/// it): marks it automated when it is the newest line here, with the same text. Returns
|
||||
/// whether it was marked. The engine polls the scrollback on the same thread as the chat
|
||||
/// dispatch, so the mark lands before the line is exported.
|
||||
/// </summary>
|
||||
internal bool NoteEaten(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
lock (_lock)
|
||||
{
|
||||
if (_count == 0) return false;
|
||||
ChatLine? newest = _ring[(_head - 1 + _ring.Length) % _ring.Length];
|
||||
if (newest == null || !string.Equals(newest.Text, text, StringComparison.Ordinal)) return false;
|
||||
long now = Environment.TickCount64;
|
||||
bool typedQuestList = now < _questShowUntilMs;
|
||||
bool bankDump = ChatClassifier.IsBankBalanceDump(text);
|
||||
bool typed = bankDump ? now < _bankShowUntilMs : typedQuestList;
|
||||
if (!typed) newest.Auto = true;
|
||||
// A quiet /bank refresh's balance dump: not even the System tab.
|
||||
if (bankDump) { if (!typed) newest.Hidden = true; }
|
||||
// A line of a quest list nobody asked for in chat (a /qb list's quest names).
|
||||
else if (!typedQuestList && now - _lastQuestListLineMs < QuestListIdleMs) newest.Hidden = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The player sent /myquests or /qb from the chat input: its list shows (game thread).</summary>
|
||||
internal void NoteTypedQuestCommand()
|
||||
{
|
||||
lock (_lock) _questShowUntilMs = Environment.TickCount64 + TypedQuestFirstLineMs;
|
||||
}
|
||||
|
||||
/// <summary>The player sent /bank (or /b) from the chat input: its balances show (game thread).</summary>
|
||||
internal void NoteTypedBankCommand()
|
||||
{
|
||||
lock (_lock) _bankShowUntilMs = Environment.TickCount64 + TypedQuestFirstLineMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lines with Seq > sinceSeq as a JSON array, oldest first. Only those are
|
||||
/// copied out under the lock: the ring holds consecutive seqs, so they are the
|
||||
|
|
@ -122,7 +207,7 @@ internal sealed class ChatBuffer
|
|||
bool first = true;
|
||||
foreach (ChatLine? line in lines)
|
||||
{
|
||||
if (line == null || line.Seq <= sinceSeq) continue;
|
||||
if (line == null || line.Seq <= sinceSeq || line.Hidden) continue;
|
||||
|
||||
if (!first) sb.Append(',');
|
||||
first = false;
|
||||
|
|
@ -147,7 +232,9 @@ internal sealed class ChatBuffer
|
|||
}
|
||||
sb.Append(",\"text\":\"");
|
||||
AppendEscaped(sb, line.Text);
|
||||
sb.Append("\"}");
|
||||
sb.Append('"');
|
||||
if (line.Auto) sb.Append(",\"auto\":true");
|
||||
sb.Append('}');
|
||||
}
|
||||
|
||||
sb.Append(']');
|
||||
|
|
|
|||
|
|
@ -32,6 +32,111 @@ internal static class ChatClassifier
|
|||
internal static bool IsItemInfo(string text) =>
|
||||
text.StartsWith("[RynthAi Item] ", StringComparison.Ordinal);
|
||||
|
||||
// ── Automated system text (0.3.4) ──────────────────────────────────────
|
||||
// Lines the engine shows in the System tab only, not under All: replies to the
|
||||
// commands plugins send by themselves (/myquests, /qb list), the server's login
|
||||
// burst, and anything a plugin ate (the engine reports those, RynthChatNoteEaten).
|
||||
|
||||
/// <summary>AdminTell: a person typed it, so it is never automated text.</summary>
|
||||
internal const int AdminTellType = 0x1F;
|
||||
|
||||
// A /myquests flag line: "key - N solves (unixtime)"description" max repeat". Its own timeout:
|
||||
// static fields initialise in file order, and the shared Timeout below isn't set yet here.
|
||||
private static readonly Regex _questFlagRe = new(@"^\S+ - \d+ solves \(\d*\)",
|
||||
RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(20));
|
||||
|
||||
/// <summary>
|
||||
/// True for the fixed formats of automated replies, whoever sent the command:
|
||||
/// /myquests flag lines and their end lines, the /qb list headers and end lines,
|
||||
/// and ACE's login welcome. Only for system-type lines, so player speech that
|
||||
/// quotes them is untouched.
|
||||
/// </summary>
|
||||
internal static bool IsAutomatedText(string text, int chatType)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text) || ChannelForType(chatType) != System || chatType == AdminTellType) return false;
|
||||
return IsQuestListText(text, chatType)
|
||||
|| text.StartsWith("Welcome to Asheron's Call", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The /myquests and /qb list replies' fixed lines (flag lines, headers, end lines), system
|
||||
/// type only. Hidden unless the player asked for the list in chat (ChatBuffer, 2026-10-25).
|
||||
/// </summary>
|
||||
internal static bool IsQuestListText(string text, int chatType)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text) || ChannelForType(chatType) != System || chatType == AdminTellType) return false;
|
||||
if (text.IndexOf(" solves (", StringComparison.Ordinal) > 0)
|
||||
{
|
||||
try { if (_questFlagRe.IsMatch(text)) return true; }
|
||||
catch (RegexMatchTimeoutException) { }
|
||||
}
|
||||
return text.StartsWith("Quest list is empty", StringComparison.Ordinal)
|
||||
|| text.StartsWith("[MyQuests] ", StringComparison.Ordinal)
|
||||
|| text.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.StartsWith("Quest bonus list is empty", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.StartsWith("[QB] ", StringComparison.Ordinal)
|
||||
|| IsDeedsListText(text);
|
||||
}
|
||||
|
||||
// ACECustom's /deeds list (2026-10-24): "Your QB: 12,345 - Deeds bonuses are ON, ..." then one message
|
||||
// per tier, "1000 QB (unlocked)\n * reward ...". RynthILT reads it for its QB Deeds window.
|
||||
private static readonly Regex _deedsTierRe = new(@"^\d+ QB( \(unlocked\))?(\n|$)",
|
||||
RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(20));
|
||||
|
||||
private static bool IsDeedsListText(string text)
|
||||
{
|
||||
if (text.StartsWith("Your QB: ", StringComparison.Ordinal))
|
||||
return text.Contains(" - Deeds bonuses are ", StringComparison.Ordinal);
|
||||
if (text.Length == 0 || !char.IsDigit(text[0])) return false;
|
||||
try { return _deedsTierRe.IsMatch(text); }
|
||||
catch (RegexMatchTimeoutException) { return false; }
|
||||
}
|
||||
|
||||
/// <summary>A plain balance read: /bank or /b (or the @ forms) with no verb.</summary>
|
||||
internal static bool IsBankBalanceCommand(string? text)
|
||||
{
|
||||
string t = (text ?? string.Empty).Trim();
|
||||
return t.Equals("/bank", StringComparison.OrdinalIgnoreCase) || t.Equals("/b", StringComparison.OrdinalIgnoreCase)
|
||||
|| t.Equals("@bank", StringComparison.OrdinalIgnoreCase) || t.Equals("@b", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>A chat command that asks for a quest list: /myquests, /qb, /qb list (or the @ forms).</summary>
|
||||
internal static bool IsQuestListCommand(string? text)
|
||||
{
|
||||
string t = (text ?? string.Empty).Trim();
|
||||
if (t.Length < 3 || (t[0] != '/' && t[0] != '@')) return false;
|
||||
t = t.Substring(1);
|
||||
return t.Equals("myquests", StringComparison.OrdinalIgnoreCase)
|
||||
|| t.Equals("deeds", StringComparison.OrdinalIgnoreCase)
|
||||
|| t.Equals("deeds list", StringComparison.OrdinalIgnoreCase)
|
||||
|| t.Equals("qb", StringComparison.OrdinalIgnoreCase)
|
||||
|| t.StartsWith("qb ", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
// "[BANK] Your balances are:" then "[BANK] Pyreals: 67,908,687,115", ... "[BANK] Prestige Coins: 98 (bound ...)".
|
||||
private static readonly Regex _bankBalanceRe = new(@"^\[BANK\] (Your balances are:|[A-Za-z ]+: [\d,]+)",
|
||||
RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(20));
|
||||
|
||||
/// <summary>
|
||||
/// The server's /bank balance dump (its header and "Label: N" lines), not the other [BANK]
|
||||
/// lines (errors, transfers). Only hidden when a plugin ate it (ChatBuffer.NoteEaten).
|
||||
/// </summary>
|
||||
internal static bool IsBankBalanceDump(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text) || !text.StartsWith("[BANK] ", StringComparison.Ordinal)) return false;
|
||||
try { return _bankBalanceRe.IsMatch(text); }
|
||||
catch (RegexMatchTimeoutException) { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True when a line counts as the login burst: system text (not an admin's tell) that
|
||||
/// arrives while the character is entering the world (<paramref name="loginBurst"/>).
|
||||
/// </summary>
|
||||
internal static bool IsLoginBurst(string channel, int chatType, bool loginBurst) =>
|
||||
loginBurst && channel == System && chatType != AdminTellType;
|
||||
|
||||
// ── Channel classification ─────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,15 @@ internal sealed class ChatLine
|
|||
internal int ChatType { get; init; }
|
||||
internal string? Sender { get; init; }
|
||||
internal string Text { get; init; } = "";
|
||||
/// <summary>
|
||||
/// Automated system text (0.3.4): a reply to a plugin's own command, the login burst, or
|
||||
/// a line a plugin ate. Exported as "auto"; the engine shows it in the System tab only.
|
||||
/// Set under ChatBuffer's lock (NoteEaten can set it after Add).
|
||||
/// </summary>
|
||||
internal bool Auto { get; set; }
|
||||
/// <summary>
|
||||
/// Never exported (2026-10-25): a plugin ate it and it is a periodic poll's reply nobody
|
||||
/// asked to see (the /bank balance dump of RynthILT's quiet refresh). Set by NoteEaten.
|
||||
/// </summary>
|
||||
internal bool Hidden { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,22 @@ public static unsafe class PluginExports
|
|||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The engine, after every plugin has seen a chat line (0.3.4): a plugin ate it, so it is
|
||||
/// automated text (a reply to a plugin's own command). Marks the newest scrollback line
|
||||
/// when its text matches; returns 1 when marked. Engines before 2026.10.18.30 never call it.
|
||||
/// </summary>
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthChatNoteEaten", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static int NoteEaten(IntPtr textUtf16)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (textUtf16 == IntPtr.Zero) return 0;
|
||||
return Runtime.Plugin?.NoteEaten(Marshal.PtrToStringUni(textUtf16)) == true ? 1 : 0;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthChatSendLine", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void SendLine(IntPtr ansiText)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using RynthCore.PluginCore;
|
||||
|
||||
|
|
@ -7,10 +7,19 @@ namespace RynthCore.Plugin.RynthChat;
|
|||
public sealed class RynthChatPlugin : RynthPluginBase
|
||||
{
|
||||
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthChat");
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.3.0");
|
||||
// Previous release: 0.3.4.
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.3.5");
|
||||
|
||||
/// <summary>How long after login completes the server's system text still counts as the login burst.</summary>
|
||||
internal const long LoginBurstMs = 30_000;
|
||||
|
||||
private readonly ChatBuffer _buffer = new();
|
||||
|
||||
// The login burst: on until a login completes, then for LoginBurstMs more (the welcome,
|
||||
// MOTD, house / allegiance notices and the plugins' login probes). On again at logout.
|
||||
private volatile bool _loggedIn;
|
||||
private long _loginBurstUntilMs;
|
||||
|
||||
public override int Initialize()
|
||||
{
|
||||
Host.Log("[RynthChat] Plugin initialized.");
|
||||
|
|
@ -19,20 +28,25 @@ public sealed class RynthChatPlugin : RynthPluginBase
|
|||
|
||||
public override void OnLoginComplete()
|
||||
{
|
||||
_loggedIn = true;
|
||||
System.Threading.Interlocked.Exchange(ref _loginBurstUntilMs, Environment.TickCount64 + LoginBurstMs);
|
||||
Host.Log("[RynthChat] Login complete.");
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
{
|
||||
_loggedIn = false;
|
||||
Host.Log("[RynthChat] Logout.");
|
||||
}
|
||||
|
||||
/// <summary>Entering the world, or within LoginBurstMs of the login completing.</summary>
|
||||
private bool InLoginBurst =>
|
||||
!_loggedIn || Environment.TickCount64 < System.Threading.Interlocked.Read(ref _loginBurstUntilMs);
|
||||
|
||||
public override void OnChatWindowText(string? text, int chatType, ref int eat)
|
||||
{
|
||||
// A plugin earlier in the dispatch ate the line (RynthAi's Meta Manager eats the
|
||||
// reply to its own /myquests poll): keep it out of the chat window.
|
||||
if (eat != 0) return;
|
||||
_buffer.Add(text, chatType);
|
||||
// Always buffer for RynthChat, even when an earlier plugin ate the line for retail.
|
||||
_buffer.Add(text, chatType, InLoginBurst);
|
||||
}
|
||||
|
||||
public override void OnChatBarEnter(string? text, ref int eat)
|
||||
|
|
@ -44,12 +58,18 @@ public sealed class RynthChatPlugin : RynthPluginBase
|
|||
|
||||
internal int SetScrollbackCapacity(int lines) => _buffer.SetCapacity(lines);
|
||||
|
||||
/// <summary>The engine reports that a plugin ate the line just dispatched (RynthChatNoteEaten).</summary>
|
||||
internal bool NoteEaten(string? text) => _buffer.NoteEaten(text);
|
||||
|
||||
// Called on the game thread from the engine's deferred chat dispatch
|
||||
// (Win32Backend posts WM_RYNTHCORE_CHAT so this runs on a fresh, non-reentrant
|
||||
// message dispatch rather than inline inside the Enter keystroke handler).
|
||||
internal void SendLine(string text)
|
||||
{
|
||||
if (!Host.HasInvokeChatParser || string.IsNullOrWhiteSpace(text)) return;
|
||||
// Typed by the player: a quest list they ask for shows (plugins' own reads stay hidden).
|
||||
if (ChatClassifier.IsQuestListCommand(text)) _buffer.NoteTypedQuestCommand();
|
||||
else if (ChatClassifier.IsBankBalanceCommand(text)) _buffer.NoteTypedBankCommand();
|
||||
Host.InvokeChatParser(text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue