feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the 2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk. Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level, RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist, RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
parent
23efcfee87
commit
7797901d69
287 changed files with 22602 additions and 1090 deletions
|
|
@ -4,7 +4,7 @@
|
|||
// GetServerStateJson), parsed: every server the engine knows (built-in ILT and
|
||||
// Aelrynth, plus each loaded server plugin's declaration), whether it is
|
||||
// active, this character's override, and which plugin owns it (the one to ask
|
||||
// for its settings through "RynthServer.Profile"; RynthILT answers it for "ilt").
|
||||
// for its settings: "RynthServer.Profile", or RynthILT's "RynthILT.Server").
|
||||
// The same verdict the Mini Remote, the menus and the Diagnostics server
|
||||
// picker use, so every plugin follows one choice, overrides included.
|
||||
//
|
||||
|
|
@ -28,6 +28,8 @@ internal sealed class EngineServerState
|
|||
/// <summary>Engine server ids with a meaning across RynthSuite.</summary>
|
||||
public const string IltId = "ilt";
|
||||
public const string AelrynthId = "aelrynth";
|
||||
/// <summary>RynthILT serves "RynthILT.Server" for the "ilt" server, not "RynthServer.Profile".</summary>
|
||||
public const string IltPlugin = "RynthILT";
|
||||
|
||||
public int Revision { get; private init; }
|
||||
/// <summary>The connect host the client was launched with ("" when not known).</summary>
|
||||
|
|
@ -155,8 +157,8 @@ internal sealed class EngineServerState
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The headline facts of a server owner's profile JSON ("RynthServer.Profile" from the plugin that
|
||||
/// owns the server), read leniently: a field the owner doesn't send stays "".
|
||||
/// The headline facts of a server owner's profile JSON ("RynthServer.Profile" from a server plugin,
|
||||
/// or RynthILT's "RynthILT.Server"), read leniently: a field the owner doesn't send stays "".
|
||||
/// </summary>
|
||||
internal sealed record ServerProfileView(string Id, string Name, string Plugin, string Ruleset, string Emulator,
|
||||
string Botting, string BottingNote, string AccountLimit, bool Ilt, int FeaturesOn)
|
||||
|
|
@ -202,23 +204,13 @@ internal sealed record ServerProfileView(string Id, string Name, string Plugin,
|
|||
|
||||
/// <summary>
|
||||
/// One salvage from a server plugin's profile "salvage" list (ServerPackInfo.Salvage): a tinkering
|
||||
/// recipe the server adds, for the Mini Remote's Crafting tab. The fields after
|
||||
/// <paramref name="NameMatch"/> are optional in the JSON; absent, a row behaves as before them.
|
||||
/// recipe the server adds, for the Mini Remote's Crafting tab.
|
||||
/// </summary>
|
||||
/// <param name="AppliedInt">"applied": an int property of the item that reads 2 once the row is on it (0 = none).</param>
|
||||
/// <param name="Prepared">"prepared": the bag must first be prepared on the chosen tier's Ammunition.</param>
|
||||
/// <param name="Order">"order": apply order (lower first); 0 = the kind-based default.</param>
|
||||
/// <param name="AfterCap">"afterCap": applied last, only once the item's tink slots are full.</param>
|
||||
/// <param name="StackGroup">"stackGroup": rows in one group share <paramref name="StackCap"/> per item ("" = none).</param>
|
||||
/// <param name="StackCap">"stackCap": the group's combined cap per item.</param>
|
||||
internal sealed record ServerSalvageView(string Bench, int Material, string Kind, string Effect, bool UsesTinkSlot, string NameMatch,
|
||||
int AppliedInt = 0, bool Prepared = false, int Order = 0, bool AfterCap = false,
|
||||
string StackGroup = "", int StackCap = 0)
|
||||
internal sealed record ServerSalvageView(string Bench, int Material, string Kind, string Effect, bool UsesTinkSlot, string NameMatch)
|
||||
{
|
||||
/// <summary>
|
||||
/// The profile's salvage rows, read leniently: a missing list (an older plugin) is empty; a row
|
||||
/// without a bench or a material id is skipped; "slot" defaults to true, the optional fields to
|
||||
/// none (a stack group without a positive cap is no group).
|
||||
/// The profile's salvage rows, read leniently: a missing list (an older plugin, or RynthILT's
|
||||
/// profile) is empty; a row without a bench or a material id is skipped; "slot" defaults to true.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<ServerSalvageView> ParseList(string? json)
|
||||
{
|
||||
|
|
@ -239,16 +231,8 @@ internal sealed record ServerSalvageView(string Bench, int Material, string Kind
|
|||
if (bench.Length == 0 || material <= 0) continue;
|
||||
string kind = EngineServerState.Str(e, "kind").Trim().ToLowerInvariant();
|
||||
bool slot = !(e.TryGetProperty("slot", out JsonElement s) && s.ValueKind == JsonValueKind.False);
|
||||
string group = EngineServerState.Str(e, "stackGroup").Trim();
|
||||
int cap = EngineServerState.Int(e, "stackCap");
|
||||
if (cap <= 0) group = string.Empty;
|
||||
rows.Add(new ServerSalvageView(bench, material, kind.Length > 0 ? kind : "tink",
|
||||
EngineServerState.Str(e, "effect"), slot, EngineServerState.Str(e, "nameMatch"),
|
||||
AppliedInt: EngineServerState.Int(e, "applied"),
|
||||
Prepared: EngineServerState.Bool(e, "prepared"),
|
||||
Order: EngineServerState.Int(e, "order"),
|
||||
AfterCap: EngineServerState.Bool(e, "afterCap"),
|
||||
StackGroup: group, StackCap: group.Length > 0 ? cap : 0));
|
||||
EngineServerState.Str(e, "effect"), slot, EngineServerState.Str(e, "nameMatch")));
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,19 @@
|
|||
// "sex": "...", "partners": 1 } }
|
||||
// PetBreedingCommand verbs (ASCII): refresh | debug | dance | apply <supplyKey> <essenceId>
|
||||
// The reader confirms "apply" and "dance" with the player first (RynthILT doesn't ask again).
|
||||
//
|
||||
// Version 3 (RynthILT 0.2.20) appends GetGuardianJson and GuardianCommand (the Temple guardians
|
||||
// on RynthOracle's Quests tab). Readers use them only when Version >= 3 and the table is that big
|
||||
// (HasGuardian); a version-2 table still answers charms, the bank and breeding (V2Size).
|
||||
//
|
||||
// GetGuardianJson payload (IltGuardian.BuildJson; read leniently):
|
||||
// { "available": true, "world": "...", "chat": true, "auto": false, "buy": true, "cooldownHours": 20,
|
||||
// "answer": "Pyreal", "npc": "Guardian of ...", "answerAgeSec": 42 (-1 none yet), "heard": "...",
|
||||
// "running": false, "status": "idle", "synced": "2026-10-18T19:05:00Z" ("" /qb not read),
|
||||
// "rows": [ { "attribute": "Strength", "npc": "...", "count": 3, "status": "Ready", "eta": "",
|
||||
// "ready": true, "exact": true } ] } exact = from /myquests (else /qb estimates)
|
||||
// GuardianCommand verbs (ASCII): handin | stop | refresh | chat on|off | auto on|off | buy on|off
|
||||
// Auto hand-in and buying a missing Temple item run inside RynthILT whatever the reader shows.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
|
@ -83,7 +96,7 @@ namespace RynthCore.Plugin.Shared;
|
|||
public unsafe struct RynthIltDataApiV1
|
||||
{
|
||||
public const string InterfaceName = "RynthILT.Data";
|
||||
public const uint InterfaceVersion = 2;
|
||||
public const uint InterfaceVersion = 3;
|
||||
|
||||
/// <summary>The size of a version-1 table (everything before GetPetBreedingJson) on this platform.</summary>
|
||||
public static uint V1Size
|
||||
|
|
@ -95,6 +108,16 @@ public unsafe struct RynthIltDataApiV1
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>The size of a version-2 table (everything before GetGuardianJson) on this platform.</summary>
|
||||
public static uint V2Size
|
||||
{
|
||||
get
|
||||
{
|
||||
RynthIltDataApiV1 t = default;
|
||||
return (uint)((byte*)&t.GetGuardianJson - (byte*)&t);
|
||||
}
|
||||
}
|
||||
|
||||
public uint Version; // InterfaceVersion of the table RynthILT filled; 0 once it has shut down
|
||||
public uint StructSize; // sizeof(RynthIltDataApiV1) as RynthILT built it
|
||||
|
||||
|
|
@ -123,6 +146,14 @@ public unsafe struct RynthIltDataApiV1
|
|||
|
||||
/// <summary>PetBreedingCommand(utf8 verb line): queues a breeding verb (header above). 1 = queued, 0 = refused.</summary>
|
||||
public delegate* unmanaged[Cdecl]<byte*, int> PetBreedingCommand;
|
||||
|
||||
// ── Version 3 ───────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>GetGuardianJson(buffer, capacity): the Temple guardian JSON, same contract as GetCharmsJson.</summary>
|
||||
public delegate* unmanaged[Cdecl]<byte*, int, int> GetGuardianJson;
|
||||
|
||||
/// <summary>GuardianCommand(utf8 verb line): queues a guardian verb (header above). 1 = queued, 0 = refused.</summary>
|
||||
public delegate* unmanaged[Cdecl]<byte*, int> GuardianCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -181,7 +212,33 @@ public sealed unsafe class RynthIltDataClient
|
|||
}
|
||||
|
||||
private static bool HasPetBreeding(RynthIltDataApiV1* t)
|
||||
=> t != null && t->Version >= 2 && t->StructSize >= (uint)sizeof(RynthIltDataApiV1);
|
||||
=> t != null && t->Version >= 2 && t->StructSize >= RynthIltDataApiV1.V2Size;
|
||||
|
||||
/// <summary>The Temple guardian JSON now ("" without a RynthILT that has it, version 3).</summary>
|
||||
public string ReadGuardian(RynthCoreHost host, long now)
|
||||
{
|
||||
RynthIltDataApiV1* t = Table(host, now);
|
||||
return !HasGuardian(t) || t->GetGuardianJson == null ? "" : Read(t->GetGuardianJson);
|
||||
}
|
||||
|
||||
/// <summary>The loaded RynthILT has the guardian functions (table version 3 or later).</summary>
|
||||
public bool GuardianSupported => HasGuardian(_table);
|
||||
|
||||
/// <summary>Queues a guardian verb line (see the header). False without RynthILT or when it refused.</summary>
|
||||
public bool GuardianCommand(RynthCoreHost host, long now, string verbLine)
|
||||
{
|
||||
RynthIltDataApiV1* t = Table(host, now);
|
||||
if (!HasGuardian(t) || t->GuardianCommand == null || string.IsNullOrWhiteSpace(verbLine)) return false;
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(verbLine + "\0");
|
||||
try
|
||||
{
|
||||
fixed (byte* p = bytes) return t->GuardianCommand(p) == 1;
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
private static bool HasGuardian(RynthIltDataApiV1* t)
|
||||
=> t != null && t->Version >= 3 && t->StructSize >= (uint)sizeof(RynthIltDataApiV1);
|
||||
|
||||
/// <summary>Asks RynthILT to use a carried charm. False without RynthILT or when it refused.</summary>
|
||||
public bool ToggleCharm(RynthCoreHost host, long now, uint objectId)
|
||||
|
|
@ -546,6 +603,88 @@ public sealed class IltBreedingView
|
|||
=> string.Join(' ', "apply", (supplyKey ?? "").Trim(), essenceId.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
/// <summary>One Temple attribute turn-in from the guardian JSON.</summary>
|
||||
public sealed record IltGuardianRow(string Attribute, string Npc, int Count, string Status, string Eta, bool Ready, bool Exact);
|
||||
|
||||
/// <summary>The Temple guardian JSON parsed. <see cref="None"/> without RynthILT; every field read leniently.</summary>
|
||||
public sealed class IltGuardianView
|
||||
{
|
||||
public static readonly IltGuardianView None = new();
|
||||
|
||||
/// <summary>RynthILT answered.</summary>
|
||||
public bool Loaded { get; private init; }
|
||||
public bool Available { get; private init; }
|
||||
public string World { get; private init; } = "";
|
||||
/// <summary>Translate the guardians' tells as they arrive.</summary>
|
||||
public bool Chat { get; private init; }
|
||||
/// <summary>Give the answer item to the guardian automatically after a chat answer.</summary>
|
||||
public bool Auto { get; private init; }
|
||||
/// <summary>Buy a missing Temple item from the nearest vendor first.</summary>
|
||||
public bool Buy { get; private init; }
|
||||
public int CooldownHours { get; private init; }
|
||||
public string Answer { get; private init; } = "";
|
||||
public string Npc { get; private init; } = "";
|
||||
/// <summary>Seconds since the last answer (-1 none yet).</summary>
|
||||
public long AnswerAgeSec { get; private init; } = -1;
|
||||
public string Heard { get; private init; } = "";
|
||||
/// <summary>A hand-in is running.</summary>
|
||||
public bool Running { get; private init; }
|
||||
public string Status { get; private init; } = "";
|
||||
/// <summary>When /qb was last read (MinValue never).</summary>
|
||||
public DateTime SyncedUtc { get; private init; } = DateTime.MinValue;
|
||||
public IReadOnlyList<IltGuardianRow> Rows { get; private init; } = Array.Empty<IltGuardianRow>();
|
||||
|
||||
public static IltGuardianView Parse(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return None;
|
||||
try
|
||||
{
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement root = doc.RootElement;
|
||||
if (root.ValueKind != JsonValueKind.Object) return None;
|
||||
var rows = new List<IltGuardianRow>();
|
||||
foreach (JsonElement r in IltJson.Array(root, "rows"))
|
||||
{
|
||||
string attr = IltJson.Str(r, "attribute");
|
||||
if (attr.Length == 0) continue;
|
||||
rows.Add(new IltGuardianRow(attr, IltJson.Str(r, "npc"), (int)IltJson.Long(r, "count"), IltJson.Str(r, "status"),
|
||||
IltJson.Str(r, "eta"), IltJson.Bool(r, "ready"), IltJson.Bool(r, "exact")));
|
||||
}
|
||||
DateTime synced = DateTime.MinValue;
|
||||
string when = IltJson.Str(root, "synced");
|
||||
if (when.Length > 0
|
||||
&& DateTime.TryParse(when, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime t))
|
||||
synced = t;
|
||||
return new IltGuardianView
|
||||
{
|
||||
Loaded = true,
|
||||
Available = IltJson.Bool(root, "available"),
|
||||
World = IltJson.Str(root, "world"),
|
||||
Chat = IltJson.Bool(root, "chat"),
|
||||
Auto = IltJson.Bool(root, "auto"),
|
||||
Buy = IltJson.Bool(root, "buy"),
|
||||
CooldownHours = (int)IltJson.Long(root, "cooldownHours"),
|
||||
Answer = IltJson.Str(root, "answer"),
|
||||
Npc = IltJson.Str(root, "npc"),
|
||||
AnswerAgeSec = IltJson.Long(root, "answerAgeSec", -1),
|
||||
Heard = IltJson.Str(root, "heard"),
|
||||
Running = IltJson.Bool(root, "running"),
|
||||
Status = IltJson.Str(root, "status"),
|
||||
SyncedUtc = synced,
|
||||
Rows = rows,
|
||||
};
|
||||
}
|
||||
catch (JsonException) { return None; }
|
||||
}
|
||||
|
||||
/// <summary>The guardian verb lines (header of this file); pure so the tests check them.</summary>
|
||||
public static string HandInVerb() => "handin";
|
||||
public static string StopVerb() => "stop";
|
||||
public static string RefreshVerb() => "refresh";
|
||||
/// <summary>"chat on", "auto off", "buy on": <paramref name="name"/> is chat, auto or buy.</summary>
|
||||
public static string SwitchVerb(string name, bool on) => (name ?? "").Trim().ToLowerInvariant() + (on ? " on" : " off");
|
||||
}
|
||||
|
||||
/// <summary>Lenient JSON field reads shared by the views above.</summary>
|
||||
internal static class IltJson
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,10 +46,7 @@ public static class RynthIltHub
|
|||
public const string SectionQuestBonus = "quests-qb";
|
||||
/// <summary>Pets tab: the /pets and /shinies logs.</summary>
|
||||
public const string SectionPetLogs = "pets-logs";
|
||||
/// <summary>
|
||||
/// Pets tab, Breeding sub-tab: the pet breeding tracker, the sub-tab's whole body (RynthILT 0.3.1+;
|
||||
/// older copies draw nothing). RynthAi shows the sub-tab on an ILT world unless FeaturePetBreeding is off.
|
||||
/// </summary>
|
||||
/// <summary>Pets tab, Breeding sub-tab: the pet breeding tracker (RynthILT 0.2.7+; older copies draw nothing).</summary>
|
||||
public const string SectionPetBreeding = "pets-breeding";
|
||||
/// <summary>Mini Remote menu, under Infinite Leaftide: why no ILT feature is on, the Force-ILT override, Refresh.</summary>
|
||||
public const string SectionIltStatus = "ilt-status";
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
// for any plugin that wants the server's settings without drawing the card.
|
||||
// RynthCore says which server is active and which plugin owns it (plugin API
|
||||
// v86, GetServerStateJson: "active", "activePlugin"); the reader then asks that
|
||||
// plugin for this interface (host GetPluginInterface). RynthILT answers it too,
|
||||
// for "ilt" (RynthILT/ProfileInterface.cs).
|
||||
// Compiled into the server plugins, RynthILT and their readers (linked source),
|
||||
// so the layout can't drift.
|
||||
// plugin for this interface (host GetPluginInterface). RynthILT answers its own
|
||||
// "RynthILT.Server" instead (RynthIltServerApi.cs).
|
||||
// Compiled into the server plugins and their readers (linked source), so the
|
||||
// layout can't drift.
|
||||
//
|
||||
// Rules (as the other shared interfaces):
|
||||
// - Append-only: new functions go at the end, and Version goes up.
|
||||
|
|
@ -28,18 +28,6 @@
|
|||
// "botting": "unknown|allowed|restricted|forbidden", "bottingNote": "",
|
||||
// "accountLimit": "", "summary": "",
|
||||
// "facts": [ "..." ], "commands": [ { "command": "/x", "what": "..." } ],
|
||||
// "salvage": [ { // the server's own tinkering (the Mini Remote's Crafting tab)
|
||||
// "bench": "melee", // armor, melee, missile, caster, jewelry, items, trinkets
|
||||
// "material": 52, "kind": "tink|imbue|once", "effect": "...",
|
||||
// "slot": true, // counts toward the item's 10 tinks
|
||||
// "nameMatch": "", // the bag's name must contain this
|
||||
// // optional (absent = off / the default):
|
||||
// "applied": 370, // item int that reads 2 once the row is on it
|
||||
// "prepared": true, // the bag is first prepared on the tier's Ammunition
|
||||
// "order": 10, // apply order, lower first (else imbue, tink, once)
|
||||
// "afterCap": true, // last, only once the item's tink slots are full
|
||||
// "stackGroup": "x", "stackCap": 10 // rows of one group share this cap per item
|
||||
// } ],
|
||||
// "discord": "", "website": "", "wiki": "", "source": ""
|
||||
// }
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ internal static class ServerPackProfile
|
|||
sb.Append('}');
|
||||
}
|
||||
sb.Append(']');
|
||||
// Added within schema 1: readers that don't know "salvage" skip it. The optional row fields
|
||||
// (applied, prepared, order, afterCap, stackGroup + stackCap) are written only when set.
|
||||
// Added within schema 1: readers that don't know "salvage" skip it.
|
||||
sb.Append(",\"salvage\":[");
|
||||
for (int i = 0; i < info.Salvage.Length; i++)
|
||||
{
|
||||
|
|
@ -80,16 +79,6 @@ internal static class ServerPackProfile
|
|||
sb.Append(",\"slot\":").Append(s.UsesTinkSlot ? "true" : "false");
|
||||
sb.Append(",\"nameMatch\":");
|
||||
Str(sb, s.NameMatch);
|
||||
if (s.AppliedInt != 0) sb.Append(",\"applied\":").Append(s.AppliedInt);
|
||||
if (s.Prepared) sb.Append(",\"prepared\":true");
|
||||
if (s.Order != 0) sb.Append(",\"order\":").Append(s.Order);
|
||||
if (s.AfterCap) sb.Append(",\"afterCap\":true");
|
||||
if (!string.IsNullOrEmpty(s.StackGroup))
|
||||
{
|
||||
sb.Append(",\"stackGroup\":");
|
||||
Str(sb, s.StackGroup);
|
||||
sb.Append(",\"stackCap\":").Append(s.StackCap);
|
||||
}
|
||||
sb.Append('}');
|
||||
}
|
||||
sb.Append(']');
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@
|
|||
// 1. RynthCore's server list (plugin API v86 GetServerStateJson, parsed by
|
||||
// EngineServerState.cs): the active server, overrides and the Diagnostics
|
||||
// pick included, and the plugin that owns it;
|
||||
// 2. that plugin's profile JSON through "RynthServer.Profile"
|
||||
// (RynthServerProfileApi.cs): a server plugin for its server, RynthILT
|
||||
// for "ilt".
|
||||
// 2. that plugin's profile JSON: "RynthServer.Profile" from a server plugin
|
||||
// (RynthServerProfileApi.cs), "RynthILT.Server" from RynthILT for "ilt".
|
||||
// Both are polled (every 2 s, cheap when not due) and Revision goes up when
|
||||
// either changes, so a reader re-applies its server-specific state then.
|
||||
//
|
||||
// Needs, linked into the reader: EngineServerState.cs, RynthServerProfileApi.cs.
|
||||
// Engines older than v86 report Supported = false (the reader keeps its own
|
||||
// detection).
|
||||
// Needs, linked into the reader: EngineServerState.cs, RynthServerProfileApi.cs,
|
||||
// RynthIltServerApi.cs. Engines older than v86 report Supported = false (the
|
||||
// reader keeps its own detection).
|
||||
// Pump thread only.
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ internal sealed unsafe class ServerStateClient
|
|||
|
||||
private long _nextPollAt, _nextQueryAt;
|
||||
private string _stateJson = string.Empty;
|
||||
// The owner's "RynthServer.Profile" table.
|
||||
// The owner's table: both interfaces start Version, StructSize, GetProfileJson.
|
||||
private string _tableOwner = string.Empty;
|
||||
private uint* _tableVersion;
|
||||
private delegate* unmanaged[Cdecl]<byte*, int, int> _getProfileJson;
|
||||
|
|
@ -44,6 +43,8 @@ internal sealed unsafe class ServerStateClient
|
|||
public string ProfileJson { get; private set; } = string.Empty;
|
||||
/// <summary>The plugin <see cref="ProfileJson"/> came from ("" with none).</summary>
|
||||
public string ProfilePlugin { get; private set; } = string.Empty;
|
||||
/// <summary>The interface it came through ("RynthServer.Profile" / "RynthILT.Server", "" with none).</summary>
|
||||
public string ProfileInterface { get; private set; } = string.Empty;
|
||||
/// <summary>Goes up whenever <see cref="State"/> or <see cref="ProfileJson"/> changes.</summary>
|
||||
public int Revision { get; private set; }
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ internal sealed unsafe class ServerStateClient
|
|||
bool changed = State != null || ProfileJson.Length > 0;
|
||||
_stateJson = string.Empty;
|
||||
State = null;
|
||||
ProfileJson = ProfilePlugin = string.Empty;
|
||||
ProfileJson = ProfilePlugin = ProfileInterface = string.Empty;
|
||||
if (changed) Revision++;
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +86,16 @@ internal sealed unsafe class ServerStateClient
|
|||
changed = true;
|
||||
}
|
||||
ProfilePlugin = profile.Length > 0 ? owner : string.Empty;
|
||||
ProfileInterface = profile.Length > 0 ? InterfaceFor(owner) : string.Empty;
|
||||
if (changed) Revision++;
|
||||
}
|
||||
|
||||
/// <summary>The interface the owner of a server serves its settings through.</summary>
|
||||
public static string InterfaceFor(string owner)
|
||||
=> owner.Equals(EngineServerState.IltPlugin, StringComparison.OrdinalIgnoreCase)
|
||||
? RynthIltServerApiV1.InterfaceName
|
||||
: RynthServerProfileApiV1.InterfaceName;
|
||||
|
||||
/// <summary>The owner's profile JSON, querying (or re-querying) its table as needed.</summary>
|
||||
private string ReadProfile(RynthCoreHost host, string owner, long now)
|
||||
{
|
||||
|
|
@ -109,6 +117,14 @@ internal sealed unsafe class ServerStateClient
|
|||
|
||||
private bool Query(RynthCoreHost host, string owner)
|
||||
{
|
||||
if (InterfaceFor(owner) == RynthIltServerApiV1.InterfaceName)
|
||||
{
|
||||
var t = (RynthIltServerApiV1*)host.GetPluginInterface(owner, RynthIltServerApiV1.InterfaceName, RynthIltServerApiV1.InterfaceVersion);
|
||||
if (t == null || t->Version < 1 || t->StructSize < (uint)sizeof(RynthIltServerApiV1) || t->GetProfileJson == null) return false;
|
||||
_tableVersion = &t->Version;
|
||||
_getProfileJson = t->GetProfileJson;
|
||||
return true;
|
||||
}
|
||||
var p = (RynthServerProfileApiV1*)host.GetPluginInterface(owner, RynthServerProfileApiV1.InterfaceName, RynthServerProfileApiV1.InterfaceVersion);
|
||||
if (p == null || p->Version < 1 || p->StructSize < (uint)sizeof(RynthServerProfileApiV1) || p->GetProfileJson == null) return false;
|
||||
_tableVersion = &p->Version;
|
||||
|
|
|
|||
Loading…
Reference in a new issue