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

@ -0,0 +1,145 @@
// ServerPackExports.cs - The native exports every server plugin has (compiled into each one).
// UnmanagedCallersOnly entry points can't live in a generic or shared assembly, so each server
// plugin compiles this file itself, around its own ServerPackPlugin.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using RynthCore.PluginCore;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.ServerPack;
public static unsafe class ServerPackExports
{
private static readonly RynthPluginRuntime<ServerPackPlugin> Runtime = new();
/// <summary>The live plugin (null before init and after shutdown).</summary>
internal static ServerPackPlugin? Plugin => Runtime.Plugin;
[UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })]
private static int Init(RynthCoreApiNative* api) => Runtime.Init(api);
/// <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.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginQueryInterface", CallConvs = new[] { typeof(CallConvCdecl) })]
private static IntPtr QueryInterface(IntPtr ifaceAnsi, uint version)
{
try
{
string iface = ifaceAnsi == IntPtr.Zero ? "" : Marshal.PtrToStringAnsi(ifaceAnsi) ?? "";
return ServerPackInterface.Query(iface, version);
}
catch
{
return IntPtr.Zero; // an exception crossing UnmanagedCallersOnly would fail-fast the client
}
}
[UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void Shutdown()
{
try { ServerPackInterface.Release(); } catch { }
Runtime.Shutdown();
IntPtr old = Interlocked.Exchange(ref _sectionsPtr, IntPtr.Zero);
if (old != IntPtr.Zero) Marshal.FreeCoTaskMem(old);
_sectionsJson = null;
}
[UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })]
public static IntPtr GetName() => ServerPackPlugin.NamePointer;
[UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })]
public static IntPtr GetVersion() => ServerPackPlugin.VersionPointer;
[UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void Tick() => Runtime.OnTick();
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLoginComplete", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void OnLoginComplete() => Runtime.OnLoginComplete();
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLogout", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void OnLogout() => Runtime.OnLogout();
// "/rserver ..." commands.
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatBarEnter", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void OnChatBarEnter(IntPtr textUtf16, IntPtr eatFlag) => Runtime.OnChatBarEnter(textUtf16, eatFlag);
/// <summary>The standalone server card ("/rserver"). Render thread.</summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRender", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void Render()
{
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
/// any thread is fine.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginApplyRemoteCommand", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void ApplyRemoteCommand(IntPtr actionAnsi, IntPtr valueAnsi)
{
try
{
string action = actionAnsi != IntPtr.Zero ? (Marshal.PtrToStringAnsi(actionAnsi) ?? string.Empty) : string.Empty;
if (action.Length == 0 || action.Length > 32) return;
string value = valueAnsi != IntPtr.Zero ? (Marshal.PtrToStringAnsi(valueAnsi) ?? string.Empty) : string.Empty;
Runtime.Plugin?.ApplyRemoteCommand(action, value);
}
catch { /* never let a managed exception cross the native boundary */ }
}
/// <summary>
/// RynthCore's Mini Remote sections: "section:server-&lt;id&gt;" (":popout" added in a popped-out
/// window) draws the server card into the engine's current window. 1 = drawn, 0 = not ready or
/// not ours.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderEmbed", CallConvs = new[] { typeof(CallConvCdecl) })]
public static int RenderEmbed(byte* surface, float width, float height, float* wantWidth, float* wantHeight)
{
try
{
if (surface == null) return 0;
string name = Marshal.PtrToStringUTF8((IntPtr)surface) ?? string.Empty;
if (name.EndsWith(":popout", StringComparison.Ordinal)) name = name[..^":popout".Length];
if (!name.Equals(ServerPackPlugin.SettingsSurface, StringComparison.Ordinal)) return 0;
var plugin = Runtime.Plugin;
if (plugin == null || !plugin.RenderEmbeddedCard(out float wantH)) return 0;
if (wantWidth != null) *wantWidth = width;
if (wantHeight != null) *wantHeight = wantH;
return 1;
}
catch
{
return 0; // an exception crossing UnmanagedCallersOnly would fail-fast the client
}
}
private static IntPtr _sectionsPtr = IntPtr.Zero;
private static string? _sectionsJson;
/// <summary>
/// RynthCore 2026.10.5.46+: the server and the card's Mini Remote spot (UTF-8 JSON, schema 1).
/// Null before login. An unchanged manifest keeps the same buffer.
/// </summary>
[UnmanagedCallersOnly(EntryPoint = "RynthPluginGetSectionsJson", CallConvs = new[] { typeof(CallConvCdecl) })]
public static IntPtr GetSectionsJson()
{
try
{
string? json = Runtime.Plugin?.BuildSectionsJson();
if (json == null) return IntPtr.Zero;
if (json == _sectionsJson && _sectionsPtr != IntPtr.Zero) return _sectionsPtr;
_sectionsJson = json;
IntPtr newPtr = Marshal.StringToCoTaskMemUTF8(json);
IntPtr oldPtr = Interlocked.Exchange(ref _sectionsPtr, newPtr);
if (oldPtr != IntPtr.Zero) Marshal.FreeCoTaskMem(oldPtr);
return newPtr;
}
catch { return IntPtr.Zero; }
}
}

View file

@ -0,0 +1,103 @@
// ServerPackInfo.cs - What a server plugin knows about its game server (shared by every server plugin).
//
// Identity (id, name, hosts, world names) comes from the plugin's csproj through RynthPluginInfo, the
// same values the engine reads from the embedded manifest, so detection has one source. The rest is
// what is publicly known about the server (ServerData.cs in each project): connection, rule set,
// summary, links, account limits and the botting policy. Unknown stays empty; nothing is guessed.
// Pure: RynthServerPack.Tests compiles it.
using System;
namespace RynthCore.Plugin.ServerPack;
/// <summary>What the server's rules say about bots (RynthAi automation).</summary>
internal enum BottingPolicy
{
/// <summary>Not published here: check the server's own rules.</summary>
Unknown,
Allowed,
/// <summary>Allowed with limits (attended only, a client cap, ...): see <see cref="ServerPackInfo.BottingNote"/>.</summary>
Restricted,
/// <summary>The server forbids bots.</summary>
Forbidden,
}
/// <summary>A chat command the server adds, and what it does.</summary>
internal sealed record ServerCommand(string Command, string What);
/// <summary>
/// A salvage the server's own recipes apply (beyond retail tinkering), shown on the Mini Remote's
/// Crafting tab under "Server tinkering".
/// </summary>
/// <param name="Bench">The Crafting tab: "armor", "melee", "missile", "caster", "jewelry", "items" or "trinkets".</param>
/// <param name="Material">The bag's MaterialType (131), e.g. 64 = Steel.</param>
/// <param name="Effect">What it does, one short line.</param>
/// <param name="Kind">"tink" (repeatable), "imbue" (one per item) or "once" (one application).</param>
/// <param name="UsesTinkSlot">Counts toward the item's 10 tinks.</param>
/// <param name="NameMatch">The bag's name must contain this (bags that share a material id); "" = any.</param>
/// <param name="AppliedInt">An int property of the item that reads 2 once this salvage is on it (0 = none).</param>
/// <param name="Prepared">The bag must first be prepared on the chosen tier's Ammunition (its name then carries the tier).</param>
/// <param name="Order">Apply order on the tab (lower first); 0 = by kind (imbues, then tinks, then one-application rows).</param>
/// <param name="AfterCap">Applied last, and only once the item's tink slots are full.</param>
/// <param name="StackGroup">Rows with the same group share one cap per item (<paramref name="StackCap"/>); "" = none.</param>
/// <param name="StackCap">The group's combined cap per item (with <paramref name="StackGroup"/>).</param>
internal sealed record ServerSalvage(string Bench, int Material, string Effect, string Kind = "tink",
bool UsesTinkSlot = true, string NameMatch = "", int AppliedInt = 0,
bool Prepared = false, int Order = 0, bool AfterCap = false,
string StackGroup = "", int StackCap = 0);
internal sealed class ServerPackInfo
{
public ServerPackInfo(string id, string name, string[] hosts, string[] worldNames)
{
Id = (id ?? string.Empty).Trim().ToLowerInvariant();
Name = string.IsNullOrWhiteSpace(name) ? Id : name.Trim();
Hosts = hosts ?? Array.Empty<string>();
WorldNames = worldNames ?? Array.Empty<string>();
}
/// <summary>The engine's id for the server ("coldeve"); a built-in one ("ilt", "aelrynth") keeps the engine's own detection.</summary>
public string Id { get; }
public string Name { get; }
/// <summary>Connect hosts (the first is the one players are given).</summary>
public string[] Hosts { get; }
/// <summary>World names the server announces at login.</summary>
public string[] WorldNames { get; }
public int Port { get; init; } = 9000;
/// <summary>"ACE" or "GDLE" (the launcher's emulator setting).</summary>
public string Emulator { get; init; } = "ACE";
/// <summary>"PvE" or "PvP".</summary>
public string Ruleset { get; init; } = "PvE";
/// <summary>"Stable", "Development", ... as the server list says.</summary>
public string Status { get; init; } = string.Empty;
/// <summary>The server's own one-paragraph description.</summary>
public string Summary { get; init; } = string.Empty;
/// <summary>Notable rules and features, one line each.</summary>
public string[] Facts { get; init; } = Array.Empty<string>();
/// <summary>Chat commands the server adds (only ones known to exist).</summary>
public ServerCommand[] Commands { get; init; } = Array.Empty<ServerCommand>();
/// <summary>The server's own tinkering salvage (only recipes known to exist); empty = none defined.</summary>
public ServerSalvage[] Salvage { get; init; } = Array.Empty<ServerSalvage>();
/// <summary>"3 accounts", "3 active characters", ...; empty when not published.</summary>
public string AccountLimit { get; init; } = string.Empty;
public BottingPolicy Botting { get; init; } = BottingPolicy.Unknown;
/// <summary>The rule in the server's words, when there is one.</summary>
public string BottingNote { get; init; } = string.Empty;
public string Discord { get; init; } = string.Empty;
public string Website { get; init; } = string.Empty;
public string Wiki { get; init; } = string.Empty;
/// <summary>Where the facts come from, and when they were checked.</summary>
public string Source { get; init; } = string.Empty;
/// <summary>"play.coldeve.ac:9000" (the first host), or "" with none.</summary>
public string Address => Hosts.Length == 0 ? string.Empty : Hosts[0] + ":" + Port;
/// <summary>The botting line for the card.</summary>
public string BottingText => Botting switch
{
BottingPolicy.Allowed => "Allowed" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
BottingPolicy.Restricted => "Restricted" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
BottingPolicy.Forbidden => "Forbidden" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
_ => "Not published here - check the server's rules" + (Discord.Length > 0 ? " (Discord)" : string.Empty),
};
}

View file

@ -0,0 +1,86 @@
// ServerPackInterface.cs - A server plugin's side of "RynthServer.Profile"
// (Plugins/Shared/RynthServerProfileApi.cs): the server's settings as JSON (ServerPackProfile) for
// other plugins, answered through RynthPluginQueryInterface (ServerPackExports).
//
// The table is allocated once per loaded copy of the plugin and never freed (a plugin DLL is never
// unloaded); after Release() it reports Version 0 and GetProfileJson answers 0. Before the plugin is
// up, or between characters, the profile still describes the server (active false, no world).
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.ServerPack;
internal static unsafe class ServerPackInterface
{
private static RynthServerProfileApiV1* _table;
private static volatile bool _released;
/// <summary>The last JSON handed out, and what it was built for (rebuilt only when that changes).</summary>
private sealed record Snapshot(bool Active, string World, string Json);
private static Snapshot? _last;
/// <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 != RynthServerProfileApiV1.InterfaceName || version < 1 || version > RynthServerProfileApiV1.InterfaceVersion || _released)
return IntPtr.Zero;
if (_table == null)
{
var t = (RynthServerProfileApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthServerProfileApiV1));
t->StructSize = (uint)sizeof(RynthServerProfileApiV1);
t->GetProfileJson = &GetProfileJson;
t->Version = RynthServerProfileApiV1.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. Any thread: the plugin's state is read through volatile fields.</summary>
internal static string CurrentJson(ServerPackPlugin? plugin)
{
ServerPackInfo info = plugin?.Info ?? ServerPackPlugin.StaticInfo;
bool active = plugin?.Active ?? false;
string world = plugin?.World ?? string.Empty;
Snapshot? last = Volatile.Read(ref _last);
if (last != null && last.Active == active && last.World == world) return last.Json;
string json = ServerPackProfile.BuildJson(info, RynthPluginInfo.Name, RynthPluginInfo.Version, active, world);
Volatile.Write(ref _last, new Snapshot(active, world, json));
return json;
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
private static int GetProfileJson(byte* buffer, int capacity)
{
try
{
if (_released) return 0;
return Write(CurrentJson(ServerPackExports.Plugin), 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;
}
}

View file

@ -0,0 +1,224 @@
// ServerPackModel.cs - A server plugin's view of "is this my server", and what it tells RynthCore.
//
// RynthCore owns the verdict. Each server plugin declares its server in its Mini Remote sections
// manifest (RynthPluginGetSectionsJson, "servers"), so RynthCore detects it (connect host, then the
// announced world name), applies this character's Auto / On / Off override, and pushes the result
// to the plugin as "servermenu" (RynthCore UI/ServerMenus.cs):
// V id name active 0/1 force auto|on|off detected 0/1 reason
// Other line kinds are RynthAi's menus and are skipped. Until a push arrives (an engine older than
// 2026.10.5.48), the plugin falls back to matching the world name itself.
//
// Pushes arrive on whichever thread sent them; each is parsed into one immutable view and published
// with a single reference write, so the render thread always reads a whole one.
// Pure (no host calls): RynthServerPack.Tests covers it.
using System;
using System.Text;
using System.Threading;
namespace RynthCore.Plugin.ServerPack;
/// <summary>RynthCore's verdict for this plugin's server.</summary>
internal sealed record ServerVerdictView(string Name, bool Active, string Force, bool Detected, string Reason);
internal sealed class ServerPackModel
{
/// <summary>Payloads longer than this are not ours (a push is a few hundred bytes).</summary>
public const int MaxPayload = 64 * 1024;
private readonly ServerPackInfo _info;
private ServerVerdictView? _engine;
private long _engineAtMs;
public ServerPackModel(ServerPackInfo info) => _info = info;
public ServerPackInfo Info => _info;
/// <summary>The last RynthCore verdict for this server (null until a push lists it). Any thread.</summary>
public ServerVerdictView? Engine => Volatile.Read(ref _engine);
/// <summary>When the last push arrived (Environment.TickCount64), 0 for never.</summary>
public long EngineAtMs => Interlocked.Read(ref _engineAtMs);
/// <summary>A RynthCore "servermenu" push. Any thread. False when it was not usable.</summary>
public bool ApplyEngine(string? payload, long nowMs)
{
ServerVerdictView? view = ParseEngine(payload, _info.Id, out bool listed);
if (!listed) return false;
Volatile.Write(ref _engine, view);
Interlocked.Exchange(ref _engineAtMs, nowMs);
return true;
}
/// <summary>Logout: the next character's verdict comes fresh.</summary>
public void Clear()
{
Volatile.Write(ref _engine, null);
Interlocked.Exchange(ref _engineAtMs, 0);
}
/// <summary>
/// True when this plugin should act: RynthCore's verdict when it sent one, else the world
/// name (<paramref name="world"/>) against the plugin's own list.
/// </summary>
public bool IsActive(string? world)
{
ServerVerdictView? v = Engine;
return v != null ? v.Active : WorldMatches(world, _info.WorldNames);
}
/// <summary>
/// The verdict for <paramref name="serverId"/> in a "servermenu" payload. <paramref name="listed"/>
/// is false when the payload has no server lines at all (not a push); the view is null when it has
/// some but not this server (RynthCore hasn't read this plugin's manifest yet).
/// </summary>
public static ServerVerdictView? ParseEngine(string? payload, string serverId, out bool listed)
{
listed = false;
if (string.IsNullOrEmpty(payload) || payload.Length > MaxPayload || string.IsNullOrEmpty(serverId)) return null;
ServerVerdictView? view = null;
foreach (string raw in payload.Split('\n'))
{
string[] f = raw.TrimEnd('\r').Split('\t');
if (f[0] != "V" || f.Length < 6) continue;
listed = true;
if (!f[1].Equals(serverId, StringComparison.OrdinalIgnoreCase)) continue;
view = new ServerVerdictView(f[2], f[3] == "1", NormalizeForce(f[4]), f[5] == "1", f.Length >= 7 ? f[6] : string.Empty);
}
return view;
}
/// <summary>"auto", "on" or "off" (anything else reads as auto).</summary>
public static string NormalizeForce(string? text)
{
string t = (text ?? string.Empty).Trim().ToLowerInvariant();
return t is "on" or "off" ? t : "auto";
}
/// <summary>"/rc server {id} {mode}" for auto / on / off; "" for anything else.</summary>
public static string ForceCommand(string serverId, string mode)
{
string m = (mode ?? string.Empty).Trim().ToLowerInvariant();
if (m is not ("auto" or "on" or "off") || !IsSafeId(serverId)) return string.Empty;
return "/rc server " + serverId + " " + m;
}
/// <summary>True for an id RynthCore accepts in a command: 1-32 of a-z, 0-9 and '-'.</summary>
public static bool IsSafeId(string? id)
{
if (string.IsNullOrEmpty(id) || id.Length > 32) return false;
foreach (char c in id)
if (!(c is >= 'a' and <= 'z' || c is >= '0' and <= '9' || c == '-')) return false;
return true;
}
/// <summary>Case-insensitive world-name match, '*' standing for any text (RynthCore's rules).</summary>
public static bool WorldMatches(string? world, string[] patterns)
{
if (string.IsNullOrWhiteSpace(world)) return false;
string w = world.Trim();
foreach (string p in patterns)
if (!string.IsNullOrWhiteSpace(p) && Glob(w, p.Trim())) return true;
return false;
}
private static bool Glob(string text, string pattern)
{
if (!pattern.Contains('*')) return text.Equals(pattern, StringComparison.OrdinalIgnoreCase);
string[] parts = pattern.Split('*');
int pos = 0;
for (int i = 0; i < parts.Length; i++)
{
string part = parts[i];
if (part.Length == 0) continue;
if (i == 0)
{
if (!text.StartsWith(part, StringComparison.OrdinalIgnoreCase)) return false;
pos = part.Length;
continue;
}
if (i == parts.Length - 1)
return text.Length - pos >= part.Length && text.EndsWith(part, StringComparison.OrdinalIgnoreCase);
int at = text.IndexOf(part, pos, StringComparison.OrdinalIgnoreCase);
if (at < 0) return false;
pos = at + part.Length;
}
return true;
}
// ── RynthPluginGetSectionsJson ────────────────────────────────────────
/// <summary>The Mini Remote surface of the server card.</summary>
public static string SurfaceFor(string serverId) => "section:server-" + serverId;
/// <summary>
/// The Mini Remote section the server cards share: right after Session Stats (core order 0) and
/// before Map (100). Every server plugin declares it the same way; the first declaration wins.
/// </summary>
public const string SectionId = "server";
public const string SectionLabel = "Server";
public const int SectionOrder = 50;
/// <summary>
/// The plugin's sections manifest (schema 1): its server, for RynthCore to detect, and the server
/// card in the shared "Server" section, shown only while that server is active (detected or
/// forced in RynthCore Options > Diagnostics). The card left the Char section on 2026-10-13: that
/// section is Session Stats now, session stats only.
/// </summary>
public static string BuildSectionsJson(ServerPackInfo info, string pluginName)
{
var sb = new StringBuilder(512);
sb.Append("{\"version\":1,\"servers\":[{\"id\":").Append(Q(info.Id)).Append(",\"name\":").Append(Q(info.Name));
sb.Append(",\"worldNames\":[");
AppendList(sb, info.WorldNames);
sb.Append("],\"hosts\":[");
AppendList(sb, info.Hosts);
sb.Append("]}],\"sections\":[{\"id\":").Append(Q(SectionId)).Append(",\"label\":").Append(Q(SectionLabel));
sb.Append(",\"order\":").Append(SectionOrder).Append("}],\"contributions\":[{\"section\":").Append(Q(SectionId));
sb.Append(",\"server\":").Append(Q(info.Id));
sb.Append(",\"label\":").Append(Q(info.Name + " server (" + pluginName + ")"));
sb.Append(",\"surface\":").Append(Q(SurfaceFor(info.Id)));
sb.Append(",\"primary\":false,\"height\":320,\"enabled\":true,\"tooltip\":");
sb.Append(Q("What is known about " + info.Name + ": rules, account limits, botting policy, links and setup ("
+ pluginName + "; also /rserver)."));
sb.Append(",\"order\":130}]}");
return sb.ToString();
}
private static void AppendList(StringBuilder sb, string[] values)
{
for (int i = 0; i < values.Length; i++) sb.Append(i == 0 ? "" : ",").Append(Q(values[i]));
}
/// <summary>A JSON string literal.</summary>
public static string Q(string? s)
{
var sb = new StringBuilder((s?.Length ?? 0) + 2).Append('"');
foreach (char c in s ?? string.Empty)
{
switch (c)
{
case '"': sb.Append("\\\""); break;
case '\\': sb.Append("\\\\"); break;
case '\n': sb.Append("\\n"); break;
case '\r': sb.Append("\\r"); break;
case '\t': sb.Append("\\t"); break;
default:
if (c < 0x20) sb.Append("\\u").Append(((int)c).ToString("x4"));
else sb.Append(c);
break;
}
}
return sb.Append('"').ToString();
}
// ── The launcher side ─────────────────────────────────────────────────
/// <summary>How to set up an account for this server in the RynthCore launcher.</summary>
public static string[] LauncherSteps(ServerPackInfo info) => new[]
{
"1. Launcher > Servers > Add: pick \"" + info.Name + "\" under Known server. It fills in "
+ (info.Address.Length > 0 ? info.Address : "the host and port") + " (" + info.Emulator + ").",
"2. Launcher > Accounts > Add: choose that server, then the account and character.",
"3. Launch: RynthCore loads this plugin only for clients connecting to " + info.Name + ".",
};
}

View file

@ -0,0 +1,276 @@
// ServerPackPlugin.cs - The shared body of every server plugin (RynthColdeve, RynthAelrynth, ...),
// built like RynthILT: one plugin per game server, so each one ships and updates on its own.
//
// What it does for its server:
// * declares the server to RynthCore (RynthPluginGetSectionsJson "servers": its hosts and world
// names), so RynthCore detects it and puts this plugin's views in the right Mini Remote spots
// (contributions with "server": <id> show only while that server is active);
// * shows the server card (ServerPackUi): RynthCore's verdict, this character's override, what is
// known about the server, and how to set an account up for it in the launcher;
// * stays quiet anywhere else. RynthCore usually doesn't even load it there: the embedded manifest
// names the server's hosts, and the engine loads only the plugin for the host the client
// connects to (PluginManifestGate.SelectServerPlugins).
//
// Server-specific features: add files to the server's project implementing the partial hooks below
// (ServerLoginComplete, ServerTick, ServerChatCommand, ...). Unimplemented hooks compile away.
//
// Threads: OnTick, login/logout and the engine's export calls run on the plugin pump. OnChatBarEnter
// runs on AC's main thread, so it only queues. The card draws on the render thread (OnRender,
// RynthPluginRenderEmbed) and queues its commands for the tick.
using System;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using ImGuiNET;
using RynthCore.PluginCore;
namespace RynthCore.Plugin.ServerPack;
public sealed partial class ServerPackPlugin : RynthPluginBase
{
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi(RynthPluginInfo.Name);
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi(
RynthPluginInfo.Version.Length > 0 ? RynthPluginInfo.Version : "0.1.0");
/// <summary>The chat command every server plugin answers ("/rserver [show|hide|toggle|info]").</summary>
internal const string ChatCommand = "/rserver";
/// <summary>The card's surface in RynthCore's Mini Remote sections ("section:server-coldeve").</summary>
internal static readonly string SettingsSurface = ServerPackModel.SurfaceFor(RynthPluginInfo.ServerId);
private readonly ServerPackModel _model;
private readonly ServerPackUi _ui;
private readonly string _sectionsJson;
// RynthCore commands from the card (render thread), run on the next tick.
private readonly ConcurrentQueue<string> _engineCommands = new();
// "/rserver ..." lines from OnChatBarEnter, run on the next tick.
private readonly ConcurrentQueue<string[]> _commands = new();
private volatile bool _loginComplete;
private volatile string? _world;
private bool _wasActive;
public ServerPackPlugin()
{
ServerPackInfo info = ServerData.Create();
_model = new ServerPackModel(info);
_ui = new ServerPackUi(_model, RynthPluginInfo.Name + " " + Marshal.PtrToStringAnsi(VersionPointer), () => _world);
_sectionsJson = ServerPackModel.BuildSectionsJson(info, RynthPluginInfo.Name);
}
internal ServerPackInfo Info => _model.Info;
private static ServerPackInfo? _staticInfo;
/// <summary>The server's facts before the plugin object exists ("RynthServer.Profile" asked early).</summary>
internal static ServerPackInfo StaticInfo => _staticInfo ??= ServerData.Create();
/// <summary>RynthCore (or the world name) says this is the plugin's server now.</summary>
internal bool Active => _loginComplete && _model.IsActive(_world);
/// <summary>The world name the client reports ("" before login). Any thread.</summary>
internal string World => _world ?? string.Empty;
// ── Hooks for a server's own features (implement in the server's project) ──
partial void ServerInitialize();
partial void ServerLoginComplete();
partial void ServerLogout();
partial void ServerShutdown();
/// <summary>Every plugin tick while logged in; <paramref name="active"/> = this is the plugin's server.</summary>
partial void ServerTick(bool active);
/// <summary>"/rserver &lt;verb&gt; ..." verbs the shared code doesn't know; set handled to stop the help text.</summary>
partial void ServerChatCommand(string[] parts, ref bool handled);
/// <summary>Extra lines for "/rserver info".</summary>
partial void ServerInfoLines(Action<string> line);
public override int Initialize()
{
Host.Log($"[{RynthPluginInfo.Name}] Plugin initialized for {Info.Name} ({Info.Id}).");
ServerInitialize();
return 0;
}
// Also called on a freshly (re)loaded plugin while already in game.
public override void OnLoginComplete()
{
_loginComplete = true;
_wasActive = false;
RefreshWorld();
ServerLoginComplete();
}
public override void OnLogout()
{
_loginComplete = false;
_world = null;
while (_commands.TryDequeue(out _)) { }
while (_engineCommands.TryDequeue(out _)) { }
_model.Clear();
ServerLogout();
}
public override void Shutdown() => ServerShutdown();
public override void OnTick()
{
if (!_loginComplete) return;
if (_world == null) RefreshWorld();
while (_commands.TryDequeue(out string[]? parts)) RunCommand(parts);
while (_engineCommands.TryDequeue(out string? command))
{
if (!Host.HasInvokeChatParser || !Host.InvokeChatParser(command))
ChatLine($"[{RynthPluginInfo.Name}] RynthCore didn't take: " + command);
}
bool active = Active;
if (active && !_wasActive && Info.Botting == BottingPolicy.Forbidden)
ChatLine($"[{RynthPluginInfo.Name}] {Info.Name} forbids bots: don't run RynthAi's combat, navigation or looting here.");
_wasActive = active;
ServerTick(active);
}
/// <summary>The world name the client reports (the server's own once logged in).</summary>
private void RefreshWorld()
{
if (Host.HasGetWorldName && Host.TryGetWorldName(out string w) && !string.IsNullOrWhiteSpace(w))
_world = w.Trim();
}
// ── RynthCore's verdict ──────────────────────────────────────────────
/// <summary>RynthPluginApplyRemoteCommand: "servermenu" from RynthCore. Any thread: parsed and published only.</summary>
internal void ApplyRemoteCommand(string action, string value)
{
if (action.Equals("servermenu", StringComparison.OrdinalIgnoreCase))
_model.ApplyEngine(value, Environment.TickCount64);
}
/// <summary>
/// RynthPluginGetSectionsJson: the server and the card's Mini Remote spot. Always declared
/// (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;
// ── Drawing ──────────────────────────────────────────────────────────
/// <summary>The standalone card window. Render thread.</summary>
public override void OnRender()
{
if (!_loginComplete || !_ui.WindowOpen || 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; }
finally { ImGui.SetCurrentContext(previous); }
}
/// <summary>
/// RynthPluginRenderEmbed "section:server-&lt;id&gt;": the card 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. Render thread.
/// </summary>
internal bool RenderEmbeddedCard(out float wantHeight)
{
wantHeight = 0;
if (!_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
{
float startY = ImGui.GetCursorPosY();
_ui.RenderBody();
wantHeight = MathF.Max(40f, ImGui.GetCursorPosY() - startY + 4f);
return true;
}
catch (Exception ex)
{
Host.Log($"[{RynthPluginInfo.Name}] Server card failed: {ex.Message}");
return false;
}
finally { ImGui.SetCurrentContext(previous); }
}
// ── Commands ─────────────────────────────────────────────────────────
public override void OnChatBarEnter(string? text, ref int eat)
{
if (!_loginComplete || string.IsNullOrEmpty(text)) return;
string trimmed = text.Trim();
if (!trimmed.Equals(ChatCommand, StringComparison.OrdinalIgnoreCase)
&& !trimmed.StartsWith(ChatCommand + " ", StringComparison.OrdinalIgnoreCase))
return;
string[] parts = trimmed.Split(' ', StringSplitOptions.RemoveEmptyEntries);
// "/rserver <id> ...": only that server's plugin answers (several load when the host is unknown).
if (parts.Length >= 2 && ServerPackModel.IsSafeId(parts[1].ToLowerInvariant()) && !IsVerb(parts[1]))
{
if (!parts[1].Equals(Info.Id, StringComparison.OrdinalIgnoreCase)) return;
parts = Shift(parts);
}
eat = 1;
_commands.Enqueue(parts);
}
private static bool IsVerb(string word) =>
word.ToLowerInvariant() is "show" or "hide" or "toggle" or "info" or "help" or "on" or "off" or "auto";
/// <summary>Drops the server id: "/rserver coldeve info" -> "/rserver info".</summary>
private static string[] Shift(string[] parts)
{
var rest = new string[parts.Length - 1];
rest[0] = parts[0];
Array.Copy(parts, 2, rest, 1, parts.Length - 2);
return rest;
}
private void RunCommand(string[] parts)
{
string verb = parts.Length >= 2 ? parts[1].ToLowerInvariant() : "toggle";
switch (verb)
{
case "show":
_ui.WindowOpen = true;
return;
case "hide":
_ui.WindowOpen = false;
return;
case "toggle":
_ui.WindowOpen = !_ui.WindowOpen;
return;
case "auto":
case "on":
case "off":
_engineCommands.Enqueue(ServerPackModel.ForceCommand(Info.Id, verb));
return;
case "info":
PrintInfo();
return;
}
bool handled = false;
ServerChatCommand(parts, ref handled);
if (handled) return;
ChatLine($"[{RynthPluginInfo.Name}] {ChatCommand} [show|hide|toggle] - the {Info.Name} server card (also in the Mini Remote's Char section).");
ChatLine($"[{RynthPluginInfo.Name}] {ChatCommand} info - what is known about {Info.Name}; {ChatCommand} auto|on|off - this character's override.");
}
private void PrintInfo()
{
string tag = $"[{RynthPluginInfo.Name}] ";
ServerVerdictView? v = _model.Engine;
string verdict = v != null
? (v.Active ? "on for this world" : "not this world") + (v.Reason.Length > 0 ? " (" + v.Reason + ")" : "")
: (_model.IsActive(_world) ? "this world, by its name" : "not this world, by its name") + " (no RynthCore verdict yet)";
ChatLine(tag + Info.Name + ": " + verdict);
if (Info.Address.Length > 0) ChatLine(tag + "Address " + Info.Address + " (" + Info.Emulator + ", " + Info.Ruleset + ")");
if (Info.AccountLimit.Length > 0) ChatLine(tag + "Account limit: " + Info.AccountLimit);
ChatLine(tag + "Botting: " + Info.BottingText);
ServerInfoLines(line => ChatLine(tag + line));
}
internal void ChatLine(string text)
{
if (Host.HasWriteToChat) Host.WriteToChat(text, 1);
}
}

View file

@ -0,0 +1,145 @@
// ServerPackProfile.cs - A server plugin's settings as JSON, for other plugins ("RynthServer.Profile",
// Plugins/Shared/RynthServerProfileApi.cs, served by ServerPackExports' RynthPluginQueryInterface).
//
// RynthCore's GetServerStateJson (plugin API v86) names the active server and the plugin that owns
// it; a reader (RynthOracle, RynthAi's "/ra server", ...) asks that plugin for this profile to get
// the server's rules without knowing the server: connection, rule set, botting policy, account
// limits, commands, tinkering salvage and links. Everything ServerPackInfo holds, nothing guessed.
//
// The JSON is plain ASCII (anything else is \u-escaped), so a reader can show it in the AC client.
// Pure (no host calls): RynthServerPack.Tests covers it.
using System;
using System.Text;
namespace RynthCore.Plugin.ServerPack;
internal static class ServerPackProfile
{
/// <summary>The profile JSON's schema (RynthServerProfile.Schema).</summary>
public const int Schema = 1;
/// <summary>The "botting" value for a policy.</summary>
public static string BottingName(BottingPolicy policy) => policy switch
{
BottingPolicy.Allowed => "allowed",
BottingPolicy.Restricted => "restricted",
BottingPolicy.Forbidden => "forbidden",
_ => "unknown",
};
/// <summary>
/// The profile for <paramref name="info"/>: <paramref name="active"/> is this plugin's verdict
/// (RynthCore's when it pushed one), <paramref name="world"/> the world name the client reports.
/// </summary>
public static string BuildJson(ServerPackInfo info, string pluginName, string pluginVersion, bool active, string? world)
{
var sb = new StringBuilder(1024);
sb.Append("{\"schema\":").Append(Schema);
Field(sb, "id", info.Id);
Field(sb, "name", info.Name);
Field(sb, "plugin", pluginName);
Field(sb, "version", pluginVersion);
sb.Append(",\"active\":").Append(active ? "true" : "false");
Field(sb, "world", world ?? string.Empty);
List(sb, "hosts", info.Hosts);
List(sb, "worldNames", info.WorldNames);
sb.Append(",\"port\":").Append(info.Port);
Field(sb, "emulator", info.Emulator);
Field(sb, "ruleset", info.Ruleset);
Field(sb, "status", info.Status);
Field(sb, "botting", BottingName(info.Botting));
Field(sb, "bottingNote", info.BottingNote);
Field(sb, "accountLimit", info.AccountLimit);
Field(sb, "summary", info.Summary);
List(sb, "facts", info.Facts);
sb.Append(",\"commands\":[");
for (int i = 0; i < info.Commands.Length; i++)
{
if (i > 0) sb.Append(',');
sb.Append("{\"command\":");
Str(sb, info.Commands[i].Command);
sb.Append(",\"what\":");
Str(sb, info.Commands[i].What);
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.
sb.Append(",\"salvage\":[");
for (int i = 0; i < info.Salvage.Length; i++)
{
ServerSalvage s = info.Salvage[i];
if (i > 0) sb.Append(',');
sb.Append("{\"bench\":");
Str(sb, s.Bench);
sb.Append(",\"material\":").Append(s.Material);
sb.Append(",\"kind\":");
Str(sb, s.Kind);
sb.Append(",\"effect\":");
Str(sb, s.Effect);
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(']');
Field(sb, "discord", info.Discord);
Field(sb, "website", info.Website);
Field(sb, "wiki", info.Wiki);
Field(sb, "source", info.Source);
sb.Append('}');
return sb.ToString();
}
private static void Field(StringBuilder sb, string name, string? value)
{
sb.Append(",\"").Append(name).Append("\":");
Str(sb, value);
}
private static void List(StringBuilder sb, string name, string[]? values)
{
sb.Append(",\"").Append(name).Append("\":[");
if (values != null)
{
for (int i = 0; i < values.Length; i++)
{
if (i > 0) sb.Append(',');
Str(sb, values[i]);
}
}
sb.Append(']');
}
/// <summary>A JSON string literal in plain ASCII (control and non-ASCII characters \u-escaped).</summary>
private static void Str(StringBuilder sb, string? s)
{
sb.Append('"');
foreach (char c in s ?? string.Empty)
{
switch (c)
{
case '"': sb.Append("\\\""); break;
case '\\': sb.Append("\\\\"); break;
case '\n': sb.Append("\\n"); break;
case '\r': sb.Append("\\r"); break;
case '\t': sb.Append("\\t"); break;
default:
if (c < 0x20 || c > 0x7e) sb.Append("\\u").Append(((int)c).ToString("x4"));
else sb.Append(c);
break;
}
}
sb.Append('"');
}
}

View file

@ -0,0 +1,217 @@
// ServerPackUi.cs - A server plugin's "server card".
//
// Drawn in two places: RynthCore's Mini Remote, the shared "Server" section, this server's area
// (the surface "section:server-<id>" through RynthPluginRenderEmbed), and its own window ("/rserver").
// Shows RynthCore's verdict and this character's Auto / On / Off override (read only: it is set in
// RynthCore Options > Diagnostics, 2026-10-13), what is known about the server (address, rule set,
// account limit, botting policy, its features), the commands it adds, its links, and how to set an
// account up for it in the launcher. Render thread only.
using System;
using System.Numerics;
using ImGuiNET;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.ServerPack;
internal sealed class ServerPackUi
{
private static readonly Vector4 Teal = new(0.30f, 0.85f, 0.80f, 1f);
private static readonly Vector4 Mute = new(0.60f, 0.62f, 0.66f, 1f);
private static readonly Vector4 Warn = new(0.95f, 0.55f, 0.45f, 1f);
private static readonly Vector4 Good = new(0.55f, 0.85f, 0.45f, 1f);
private readonly ServerPackModel _model;
private readonly string _pluginLabel;
private readonly Func<string?> _world;
private readonly string _windowTitle;
private string _status = string.Empty;
/// <summary>The standalone window is open ("/rserver").</summary>
public bool WindowOpen;
/// <param name="pluginLabel">"RynthColdeve 0.1.0", for the title and the card.</param>
/// <param name="world">The world name the client reports now (null when unknown).</param>
public ServerPackUi(ServerPackModel model, string pluginLabel, Func<string?> world)
{
_model = model;
_pluginLabel = pluginLabel;
_world = world;
_windowTitle = model.Info.Name + " server (" + pluginLabel + ")##server_" + model.Info.Id;
}
/// <summary>The standalone window, while open.</summary>
public void RenderWindow()
{
if (!WindowOpen) return;
ImGui.SetNextWindowSize(new Vector2(460, 520), ImGuiCond.FirstUseEver);
bool open = WindowOpen;
if (ImGui.Begin(_windowTitle, ref open)) RenderBody();
ImGui.End();
WindowOpen = open;
}
/// <summary>The card's content, into the current window.</summary>
public void RenderBody()
{
ServerPackInfo info = _model.Info;
RenderVerdict(info);
ImGui.Separator();
RenderFacts(info);
if (info.Commands.Length > 0)
{
ImGui.Separator();
RenderCommands(info);
}
ImGui.Separator();
RenderLinks(info);
ImGui.Separator();
RenderSetup(info);
if (info.Source.Length > 0)
{
ImGui.Spacing();
SafeImGui.TextDisabled("Server data: " + info.Source);
}
if (_status.Length > 0)
{
ImGui.Separator();
SafeImGui.TextWrapped(_status);
}
}
private void RenderVerdict(ServerPackInfo info)
{
ServerVerdictView? v = _model.Engine;
if (v == null)
{
bool byName = _model.IsActive(_world());
SafeImGui.TextColored(byName ? Teal : Mute, byName
? info.Name + ": this world (by its name)"
: info.Name + ": not this world (by its name)");
ImGui.PushStyleColor(ImGuiCol.Text, Mute);
ImGui.TextWrapped("Waiting for RynthCore's verdict and the override (RynthCore 2026.10.5.48 or later sends them).");
ImGui.PopStyleColor();
return;
}
SafeImGui.TextColored(v.Active ? Teal : Mute, v.Active ? info.Name + ": on for this world" : info.Name + ": not this world");
if (v.Reason.Length > 0)
{
ImGui.PushStyleColor(ImGuiCol.Text, Mute);
SafeImGui.TextWrapped(v.Reason);
ImGui.PopStyleColor();
}
// Read only: a server is forced in one place, RynthCore Options > Diagnostics (2026-10-13).
SafeImGui.TextDisabled("This character: " + ForceText(ServerPackModel.NormalizeForce(v.Force))
+ " (change it in RynthCore Options > Diagnostics)");
if (ImGui.IsItemHovered())
SafeImGui.SetTooltip("RynthCore's server selection (Options > Diagnostics) forces a server for this character,\n"
+ "or /rc server " + info.Id + " auto|on|off in chat.");
}
/// <summary>The override as words: Auto (detected), On (forced on) or Off (forced off).</summary>
private static string ForceText(string force) => force switch
{
"on" => "forced on",
"off" => "forced off",
_ => "auto (detected)",
};
private static void RenderFacts(ServerPackInfo info)
{
if (ImGui.BeginTable("##facts_" + info.Id, 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp))
{
ImGui.TableSetupColumn("Item", ImGuiTableColumnFlags.WidthFixed, 110);
ImGui.TableSetupColumn("Value");
Row("Address", info.Address.Length > 0 ? info.Address : "(not published)");
Row("Emulator", info.Emulator);
Row("Rule set", info.Ruleset);
if (info.Status.Length > 0) Row("Status", info.Status);
Row("Account limit", info.AccountLimit.Length > 0 ? info.AccountLimit : "(not published)");
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TextUnformatted("Botting");
ImGui.TableNextColumn();
Vector4 color = info.Botting switch
{
BottingPolicy.Forbidden => Warn,
BottingPolicy.Restricted => Warn,
BottingPolicy.Allowed => Good,
_ => Mute,
};
ImGui.PushStyleColor(ImGuiCol.Text, color);
SafeImGui.TextWrapped(info.BottingText);
ImGui.PopStyleColor();
ImGui.EndTable();
}
if (info.Botting == BottingPolicy.Forbidden)
SafeImGui.TextColored(Warn, "This server forbids bots: don't run RynthAi's combat, navigation or looting here.");
if (info.Summary.Length > 0)
{
ImGui.Spacing();
SafeImGui.TextWrapped(info.Summary);
}
foreach (string fact in info.Facts)
SafeImGui.BulletText(fact);
}
private static void Row(string label, string value)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
SafeImGui.Text(label);
ImGui.TableNextColumn();
SafeImGui.TextWrapped(value);
}
private void RenderCommands(ServerPackInfo info)
{
ImGui.TextUnformatted("Server commands");
for (int i = 0; i < info.Commands.Length; i++)
{
ServerCommand c = info.Commands[i];
ImGui.PushID(i);
if (ImGui.SmallButton("Copy")) Copy(c.Command);
ImGui.PopID();
ImGui.SameLine();
SafeImGui.Text(c.Command);
ImGui.SameLine();
SafeImGui.TextDisabled("- " + c.What);
}
}
private void RenderLinks(ServerPackInfo info)
{
ImGui.TextUnformatted("Links");
bool any = false;
any |= Link("Discord", info.Discord);
any |= Link("Website", info.Website);
any |= Link("Wiki", info.Wiki);
if (!any) ImGui.TextDisabled("(none published)");
}
private bool Link(string label, string url)
{
if (url.Length == 0) return false;
ImGui.PushID(label);
if (ImGui.SmallButton("Copy")) Copy(url);
ImGui.PopID();
ImGui.SameLine();
SafeImGui.Text(label + ": " + url);
return true;
}
private static void RenderSetup(ServerPackInfo info)
{
ImGui.TextUnformatted("Account setup (RynthCore launcher)");
foreach (string step in ServerPackModel.LauncherSteps(info))
SafeImGui.TextWrapped(step);
}
private void Copy(string text)
{
ImGui.SetClipboardText(text);
_status = "Copied: " + text;
}
}

View file

@ -0,0 +1,72 @@
<Project>
<!--
The common build of a server plugin (RynthColdeve, RynthAelrynth, ...): one NativeAOT plugin
per game server, built like RynthILT, so each server's plugin ships and updates on its own
(its own DLL, feed entry and C:\Games\RynthSuite\<Name>\ folder).
A server plugin's csproj sets, then imports this file:
AssemblyName RynthCore.Plugin.Rynth<Server> (plugin name = without the prefix)
Version its own version (Publish-Update.ps1 overrides it for a release)
RynthPluginServerId lower-case id (a-z 0-9 -); the Mini Remote's server id
RynthPluginServerName display name
RynthPluginServerHosts connect hosts, '|'-separated (a name matches hosts under it)
RynthPluginServerWorldNames world names the server announces, '|'-separated ('*' wildcards)
RynthPluginDescription one line for the launcher's plugin list
and keeps one source file, ServerData.cs (ServerData.Create: what is known about the server).
Detection data lives only in the csproj: the SDK writes it into the embedded manifest (the
engine loads the plugin only for its server) and into RynthPluginInfo (the plugin's own use).
Server-specific features go in the project as more files, through the partial hooks in
ServerPackPlugin.cs (ServerTick, ServerChatCommand, ...), so the shared code stays the same for all.
-->
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<NativeLib>Shared</NativeLib>
<InvariantGlobalization>true</InvariantGlobalization>
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
<StripSymbols>false</StripSymbols>
<RootNamespace>RynthCore.Plugin.ServerPack</RootNamespace>
<Platforms>x86</Platforms>
<!-- Nothing above the v66 baseline: chat commands, world names and the plugin-command broker
are behind HasInvokeChatParser / HasGetWorldName / HasWriteToChat. -->
<RynthPluginMinEngineApi Condition="'$(RynthPluginMinEngineApi)' == ''">66</RynthPluginMinEngineApi>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\SafeImGui.cs" Link="Shared\SafeImGui.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackInfo.cs" Link="ServerPack\ServerPackInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackModel.cs" Link="ServerPack\ServerPackModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackUi.cs" Link="ServerPack\ServerPackUi.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackPlugin.cs" Link="ServerPack\ServerPackPlugin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackExports.cs" Link="ServerPack\ServerPackExports.cs" />
<!-- "RynthServer.Profile": the server's settings for other plugins (RynthPluginQueryInterface). -->
<Compile Include="$(MSBuildThisFileDirectory)..\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackProfile.cs" Link="ServerPack\ServerPackProfile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServerPackInterface.cs" Link="ServerPack\ServerPackInterface.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ImGui.NET" Version="1.91.6.1" />
<TrimmerRootAssembly Include="ImGui.NET" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\RynthCore\src\RynthCore.PluginCore\RynthCore.PluginCore.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\RynthCore\src\RynthCore.PluginSdk\RynthCore.PluginSdk.csproj" />
</ItemGroup>
<!-- The engine already loaded cimgui.dll into the client; a second copy next to the plugin is never used. -->
<Target Name="RemoveBundledImGuiNativeFromBuild" AfterTargets="Build">
<Delete Files="$(OutputPath)cimgui.dll" Condition="Exists('$(OutputPath)cimgui.dll')" />
</Target>
<Target Name="RemoveBundledImGuiNativeFromPublish" AfterTargets="Publish" Condition="'$(PublishDir)' != ''">
<Delete Files="$(PublishDir)cimgui.dll" Condition="Exists('$(PublishDir)cimgui.dll')" />
</Target>
</Project>