RynthSuite as of 2026-11-17 (internal d924ac04): release 2026.11.17.1

This commit is contained in:
Tom Bohar 2026-11-17 10:32:00 -05:00
commit 88f0aac49a
72 changed files with 7910 additions and 172 deletions

View file

@ -32,8 +32,11 @@ internal sealed class QuestFlag
}
}
/// <summary>What one chat line is, as far as /myquests goes.</summary>
internal enum MyQuestsLine { None, Quest, Empty, Disabled, Throttled }
/// <summary>
/// What one chat line is, as far as /myquests goes. TooRecent: the server turned a quest down
/// ("You have solved this quest too recently!" and its "You may complete this quest again in ...").
/// </summary>
internal enum MyQuestsLine { None, Quest, Empty, Disabled, Throttled, TooRecent }
/// <summary>
/// The character's quest flags, read from the server's /myquests reply (ACE: one Broadcast line
@ -57,6 +60,23 @@ internal sealed class QuestFlagStore
public const string DisabledText = "The command \"myquests\" is not currently enabled on this server.";
/// <summary>ACECustom's per-session throttle reply ("... may only be run once every 60 seconds.").</summary>
public const string ThrottledText = "[MyQuests] This command may only be run once every";
/// <summary>ACE's QuestManager when a quest is turned down on its timer; the next line says how long.</summary>
public const string TooRecentText = "You have solved this quest too recently!";
public const string AgainInText = "You may complete this quest again in ";
// A chat timestamp the client may put first (as LineRegex allows), then the server's line.
private static readonly Regex AgainInRegex = new(
@"^\s*(?:\d{1,2}:\d{2}(?::\d{2})?(?:\s*[AP]M)?\s+)?You may complete this quest again in (?<left>[^.]+)\.?\s*$",
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
private static readonly Regex WaitPartRegex = new(@"(?<n>\d+)\s*(?<u>d|h|m|s)[a-z]*",
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
/// <summary>
/// How old the flags may get while a page or alert uses their timers before they are read again
/// (2026-11-13, R-20261110-155059-e947). /myquests was read once at login, so a quest done after
/// that kept the stamp from before it and showed "ready" for the rest of a long session.
/// </summary>
public static readonly TimeSpan StaleAfter = TimeSpan.FromMinutes(10);
private const int QuietMs = 1500; // a reply is complete once no line came for this long
private const int RequestTimeoutMs = 10_000;
@ -89,6 +109,17 @@ internal sealed class QuestFlagStore
/// <summary>Bumps whenever the flags change (views rebuild their caches on it).</summary>
public int Revision { get; private set; }
/// <summary>
/// The flags held are known to be out of date (the server turned a quest down on its timer, or a
/// timer alert wants the fresh reading first): read again as soon as the server allows. Cleared
/// when a reply lands. 2026-11-13, R-20261110-155059-e947.
/// </summary>
public bool RereadWanted { get; private set; }
/// <summary>The server's last "You may complete this quest again in ..." (the wait, and when it was said).</summary>
public (TimeSpan Left, DateTime AtUtc)? LastServerWait { get; private set; }
public void WantReread() => RereadWanted = true;
// Our own request: its reply may be hidden from chat.
public bool AwaitingOurs { get; private set; }
private long _requestedMs = long.MinValue / 2;
@ -127,7 +158,9 @@ internal sealed class QuestFlagStore
}
/// <summary>Classifies a chat line and takes in its flag.</summary>
public MyQuestsLine OnChatLine(string? text, long nowMs)
public MyQuestsLine OnChatLine(string? text, long nowMs) => OnChatLine(text, nowMs, DateTime.UtcNow);
public MyQuestsLine OnChatLine(string? text, long nowMs, DateTime utcNow)
{
if (string.IsNullOrEmpty(text)) return MyQuestsLine.None;
string line = text.Trim();
@ -156,6 +189,22 @@ internal sealed class QuestFlagStore
Revision++;
return MyQuestsLine.Throttled;
}
// The server turned a quest down on its timer: what is held for it is out of date (the
// report above: Oracle said "ready", the server said 2h 50m). The lines don't name the quest,
// so the fix is a fresh /myquests; the wait is kept so the plugin can log which flag it was.
// Only a whole line counts: a player quoting it in a tell gets at most one extra read.
if (line.EndsWith(TooRecentText, StringComparison.Ordinal) && line.Length - TooRecentText.Length <= 12)
{
RereadWanted = true;
return MyQuestsLine.TooRecent;
}
if (line.Contains(AgainInText, StringComparison.Ordinal))
{
if (!TryParseAgainIn(line, out TimeSpan left)) return MyQuestsLine.None;
LastServerWait = (left, utcNow);
RereadWanted = true;
return MyQuestsLine.TooRecent;
}
if (line.IndexOf(" solves (", StringComparison.Ordinal) < 0) return MyQuestsLine.None;
QuestFlag? flag = Parse(line);
@ -193,6 +242,7 @@ internal sealed class QuestFlagStore
Flags = reply;
}
LastReadUtc = DateTime.UtcNow;
RereadWanted = false;
// On a throttling server any reply (ours, the player's, RynthAi's poll) starts its minute.
if (_serverThrottles)
ThrottledUntilMs = nowMs + ServerThrottleMs - QuietMs;
@ -215,9 +265,64 @@ internal sealed class QuestFlagStore
ThrottledUntilMs = long.MinValue / 2;
_serverThrottles = false;
LastPartialReply = null;
RereadWanted = false;
LastServerWait = null;
Revision++;
}
/// <summary>
/// Whether the held flags should be read again now (the plugin also checks its own settings and
/// spacing): the server said they are out of date, or something uses their timers
/// (<paramref name="timersInUse"/>: a quest page or the Quest Timers window showing, timer alerts
/// on) and they are older than <see cref="StaleAfter"/>. Never before the first read (the login
/// read does that), while a reply is coming in, or on a server without /myquests.
/// 2026-11-13, R-20261110-155059-e947.
/// </summary>
public bool NeedsReread(DateTime utcNow, bool timersInUse)
{
if (LastReadUtc == DateTime.MinValue || Loading || ServerDisabled) return false;
return RereadWanted || timersInUse && utcNow - LastReadUtc >= StaleAfter;
}
/// <summary>"You may complete this quest again in 2h 50m 42s." -> 2:50:42 (ACE's friendly time: d, h, m, s parts).</summary>
internal static bool TryParseAgainIn(string line, out TimeSpan left)
{
left = TimeSpan.Zero;
Match m = AgainInRegex.Match(line);
if (!m.Success) return false;
bool any = false;
foreach (Match p in WaitPartRegex.Matches(m.Groups["left"].Value))
{
if (!long.TryParse(p.Groups["n"].Value, NumberStyles.None, CultureInfo.InvariantCulture, out long n) || n > 100_000) return false;
left += char.ToLowerInvariant(p.Groups["u"].Value[0]) switch
{
'd' => TimeSpan.FromDays(n),
'h' => TimeSpan.FromHours(n),
'm' => TimeSpan.FromMinutes(n),
_ => TimeSpan.FromSeconds(n),
};
any = true;
}
return any;
}
/// <summary>
/// The held flags whose timers have about <paramref name="left"/> to go at <paramref name="atUtc"/>
/// (the server's "again in" wait), closest first: which quest the server turned down, for the log.
/// </summary>
public List<(QuestFlag Flag, TimeSpan Off)> WaitingAbout(TimeSpan left, DateTime atUtc, TimeSpan tolerance)
{
var found = new List<(QuestFlag, TimeSpan)>();
foreach (QuestFlag f in Flags.Values)
{
if (f.RepeatTime <= TimeSpan.Zero) continue;
TimeSpan off = f.NextAvailableTime(atUtc) - left;
if (off.Duration() <= tolerance) found.Add((f, off));
}
found.Sort((a, b) => a.Item2.Duration().CompareTo(b.Item2.Duration()));
return found;
}
public bool TryGet(string flag, out QuestFlag q) => Flags.TryGetValue(flag, out q!);
internal static QuestFlag? Parse(string line)

