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,20 @@ public static unsafe class ServerPackExports
[UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })]
private static int Init(RynthCoreApiNative* api) => Runtime.Init(api);
/// <summary>
/// Plugin API v78: a reassembled server message the server's code asked for (ServerMessageInterest,
/// 2026-11-07). <paramref name="data"/> is the message after its opcode, valid only during the call. Pump thread.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnServerMessage", CallConvs = new[] { typeof(CallConvCdecl) })]
private static void OnServerMessage(uint opcode, byte* data, int length)
{
try
{
Runtime.Plugin?.OnServerMessage(opcode, data != null && length > 0 ? new ReadOnlySpan<byte>(data, length) : ReadOnlySpan<byte>.Empty);
}
catch { /* never let a managed exception cross the native boundary */ }
}
/// <summary>
/// Plugin API v68 plugin-to-plugin interfaces: "RynthServer.Profile" v1 (ServerPackInterface),
/// the server's settings for any plugin RynthCore's GetServerStateJson points at this one, and
@ -80,6 +94,18 @@ public static unsafe class ServerPackExports
catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ }
}
/// <summary>
/// The same while RynthCore's ImGui shell is off (the bar UI: the engine calls this instead of
/// RynthPluginRender). Without it the per-frame ServerRender hook never ran there (2026-11-07:
/// RynthDreamWeave's "open this instead of AC's Character window" didn't). Render thread.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderOverlay", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void RenderOverlay()
{
try { Runtime.OnRender(); }
catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ }
}
/// <summary>
/// The engine's plugin-command broker: "servermenu" from RynthCore (2026.10.5.48+). The ANSI
/// strings are copied before returning (the caller frees them); the payload is only parsed, so
@ -112,11 +138,18 @@ public static unsafe class ServerPackExports
{
if (surface == null) return 0;
string name = Marshal.PtrToStringUTF8((IntPtr)surface) ?? string.Empty;
if (name.EndsWith(":popout", StringComparison.Ordinal)) name = name[..^":popout".Length];
bool popped = name.EndsWith(":popout", StringComparison.Ordinal);
if (popped) name = name[..^":popout".Length];
var plugin = Runtime.Plugin;
if (plugin == null) return 0;
float wantH;
if (name.Equals(ServerPackModel.WindowSurface, StringComparison.Ordinal))
float wantH, wantW = 0;
string? ownWindow = ServerPackWindows.IdOf(name);
if (ownWindow != null)
{
// One of the server's own windows (ServerWindows, 2026-11-07); it may size its width too.
if (!plugin.RenderServerWindow(ownWindow, popped, out wantH, out wantW)) return 0;
}
else if (name.Equals(ServerPackModel.WindowSurface, StringComparison.Ordinal))
{
if (!plugin.RenderEmbeddedWindow(out wantH)) return 0;
}
@ -129,7 +162,7 @@ public static unsafe class ServerPackExports
string? page = ServerPackPages.PageIdOf(name, RynthPluginInfo.ServerId);
if (page == null || !plugin.RenderEmbeddedPage(page, out wantH)) return 0;
}
if (wantWidth != null) *wantWidth = width;
if (wantWidth != null) *wantWidth = wantW > 0 ? wantW : width;
if (wantHeight != null) *wantHeight = wantH;
return 1;
}

View file

@ -169,7 +169,8 @@ internal sealed class ServerPackModel
/// is easy to find, not mixed in with the rest; until then the card and pages were sub-tabs of a
/// shared "Server" section of the Mini Remote.
/// </summary>
public static string BuildSectionsJson(ServerPackInfo info, string pluginName, IReadOnlyList<ServerPage>? pages = null)
public static string BuildSectionsJson(ServerPackInfo info, string pluginName, IReadOnlyList<ServerPage>? pages = null,
IReadOnlyList<ServerWindow>? windows = null, bool frameless = false)
{
var sb = new StringBuilder(512);
sb.Append("{\"version\":1,\"servers\":[{\"id\":").Append(Q(info.Id)).Append(",\"name\":").Append(Q(info.Name));
@ -184,7 +185,10 @@ internal sealed class ServerPackModel
sb.Append(",\"icon\":").Append(Q(WindowIcon));
sb.Append(",\"width\":").Append(tabs ? ServerPackPages.Width : 460).Append(",\"height\":").Append(ServerPackPages.Height);
sb.Append(",\"minWidth\":320,\"minHeight\":200,\"bar\":true,\"server\":").Append(Q(info.Id));
sb.Append("}]}");
sb.Append('}');
// The server's own windows (ServerWindows, ServerPackWindows.cs, 2026-11-07).
if (windows != null) sb.Append(ServerPackWindows.Json(windows, info.Id, frameless));
sb.Append("]}");
return sb.ToString();
}

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); }
}

View file

