Snapshot for release 2026.10.15.2 (internal 9094d68)

This commit is contained in:
Tom Bohar 2026-10-15 20:32:34 -04:00
commit 516ad2bdf2
121 changed files with 6486 additions and 781 deletions

View file

@ -29,6 +29,74 @@ public sealed class RynthPluginDependency
public bool Optional { get; set; }
}
/// <summary>
/// The one game server a server plugin is for (RynthColdeve, RynthILT, ...). The engine loads such a
/// plugin only where the client's connect host is this server's, or where no installed server
/// plugin claims the host (PluginManifestGate). Older engines and launchers ignore it.
/// </summary>
public sealed class RynthPluginServer
{
/// <summary>Lower-case id, the same one the plugin's Mini Remote sections use ("coldeve", "ilt").</summary>
public string Id { get; set; } = "";
public string Name { get; set; } = "";
/// <summary>Connect hosts: a name also matches hosts under it; an IP address matches only itself; '*' wildcards.</summary>
public List<string> Hosts { get; set; } = new();
/// <summary>World names the server announces ('*' wildcards, case-insensitive).</summary>
public List<string> WorldNames { get; set; } = new();
/// <summary>
/// True when <paramref name="host"/> is one of <see cref="Hosts"/>: the same name, a host under
/// it ("game.infiniteleaftide.online" for "infiniteleaftide.online"), or a '*' pattern match. An
/// IP address matches only itself. Case and a trailing dot are ignored (the engine's IltDetect
/// rules, kept BCL-only here for the manifest gate).
/// </summary>
public bool MatchesHost(string? host, out string matched)
{
matched = "";
if (string.IsNullOrWhiteSpace(host)) return false;
string h = host.Trim().TrimEnd('.').ToLowerInvariant();
foreach (string raw in Hosts)
{
string p = raw.Trim().TrimEnd('.').ToLowerInvariant();
if (p.Length == 0) continue;
bool hit = p.Contains('*')
? Glob(h, p)
: h == p || (!IsIpv4(p) && h.EndsWith("." + p, StringComparison.Ordinal));
if (!hit) continue;
matched = raw.Trim();
return true;
}
return false;
}
private static bool IsIpv4(string text) =>
System.Net.IPAddress.TryParse(text, out System.Net.IPAddress? ip) && ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork;
/// <summary>Case-insensitive match where '*' stands for any run of characters.</summary>
private static bool Glob(string text, string pattern)
{
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;
}
}
/// <summary>A plugin's manifest (schema 1). Unknown JSON fields are ignored, so later schemas can add fields.</summary>
public sealed class RynthPluginManifest
{
@ -50,6 +118,11 @@ public sealed class RynthPluginManifest
public string Description { get; set; } = "";
public string Homepage { get; set; } = "";
public string License { get; set; } = "";
/// <summary>Set for a server plugin (one game server's features); null for every other plugin.</summary>
public RynthPluginServer? Server { get; set; }
/// <summary>Most hosts or world names a server block may list (a manifest is read before every load).</summary>
public const int MaxServerPatterns = 16;
/// <summary>Parses a manifest; throws <see cref="InvalidDataException"/> with the reason when it isn't one.</summary>
public static RynthPluginManifest Parse(string json)
@ -118,10 +191,50 @@ public sealed class RynthPluginManifest
m.Dependencies.Add(dep);
}
}
if (r.TryGetProperty("server", out JsonElement srv) && srv.ValueKind != JsonValueKind.Null)
m.Server = ParseServer(srv);
return m;
}
}
/// <summary>The "server" block: an object with an id; hosts and worldNames are string arrays.</summary>
private static RynthPluginServer ParseServer(JsonElement srv)
{
if (srv.ValueKind != JsonValueKind.Object)
throw new InvalidDataException("the plugin manifest's server is not an object");
var s = new RynthPluginServer
{
Id = Str(srv, "id").Trim().ToLowerInvariant(),
Name = Str(srv, "name").Trim(),
};
if (s.Id.Length == 0 || s.Id.Length > 32)
throw new InvalidDataException("the plugin manifest's server has no id (or one over 32 characters)");
foreach (char c in s.Id)
if (!(c is >= 'a' and <= 'z' || c is >= '0' and <= '9' || c == '-'))
throw new InvalidDataException($"the plugin manifest's server id '{s.Id}' may only have a-z, 0-9 and '-'");
if (s.Name.Length == 0) s.Name = s.Id;
s.Hosts = Patterns(srv, "hosts");
s.WorldNames = Patterns(srv, "worldNames");
return s;
}
private static List<string> Patterns(JsonElement o, string name)
{
var list = new List<string>();
if (!o.TryGetProperty(name, out JsonElement a) || a.ValueKind == JsonValueKind.Null) return list;
if (a.ValueKind != JsonValueKind.Array)
throw new InvalidDataException($"the plugin manifest's server {name} is not an array");
foreach (JsonElement e in a.EnumerateArray())
{
string p = e.ValueKind == JsonValueKind.String ? (e.GetString() ?? "").Trim() : "";
if (p.Length == 0 || p.Length > 128) continue;
if (list.Count >= MaxServerPatterns) break;
list.Add(p);
}
return list;
}
/// <summary>Parses, or returns null with the reason in <paramref name="error"/>.</summary>
public static RynthPluginManifest? TryParse(string json, out string error)
{
@ -155,6 +268,19 @@ public sealed class RynthPluginManifest
if (Description.Length > 0) w.WriteString("description", Description);
if (Homepage.Length > 0) w.WriteString("homepage", Homepage);
if (License.Length > 0) w.WriteString("license", License);
if (Server != null)
{
w.WriteStartObject("server");
w.WriteString("id", Server.Id);
w.WriteString("name", Server.Name);
w.WriteStartArray("hosts");
foreach (string h in Server.Hosts) w.WriteStringValue(h);
w.WriteEndArray();
w.WriteStartArray("worldNames");
foreach (string n in Server.WorldNames) w.WriteStringValue(n);
w.WriteEndArray();
w.WriteEndObject();
}
w.WriteEndObject();
}
return Encoding.UTF8.GetString(ms.ToArray());