View file

@ -27,6 +27,15 @@ public sealed class RynthOraclePlugin : RynthPluginBase
// The Character tab's session (RynthAi): read only while that tab is on screen.
private const long CharacterExtrasReadMs = 2000;
private const long BookWorldWaitMs = 15_000; // how long the quest book waits for the world name
// Re-reading /myquests during a session (2026-11-13, R-20261110-155059-e947): at most one of
// RynthOracle's own re-reads a minute (the throttling servers' limit, and a long list is a big
// chat burst), and a timer alert holds this long for the fresh reading before printing anyway.
private const long AutoReadGapMs = 60_000;
private const long AlertConfirmWaitMs = 120_000;
// A timer alert from flags read longer ago than this is checked against a fresh read first.
private static readonly TimeSpan AlertConfirmAge = TimeSpan.FromMinutes(2);
// How far the server's "again in" wait may sit from a held flag's timer and still be that quest.
private static readonly TimeSpan ServerWaitTolerance = TimeSpan.FromMinutes(2);
private readonly OracleContext _c = new();
private readonly UiHost _ui = new();
@ -51,6 +60,14 @@ public sealed class RynthOraclePlugin : RynthPluginBase
private int _seenPackRevision = -1; // the active server plugin's quest pack (ServerQuestPackClient.Revision)
private int _titleCount = -2;
private uint _titleCurrent;
private long _nextAutoReadMs;
private DateTime _seenReadUtc = DateTime.MinValue;
// The server's "again in" wait not yet checked against a read made after it (the log line).
private (TimeSpan Left, DateTime AtUtc)? _uncheckedServerWait;
// Timer alerts held for a fresh read (flags read too long ago to trust a "ready").
private readonly System.Collections.Generic.List<Quest> _heldAlerts = new();
private long _heldAlertsSinceMs;
private DateTime _heldAlertsReadUtc;
public override int Initialize()
{
@ -146,9 +163,18 @@ public sealed class RynthOraclePlugin : RynthPluginBase
// The quest book loads once the character's name (and world) are known (TickData).
_c.Book.Clear();
_c.Timers.Reset();
ResetRereads();
if (_timers != null) { _timers.Visible = _c.Settings.QuestTimersOpen; _timers.NeedsPass = true; }
}
private void ResetRereads()
{
_nextAutoReadMs = 0;
_seenReadUtc = DateTime.MinValue;
_uncheckedServerWait = null;
_heldAlerts.Clear();
}
public override void OnLogout()
{
_c.InWorld = false;
@ -161,6 +187,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
_ui.SubmitEmpty(Host);
_c.Book.Clear(); // saved as it changed
_c.Timers.Reset();
ResetRereads();
_c.Flags.Clear();
_c.Void.Clear();
_c.Server.Reset();
@ -253,7 +280,17 @@ public sealed class RynthOraclePlugin : RynthPluginBase
long now = Environment.TickCount64;
string line = text.TrimEnd('\r', '\n');
MyQuestsLine kind = _c.Flags.OnChatLine(line, now);
MyQuestsLine kind = _c.Flags.OnChatLine(line, now, DateTime.UtcNow);
if (kind == MyQuestsLine.TooRecent)
{
// Shown as the server sent it; the store now wants a fresh read (TickData sends it).
if (_c.Flags.LastServerWait is { } wait && wait.AtUtc != _uncheckedServerWait?.AtUtc)
{
_uncheckedServerWait = wait;
Host.Log("[RynthOracle] The server turned a quest down: " + DescribeServerWait(wait, "the flags held"));
}
return;
}
if (kind != MyQuestsLine.None)
{
// Only the reply to RynthOracle's own request, and only when the setting says so.
@ -382,6 +419,81 @@ public sealed class RynthOraclePlugin : RynthPluginBase
return sent;
}
// ── Keeping the flags current (2026-11-13, R-20261110-155059-e947) ──────
// The report: every daily quest showed "ready" hours early, and the server turned one down with
// "again in 2h 50m 42s". /myquests was read once at login (34 hours before, in that log), so a
// quest done since kept the stamp from before it and its old timer had long run out. Nothing in
// the log said when the flags were read, so reads, re-reads and the server's turn-downs log now.
/// <summary>
/// RynthOracle may send /myquests on its own during a session: only with the login read on and
/// its replies hidden (a re-read must never print the whole list into chat).
/// </summary>
private bool AutoRereads() => _c.Settings.ReadQuestsAtLogin && _c.Settings.HideOwnQuestReplies;
/// <summary>Something on screen shows quest timers: a quest page of the Oracle window, or the Quest Timers window.</summary>
private bool TimersOnScreen()
{
if (_timers?.Visible == true) return true;
if (_main?.Visible != true || _mainView == null) return false;
string tab = _mainView.Tab;
return tab == OracleView.TabQuests || tab == OracleView.TabAugs || tab == OracleView.TabSociety;
}
/// <summary>Re-reads /myquests when the flags are known stale, or old and on screen; at most once a minute.</summary>
private void RereadIfStale(long now)
{
if (now < _nextAutoReadMs || !AutoRereads()) return;
bool wanted = _c.Flags.RereadWanted;
if (!_c.Flags.NeedsReread(_c.UtcNow, TimersOnScreen())) return;
_nextAutoReadMs = now + AutoReadGapMs;
string why = wanted
? "the server turned a quest down, or a timer alert wants a fresh reading"
: $"the quest timers are on screen and the flags were read {TimeText.Friendly(_c.UtcNow - _c.Flags.LastReadUtc)} ago";
if (RequestQuests()) Host.Log($"[RynthOracle] Re-reading /myquests: {why}.");
}
/// <summary>Logs each /myquests reply that landed (whoever asked) and checks the server's last "again in" against it.</summary>
private void NoteRead()
{
DateTime read = _c.Flags.LastReadUtc;
if (read == _seenReadUtc || read == DateTime.MinValue) return;
DateTime previous = _seenReadUtc;
_seenReadUtc = read;
Host.Log($"[RynthOracle] Read {_c.Flags.Flags.Count} quest flags"
+ (previous == DateTime.MinValue ? " (the first read since login)." : $" (the read before was {TimeText.Friendly(read - previous)} earlier)."));
if (_uncheckedServerWait is { } w && read > w.AtUtc)
{
_uncheckedServerWait = null;
Host.Log("[RynthOracle] After the server turned a quest down: " + DescribeServerWait(w, "the flags just read"));
}
}
/// <summary>
/// "again in 2h 50m 42s; the flags held (read 07:12:05 UTC, 2h 33m before it) have aaaflag at 2h 50m",
/// or that none has about that long to go: which quest it was, and whether Oracle's timer agrees.
/// </summary>
private string DescribeServerWait((TimeSpan Left, DateTime AtUtc) w, string which)
{
var sb = new System.Text.StringBuilder();
sb.Append("again in ").Append(TimeText.Friendly(w.Left)).Append("; ").Append(which);
if (_c.Flags.LastReadUtc == DateTime.MinValue) return sb.Append(" (none read yet)").ToString();
TimeSpan gap = w.AtUtc - _c.Flags.LastReadUtc;
sb.Append($" (read {_c.Flags.LastReadUtc:HH:mm:ss} UTC, ")
.Append(gap >= TimeSpan.Zero ? TimeText.Friendly(gap) + " before it)" : TimeText.Friendly(-gap) + " after it)");
var near = _c.Flags.WaitingAbout(w.Left, w.AtUtc, ServerWaitTolerance);
if (near.Count == 0)
return sb.Append(" have no quest with about that long to go: out of date, or the server's timer isn't the one /myquests gives.").ToString();
sb.Append(" have ");
for (int i = 0; i < near.Count && i < 3; i++)
{
if (i > 0) sb.Append(", ");
TimeSpan held = near[i].Flag.NextAvailableTime(w.AtUtc);
sb.Append(near[i].Flag.Key).Append(" at ").Append(TimeText.Friendly(held));
}
return sb.Append('.').ToString();
}
// ── The Oracle window's Refresh buttons (the data side; Views\RefreshBar.cs has the rest) ──
/// <summary>Reads the character's stats, buffs and (on the Character tab) RynthAi's session now, not at the next timer.</summary>
@ -469,6 +581,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
_c.Flags.LastPartialReply = null;
Host.Log($"[RynthOracle] /myquests reply looked cut short ({partial.Got} lines, {partial.Had} flags held): merged it instead of replacing the list.");
}
NoteRead();
if (_c.Flags.Revision != _seenFlagRevision)
{
_seenFlagRevision = _c.Flags.Revision;
@ -530,6 +643,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
// Another plugin (RynthAi's meta manager) or the player may already have asked.
if (_c.Flags.LastReadUtc == DateTime.MinValue && !_c.Flags.Loading) RequestQuests();
}
RereadIfStale(now);
if (!_dailyCheckStarted && _c.Settings.CheckQuestListDaily
&& _c.UtcNow - _c.Settings.LastQuestListCheckUtc >= QuestCatalogUpdater.Interval)
@ -572,10 +686,41 @@ public sealed class RynthOraclePlugin : RynthPluginBase
/// <summary>Says in chat which watched quest timers came up: tracked quests, or every held quest if so set.</summary>
private void AnnounceTimers()
{
if (!_c.Settings.AlertTimers || !_c.Book.Loaded) { _c.Timers.Reset(); return; }
if (!_c.Settings.AlertTimers || !_c.Book.Loaded) { _c.Timers.Reset(); _heldAlerts.Clear(); return; }
long now = _c.NowMs;
var ready = _c.Timers.Check(_c.Flags, _c.Catalog, _c.Settings.AlertAllTimers ? null : _c.Book.Tracked, _c.UtcNow);
// A timer that ran out on flags read a while ago may be a quest done again since (R-20261110-155059-e947):
// hold the alert for a fresh read rather than call it ready (2026-11-13).
bool confirm = ready.Count > 0 && AutoRereads() && !_c.Flags.ServerDisabled
&& _c.UtcNow - _c.Flags.LastReadUtc > AlertConfirmAge;
foreach (Quest q in ready)
_c.Print($"Quest ready again: {q.Label}");
{
if (!confirm) { _c.Print($"Quest ready again: {q.Label}"); continue; }
if (_heldAlerts.Count == 0) { _heldAlertsSinceMs = now; _heldAlertsReadUtc = _c.Flags.LastReadUtc; }
if (!_heldAlerts.Exists(h => string.Equals(h.Flag, q.Flag, StringComparison.OrdinalIgnoreCase))) _heldAlerts.Add(q);
}
if (confirm) _c.Flags.WantReread();
ReleaseHeldAlerts(now);
}
/// <summary>
/// Held timer alerts once a fresh read is in: still ready, they print; on a timer again (the quest
/// was done since the old read) they're dropped and the watcher alerts when that timer ends. With
/// no read in <see cref="AlertConfirmWaitMs"/> (throttled, no reply) they print as before.
/// </summary>
private void ReleaseHeldAlerts(long now)
{
if (_heldAlerts.Count == 0) return;
bool fresh = _c.Flags.LastReadUtc > _heldAlertsReadUtc;
if (!fresh && now - _heldAlertsSinceMs < AlertConfirmWaitMs) return;
foreach (Quest q in _heldAlerts)
{
if (!fresh || QuestTimer.State(q, _c.Flags, _c.UtcNow, out _) == QuestTimerState.Ready)
_c.Print($"Quest ready again: {q.Label}");
else
Host.Log($"[RynthOracle] No \"ready again\" for {q.Flag}: the fresh read has it on a timer (done again since the last read).");
}
_heldAlerts.Clear();
}
/// <summary>

View file

@ -17,7 +17,10 @@ internal sealed partial class OracleView
OracleSettings s = _c.Settings;
w.SeparatorText("Settings");
w.Checkbox("Read quest flags when you log in", "o.readlogin", s.ReadQuestsAtLogin, v => { s.ReadQuestsAtLogin = v; s.Save(); });
w.Tooltip("Sends /myquests once after login so the quest pages have data.");
// 2026-11-13 (R-20261110-155059-e947): the login read alone went stale over a long session.
w.Tooltip("Sends /myquests after login so the quest pages have data, and again while quest timers are on screen "
+ "and the flags are over 10 minutes old, or when the server turns a quest down as solved too recently "
+ "(only with the replies hidden).");
w.Checkbox("Hide the replies to RynthOracle's own requests", "o.hide", s.HideOwnQuestReplies, v => { s.HideOwnQuestReplies = v; s.Save(); });
w.Tooltip("/myquests. A command you type yourself always shows its reply.");
w.Checkbox("Show the Void window for characters with Void Magic", "o.void", s.AutoShowVoidWindow, v => { s.AutoShowVoidWindow = v; s.Save(); });