RynthServers as of 2026-11-08 (internal 471970b): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:49 -05:00
commit e52923ba5c
40 changed files with 4831 additions and 31 deletions

View file

@ -20,6 +20,9 @@
// ServerPages(list) pages of its own (ServerPackPages.cs): sub-tabs of the Mini Remote's
// Server section, only while its server is active, and tabs of the
// /rserver window. Draw runs on the render thread.
// ServerWindows(list) windows of its own on RynthCore's bar (ServerPackWindows.cs, 2026-11-07:
// RynthDreamWeave's Skills panel), only while its server is active;
// "frameless" ones draw their own frame (engines with v90 windows).
// ServerChatText(...) every incoming chat line (pump thread), to read the server's replies
// and hide the ones answering the plugin's own requests (eat).
// ServerChatBar(text) every line sent through the chat bar (AC's thread: note it only),
@ -66,9 +69,11 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
private readonly ServerPackModel _model;
private readonly ServerPackUi _ui;
private readonly string _sectionsJson;
private string? _sectionsJson;
// The server's own pages (ServerPages), validated; what was left out is logged at Initialize.
private readonly List<ServerPage> _pages;
// The server's own windows (ServerWindows), validated the same way.
private readonly List<ServerWindow> _windows;
private readonly List<string> _pageNotes = new();
private readonly ServerPackSettings _settings = new(ServerPackSettings.DefaultPath(RynthPluginInfo.Name));
private readonly ServerProfileValues _profileValues = new();
@ -91,11 +96,13 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
var pages = new List<ServerPage>();
ServerPages(pages);
_pages = ServerPackPages.Validate(pages, _pageNotes.Add);
var windows = new List<ServerWindow>();
ServerWindows(windows);
_windows = ServerPackWindows.Validate(windows, _pageNotes.Add);
var verbs = new List<string>();
ServerCommandVerbs(verbs);
foreach (string v in verbs) if (!string.IsNullOrWhiteSpace(v)) _serverVerbs.Add(v.Trim());
_ui = new ServerPackUi(_model, RynthPluginInfo.Name + " " + Marshal.PtrToStringAnsi(VersionPointer), () => _world, _pages);
_sectionsJson = ServerPackModel.BuildSectionsJson(info, RynthPluginInfo.Name, _pages);
}
internal ServerPackInfo Info => _model.Info;
@ -130,6 +137,15 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
partial void ServerInfoLines(Action<string> line);
/// <summary>The server's own pages (ServerPackPages.cs). Called once, from the constructor (no Host yet).</summary>
partial void ServerPages(List<ServerPage> pages);
/// <summary>The server's own windows on RynthCore's bar (ServerPackWindows.cs). Called once, from the constructor (no Host yet).</summary>
partial void ServerWindows(List<ServerWindow> windows);
/// <summary>Game event types (0xF7B0 events) the server's code wants on <see cref="ServerMessage"/>. Called once, at Initialize.</summary>
partial void ServerMessageInterest(List<uint> gameEvents);
/// <summary>A server message asked for in ServerMessageInterest (pump thread; <paramref name="body"/> is the bytes after
/// the opcode, valid only during the call: RynthCore.PluginSdk.Net.ServerMessage reads it).</summary>
partial void ServerMessage(uint opcode, ReadOnlySpan<byte> body);
/// <summary>Every frame while logged in (render thread, AC's main thread; the engine's ImGui context current).</summary>
partial void ServerRender();
/// <summary>
/// An incoming chat line (pump thread, logged in only): set <paramref name="eat"/> to keep it out of
/// the chat window (it comes in true when an earlier plugin already ate it).
@ -180,9 +196,20 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
_settings.Load();
if (_settings.LastError.Length > 0) LogTagged($"Settings ({_settings.FilePath}) not read: {_settings.LastError}; using defaults.");
ServerInitialize();
// The server's own server-message wishes (ServerMessageInterest, 2026-11-07), streamed to ServerMessage.
var events = new List<uint>();
ServerMessageInterest(events);
if (events.Count > 0 && Host.HasServerMessages)
{
int r = Host.SetServerMessageInterest(ReadOnlySpan<uint>.Empty, events.ToArray());
if (r != 1) LogTagged($"Server messages not streamed (SetServerMessageInterest answered {r}).");
}
return 0;
}
/// <summary>RynthPluginOnServerMessage (pump thread): a server message the server's code asked for.</summary>
internal void OnServerMessage(uint opcode, ReadOnlySpan<byte> body) => ServerMessage(opcode, body);
// Also called on a freshly (re)loaded plugin while already in game.
public override void OnLoginComplete()
{
@ -251,18 +278,55 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
/// (the manifest is static): the engine only collects it once in game, and keeping it across
/// logout and character switches stops the server dropping out of Options > Diagnostics.
/// </summary>
internal string? BuildSectionsJson() => _sectionsJson;
internal string? BuildSectionsJson()
=> _sectionsJson ??= ServerPackModel.BuildSectionsJson(Info, RynthPluginInfo.Name, _pages, _windows,
frameless: _windows.Count > 0 && Host.HasFramelessWindows);
/// <summary>
/// RynthPluginRenderEmbed "window:&lt;id&gt;": one of the server's own windows (ServerWindows), into the
/// host's window. False for an id this plugin doesn't have, or before login. Render thread.
/// </summary>
internal bool RenderServerWindow(string id, bool popped, out float wantHeight, out float wantWidth)
{
wantHeight = 0;
wantWidth = 0;
ServerWindow? window = _windows.Find(w => w.Id == id);
if (window == null || !_loginComplete) return false;
IntPtr previous = ImGui.GetCurrentContext();
IntPtr context = previous != IntPtr.Zero ? previous : Host.ImGuiContext;
if (context == IntPtr.Zero) return false;
ImGui.SetCurrentContext(context);
try
{
System.Numerics.Vector2 want = window.Draw(popped);
wantHeight = want.Y;
wantWidth = want.X;
return true;
}
catch (Exception ex)
{
Host.Log($"[{RynthPluginInfo.Name}] Window {window.Title} failed: {ex.Message}");
return false;
}
finally { ImGui.SetCurrentContext(previous); }
}
// ── Drawing ──────────────────────────────────────────────────────────
/// <summary>The standalone card window. Render thread.</summary>
public override void OnRender()
{
if (!_loginComplete || !_ui.WindowOpen || Host.ImGuiContext == IntPtr.Zero) return;
if (!_loginComplete || Host.ImGuiContext == IntPtr.Zero) return;
IntPtr previous = ImGui.GetCurrentContext();
ImGui.SetCurrentContext(Host.ImGuiContext);
try { _ui.RenderWindow(); }
catch (Exception ex) { Host.Log($"[{RynthPluginInfo.Name}] Server window failed: {ex.Message}"); _ui.WindowOpen = false; }
try
{
try { ServerRender(); }
catch (Exception ex) { LogTagged($"Render hook failed: {ex.GetType().Name}: {ex.Message}"); }
if (!_ui.WindowOpen) return;
try { _ui.RenderWindow(); }
catch (Exception ex) { Host.Log($"[{RynthPluginInfo.Name}] Server window failed: {ex.Message}"); _ui.WindowOpen = false; }
}
finally { ImGui.SetCurrentContext(previous); }
}