View file

@ -174,6 +174,11 @@ public struct RynthCoreApiNative
public IntPtr RemoveClientObjectFn; // int RemoveClientObject(uint id) -> 1 removed, 2 queued, 0 refused, -1 unbound
// v84: every property of an object (/ub propertydump), one record (ObjectProperties.TryParse)
public IntPtr GetObjectPropertiesFn; // int GetObjectProperties(uint id, byte* buf, int size) -> record size (copied if <= size), 0 unknown, -1 bad args
// v85: answer the server's yes/no prompt (craft chance) without the client's dialog
public IntPtr ArmConfirmationFn; // int ArmConfirmation(uint type, int minPercent, int timeoutMs) -> 1 armed, 0 unavailable, -3 bad args
public IntPtr GetLastConfirmationFn; // int GetLastConfirmation(uint* type, uint* ctx, int* percent, int* outcome, int* ageMs) -> seq
// v86: which server this is, for every plugin (servers, verdicts, overrides, owning plugins)
public IntPtr GetServerStateJsonFn; // int GetServerStateJson(byte* buffer, int capacity) -> UTF-8 byte length (>= capacity: too small)
}
/// <summary>

View file

@ -142,6 +142,8 @@ public readonly unsafe struct RynthCoreHost
public bool HasGetCharacterTitles => _api.Version >= 75 && _api.GetCharacterTitlesFn != IntPtr.Zero;
/// <summary>v75: <see cref="TryGetServerInfo"/> (which server this is).</summary>
public bool HasGetServerInfo => _api.Version >= 75 && _api.GetServerInfoFn != IntPtr.Zero;
/// <summary>v86: <see cref="TryGetServerStateJson"/> (the server list for every plugin).</summary>
public bool HasGetServerStateJson => _api.Version >= 86 && _api.GetServerStateJsonFn != IntPtr.Zero;
/// <summary>v76: <see cref="CloseContainer"/> (close a corpse or chest like the client's window close).</summary>
public bool HasCloseContainer => _api.Version >= 76 && _api.CloseContainerFn != IntPtr.Zero;
/// <summary>v77: <see cref="GetScreenMode"/>, <see cref="GetUiHookFlags"/> and the UI callbacks
@ -182,6 +184,8 @@ public readonly unsafe struct RynthCoreHost
public bool HasGetPluginExportJson => _api.Version >= 66 && _api.GetPluginExportJsonFn != IntPtr.Zero;
// Version-checked first: on an older engine the field lies past the end of its API table.
public bool HasGetMergeStackResult => _api.Version >= 81 && _api.GetMergeStackResultFn != IntPtr.Zero;
/// <summary>v85: <see cref="ArmConfirmation"/> and <see cref="TryGetLastConfirmation"/>.</summary>
public bool HasConfirmationAnswers => _api.Version >= 85 && _api.ArmConfirmationFn != IntPtr.Zero && _api.GetLastConfirmationFn != IntPtr.Zero;
public bool HasGetPluginInterface => _api.Version >= 68 && _api.GetPluginInterfaceFn != IntPtr.Zero;
public bool HasGetLiveObjectIds => _api.Version >= 69 && _api.GetLiveObjectIdsFn != IntPtr.Zero;
public bool HasGetLastUseDone => _api.Version >= 70 && _api.GetLastUseDoneFn != IntPtr.Zero;
@ -619,6 +623,65 @@ public readonly unsafe struct RynthCoreHost
return status;
}
/// <summary>Server yes/no prompt types (ConfirmationRequest 0x0274).</summary>
public static class ConfirmationKind
{
public const uint SwearAllegiance = 1;
public const uint AlterSkill = 2;
public const uint AlterAttribute = 3;
public const uint Fellowship = 4;
public const uint CraftInteraction = 5;
public const uint Augmentation = 6;
public const uint YesNo = 7;
}
/// <summary>What happened to the last prompt (<see cref="TryGetLastConfirmation"/>).</summary>
public static class ConfirmationOutcome
{
public const int None = 0; // no prompt this session
public const int Shown = 1; // not armed: the client showed its dialog
public const int Accepted = 2; // answered Yes for the plugin
public const int Declined = 3; // answered No: the server's percent was below the minimum
public const int SendFailed = 4; // armed, but the send failed: the client showed it
}
/// <summary>
/// v85: answer the next server prompt of <paramref name="type"/> (a
/// <see cref="ConfirmationKind"/>) that arrives within <paramref name="timeoutMs"/>,
/// without the client opening its dialog: Yes when the server's "N percent chance" is at
/// least <paramref name="minPercent"/> (or it is 0), else No. One-shot; timeoutMs &lt;= 0
/// disarms. 1 armed, 0 unavailable (engine before v85, sender or hook missing), -3 bad
/// arguments.
/// </summary>
public int ArmConfirmation(uint type, int minPercent, int timeoutMs)
{
if (!HasConfirmationAnswers)
return 0;
return ((delegate* unmanaged[Cdecl]<uint, int, int, int>)_api.ArmConfirmationFn)(type, minPercent, timeoutMs);
}
/// <summary>
/// v85: the last prompt the server sent. <paramref name="seq"/> counts them (0 = none yet);
/// <paramref name="contextId"/> is the server's context for it; <paramref name="percent"/> is
/// -1 when the text has none; <paramref name="outcome"/> is a <see cref="ConfirmationOutcome"/>.
/// False on an engine before v85.
/// </summary>
public bool TryGetLastConfirmation(out int seq, out uint type, out uint contextId, out int percent, out int outcome, out int ageMs)
{
seq = 0; type = 0; contextId = 0; percent = -1; outcome = 0; ageMs = 0;
if (!HasConfirmationAnswers)
return false;
uint t = 0, ctx = 0;
int pct = -1, oc = 0, age = 0;
seq = ((delegate* unmanaged[Cdecl]<uint*, uint*, int*, int*, int*, int>)_api.GetLastConfirmationFn)(&t, &ctx, &pct, &oc, &age);
type = t; contextId = ctx; percent = pct; outcome = oc; ageMs = age;
return true;
}
/// <summary>v85: <see cref="TryGetLastConfirmation(out int, out uint, out uint, out int, out int, out int)"/> without the context id.</summary>
public bool TryGetLastConfirmation(out int seq, out uint type, out int percent, out int outcome, out int ageMs)
=> TryGetLastConfirmation(out seq, out type, out _, out percent, out outcome, out ageMs);
/// <summary>
/// Gives an item to an NPC or another player by sending the F7B1 give
/// GameAction (CM_Inventory::Event_GiveObjectRequest). This is the correct
@ -1054,6 +1117,37 @@ public readonly unsafe struct RynthCoreHost
return true;
}
/// <summary>
/// v86: which server this is, as JSON: every server the engine knows (built in, or declared
/// by a loaded server plugin) with its verdict, this character's override, the reason and the
/// plugin that owns its settings, plus "active" / "activePlugin" and the Diagnostics "pick".
/// Schema: RynthCore.Engine UI/Sections/ServerStateJson.cs. False when the engine predates
/// v86 or the call failed. Any thread; a few hundred bytes, so poll it (every second or two)
/// rather than caching it for a session: an override changes it live.
/// </summary>
public bool TryGetServerStateJson(out string json)
{
json = string.Empty;
if (!HasGetServerStateJson)
return false;
var fn = (delegate* unmanaged[Cdecl]<byte*, int, int>)_api.GetServerStateJsonFn;
int capacity = 2048;
for (int attempt = 0; attempt < 3; attempt++)
{
byte[] buffer = new byte[capacity];
int length;
fixed (byte* p = buffer) length = fn(p, capacity);
if (length < 0) return false;
if (length < capacity)
{
json = System.Text.Encoding.UTF8.GetString(buffer, 0, length);
return true;
}
capacity = length + 256;
}
return false;
}
public bool TryGetObjectBoolProperty(uint objectId, uint stype, out bool value)
{
value = false;

View file

@ -14,6 +14,9 @@
description RynthPluginDescription (default: Description)
homepage RynthPluginHomepage (default: PackageProjectUrl)
license RynthPluginLicense (default: PackageLicenseExpression)
server RynthPluginServerId (lower-case a-z 0-9 -), RynthPluginServerName,
RynthPluginServerHosts and RynthPluginServerWorldNames ('|'-separated):
a server plugin, loaded only for its own server (engine PluginManifestGate)
2. adds [assembly: RynthPluginManifest(minEngineApi)], which RynthPluginBase.MinimumApiVersion
defaults to (the plugin's own runtime check, which also covers engines from before
manifests), and generates RynthPluginInfo (Name, Version, MinEngineApi constants) in the
@ -33,7 +36,7 @@
<PropertyGroup>
<!-- The engine API this SDK knows; tools\PluginManifestTests checks it equals PluginContractVersion.Current. -->
<RynthCoreSdkApiVersion>84</RynthCoreSdkApiVersion>
<RynthCoreSdkApiVersion>86</RynthCoreSdkApiVersion>
<_RynthPluginManifestOn Condition="'$(RynthPluginMinEngineApi)' != '' and '$(RynthPluginManifest)' != 'false'">true</_RynthPluginManifestOn>
</PropertyGroup>
@ -79,6 +82,10 @@ public class RynthWritePluginManifest : Task
public string Description { get; set; }
public string Homepage { get; set; }
public string License { get; set; }
public string ServerId { get; set; }
public string ServerName { get; set; }
public string ServerHosts { get; set; }
public string ServerWorldNames { get; set; }
public ITaskItem[] Dependencies { get; set; }
public string RootNamespace { get; set; }
[Required] public string JsonPath { get; set; }
@ -126,6 +133,21 @@ public class RynthWritePluginManifest : Task
AppendOpt(sb, "description", Description);
AppendOpt(sb, "homepage", Homepage);
AppendOpt(sb, "license", License);
string serverId = (ServerId ?? "").Trim().ToLowerInvariant();
string serverName = (ServerName ?? "").Trim();
string[] hosts = Split(ServerHosts), worlds = Split(ServerWorldNames);
if (serverId.Length > 0)
{
foreach (char c in serverId)
if (!(c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '-'))
{ Log.LogError("RynthPluginServerId '{0}' may only have a-z, 0-9 and '-'.", serverId); return false; }
if (hosts.Length + worlds.Length == 0)
{ Log.LogError("RynthPluginServerId '{0}' needs RynthPluginServerHosts or RynthPluginServerWorldNames.", serverId); return false; }
if (serverName.Length == 0) serverName = serverId;
sb.Append(",\n \"server\": { \"id\": ").Append(Q(serverId)).Append(", \"name\": ").Append(Q(serverName));
sb.Append(", \"hosts\": [").Append(JoinQ(hosts)).Append("], \"worldNames\": [").Append(JoinQ(worlds)).Append("] }");
}
sb.Append("\n}\n");
WriteIfChanged(JsonPath, sb.ToString());
@ -139,6 +161,11 @@ public class RynthWritePluginManifest : Task
cs.Append(" public const string Version = ").Append(Q((Version ?? "").Trim())).Append(";\n");
cs.Append(" /// <summary>The oldest engine API this plugin runs on (its manifest's minEngineApi).</summary>\n");
cs.Append(" public const uint MinEngineApi = ").Append(min).Append(";\n");
cs.Append(" /// <summary>The manifest's server block (\"\" and empty lists for a plugin that isn't a server plugin).</summary>\n");
cs.Append(" public const string ServerId = ").Append(Q(serverId)).Append(";\n");
cs.Append(" public const string ServerName = ").Append(Q(serverId.Length > 0 ? serverName : "")).Append(";\n");
cs.Append(" public static readonly string[] ServerHosts = { ").Append(serverId.Length > 0 ? JoinQ(hosts) : "").Append(" };\n");
cs.Append(" public static readonly string[] ServerWorldNames = { ").Append(serverId.Length > 0 ? JoinQ(worlds) : "").Append(" };\n");
cs.Append("}\n");
WriteIfChanged(InfoSourcePath, cs.ToString());
return !Log.HasLoggedErrors;
@ -150,6 +177,25 @@ public class RynthWritePluginManifest : Task
sb.Append(",\n ").Append(Q(key)).Append(": ").Append(Q(value.Trim()));
}
// '|'-separated (MSBuild would split ';' lists into items), blanks dropped, at most 16.
private static string[] Split(string text)
{
var list = new List<string>();
foreach (string part in (text ?? "").Split('|'))
{
string p = part.Trim();
if (p.Length > 0 && list.Count < 16) list.Add(p);
}
return list.ToArray();
}
private static string JoinQ(string[] values)
{
var sb = new StringBuilder();
for (int i = 0; i < values.Length; i++) sb.Append(i == 0 ? "" : ", ").Append(Q(values[i]));
return sb.ToString();
}
private static void WriteIfChanged(string path, string text)
{
if (File.Exists(path) && File.ReadAllText(path) == text) return;
@ -241,6 +287,8 @@ public class RynthEmbedPluginManifest : Task
MaxEngineApi="$(RynthPluginMaxEngineApi)" SdkApiVersion="$(RynthCoreSdkApiVersion)"
Author="$(RynthPluginAuthor)" Description="$(RynthPluginDescription)"
Homepage="$(RynthPluginHomepage)" License="$(RynthPluginLicense)"
ServerId="$(RynthPluginServerId)" ServerName="$(RynthPluginServerName)"
ServerHosts="$(RynthPluginServerHosts)" ServerWorldNames="$(RynthPluginServerWorldNames)"
Dependencies="@(RynthPluginDependency)" RootNamespace="$(RootNamespace)"
JsonPath="$(_RynthPluginManifestJson)" InfoSourcePath="$(_RynthPluginInfoSource)" />
<ItemGroup>