@ -0,0 +1,81 @@
// ServerPackWindows.cs - Windows of its own a server plugin adds to RynthCore's bar, beside the server's
// window (2026-11-07: RynthDreamWeave's Skills panel, the retail Character panel drawn by the plugin).
//
// The ServerPackPlugin.ServerWindows hook lists them once, at construction. Each is declared in the
// sections manifest's "windows" (plugin windows, API v89; "chrome": "none" for one that draws its own
// frame, v90), only while the server is active, and drawn through RynthPluginRenderEmbed "window:<id>"
// on the render thread. A frameless window is declared only on engines with frameless windows (an older
// engine would wrap it in its own frame), so it simply isn't there on those.
// Pure (no ImGui, no host calls): RynthServerPack.Tests covers it.
using System;
using System.Collections.Generic;
using System.Text;
namespace RynthCore.Plugin.ServerPack;
/// <summary>
/// One window a server plugin adds. <paramref name="Id"/> is 1-16 of a-z, 0-9 and '-' (its surface is
/// "window:&lt;id&gt;"); <paramref name="Title"/> is its panel key (bar tooltip, saved place, /rc commands).
/// <paramref name="Draw"/> draws the body (popped out or not) and returns the size it wants: the height it used and, for a window that sizes its width too, that width (0: the width it was given). Render thread.
/// </summary>
internal sealed record ServerWindow(string Id, string Title, string Icon, int Width, int Height, int MinWidth, int MinHeight,
bool Frameless, Func<bool, System.Numerics.Vector2> Draw, bool FitHeight = false, bool UnderUi = false, bool DrawScale = false);
internal static class ServerPackWindows
{
/// <summary>At most this many windows besides the server's own.</summary>
public const int MaxWindows = 3;
public static string SurfaceFor(string id) => "window:" + id;
/// <summary>The window id a surface names ("window:skills" -> "skills"), or null. ":popout" is the caller's to strip.</summary>
public static string? IdOf(string? surface)
{
if (surface == null || !surface.StartsWith("window:", StringComparison.Ordinal)) return null;
string id = surface["window:".Length..];
return ServerPackPages.IsValidId(id) && id != ServerPackModel.WindowId ? id : null;
}
/// <summary>The windows that can be declared: a valid id that isn't the server window's, a title, each id once.</summary>
public static List<ServerWindow> Validate(List<ServerWindow> windows, Action<string> note)
{
var ok = new List<ServerWindow>();
var ids = new HashSet<string>(StringComparer.Ordinal);
foreach (ServerWindow w in windows)
{
if (w == null) continue;
if (!ServerPackPages.IsValidId(w.Id) || w.Id == ServerPackModel.WindowId) { note($"Window \"{w.Id}\" left out: its id must be 1-16 of a-z, 0-9 and '-', not \"server\"."); continue; }
if (string.IsNullOrWhiteSpace(w.Title)) { note($"Window \"{w.Id}\" left out: it has no title."); continue; }
if (!ids.Add(w.Id)) { note($"Window \"{w.Id}\" left out: the id is used twice."); continue; }
if (ok.Count >= MaxWindows) { note($"Window \"{w.Id}\" left out: at most {MaxWindows} windows."); continue; }
ok.Add(w);
}
return ok;
}
/// <summary>The manifest entries (",{...}" each) for <paramref name="windows"/>; frameless ones only when <paramref name="frameless"/>.</summary>
public static string Json(IReadOnlyList<ServerWindow> windows, string serverId, bool frameless)
{
var sb = new StringBuilder();
foreach (ServerWindow w in windows)
{
if (w.Frameless && !frameless) continue;
sb.Append(",{\"id\":").Append(ServerPackModel.Q(w.Id));
sb.Append(",\"title\":").Append(ServerPackModel.Q(w.Title.Trim()));
sb.Append(",\"surface\":").Append(ServerPackModel.Q(SurfaceFor(w.Id)));
sb.Append(",\"icon\":").Append(ServerPackModel.Q(w.Icon));
sb.Append(",\"width\":").Append(w.Width).Append(",\"height\":").Append(w.Height);
sb.Append(",\"minWidth\":").Append(w.MinWidth).Append(",\"minHeight\":").Append(w.MinHeight);
sb.Append(",\"bar\":true,\"server\":").Append(ServerPackModel.Q(serverId));
if (w.Frameless) sb.Append(",\"chrome\":\"none\"");
// The window is as tall as the height the draw reports (the plugin sizes it itself, v90).
if (w.FitHeight && w.Frameless) sb.Append(",\"fitHeight\":true");
// Drawn under AC's own UI, like a native AC window (engines from 2026-11-07; older ones ignore it).
if (w.UnderUi && w.Frameless) sb.Append(",\"layer\":\"underUi\"");
// It draws itself at any size: Ctrl+wheel steps its own draw size (PanelScale, 30-250%), not its text.
if (w.DrawScale && w.Frameless) sb.Append(",\"scale\":\"draw\"");
sb.Append('}');
}
return sb.ToString();
}
}

View file

@ -49,6 +49,8 @@
<Compile Include="$(MSBuildThisFileDirectory)ServerPackModel.cs" Link="ServerPack\ServerPackModel.cs" />
<!-- The server's own pages, settings file, reply window and Refresh row (ServerPackPlugin.cs lists the hooks). -->
<Compile Include="$(MSBuildThisFileDirectory)ServerPackPages.cs" Link="ServerPack\ServerPackPages.cs" />
<!-- Windows of its own on RynthCore's bar (ServerWindows, 2026-11-07). -->
<Compile Include="$(MSBuildThisFileDirectory)ServerPackWindows.cs" Link="ServerPack\ServerPackWindows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackSettings.cs" Link="ServerPack\ServerPackSettings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerChatRequest.cs" Link="ServerPack\ServerChatRequest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackRefresh.cs" Link="ServerPack\ServerPackRefresh.cs" />