feat(suite): ILT Server restore, progress lum/Enl, Oracle Benediction, Handler ring evade

RynthILT: restore RynthILT.Server for Oracle/Mini Remote; aug/enl planners use character AvailableLuminance.
RynthOracle: Asheron Lesser Benediction via lesserbenedictionaug; Skills tabs.
RynthAi: Empyrean Handler lethal-ring back-jump evade (face Handler then xs); pet CD already on sk.
Inventory/Sort: GInv/RSort off bar; inventory links and autostack polish.
This commit is contained in:
BlankenshipG 2026-10-16 12:34:16 -04:00
commit 23efcfee87
42 changed files with 882 additions and 98 deletions

View file

@ -15,8 +15,9 @@
// are bound (deposit and withdraw only); pyreal peas and luminance tokens deposit only.
// Deposit, withdraw and transfer share the server's bank_command_limit throttle; a balance
// refresh doesn't, so it has its own (client-side) spacing.
// Balance lines are parsed whenever they appear (player-typed /bank too) but only EATEN
// when the Hub asked. Transfers always need a confirmation (UB had none).
// Balance lines are parsed whenever they appear. They are EATEN for quiet Hub refreshes
// (login probe, auto-refresh, Banking tab Refresh) and shown only when the player asked
// (typed /bank, or RequestRefresh(quiet: false)). Transfers always need a confirmation.
using System;
using System.Collections.Generic;
using System.Linq;
@ -57,6 +58,12 @@ internal sealed class IltBanking : IIltFeature
private long _moveUntil;
/// <summary>How long after a deposit / withdrawal reply the moved amounts are not income (covers the balance re-read).</summary>
private const long MoveWindowMs = 12_000;
/// <summary>
/// Until this tick, [BANK] balance lines may show in chat (player typed /bank or asked for a
/// loud refresh). Quiet Hub / login probes leave this at 0 so the lines stay hidden.
/// </summary>
private long _showBankReplyUntil;
private const long ShowBankReplyWindowMs = 15_000;
// Render-thread form state.
private string _amountText = string.Empty;
@ -116,6 +123,16 @@ internal sealed class IltBanking : IIltFeature
// ── Commands ────────────────────────────────────────────────────────────
/// <summary>
/// Player typed /bank (or /b with no verb) in the chat bar: the next balance dump may show.
/// Pump thread.
/// </summary>
public void NoteTypedBalanceCommand()
{
_showBankReplyUntil = IltHubContext.NowMs + ShowBankReplyWindowMs;
RynthLog.Trace(LogCat.IltBanking, "NoteTypedBalanceCommand: next [BANK] dump may show in chat");
}
/// <summary>Queues a /bank balance refresh (eaten when <paramref name="quiet"/>).</summary>
public void RequestRefresh(bool quiet)
{
@ -124,6 +141,8 @@ internal sealed class IltBanking : IIltFeature
long now = IltHubContext.NowMs;
if (now - _lastBalanceAt < BalanceSpacingMs) return;
_lastBalanceAt = now;
if (!quiet)
_showBankReplyUntil = now + ShowBankReplyWindowMs;
_ctx.Capture.Enqueue(new IltChatRequest
{
Command = "/bank",
@ -294,7 +313,11 @@ internal sealed class IltBanking : IIltFeature
if (text.StartsWith("[BANK]", StringComparison.OrdinalIgnoreCase))
{
ParseBalanceLine(text);
return false; // eating is decided by the capture queue
// Capture.Eat already hides quiet refreshes; this is the backstop when that miss
// (Silentstorm 2026-10-16: Mini Remote open + 120s auto-refresh leaked every dump).
// Show only while the player asked (typed /bank or loud RequestRefresh).
bool show = IltHubContext.NowMs < _showBankReplyUntil;
return !show;
}
// A deposit or withdrawal reply (ours or a typed /b): the next balance and pack changes are moves.
if (text.StartsWith("Deposited ", StringComparison.Ordinal) || text.StartsWith("Withdrew ", StringComparison.Ordinal))
@ -438,8 +461,10 @@ internal sealed class IltBanking : IIltFeature
int refresh = Bank.AutoRefreshSeconds;
ImGui.SetNextItemWidth(120);
if (ImGui.InputInt("Auto-refresh seconds (0 = off)", ref refresh, 30))
if (ImGui.InputInt("Auto-refresh seconds (0 = login/manual only)", ref refresh, 30))
Bank.AutoRefreshSeconds = refresh <= 0 ? 0 : Math.Max(30, refresh);
if (ImGui.IsItemHovered())
ImGui.SetTooltip("While Mini Remote / Banking is open, re-read /bank this often. 0 = only at login and when you press Refresh (recommended; avoids chat spam).");
ImGui.Separator();
RenderDepositWithdraw();

View file

@ -79,9 +79,9 @@ internal static class IltFeatureCatalog
public static readonly IltFeatureInfo[] All =
{
// Character progression and money.
new("bank", "Banking", GroupCharacter, "Global Inventory > Banking (/ginv bank); Remote tab bank line",
new("bank", "Banking", GroupCharacter, "Global Inventory (/ginv bank); Remote tab bank line",
"Bank pyreals, luminance, keys and coins; deposit, withdraw and transfer (/bank).", IltFeature.Bank, IltKnown.Checked),
new("bank_notes", "Trade note banking", GroupCharacter, "Global Inventory > Banking (/ginv bank, notes)",
new("bank_notes", "Trade note banking", GroupCharacter, "Global Inventory (/ginv bank); trade notes",
"Deposit trade notes as pyreals, withdraw any note from I to MMD, transfer note value (/bank d n).", "bank_notes"),
new("guardian", "Guardian (infinite base attributes)", GroupCharacter, "Guardian panel (/rc guardian)",
"Temple of Enlightenment guardians raise base attributes past the retail cap.", null),

View file

@ -47,6 +47,11 @@ internal sealed class IltHubController
private volatile string _bankJson = string.Empty;
private List<IltBankExport.Row> _siblings = new();
// "RynthILT.Server" profile JSON (Oracle Fellowship / Quests qb / feature list). Rebuilt ~1 s.
private const long ProfileRebuildMs = 1000;
private long _profileBuiltAt;
private volatile string _profileJson = string.Empty;
public IltBanking Banking { get; }
public IltSessionRates Rates { get; }
/// <summary>The quest bonus list (/qb): the Quests tab's section and the Temple tracker's stamps.</summary>
@ -102,6 +107,25 @@ internal sealed class IltHubController
options.ProbeReplyTap = OnProbeReply;
_ui = new IltHubUi(this, _ctx);
_ctx.ShowTab = section => _ctx.Ai.MiniRemoteTab(IltSections.TabId(section), "show");
RebuildProfile();
}
/// <summary>
/// The latest "RynthILT.Server" profile JSON: Leaftide features, fellowship rules, and the /qb
/// list (Plugins/Shared/RynthIltServerApi.cs). Rebuilt on the pump about once a second so any
/// thread (ServerInterface) may read it.
/// </summary>
public string ProfileJson => _profileJson;
/// <summary>Rebuilds <see cref="ProfileJson"/> from the current server options. Pump thread.</summary>
private void RebuildProfile()
{
IltServerOptions o = _ctx.Options;
bool ilt = o.IsIltLikeWorld;
_profileJson = IltFeatureCatalog.BuildProfileJson(
ilt, o.WorldName, _ctx.State.ForceLeaftideFeatures,
o.Source ?? string.Empty, o.LastRefreshUtc, o.Get,
QuestBonus.Snapshot());
}
/// <summary>
@ -286,6 +310,14 @@ internal sealed class IltHubController
try { RebuildReaderData(now); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "RebuildReaderData"); }
// Profile other plugins read (RynthILT.Server): world, feature states, fellowship, /qb.
if (now - _profileBuiltAt >= ProfileRebuildMs)
{
_profileBuiltAt = now;
try { RebuildProfile(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "RebuildProfile"); }
}
// "Mini Remote on screen" gates bank auto-refresh and the gear / split-arrow scans.
_ctx.State.WindowVisible = _ctx.Ai.MiniRemoteVisible;

View file

@ -85,8 +85,12 @@ public sealed class IltBankState
public int WithdrawIndex;
public int WithdrawNoteIndex = 9;
/// <summary>Re-issue /bank every N seconds while the Hub is open (0 = manual only).</summary>
public int AutoRefreshSeconds = 120;
/// <summary>
/// Re-issue /bank every N seconds while the Hub (or a Banking reader) is open.
/// Default 0 (2026-10-16): login probe + manual Refresh only — a 120s timer with Mini Remote
/// open was spamming [BANK] lines into chat when quiet-eat missed.
/// </summary>
public int AutoRefreshSeconds = 0;
}
/// <summary>One "Transferred …" / "Received …" bank line seen in chat.</summary>

View file

@ -155,7 +155,7 @@ internal sealed class IltHubUi
/// <summary>A button that opens a moved section's new home (posted: the command runs on the pump).</summary>
private void MovedLink(IltSection section, string command)
{
string home = command == IltSections.GlobalBankCommand ? "Global Inventory > Banking" : "RynthOracle > Character";
string home = command == IltSections.GlobalBankCommand ? "Global Inventory" : "RynthOracle > Character";
ImGui.TextDisabled($"{IltSections.Label(section)} moved to {home}.");
if (ImGui.SmallButton($"Open {home}##moved{(int)section}"))
_ctx.Post(() => _hub.OpenMoved(section, command));
@ -204,7 +204,7 @@ internal sealed class IltHubUi
ImGui.TextDisabled("Bank: not loaded yet");
ImGui.SameLine();
if (ImGui.SmallButton("Load##mrbank")) _ctx.Post(() => _hub.Banking.RequestRefresh(quiet: true));
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Reads your bank balances (/bank, reply hidden). Global Inventory > Banking (/ginv bank) has the details.");
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Reads your bank balances (/bank, reply hidden). Global Inventory (/ginv bank) has every character's saved packs and storage.");
BankLink();
return;
}
@ -221,14 +221,14 @@ internal sealed class IltHubUi
ImGui.EndTable();
}
/// <summary>The Bank line's link to RynthInventory's Global Inventory "Banking" tab (every character here).</summary>
/// <summary>The Bank line's link to RynthInventory's Global Inventory (every character here).</summary>
private void BankLink()
{
ImGui.SameLine();
if (ImGui.SmallButton("Banks##mrbanklink"))
_ctx.Post(() => _hub.OpenMoved(IltSection.Banking, IltSections.GlobalBankCommand));
if (ImGui.IsItemHovered())
SafeImGui.SetTooltip("Global Inventory > Banking (/ginv bank): deposits, withdrawals, transfers and\nevery character's bank on this server.");
SafeImGui.SetTooltip("Global Inventory (/ginv bank): every character's saved packs and storage\n(banks when Include Storage is on).");
}
private static void Stat(string label, string value)

View file

@ -78,6 +78,10 @@ internal sealed class IltInventory
public const uint QuadTotalXp = 1;
public const uint QuadAvailableXp = 2;
public const uint QuadItemTotalXp = 4;
/// <summary>ACE PropertyInt64.AvailableLuminance — lum on the character (not the bank).</summary>
public const uint QuadAvailableLuminance = 6;
/// <summary>ACE PropertyInt64.MaximumLuminance.</summary>
public const uint QuadMaximumLuminance = 7;
/// <summary>ACECustom PropertyInt64.BankedLuminance (sent with each XP batch).</summary>
public const uint QuadBankedLuminance = 9005;
public const uint BoolNeverChunk = 9030;

View file

@ -71,6 +71,9 @@ internal sealed class IltProgression : IIltFeature
// Cached player facts for the render thread (refreshed in Tick).
private volatile int _enl, _level, _freeSlots;
private long _unassignedXp;
/// <summary>PropertyInt64 AvailableLuminance on the character (not banked /bank lum).</summary>
private long _characterLum;
private long _bankedLum;
private volatile bool _peace, _hasVitae;
private readonly long[] _enlHave = new long[4]; // tokens, medallions, sigils, crests
// 301-325 sigil chain stock (pack items by name; EnlightenedCoins = bank + pack). Pump thread only.
@ -261,6 +264,9 @@ internal sealed class IltProgression : IIltFeature
_enl = inv.PlayerInt(IltInventory.IntEnlightenment);
_level = inv.PlayerInt(IltInventory.IntLevel);
_unassignedXp = inv.PlayerQuad(IltInventory.QuadAvailableXp);
// Aug / Enl planners use character AvailableLuminance, not /bank's banked line.
_characterLum = inv.PlayerQuad(IltInventory.QuadAvailableLuminance);
_bankedLum = _ctx.State.Bank.Luminance;
_peace = inv.InPeaceMode;
_freeSlots = inv.FreeMainPackSlots();
_enlHave[0] = inv.CountByWcid(IltInventory.WcidEnlToken);
@ -315,7 +321,8 @@ internal sealed class IltProgression : IIltFeature
: string.Empty;
list.Add($"Need {cost.Count} {cost.Item} (have {HaveFor(cost.Wcid)}{craft}).");
}
if (cost.Lum > 0 && _ctx.State.Bank.Luminance < cost.Lum) list.Add($"Need {IltParse.Compact((double)cost.Lum)} banked luminance.");
if (cost.Lum > 0 && _characterLum < cost.Lum)
list.Add($"Need {IltParse.Compact((double)cost.Lum)} character luminance (have {IltParse.Compact(_characterLum)}).");
return list;
}
@ -462,7 +469,12 @@ internal sealed class IltProgression : IIltFeature
Str(sb, "short", coinsShort > 0
? $"Coins short: {IltParse.N0(coinsShort)}" + (lumPerCoin > 0 ? $" (~{IltParse.Compact((double)coinsShort * lumPerCoin)} luminance to buy)" : "")
: string.Empty);
Str(sb, "banked", $"Banked luminance: {IltParse.Compact(_ctx.State.Bank.Luminance)}");
// "banked" key kept for older SkillsFace builds; text is character AvailableLuminance.
decimal haveLum = _characterLum;
decimal stillNeed = Math.Max(0, totalLum - haveLum);
Str(sb, "banked", $"Character luminance: {IltParse.Compact(_characterLum)}"
+ (stillNeed > 0 ? $" still need ~{IltParse.Compact((double)stillNeed)} for this plan" : " covers this plan")
+ (_bankedLum > 0 ? $" (banked {IltParse.Compact(_bankedLum)}, not used here)" : ""));
Str(sb, "copyDiscord", AugDiscordText(plan));
Str(sb, "copyIngame", AugIngameText(plan));
AppendAugCostJson(sb);
@ -593,7 +605,7 @@ internal sealed class IltProgression : IIltFeature
bool firstLine = true;
foreach (var kv in totals) { StrItem(sb, $"{IltParse.N0(kv.Value)} {kv.Key}", ref firstLine); }
if (lumTotal > 0)
StrItem(sb, $"{IltParse.Compact((double)lumTotal)} luminance (banked {IltParse.Compact(_ctx.State.Bank.Luminance)})", ref firstLine);
StrItem(sb, $"{IltParse.Compact((double)lumTotal)} luminance (character {IltParse.Compact(_characterLum)})", ref firstLine);
sb.Append(']');
int coinsPerToken = C.EnlightenedCoinsPerToken;
@ -633,9 +645,9 @@ internal sealed class IltProgression : IIltFeature
/// </summary>
private void AppendEnlCalculatorJson(StringBuilder sb, int enl, int target, Dictionary<string, long> totals, decimal lumTotal)
{
// Simulated stock: tokens, medallions, crests on hand, sigils via the chain, banked luminance.
// Simulated stock: tokens, medallions, crests on hand, sigils via the chain, character lum.
long tok = _enlHave[0], med = _enlHave[1], crest = _enlHave[3];
decimal lum = (decimal)_ctx.State.Bank.Luminance;
decimal lum = (decimal)_characterLum;
var chain = _chain.Clone();
long sigilCraftable = IltSigilChain.Fulfillable(chain);
@ -668,7 +680,7 @@ internal sealed class IltProgression : IIltFeature
// Material summary: Still need = demand minus what is on hand.
long sigilsNeed = totals.TryGetValue("Enlightenment Sigils", out long sn) ? sn : 0;
var shortfall = IltSigilChain.Shortfall(sigilsNeed, _chain);
decimal bankLum = (decimal)_ctx.State.Bank.Luminance;
decimal haveLum = (decimal)_characterLum;
sb.Append(",\"materials\":[");
bool firstMat = true;
void Mat(string label, string need, string have, bool ok)
@ -683,8 +695,9 @@ internal sealed class IltProgression : IIltFeature
}
if (lumTotal > 0)
{
decimal lumStill = Math.Max(0, lumTotal - bankLum);
Mat("Luminance", lumStill > 0 ? IltParse.Compact((double)lumStill) : "0", IltParse.Compact((double)bankLum), lumStill == 0);
decimal lumStill = Math.Max(0, lumTotal - haveLum);
Mat("Luminance (character)", lumStill > 0 ? IltParse.Compact((double)lumStill) : "0",
IltParse.Compact((double)haveLum), lumStill == 0);
}
void Item(string key, string label, long have, bool extraOk = false)
{

View file

@ -125,6 +125,12 @@ internal sealed class IltQuestBonus : IIltFeature
/// <summary>Increments each time a "/qb list" reply is parsed (0 = not loaded this session).</summary>
public int QbGeneration => _qbGeneration;
/// <summary>
/// Snapshot for the "RynthILT.Server" profile JSON (Oracle Quests / Fellowship). Pump thread.
/// </summary>
public IltQuestBonusInfo Snapshot() =>
new(_ctx.Options.IsOff(IltFeature.Qb), _qbGeneration, _qbCount, _qbStatus, _qbCompleted, _qbIncomplete);
/// <summary>True when the last "/qb list" (completed or incomplete) contains the flag.</summary>
public bool QbHasFlag(string flag)
{

View file

@ -13,8 +13,8 @@
// override lives only in RynthCore Options > Diagnostics) and RynthOracle's
// Character tab ("/ro character");
// Charms -> RynthOracle's Character tab, a list fed by "RynthILT.Data" ("/ro character");
// Banking -> RynthInventory's Global Inventory "Banking" tab, every character on this server
// ("/ginv bank").
// Banking -> RynthInventory's Global Inventory ("/ginv bank"), every character's packs
// and storage on this server.
// Their names still parse, so old links and commands land on the new home (MovedCommand).
using System;
using System.Numerics;
@ -26,7 +26,7 @@ internal enum IltSection
{
/// <summary>Moved out (2026-10-13): RynthOracle's Character tab.</summary>
Character,
/// <summary>Moved out (2026-10-13): RynthInventory's Global Inventory "Banking" tab.</summary>
/// <summary>Moved out (2026-10-13): RynthInventory's Global Inventory.</summary>
Banking,
Gear,
Games,
@ -55,7 +55,7 @@ internal static class IltSections
/// <summary>RynthOracle's Character tab: the character, its session and the charms list.</summary>
public const string OracleCharacterCommand = "/ro character";
/// <summary>RynthInventory's Global Inventory "Banking" tab: every character's bank on this server.</summary>
/// <summary>RynthInventory's Global Inventory (alias used by the old Banking tab).</summary>
public const string GlobalBankCommand = "/ginv bank";
public static string Label(IltSection s) => s switch

View file

@ -11,12 +11,13 @@ public static unsafe class PluginExports
{
internal static readonly RynthPluginRuntime<RynthILTPlugin> Runtime = new();
// Typed interfaces (host GetPluginInterface, API v68): "RynthILT.Hub" v1, the ILT tabs and
// sections RynthAi's Mini Remote hosts (Plugins/Shared/RynthIltHubApi.cs, HubInterface.cs), and
// "RynthServer.Profile" v1, ILT's settings and tinkering salvage for any reader, as every server
// plugin serves its own (Plugins/Shared/RynthServerProfileApi.cs, ProfileInterface.cs), and
// "RynthILT.Data" v1, the charms list and bank balances with their actions
// (Plugins/Shared/RynthIltDataApi.cs, DataInterface.cs).
// Typed interfaces (host GetPluginInterface, API v68):
// "RynthILT.Hub" v1 — Mini Remote ILT tabs/sections (RynthIltHubApi.cs, HubInterface.cs)
// "RynthILT.Server" v1 — Leaftide feature / fellowship / qb profile JSON (RynthIltServerApi.cs,
// ServerInterface.cs; RynthOracle Fellowship & Quests). Must stay alongside Hub — it was
// dropped when RynthServer.Profile landed and Oracle kept polling an empty table.
// "RynthServer.Profile" v1 — identity + tinkering salvage (ProfileInterface.cs)
// "RynthILT.Data" v1/v2 — charms, bank, breeding (DataInterface.cs)
// Fixed signature: void* (const char* iface, uint version).
[UnmanagedCallersOnly(EntryPoint = "RynthPluginQueryInterface", CallConvs = new[] { typeof(CallConvCdecl) })]
private static IntPtr QueryInterface(IntPtr ifaceAnsi, uint version)
@ -26,6 +27,8 @@ public static unsafe class PluginExports
string iface = ifaceAnsi == IntPtr.Zero ? "" : Marshal.PtrToStringAnsi(ifaceAnsi) ?? "";
IntPtr table = HubInterface.Query(iface, version);
if (table != IntPtr.Zero) return table;
table = ServerInterface.Query(iface, version);
if (table != IntPtr.Zero) return table;
table = ProfileInterface.Query(iface, version);
return table != IntPtr.Zero ? table : DataInterface.Query(iface, version);
}
@ -44,6 +47,7 @@ public static unsafe class PluginExports
// An exception escaping an UnmanagedCallersOnly export fail-fasts the client under NativeAOT.
try { Runtime.Shutdown(); } catch { }
try { HubInterface.Release(); } catch { }
try { ServerInterface.Release(); } catch { }
try { ProfileInterface.Release(); } catch { }
try { DataInterface.Release(); } catch { }
foreach (IntPtr p in new[] { Interlocked.Exchange(ref _bountiesPtr, IntPtr.Zero), Interlocked.Exchange(ref _progressionPtr, IntPtr.Zero),

View file

@ -47,8 +47,8 @@ namespace RynthCore.Plugin.RynthILT;
public sealed class RynthILTPlugin : RynthPluginBase
{
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthILT");
// Previous release: 0.2.10.
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.11");
// Previous release: 0.2.13 (ProductVersion 2026.10.16.5).
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.14");
/// <summary>
/// The settings view's surface. No longer in the sections manifest (the force-server override
@ -473,6 +473,13 @@ public sealed class RynthILTPlugin : RynthPluginBase
_typedBounty.Enqueue(trimmed);
return;
}
// Player-typed /bank (or bare /b): allow the [BANK] dump in chat; Hub quiet refreshes stay hidden.
if (IsTypedBankBalanceCommand(trimmed))
{
try { _hub?.Banking.NoteTypedBalanceCommand(); }
catch (Exception ex) { RynthLog.Exception(LogCat.IltBanking, ex, "NoteTypedBalanceCommand"); }
return;
}
if (!trimmed.Equals("/ilt", StringComparison.OrdinalIgnoreCase)
&& !trimmed.StartsWith("/ilt ", StringComparison.OrdinalIgnoreCase))
return;
@ -480,6 +487,22 @@ public sealed class RynthILTPlugin : RynthPluginBase
_commands.Enqueue(trimmed.Split(' ', StringSplitOptions.RemoveEmptyEntries));
}
/// <summary>True for a chat-bar /bank or bare /b that asks the server for balances (not /b d, /b w, …).</summary>
private static bool IsTypedBankBalanceCommand(string trimmed)
{
if (trimmed.Equals("/bank", StringComparison.OrdinalIgnoreCase)) return true;
if (trimmed.Equals("/b", StringComparison.OrdinalIgnoreCase)) return true;
// "/bank " with only spaces, or "/bank balances" style — still a balance read.
if (trimmed.StartsWith("/bank ", StringComparison.OrdinalIgnoreCase))
{
string rest = trimmed.Substring(6).Trim();
return rest.Length == 0
|| rest.Equals("balances", StringComparison.OrdinalIgnoreCase)
|| rest.Equals("balance", StringComparison.OrdinalIgnoreCase);
}
return false;
}
// The server's killer notification: this character landed the killing blow.
public override void OnKillNotification(string? deathMessage) => _bounties?.OnKill();

View file

@ -0,0 +1,81 @@
// ServerInterface.cs - RynthILT's side of the "RynthILT.Server" interface (Plugins/Shared/RynthIltServerApi.cs):
// the profile JSON other plugins read (RynthOracle's Fellowship / Quests qb list / feature list):
// the Leaftide feature list with the server's state for each, and the server's fellowship rules.
//
// Restored 2026-10-16: this export was dropped when "RynthServer.Profile" (salvage / identity) was
// added, so Oracle still detected ILT via RynthCore but never received feature / qb / fellowship
// data from RynthILT. Hub + Data stay separate; this table is the feature-profile channel.
//
// The table is allocated once per loaded copy of RynthILT and never freed (a plugin DLL is never
// unloaded); after Release() it reports Version 0 and GetProfileJson answers 0. Before login there
// is no controller, so the profile is the not-ILT default (every feature unknown, retail fellowships).
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using RynthCore.Plugin.RynthILT.Hub;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthILT;
internal static unsafe class ServerInterface
{
private static RynthIltServerApiV1* _table;
private static volatile bool _released;
/// <summary>The profile before any login: not an ILT world, nothing known (built once).</summary>
private static readonly string NotLoggedInJson =
IltFeatureCatalog.BuildProfileJson(false, string.Empty, false, string.Empty, DateTime.MinValue, _ => IltTri.Unknown);
/// <summary>The table for (<paramref name="iface"/>, <paramref name="version"/>), or 0 when it isn't ours.</summary>
public static IntPtr Query(string iface, uint version)
{
if (iface != RynthIltServerApiV1.InterfaceName || version < 1 || version > RynthIltServerApiV1.InterfaceVersion || _released)
return IntPtr.Zero;
if (_table == null)
{
var t = (RynthIltServerApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthIltServerApiV1));
t->StructSize = (uint)sizeof(RynthIltServerApiV1);
t->GetProfileJson = &GetProfileJson;
t->Version = RynthIltServerApiV1.InterfaceVersion;
_table = t;
}
return (IntPtr)_table;
}
/// <summary>Plugin shutdown: readers see Version 0 and re-query; GetProfileJson answers 0.</summary>
public static void Release()
{
_released = true;
if (_table != null) _table->Version = 0;
}
/// <summary>The JSON to hand out now: the live controller's snapshot, or the not-logged-in default.</summary>
internal static string CurrentJson()
=> (_released ? null : PluginExports.Runtime.Plugin?.Hub?.ProfileJson) ?? NotLoggedInJson;
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
private static int GetProfileJson(byte* buffer, int capacity)
{
try
{
if (_released) return 0;
return Write(CurrentJson(), buffer, capacity);
}
catch { return 0; }
}
/// <summary>
/// Copies <paramref name="json"/> as NUL-terminated UTF-8 into the caller's buffer when it fits,
/// and returns its byte length either way (length >= capacity: too small, nothing written).
/// </summary>
internal static int Write(string json, byte* buffer, int capacity)
{
int length = Encoding.UTF8.GetByteCount(json);
if (buffer == null || capacity <= length) return length;
fixed (char* src = json)
Encoding.UTF8.GetBytes(src, json.Length, buffer, capacity);
buffer[length] = 0;
return length;
}
}