Snapshot for release 2026.10.15.2 (internal 2d4b0af)

This commit is contained in:
Tom Bohar 2026-10-15 20:32:35 -04:00
commit d5e0b50de7
224 changed files with 17914 additions and 1182 deletions

View file

@ -5,17 +5,33 @@
// /rc bounties). Its reads run only while that window polls RynthILTGetBountiesJson, and the
// engine polls only on ILT.
// * The ILT Hub (Hub/, SilentKelpie's, moved here from RynthAi 2026-10-13): the Mini Remote's
// ILT tabs (Character, Banking, Gear, Charms, Games; RynthAi's Mini Remote hosts them through
// RynthILT.Hub, HubInterface.cs), their sections in its Quests / Pets / Remote tabs, the
// Guardian panel (RynthPluginRenderEmbed "guardian"), the Skills panel's Progression data
// (RynthILTGetProgressionJson, "prog ..." through RynthILTCommand), server feature detection.
// Every feature stays dormant off an ILT-like world (IltServerOptions: no probes, no chat).
// ILT tabs (Banking, Gear, Charms, Games; RynthAi's Mini Remote hosts them through
// RynthILT.Hub, HubInterface.cs, and lists them on RynthCore's sections rail; the Gear tab has
// the Rings inscription chain; the Character tab moved to RynthOracle's Character tab), its
// own Mini Remote sections (BuildSectionsJson: the ILT session extras in Session Stats, the
// /fship buttons in Fellowship, the /qb list in a Quests section), its sections in RynthAi's
// Pets / Remote tabs, the Guardian panel (RynthPluginRenderEmbed "guardian"),
// the Skills panel's Progression data (RynthILTGetProgressionJson, "prog ..." through
// RynthILTCommand), server feature detection, and the charms and bank balances for other
// plugins ("RynthILT.Data", DataInterface.cs). Every feature stays dormant off an ILT-like
// world (IltServerOptions: no probes, no chat).
//
// Second: a copy of the ILT settings (IltSettingsView/): RynthCore's verdict, this character's
// override (read only: it is set in RynthCore Options > Diagnostics), the ILT world names and
// every feature the Hub read from the server, in its own window ("/ilt settings"). The verdict
// comes from RynthCore's server list (plugin API v86, polled every 2 s), and the Hub follows it
// once one arrives (IltEngineVerdict).
//
// Third: ILT's fellowship commands (IltFellowship/, ACECustom /fship) as buttons in RynthCore's
// Fellowship section and their own window ("/ilt fellow"). While ILT is active the list is also
// sent to RynthAi ("servercommands"), whose Fellowship view draws them; an empty list clears it.
//
// Threads: OnTick, OnChatWindowText, OnKillNotification, login/logout and the engine's export calls
// run on the plugin pump. OnChatBarEnter runs on AC's main thread (the engine's dispatcher queues it
// there, our own InvokeChatParser too), and RynthAi forwards its "/ra hub ..." verbs from there too,
// so commands only queue and run on the next tick. OnRender / RenderEmbed and the RynthILT.Hub
// render functions run on the render thread and only read what the pump built.
// render functions run on the render thread and only read what the pump built; the settings and
// fellowship windows queue their chat commands for the tick.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -24,6 +40,8 @@ using System.Runtime.InteropServices;
using ImGuiNET;
using RynthCore.Plugin.RynthILT.Bounty;
using RynthCore.Plugin.RynthILT.Hub;
using RynthCore.Plugin.RynthILT.IltFellowship;
using RynthCore.Plugin.RynthILT.IltSettingsView;
using RynthCore.Plugin.Shared;
using RynthCore.PluginCore;
@ -32,7 +50,51 @@ namespace RynthCore.Plugin.RynthILT;
public sealed class RynthILTPlugin : RynthPluginBase
{
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthILT");
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.0");
// Previous release: 0.3.1.
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.3.2");
/// <summary>
/// The settings view's surface. Not in the sections manifest (the force-server override lives
/// only in RynthCore Options > Diagnostics), but still drawn for an engine that asks.
/// </summary>
internal const string SettingsSurface = "section:ilt-settings";
/// <summary>The ILT session extras' surface in RynthCore's Mini Remote "Session Stats" section.</summary>
internal const string RatesSurface = "section:ilt-rates";
/// <summary>The fellowship commands' surface in RynthCore's Fellowship section.</summary>
internal const string FellowshipSurface = "section:ilt-fellowship";
/// <summary>
/// The quest bonus list (/qb) in RynthILT's own Mini Remote "Quests" section (it was part of
/// RynthAi's Quests tab, which moved to RynthOracle; Infinite Leaftide's /qb stays RynthILT's).
/// </summary>
internal const string QuestBonusSurface = "section:ilt-questbonus";
/// <summary>RynthAi's name for the plugin-command broker (its Fellowship view draws our commands).</summary>
private const string RynthAiPlugin = "RynthAi";
private readonly IltSettingsModel _settingsModel = new();
private readonly IltSettingsUi _settingsUi;
private readonly IltFellowshipUi _fellowshipUi;
// Chat commands from the settings and fellowship windows (render thread), run on the next tick.
private readonly ConcurrentQueue<string> _chatCommands = new();
private const int MaxQueuedChatCommands = 32;
public RynthILTPlugin()
{
_settingsUi = new IltSettingsUi(_settingsModel, cmd => QueueChatCommand(cmd), RefreshFeatures);
_fellowshipUi = new IltFellowshipUi(QueueChatCommand);
IltEngineVerdict.Attach(_settingsModel);
}
/// <summary>Render thread: queues a chat command for the tick; false when the engine can't run one.</summary>
private bool QueueChatCommand(string command)
{
if (!Host.HasInvokeChatParser || _chatCommands.Count >= MaxQueuedChatCommands) return false;
_chatCommands.Enqueue(command);
return true;
}
/// <summary>Wait this long after login for the character's name before tracking without a save file.</summary>
private const long NameWaitMs = 30_000;
@ -100,6 +162,7 @@ public sealed class RynthILTPlugin : RynthPluginBase
_nextNameTryMs = 0;
_nextHubTryMs = 0;
_ai?.Reset();
PollServerState(force: true);
TryStartBounties();
TryStartHub();
}
@ -111,16 +174,24 @@ public sealed class RynthILTPlugin : RynthPluginBase
StopHub();
_ai?.Reset();
_loginComplete = false;
ClearSharedFellowshipCommands();
while (_commands.TryDequeue(out _)) { }
while (_typedBounty.TryDequeue(out _)) { }
while (_engineCommands.TryDequeue(out _)) { }
while (_chatCommands.TryDequeue(out _)) { }
_settingsModel.Clear();
_serverStateJson = string.Empty;
}
// Plugin unload (hot reload, update, client closing): keep the list and the Hub state for the next copy.
// Plugin unload (hot reload, update, client closing): keep the list and the Hub state for the
// next copy. No broker call while the engine unloads us: RynthAi drops the fellowship commands
// once they stop arriving (ServerCommandModel.StaleMs).
public override void Shutdown()
{
SaveBounties();
StopHub();
HubInterface.Release();
IltEngineVerdict.Attach(null);
RynthLog.Shutdown();
}
@ -129,16 +200,264 @@ public sealed class RynthILTPlugin : RynthPluginBase
try { RynthLog.Pump(); } catch { }
if (!_loginComplete) return;
_ai?.Tick();
PollServerState(force: false);
if (_bounties == null) TryStartBounties();
if (_hub == null) TryStartHub();
DrainTypedBounty();
while (_commands.TryDequeue(out string[]? parts)) RunCommand(parts);
while (_engineCommands.TryDequeue(out string? engineCommand)) RunEngineCommand(engineCommand);
DrainChatCommands();
_bounties?.Tick();
try { _hub?.Tick(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "Tick"); }
RetryPendingMigration();
PostDataWriteProblems();
try { PublishHubFeatures(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "PublishHubFeatures"); }
try { ShareFellowshipCommands(); }
catch (Exception ex) { Host.Log($"[RynthILT] Fellowship commands to RynthAi failed: {ex.Message}"); }
}
// ── ILT fellowship commands for RynthAi's Fellowship view (IltFellowship/) ──
private const long FellowshipShareCheckMs = 2000;
private const long FellowshipShareResendMs = 10_000;
private long _fellowshipShareNextAt;
private long _fellowshipShareSentAt;
// The last payload RynthAi took; empty when nothing was delivered (or after a clear).
private string _fellowshipShareLast = string.Empty;
/// <summary>
/// Plugin tick: sends RynthAi ILT's fellowship commands while ILT is active (an empty list when
/// it isn't), when that changes and every <see cref="FellowshipShareResendMs"/> (RynthAi may load
/// later, and drops a list that stops arriving). Nothing on an engine without the broker.
/// </summary>
private void ShareFellowshipCommands()
{
if (!Host.HasSendPluginCommand) return;
long now = Environment.TickCount64;
if (now < _fellowshipShareNextAt) return;
_fellowshipShareNextAt = now + FellowshipShareCheckMs;
bool active = IltActive();
// Nothing to clear when RynthAi never got a list.
if (!active && _fellowshipShareLast.Length == 0) return;
string payload = IltFellowshipCommands.Payload(active);
if (payload == _fellowshipShareLast && now - _fellowshipShareSentAt < FellowshipShareResendMs) return;
_fellowshipShareSentAt = now;
// Not delivered (RynthAi not installed or not loaded yet): the resend timer tries again.
if (Host.SendPluginCommand(RynthAiPlugin, ServerCommandShare.Action, payload))
_fellowshipShareLast = active ? payload : string.Empty;
}
/// <summary>Clears RynthAi's copy of the fellowship commands (logout) if it has one.</summary>
private void ClearSharedFellowshipCommands()
{
if (_fellowshipShareLast.Length == 0) return;
_fellowshipShareLast = string.Empty;
_fellowshipShareNextAt = 0;
try
{
if (Host.HasSendPluginCommand)
Host.SendPluginCommand(RynthAiPlugin, ServerCommandShare.Action, IltFellowshipCommands.Payload(active: false));
}
catch { /* RynthAi drops a list that stops arriving */ }
}
/// <summary>
/// The Hub's world check (RynthCore's verdict once it has one, else RynthILT's server list and
/// "Treat this world as ILT"); before the Hub exists, the engine verdict or the world name
/// (IltFellowshipCommands.IsActive).
/// </summary>
private bool IltActive()
{
var hub = _hub;
if (hub != null) return hub.Options.IsIltLikeWorld;
bool? engine = IltEngineVerdict.Active;
string world = engine == null && Host.HasGetWorldName && Host.TryGetWorldName(out string w) ? w : string.Empty;
return IltFellowshipCommands.IsActive(engine, world);
}
// ── RynthCore's Mini Remote sections ─────────────────────────────────────
/// <summary>
/// The broker actions answered on arrival rather than queued for the tick: RynthCore's
/// "servermenu" push (2026.10.5.47+, every 10 s) and the older "iltfeatures" text.
/// </summary>
internal static bool IsParsedRemoteAction(string action) =>
action.Equals("servermenu", StringComparison.OrdinalIgnoreCase)
|| action.Equals("iltfeatures", StringComparison.OrdinalIgnoreCase);
/// <summary>
/// RynthPluginApplyRemoteCommand "servermenu" / "iltfeatures". Any thread. Taken and dropped:
/// the same verdicts, overrides and world names reach the settings model from RynthCore's
/// server list (plugin API v86, PollServerState), which RynthILT reads itself, so the push is
/// only acknowledged (it must not fall through to the ILT verbs).
/// </summary>
internal void ApplyRemoteCommand(string action, string value) { }
/// <summary>
/// RynthPluginRenderEmbed: <see cref="RatesSurface"/> (Session Stats), <see cref="FellowshipSurface"/>
/// (Fellowship), <see cref="QuestBonusSurface"/> (RynthILT's Quests section) or
/// <see cref="SettingsSurface"/> in RynthCore's Mini Remote, drawn into the engine's current
/// window and context (popped-out windows have their own). <paramref name="wantHeight"/> is the
/// height it used. False until login or for another surface. Render thread.
/// </summary>
internal bool RenderEmbedded(string surface, out float wantHeight)
{
wantHeight = 0;
if (!_loginComplete) return false;
Action? body = surface switch
{
SettingsSurface => _settingsUi.RenderBody,
FellowshipSurface => _fellowshipUi.RenderBody,
RatesSurface => RenderRatesSurface,
QuestBonusSurface => RenderQuestBonusSurface,
_ => null,
};
if (body == null) return false;
IntPtr previous = ImGui.GetCurrentContext();
IntPtr context = previous != IntPtr.Zero ? previous : Host.ImGuiContext;
if (context == IntPtr.Zero) return false;
ImGui.SetCurrentContext(context);
try
{
float startY = ImGui.GetCursorPosY();
body();
wantHeight = MathF.Max(40f, ImGui.GetCursorPosY() - startY + 4f);
return true;
}
catch (Exception ex)
{
Host.Log($"[RynthILT] View {surface} failed: {ex.Message}");
return false;
}
finally { ImGui.SetCurrentContext(previous); }
}
/// <summary>The ILT session extras (render thread), or a line saying they start with the Hub.</summary>
private void RenderRatesSurface()
{
IltHubController? hub = _hub;
if (hub == null) { ImGui.TextDisabled("ILT session rates start once RynthILT's Hub is ready."); return; }
hub.RenderRatesSection();
}
/// <summary>The /qb list (render thread), or a line saying it starts with the Hub.</summary>
private void RenderQuestBonusSurface()
{
IltHubController? hub = _hub;
if (hub == null) { ImGui.TextDisabled("The quest bonus list starts once RynthILT's Hub is ready."); return; }
hub.RenderQuestBonusSection();
}
/// <summary>
/// RynthPluginGetSectionsJson (schema 1, UI/Sections/SectionManifest.cs in RynthCore): the ILT
/// session extras in Session Stats ("char"), the fellowship commands in Fellowship and the /qb
/// list in a Quests section of RynthILT's own, all Infinite Leaftide areas (shown while RynthCore
/// treats this world as ILT). The Mini Remote ILT tabs (Banking, Gear, Charms, Games) are listed
/// by RynthAi, which hosts them. Null before login.
/// </summary>
internal string? BuildSectionsJson() => _loginComplete ? SectionsJson : null;
internal const string SectionsJson =
"{\"version\":1,\"sections\":[{\"id\":\"quests\",\"label\":\"Quests\",\"order\":1160}],\"contributions\":[" +
"{\"section\":\"char\",\"server\":\"ilt\"," +
"\"label\":\"ILT session rates (RynthILT)\",\"surface\":\"" + RatesSurface + "\",\"primary\":false," +
"\"height\":220,\"enabled\":true,\"tooltip\":\"Enlightened Coins, pyreals and item conversions this session, " +
"on the same clock as RynthAi's session stats (RynthILT).\",\"order\":120}," +
"{\"section\":\"fellowship\",\"server\":\"ilt\"," +
"\"label\":\"ILT fellowship (RynthILT)\",\"surface\":\"" + FellowshipSurface + "\",\"primary\":false," +
"\"height\":110,\"enabled\":true,\"tooltip\":\"Infinite Leaftide's /fship commands: create, invite, dismiss, " +
"invite your landblock, list nearby, leave, disband (RynthILT; also /ilt fellow).\",\"order\":120}," +
"{\"section\":\"quests\",\"server\":\"ilt\"," +
"\"label\":\"Quest bonus (/qb)\",\"surface\":\"" + QuestBonusSurface + "\",\"primary\":true," +
"\"width\":520,\"height\":440,\"enabled\":true,\"tooltip\":\"Infinite Leaftide's quest bonus list: completed and " +
"incomplete /qb flags (RynthILT; the quest list, timers and rewards are RynthOracle's, /ro).\",\"order\":100}]}";
/// <summary>Plugin tick: runs the settings and fellowship views' chat commands through the engine.</summary>
private void DrainChatCommands()
{
while (_chatCommands.TryDequeue(out string? command))
{
if (!Host.HasInvokeChatParser || !Host.InvokeChatParser(command))
ChatLine("[RynthILT] RynthCore didn't take: " + command);
}
}
private const long ServerStatePollMs = 2000;
private long _serverStateNextAt;
private string _serverStateJson = string.Empty;
/// <summary>
/// Plugin tick, every 2 s (and at login): RynthCore's server list (plugin API v86,
/// GetServerStateJson) into the settings model, whose "ilt" entry the Hub's world check follows
/// (IltEngineVerdict). Parsed only when the text changed. An older engine leaves it empty, and
/// RynthILT's own list decides.
/// </summary>
private void PollServerState(bool force)
{
long now = Environment.TickCount64;
if (!force && now < _serverStateNextAt) return;
_serverStateNextAt = now + ServerStatePollMs;
try
{
if (!Host.HasGetServerStateJson || !Host.TryGetServerStateJson(out string json) || json == _serverStateJson) return;
_serverStateJson = json;
_settingsModel.ApplyServerState(EngineServerState.Parse(json));
}
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "PollServerState"); }
}
private const long FeaturePublishMs = 1000;
private long _featurePublishNextAt;
/// <summary>
/// Plugin tick, at most once a second: the Hub's server read (world, last check, feature bits)
/// for the ILT settings view (IltSettingsModel.PublishFeatures); cleared while there is no Hub.
/// </summary>
private void PublishHubFeatures()
{
long now = Environment.TickCount64;
if (now < _featurePublishNextAt) return;
_featurePublishNextAt = now + FeaturePublishMs;
var hub = _hub;
if (hub == null)
{
_settingsModel.PublishFeatures(null);
return;
}
var options = hub.Options;
DateTime last = options.LastRefreshUtc;
string when = last == default ? string.Empty : last.ToLocalTime().ToString("HH:mm:ss");
_settingsModel.PublishFeatures(new IltFeatureView(options.WorldName, options.Source ?? string.Empty, when,
options.IsRefreshing, options.IsIltLikeWorld, BuildFeatureRows(options)));
}
/// <summary>
/// The settings view's feature rows: every catalog feature with its state (IltFeatureCatalog),
/// then each ILT charm ("charm:...", on with the world unless refused in chat), then any other
/// bit chat or a probe set that the catalog doesn't show. Pump thread.
/// </summary>
private static KeyValuePair<string, int>[] BuildFeatureRows(IltServerOptions options)
{
bool ilt = options.IsIltLikeWorld;
var rows = new List<KeyValuePair<string, int>>(IltFeatureCatalog.All.Length + 32);
var shown = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (IltFeatureInfo f in IltFeatureCatalog.All)
{
rows.Add(new KeyValuePair<string, int>(f.Key, (int)IltFeatureCatalog.StateOf(f, ilt, options.Get)));
if (f.ServerBit != null) shown.Add(f.ServerBit);
}
foreach (IltCharmDef def in IltInventory.Charms)
{
string key = IltFeature.Charm(def.Name);
rows.Add(new KeyValuePair<string, int>(key, (int)IltFeatureCatalog.CharmStateOf(ilt, options.Get(key))));
shown.Add(key);
}
foreach (var bit in options.SnapshotBits())
if (shown.Add(bit.Key)) rows.Add(bit);
return rows.ToArray();
}
/// <summary>
@ -151,6 +470,16 @@ public sealed class RynthILTPlugin : RynthPluginBase
DataWriteGuard.DrainChat(line => Host.WriteToChat(line, 2));
}
// ── ILT settings ─────────────────────────────────────────────────────────
/// <summary>Asks the Hub to read the server's ILT features again (as "/ilt hub refresh", on the next tick). Render thread.</summary>
private bool RefreshFeatures()
{
if (!_loginComplete || _hub == null) return false;
_commands.Enqueue(new[] { "/ilt", "hub", "refresh" });
return true;
}
public override void OnChatWindowText(string? text, int chatType, ref int eat)
{
if (string.IsNullOrEmpty(text)) return;
@ -201,15 +530,26 @@ public sealed class RynthILTPlugin : RynthPluginBase
// ── Rendering (render thread) ────────────────────────────────────────────
/// <summary>The Hub's floating extras (Games HUD, confirmations) in the engine's ImGui frame.</summary>
/// <summary>
/// The Hub's floating extras (Games HUD, confirmations) and the standalone ILT settings and
/// fellowship windows ("/ilt settings", "/ilt fellow") in the engine's ImGui frame.
/// </summary>
public override void OnRender()
{
var hub = _hub;
if (!_loginComplete || hub == null || Host.ImGuiContext == IntPtr.Zero) return;
if (!_loginComplete || Host.ImGuiContext == IntPtr.Zero) return;
if (hub == null && !_settingsUi.WindowOpen && !_fellowshipUi.WindowOpen) return;
IntPtr previous = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(Host.ImGuiContext);
try { hub.Render(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnRender"); }
try
{
try { hub?.Render(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnRender"); }
try { _settingsUi.RenderWindow(); }
catch (Exception ex) { Host.Log($"[RynthILT] Settings window failed: {ex.Message}"); _settingsUi.WindowOpen = false; }
try { _fellowshipUi.RenderWindow(); }
catch (Exception ex) { Host.Log($"[RynthILT] Fellowship window failed: {ex.Message}"); _fellowshipUi.WindowOpen = false; }
}
finally { ImGui.SetCurrentContext(previous); }
}
@ -334,9 +674,28 @@ public sealed class RynthILTPlugin : RynthPluginBase
case "hub":
case "rates":
break;
case "settings":
case "options":
{
// "/ilt settings [show|hide|toggle]": the ILT settings window.
string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle";
_settingsUi.WindowOpen = mode switch { "show" or "on" => true, "hide" or "off" => false, _ => !_settingsUi.WindowOpen };
return;
}
case "fellow":
case "fellowship":
case "fship":
{
// "/ilt fellow [show|hide|toggle]": the ILT fellowship commands window.
string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle";
_fellowshipUi.WindowOpen = mode switch { "show" or "on" => true, "hide" or "off" => false, _ => !_fellowshipUi.WindowOpen };
return;
}
case "help":
ChatLine("[RynthILT] /ilt hub ... (the Mini Remote's ILT tabs; same as /ra hub ...), /ilt guardian ..., /ilt servers [list|<names>|default],");
ChatLine("[RynthILT] /ilt bounty [list|refresh] - the tracked ACECustom bounties (the Bounties window: the ILT button on the RynthCore bar, or /rc bounties),");
ChatLine("[RynthILT] /ilt settings [show|hide|toggle] - the ILT settings: the world verdict, the ILT world names and the server's features (force a server: RynthCore Options > Diagnostics),");
ChatLine("[RynthILT] /ilt fellow [show|hide|toggle] - ILT's /fship commands as buttons (also in the Mini Remote's Fellowship section),");
ChatLine("[RynthILT] /ilt trace <category|all|list> [on|off], /ilt debug [on|off].");
return;
default: