RynthCore as of 2026-11-12 (internal eb12118): release 2026.11.12.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tom Bohar 2026-11-12 19:56:36 -05:00
commit 7f1e7d5039
71 changed files with 3413 additions and 587 deletions

View file

@ -68,6 +68,10 @@ internal static class Program
OwnColorPrecedence();
OwnColorQueue();
OwnColorCommand();
OwnSpansParse();
OwnSpansCommand();
OwnSpansQueue();
OwnSpansOverRules();
SlowRulesNeedStrikes();
Console.WriteLine();
@ -569,6 +573,109 @@ internal static class Program
Check(other == null && ChatOwnColors.TakeArmed(700) == Orange, "armed per thread: another plugin thread's line isn't coloured");
}
// 2026-11-11: colour runs for parts of a line ("nextspans": RynthAi's per-part item info).
private static void OwnSpansParse()
{
Case("own runs: the nextspans payload is read strictly");
ChatSpan[]? s = ChatOwnColors.ParseSpans("0:15:E6B450;15:15:FFFFFF;40:6:#3fbfff", out string? err);
Check(err == null && s is { Length: 3 }, "three runs");
Check(s![0] == new ChatSpan(0, 15, 0xFFE6B450) && s[1] == new ChatSpan(15, 15, 0xFFFFFFFF) && s[2] == new ChatSpan(40, 6, 0xFF3FBFFF),
"offsets as given, colours opaque, '#' and lower case allowed");
Check(ChatOwnColors.ParseSpans(" 2:3:112233 ", out _) is { Length: 1 }, "spaces around the payload are fine");
string[] bad =
{
"", "0:5", "0:5:FFFFFF:1", "a:5:FFFFFF", "0:b:FFFFFF", "-1:5:FFFFFF", "0:-5:FFFFFF", "0:0:FFFFFF",
"0:5:FFFFF", "0:5:FFFFFFF", "0:5:GGGGGG", "0:5:orange", "0:5:0xFFFFFF", "+1:5:FFFFFF", "1.5:2:FFFFFF",
"0:5:FFFFFF;", ";0:5:FFFFFF", "0:5:FFFFFF;;6:1:FFFFFF", "10:5:FFFFFF;0:5:FFFFFF", "0:10:FFFFFF;5:5:FFFFFF",
"100001:1:FFFFFF", "0:9999999:FFFFFF", "0:5:FF FFFF",
};
foreach (string b in bad)
Check(ChatOwnColors.ParseSpans(b, out string? why) == null && why != null, $"refused with a reason: '{b}'");
var many = new System.Text.StringBuilder();
for (int i = 0; i < ChatOwnColors.MaxSpans + 1; i++) many.Append(many.Length > 0 ? ";" : "").Append($"{i}:1:FFFFFF");
Check(ChatOwnColors.ParseSpans(many.ToString(), out _) == null, $"more than {ChatOwnColors.MaxSpans} runs: refused");
Check(ChatOwnColors.ParseSpans(new string(' ', 2) + new string('1', ChatOwnColors.MaxPayloadChars + 1), out _) == null, "an over-long payload: refused");
Check(ChatOwnColors.ParseSpans("0:5:FFFFFF;5:5:000000", out _) is { Length: 2 }, "runs that touch are fine");
Check(ChatOwnColors.FitSpans(s, 46, out string? fit) == s && fit == null, "runs inside the line: kept");
Check(ChatOwnColors.FitSpans(s, 45, out fit) == null && fit != null, "one run past the end: none kept, and why");
Check(ChatOwnColors.FitSpans(null, 10, out fit) == null && fit == null, "no runs: nothing to say");
}
private static void OwnSpansCommand()
{
Case("own runs: SendPluginCommand(\"RynthCore.Chat\", \"nextspans\", ...) arms the next WriteToChat");
Check(ChatOwnColors.NextSpansAction == "nextspans", "the name RynthAi sends");
Check(ChatOwnColors.TakeArmedSpans(0) == null, "nothing armed: null");
Check(ChatOwnColors.HandlePluginCommand("nextspans", "0:4:EE921E", 100, out string? err) && err == null, "understood");
Check(ChatOwnColors.TakeArmed(100) == null, "it arms no whole-line colour");
Check(ChatOwnColors.TakeArmedSpans(150) is [{ Start: 0, Length: 4, Argb: Orange }], "the next WriteToChat takes it");
Check(ChatOwnColors.TakeArmedSpans(160) == null, "only the next one");
Check(ChatOwnColors.HandlePluginCommand("NextSpans", "0:4:EE921E", 200) && ChatOwnColors.TakeArmedSpans(200 + ChatOwnColors.ArmWindowMs + 1) == null,
"any case; armed too long ago: dropped");
Check(ChatOwnColors.HandlePluginCommand("nextspans", "0:4:EE921E", 300) && ChatOwnColors.HandlePluginCommand("nextspans", "none", 301)
&& ChatOwnColors.TakeArmedSpans(302) == null, "\"none\" disarms (and answers yes: how a plugin asks)");
Check(ChatOwnColors.HandlePluginCommand("nextspans", "", 303), "\"\" answers yes too");
ChatOwnColors.HandlePluginCommand("nextspans", "0:4:EE921E", 400);
Check(!ChatOwnColors.HandlePluginCommand("nextspans", "0:4", 401, out err) && err != null && ChatOwnColors.TakeArmedSpans(402) == null,
"a bad payload: refused with a reason, and what was armed before is gone");
Check(ChatOwnColors.HandlePluginCommand("nextcolor", "#EE921E", 500) && ChatOwnColors.HandlePluginCommand("nextspans", "0:4:FFFFFF", 501)
&& ChatOwnColors.TakeArmed(502) == Orange && ChatOwnColors.TakeArmedSpans(502) is { Length: 1 }, "nextcolor then nextspans: both for the same line");
ChatOwnColors.HandlePluginCommand("nextspans", "0:4:EE921E", 600);
ChatSpan[]? other = null;
var t = new Thread(() => other = ChatOwnColors.TakeArmedSpans(600));
t.Start(); t.Join();
Check(other == null && ChatOwnColors.TakeArmedSpans(600) != null, "armed per thread");
}
private static void OwnSpansQueue()
{
Case("own runs: noted with the line, handed over when it arrives");
var q = new ChatOwnColorQueue();
var runs = new[] { new ChatSpan(0, 15, 0xFFE6B450), new ChatSpan(15, 5, 0xFFFFFFFF) };
q.Expect(ItemLine + "\n", 0x12, null, runs, 1000);
Check(q.Count == 1, "runs alone are noted");
Check(q.Take(ItemLine, 0x12, 1100, out ChatSpan[]? got) == null && got == runs, "no whole-line colour; the runs come back");
q.Expect(ItemLine, 0x12, Orange, runs, 2000);
Check(q.Take(ItemLine, 0x12, 2100, out got) == Orange && got == runs, "both together");
q.Expect(ItemLine, 0x12, null, null, 3000);
Check(q.Count == 0, "neither: nothing noted");
q.Expect(ItemLine, 0x12, Orange, 4000);
Check(q.Take(ItemLine, 0x12, 4100, out got) == Orange && got == null, "nextcolor alone: no runs (as before)");
Check(ChatOwnColors.ArrivedSpans(runs, ItemLine + "\r\n", ItemLine) == runs, "arrived as written: the runs as they are");
Check(ChatOwnColors.ArrivedSpans(runs, "<Tell:IIDString:1:Bob>Bob<\\Tell> " + ItemLine, "Bob " + ItemLine) == null,
"AC's tell links taken out of it: the offsets don't hold, none");
Check(ChatOwnColors.ArrivedSpans(null, ItemLine, ItemLine) == null, "none written: none");
string cut = ItemLine[..18];
Check(ChatOwnColors.ArrivedSpans(runs, cut, cut) is [{ Start: 0, Length: 15 }, { Start: 15, Length: 3 }],
"a line cut short: the runs inside it, the last one cut");
Check(ChatOwnColors.ArrivedSpans(runs, ItemLine[..10], ItemLine[..10]) is [{ Start: 0, Length: 10 }], "runs past the cut are dropped");
}
private static void OwnSpansOverRules()
{
Case("own runs: drawn under the rules' colours");
var own = new[] { new ChatSpan(0, 10, 0xFF111111), new ChatSpan(10, 10, 0xFF222222), new ChatSpan(25, 5, 0xFF333333) };
Check(ChatOwnColors.EffectiveSpans(null, null, false) == null, "none: none");
Check(ChatOwnColors.EffectiveSpans(own, null, false) == own, "no rule: the plugin's runs");
var rule = new[] { new ChatSpan(5, 8, 0xFFAAAAAA) };
Check(ChatOwnColors.EffectiveSpans(null, rule, false) == rule, "no runs of its own: the rule's, as before");
Check(ChatOwnColors.EffectiveSpans(own, rule, true) == rule, "a rule's line colour wins over the runs (its match colours stay)");
Check(ChatOwnColors.EffectiveSpans(own, null, true) == null, "...and with no match colours the line is the rule's colour");
ChatSpan[] eff = ChatOwnColors.EffectiveSpans(own, rule, false)!;
Check(eff is [{ Start: 0, Length: 5, Argb: 0xFF111111 }, { Start: 5, Length: 8, Argb: 0xFFAAAAAA }, { Start: 13, Length: 7, Argb: 0xFF222222 },
{ Start: 25, Length: 5, Argb: 0xFF333333 }],
"a rule's match colour over the runs it overlaps, the runs cut around it");
var inside = new[] { new ChatSpan(26, 2, 0xFFBBBBBB) };
Check(ChatOwnColors.EffectiveSpans(own, inside, false) is [_, _, { Start: 25, Length: 1 }, { Start: 26, Length: 2, Argb: 0xFFBBBBBB }, { Start: 28, Length: 2 }],
"a match inside a run splits it");
for (int i = 1; i < eff.Length; i++)
Check(eff[i].Start >= eff[i - 1].Start + eff[i - 1].Length, "sorted, not overlapping");
}
private static void LineColorJson()
{
Case("line colours: lineColors in rynthchat_settings.json");

View file

@ -75,8 +75,8 @@ namespace CombatSettingsTests
string tabName = (string)t.GetType().GetProperty("Name")!.GetValue(t)!;
tabs[tabName] = ((IEnumerable)t.GetType().GetProperty("Rows")!.GetValue(t)!).Cast<object>().ToList();
}
Check(tabs.ContainsKey("Melee Combat") && tabs.ContainsKey("Spell Combat"), "the Melee Combat and Spell Combat tabs exist");
if (!tabs.ContainsKey("Melee Combat") || !tabs.ContainsKey("Spell Combat")) return Finish();
Check(tabs.ContainsKey("Combat") && tabs.ContainsKey("Spell Combat"), "the Combat and Spell Combat tabs exist (Combat was Melee Combat until 2026-11-11)");
if (!tabs.ContainsKey("Combat") || !tabs.ContainsKey("Spell Combat")) return Finish();
static string Label(object r) => (string?)r.GetType().GetProperty("Label")!.GetValue(r) ?? "";
static string Kind(object r) => r.GetType().GetProperty("Kind")!.GetValue(r)!.ToString()!;
@ -88,17 +88,17 @@ namespace CombatSettingsTests
// (tab, label, kind, default shown, min, max)
var rows = new (string Tab, string Label, string Kind, double Default, double Min, double Max)[]
{
("Melee Combat", "Variable Min %", "Int", 50, 0, 100),
("Melee Combat", "Variable Max %", "Int", 100, 0, 100),
("Melee Combat", "Missile Response", "Combo", 0, 0, 3),
("Melee Combat", "Hits to trip", "Int", 2, 1, 10),
("Melee Combat", "Window (s)", "Int", 20, 5, 120),
("Melee Combat", "Move closer by (m)", "Int", 6, 1, 30),
("Melee Combat", "Closest (m)", "Int", 3, 1, 30),
("Melee Combat", "Skip target (s)", "Int", 30, 5, 300),
("Melee Combat", "Pull Distance (m)", "Int", 20, 3, 100),
("Melee Combat", "Tag Before Fleeing", "Bool", 1, 0, 1),
("Spell Combat", "Magic Response", "Combo", 0, 0, 3),
("Combat", "Variable Min %", "Int", 50, 0, 100),
("Combat", "Variable Max %", "Int", 100, 0, 100),
("Combat", "Missile Response", "Combo", 0, 0, 3),
("Combat", "Hits to trip", "Int", 2, 1, 10),
("Combat", "Window (s)", "Int", 20, 5, 120),
("Combat", "Move closer by (m)", "Int", 6, 1, 30),
("Combat", "Closest (m)", "Int", 3, 1, 30),
("Combat", "Skip target (s)", "Int", 30, 5, 300),
("Combat", "Pull Distance (m)", "Int", 20, 3, 100),
("Combat", "Tag Before Fleeing", "Bool", 1, 0, 1),
("Combat", "Magic Response", "Combo", 0, 0, 3), // beside Missile Response since 2026-11-11
};
object older = Parse("{\"BoostNavPriority\":true}"); // what an older RynthAi sends
object newer = Parse("{\"VariablePowerMin\":50,\"VariablePowerMax\":100,\"MissileEnvironmentResponse\":0,\"MagicEnvironmentResponse\":0," +
@ -119,32 +119,34 @@ namespace CombatSettingsTests
// Section headers and spacers of these groups follow the same gate (no empty headers on an older RynthAi).
foreach (string sec in new[] { "Variable Power (monster rules)", "Hitting the Environment", "Pull Away (Kite)" })
foreach (string tab in new[] { "Melee Combat", "Spell Combat" })
foreach (string tab in new[] { "Combat" })
{
object? header = Row(tab, sec, "Section");
if (header == null) continue;
Check(!Visible(header, older), $"{tab} / {sec}: the header is hidden for an older RynthAi");
Check(Visible(header, newer), $"{tab} / {sec}: the header shows for a newer one");
}
Check(Row("Melee Combat", "Pull Away (Kite)", "Section") != null && Row("Melee Combat", "Hitting the Environment", "Section") != null
&& Row("Melee Combat", "Variable Power (monster rules)", "Section") != null && Row("Spell Combat", "Hitting the Environment", "Section") != null, "all four section headers exist");
Check(Row("Combat", "Pull Away (Kite)", "Section") != null && Row("Combat", "Hitting the Environment", "Section") != null
&& Row("Combat", "Variable Power (monster rules)", "Section") != null, "all three section headers exist");
Check(Row("Spell Combat", "Hitting the Environment", "Section") == null && Row("Spell Combat", "Magic Response", "Combo") == null,
"Spell Combat no longer has its own Hitting the Environment (Magic Response is on Combat, with the rest)");
// The combos list RynthAi's EnvironmentResponse in its order.
object missile = Row("Melee Combat", "Missile Response", "Combo")!;
object missile = Row("Combat", "Missile Response", "Combo")!;
var items = (string[])missile.GetType().GetProperty("Items")!.GetValue(missile)!;
Check(items.SequenceEqual(new[] { "Off", "Move closer", "New target", "Move closer, then new target" }), "Missile Response: Off, Move closer, New target, Move closer then new target (RynthAi's order)");
// A row edits only its own property; the rest rides along.
object edit = Parse("{\"BoostNavPriority\":true," + sent.TrimStart('{'));
Set(Row("Melee Combat", "Pull Distance (m)", "Int")!, edit, 55);
Set(Row("Melee Combat", "Tag Before Fleeing", "Bool")!, edit, 1);
Set(Row("Spell Combat", "Magic Response", "Combo")!, edit, 1);
Set(Row("Combat", "Pull Distance (m)", "Int")!, edit, 55);
Set(Row("Combat", "Tag Before Fleeing", "Bool")!, edit, 1);
Set(Row("Combat", "Magic Response", "Combo")!, edit, 1);
string after = JsonSerializer.Serialize(edit, info);
Check(after.Contains("\"KitePullMeters\":55") && after.Contains("\"KiteTagFirst\":true") && after.Contains("\"MagicEnvironmentResponse\":1"), "the edits land on their own properties");
Check(after.Contains("\"BoostNavPriority\":true") && after.Contains("\"EnvironmentSkipSec\":60") && after.Contains("\"MissileEnvironmentResponse\":2"), "the other settings ride along unchanged");
// The rows an older RynthAi lacks don't change what a plain save sends.
Set(Row("Melee Combat", "Pull Distance (m)", "Int")!, older, 30); // can't happen in the UI (hidden); must not throw
Set(Row("Combat", "Pull Distance (m)", "Int")!, older, 30); // can't happen in the UI (hidden); must not throw
Check(true, "setting a hidden row doesn't throw");
// ── The monster rule: Power and Kite ────────────────────────────────────────

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the engine's answers to the server's yes/no prompts (plugin API v85, v97):
src\RynthCore.Engine\Compatibility\ConfirmationArmPolicy.cs, compiled in. The one-shot arm
(v85: Yes at the minimum, else No, then spent) must behave as before; the leave-below arm
(v97, minPercent | 0x100) answers Yes at the minimum, leaves a prompt below it to the client
and stays armed until it times out or is disarmed. Also the "N percent" parse.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>ConfirmationResponderTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\ConfirmationArmPolicy.cs" Link="Engine\ConfirmationArmPolicy.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,273 @@
using System.Text;
using RynthCore.Engine.Compatibility;
using P = RynthCore.Engine.Compatibility.ConfirmationArmPolicy;
using V = RynthCore.Engine.Compatibility.ConfirmationArmPolicy.Verdict;
namespace ConfirmationResponderTests;
/// <summary>
/// What the armed answers do with the server's yes/no prompts (ConfirmationArmPolicy.cs, the pure
/// half of ConfirmationResponder): the v85 one-shot arm, unchanged, and the v97 sticky arm
/// (minPercent | 0x100), which answers Yes at its minimum, leaves a prompt below it to the client's
/// own dialog, stays armed, and never fights a one-shot. CraftInteraction is type 5.
/// </summary>
internal static class Program
{
private const uint Craft = 5, YesNo = 7;
private const int Flag = P.ArmFlagLeaveBelow;
private static int _checks, _failed;
private static string _case = "";
/// <summary>The responder's two slots, driven the way ConfirmationResponder drives them.</summary>
private sealed class Slots
{
public ConfirmationArm OneShot, Sticky;
public bool Available = true;
public int Arm(uint type, int minArg, int timeoutMs, long now)
=> P.Apply(ref OneShot, ref Sticky, type, minArg, timeoutMs, now, Available);
public V Request(uint type, int percent, long now)
=> P.Decide(ref OneShot, ref Sticky, type, percent, now);
}
private static int Main()
{
Run(nameof(ArgumentsAreChecked), ArgumentsAreChecked);
Run(nameof(OneShotUnchanged), OneShotUnchanged);
Run(nameof(StickyYesAtTheMinimum), StickyYesAtTheMinimum);
Run(nameof(StickyBelowIsLeftAndStaysArmed), StickyBelowIsLeftAndStaysArmed);
Run(nameof(StickyExpiresAndReArms), StickyExpiresAndReArms);
Run(nameof(OtherTypesAreLeft), OtherTypesAreLeft);
Run(nameof(OneShotGoesFirstAndNeverFights), OneShotGoesFirstAndNeverFights);
Run(nameof(DisarmPicksTheSlot), DisarmPicksTheSlot);
Run(nameof(Unavailable), Unavailable);
Run(nameof(PercentParse), PercentParse);
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
return _failed == 0 ? 0 : 1;
}
private static void Run(string name, Action body)
{
_case = name;
try { body(); }
catch (Exception ex) { _checks++; _failed++; Console.WriteLine($"[FAIL] {name}: threw {ex.GetType().Name}: {ex.Message}"); }
}
private static void Check(bool ok, string what)
{
_checks++;
if (ok) return;
_failed++;
Console.WriteLine($"[FAIL] {_case}: {what}");
}
private static void Eq<T>(T actual, T expected, string what) =>
Check(EqualityComparer<T>.Default.Equals(actual, expected), $"{what}: expected {expected}, got {actual}");
private static void ArgumentsAreChecked()
{
var s = new Slots();
// v85's rules, as before.
Eq(s.Arm(0, 50, 1000, 0), P.ArmBadArgs, "type 0");
Eq(s.Arm(Craft, -1, 1000, 0), P.ArmBadArgs, "minimum -1");
Eq(s.Arm(Craft, 101, 1000, 0), P.ArmBadArgs, "minimum 101");
Eq(s.Arm(Craft, 50, 120_001, 0), P.ArmBadArgs, "timeout over 120 s");
Check(!s.OneShot.Armed && !s.Sticky.Armed, "bad arguments arm nothing");
Eq(s.Arm(Craft, 0, 1000, 0), P.ArmOk, "one-shot, minimum 0");
Eq(s.Arm(Craft, 100, 120_000, 0), P.ArmOk, "one-shot 100 for 120 s");
Check(s.OneShot.Armed && s.OneShot.MinPercent == 100 && !s.Sticky.Armed, "a one-shot goes in the one-shot slot");
// v97's flag.
Eq(Flag, 0x100, "the flag's value (ABI)");
s = new Slots();
Eq(s.Arm(Craft, 100 | Flag, 60_000, 0), P.ArmOk, "sticky 100");
Check(s.Sticky.Armed && s.Sticky.MinPercent == 100 && !s.OneShot.Armed, "a sticky arm goes in the sticky slot, minimum 100");
Eq(s.Arm(Craft, 1 | Flag, 60_000, 0), P.ArmOk, "sticky 1");
Eq(s.Arm(Craft, 0 | Flag, 60_000, 0), P.ArmBadArgs, "sticky with no minimum (would say Yes to everything)");
Eq(s.Arm(Craft, 101 | Flag, 60_000, 0), P.ArmBadArgs, "sticky 101");
Eq(s.Arm(Craft, 100 | Flag, 120_001, 0), P.ArmBadArgs, "sticky: the same 120 s cap");
Eq(s.Arm(Craft, 100 | 0x200, 60_000, 0), P.ArmBadArgs, "an unknown flag bit");
Eq(s.Arm(Craft, 100 | 0x300, 60_000, 0), P.ArmBadArgs, "the flag with an unknown bit");
Eq(s.Arm(Craft, int.MinValue | 100, 60_000, 0), P.ArmBadArgs, "the sign bit");
Eq(s.Sticky.MinPercent, 1, "a refused call leaves the arm before it (sticky 1)");
// What an engine before v97 does with the flag: its check was minPercent > 100 -> -3.
Check((100 | Flag) > 100 && (1 | Flag) > 100, "the flag makes minPercent > 100, which a v85-v96 engine refuses as bad arguments");
}
private static void OneShotUnchanged()
{
long t = 1_000;
var s = new Slots();
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(Craft, 90, t + 10), V.Accept, "90% with a minimum of 80: Yes");
Check(!s.OneShot.Armed, "spent after one answer");
Eq(s.Request(Craft, 100, t + 20), V.LeaveToClient, "the next prompt is the client's");
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(Craft, 38, t + 10), V.Decline, "38% with a minimum of 80: No (as v85 always did)");
Check(!s.OneShot.Armed, "spent after a No too");
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(Craft, -1, t + 10), V.Decline, "no percent with a minimum: No");
s.Arm(Craft, 0, 15_000, t);
Eq(s.Request(Craft, -1, t + 10), V.Accept, "minimum 0: Yes even without a percent");
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(Craft, 100, t + 15_000), V.Accept, "at the timeout itself: still armed");
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(Craft, 100, t + 15_001), V.LeaveToClient, "past the timeout: the client's");
Check(!s.OneShot.Armed, "an expired arm is dropped");
s.Arm(Craft, 80, 15_000, t);
s.Arm(Craft, 50, 15_000, t + 1);
Eq(s.Request(Craft, 60, t + 2), V.Accept, "a new one-shot replaces the old (60% with 50: Yes)");
Eq(s.Arm(Craft, 0, 0, t + 3), P.ArmOk, "disarm: 1");
}
private static void StickyYesAtTheMinimum()
{
long t = 5_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
for (int i = 0; i < 5; i++)
{
Eq(s.Request(Craft, 100, t + 1_000 * (i + 1)), V.AcceptSticky, $"craft {i + 1} at 100%: Yes (sticky)");
Check(s.Sticky.Armed, $"still armed after craft {i + 1}");
}
s.Arm(Craft, 90 | Flag, 60_000, t);
Eq(s.Request(Craft, 90, t + 1), V.AcceptSticky, "90% with a minimum of 90: Yes");
Eq(s.Request(Craft, 95, t + 2), V.AcceptSticky, "95%: Yes");
Check(s.Sticky.Armed, "and still armed");
}
private static void StickyBelowIsLeftAndStaysArmed()
{
long t = 10_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
Eq(s.Request(Craft, 99, t + 1), V.LeaveToClient, "99% with a minimum of 100: the client's dialog, never No");
Check(s.Sticky.Armed, "still armed after a prompt it left");
Eq(s.Request(Craft, 0, t + 2), V.LeaveToClient, "0%: the client's");
Eq(s.Request(Craft, -1, t + 3), V.LeaveToClient, "no percent in the text: the client's");
Check(s.Sticky.Armed, "still armed");
Eq(s.Request(Craft, 100, t + 4), V.AcceptSticky, "then 100%: Yes");
Check(s.Sticky.Armed, "still armed after that");
for (int pct = -1; pct <= 100; pct++)
{
V v = s.Request(Craft, pct, t + 5);
Check(v != V.Decline, $"never No ({pct}%)");
Eq(v, pct == 100 ? V.AcceptSticky : V.LeaveToClient, $"{pct}% with a minimum of 100");
}
}
private static void StickyExpiresAndReArms()
{
long t = 20_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
Eq(s.Request(Craft, 100, t + 60_000), V.AcceptSticky, "at the timeout itself: Yes");
Eq(s.Request(Craft, 100, t + 60_001), V.LeaveToClient, "past it: the client's");
Check(!s.Sticky.Armed, "dropped");
Eq(s.Request(Craft, 100, t + 60_002), V.LeaveToClient, "and stays dropped");
// Re-arming before it runs out keeps it going (what RynthAi does).
s.Arm(Craft, 100 | Flag, 60_000, t);
s.Arm(Craft, 100 | Flag, 60_000, t + 30_000);
Eq(s.Request(Craft, 100, t + 75_000), V.AcceptSticky, "re-armed at +30 s: still Yes at +75 s");
// A new sticky arm replaces the old one (one sticky slot).
s.Arm(Craft, 90 | Flag, 60_000, t + 76_000);
Eq(s.Request(Craft, 92, t + 76_001), V.AcceptSticky, "re-armed at 90: 92% is Yes");
}
private static void OtherTypesAreLeft()
{
long t = 30_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
Eq(s.Request(YesNo, 100, t + 1), V.LeaveToClient, "another type: the client's");
Check(s.Sticky.Armed, "the craft arm is kept");
s.Arm(Craft, 80, 15_000, t);
Eq(s.Request(YesNo, 100, t + 1), V.LeaveToClient, "one-shot, another type: the client's");
Check(s.OneShot.Armed, "the one-shot is kept for its own type (as before)");
var none = new Slots();
Eq(none.Request(Craft, 100, t), V.LeaveToClient, "unarmed: the client's");
}
private static void OneShotGoesFirstAndNeverFights()
{
// A tinker run arms a one-shot per step (Yes at its own minimum, else No) and disarms it when a
// step fails to go out or the run stops; a sticky arm stands the whole time.
long t = 40_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
s.Arm(Craft, 70, 15_000, t + 1);
Check(s.Sticky.Armed && s.OneShot.Armed, "both armed");
Eq(s.Request(Craft, 60, t + 2), V.Decline, "the step's prompt: the one-shot's own rule (60% under 70 is No)");
Check(!s.OneShot.Armed, "the one-shot is spent");
Check(s.Sticky.Armed, "the sticky arm is untouched");
Eq(s.Request(Craft, 100, t + 3), V.AcceptSticky, "the next (hand-made) prompt: the sticky arm");
s.Arm(Craft, 0, 15_000, t + 4);
Eq(s.Request(Craft, 100, t + 5), V.Accept, "a one-shot's Yes is the one-shot's (not counted as the sticky arm's)");
// The sticky arm re-arming mid-step does not replace the step's one-shot.
s.Arm(Craft, 70, 15_000, t + 6);
s.Arm(Craft, 100 | Flag, 60_000, t + 7);
Check(s.OneShot.Armed && s.OneShot.MinPercent == 70, "a sticky re-arm leaves the one-shot as it was");
Eq(s.Request(Craft, 80, t + 8), V.Accept, "80% on the step: the one-shot's Yes");
// The run's disarm (timeout 0, no flag) leaves the sticky arm.
s.Arm(Craft, 70, 15_000, t + 9);
Eq(s.Arm(Craft, 0, 0, t + 10), P.ArmOk, "the run disarms its one-shot");
Check(!s.OneShot.Armed && s.Sticky.Armed, "only the one-shot is gone");
Eq(s.Request(Craft, 100, t + 11), V.AcceptSticky, "a 100% prompt after the run: the sticky arm");
Eq(s.Request(Craft, 50, t + 12), V.LeaveToClient, "a 50% prompt after the run: the client's");
// An expired one-shot falls through to the sticky arm.
s.Arm(Craft, 70, 15_000, t + 13);
Eq(s.Request(Craft, 100, t + 13 + 15_001), V.AcceptSticky, "past the one-shot's timeout: the sticky arm");
}
private static void DisarmPicksTheSlot()
{
long t = 50_000;
var s = new Slots();
s.Arm(Craft, 100 | Flag, 60_000, t);
s.Arm(Craft, 70, 15_000, t);
Eq(s.Arm(Craft, Flag, 0, t + 1), P.ArmOk, "sticky disarm (the flag, timeout 0)");
Check(!s.Sticky.Armed && s.OneShot.Armed, "only the sticky arm is gone");
Eq(s.Arm(Craft, 100 | Flag, -1, t + 2), P.ArmOk, "a negative timeout with the flag disarms too");
s.Arm(Craft, 100 | Flag, 60_000, t + 3);
Eq(s.Arm(Craft, 100 | Flag, 0, t + 4), P.ArmOk, "the flag with a minimum and timeout 0: disarm");
Check(!s.Sticky.Armed, "gone");
Eq(s.Request(Craft, 100, t + 5), V.Accept, "the one-shot is still there");
}
private static void Unavailable()
{
var s = new Slots { Available = false };
Eq(s.Arm(Craft, 100 | Flag, 60_000, 0), P.ArmUnavailable, "no sender or hook: 0");
Eq(s.Arm(Craft, 100, 15_000, 0), P.ArmUnavailable, "one-shot: 0");
Eq(s.Arm(Craft, 101 | Flag, 60_000, 0), P.ArmBadArgs, "bad arguments still -3 first");
Check(!s.OneShot.Armed && !s.Sticky.Armed, "nothing armed");
Eq(s.Arm(Craft, Flag, 0, 0), P.ArmOk, "a disarm still answers 1");
}
private static int Pct(string s) => P.ParsePercent(Encoding.Latin1.GetBytes(s));
private static void PercentParse()
{
Eq(Pct("You determine that you have a 38 percent chance to succeed."), 38, "38");
Eq(Pct("You determine that you have a 100 percent chance to succeed."), 100, "100");
Eq(Pct("You determine that you have a 0 percent chance to succeed."), 0, "0");
Eq(Pct("You determine that you have a 5 percent chance to succeed."), 5, "5");
Eq(Pct("Are you sure?"), -1, "no percent");
Eq(Pct(" percent at the start"), -1, "' percent' first");
Eq(Pct("a percent chance"), -1, "no digits");
Eq(Pct("1000 percent"), -1, "four digits");
Eq(Pct("999 percent"), 100, "over 100 reads as 100");
Eq(Pct(""), -1, "empty");
}
}

View file

@ -25,6 +25,8 @@
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelLayoutFiles.cs" Link="Engine\PanelLayoutFiles.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelStateStore.cs" Link="Engine\PanelStateStore.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\BarLayout.cs" Link="Engine\BarLayout.cs" />
<!-- Where a docked window draws versus its home (the saved spot): 2026-11-12, panels moving on reload/login. -->
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelPlacement.cs" Link="Engine\PanelPlacement.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\EngineSettingsFile.cs" Link="Engine\EngineSettingsFile.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\ChatCommandReplies.cs" Link="Engine\ChatCommandReplies.cs" />
<!-- ChatCommandReplies' /rc sense row names SenseLayout (the Sense views, feature/sense-compact). -->

View file

@ -66,6 +66,9 @@ namespace PanelLayoutTests
Run(HotReloadWithTheNameNotKnownYet);
Run(TheDefaultIsOnlyReadInUse);
Run(CommandReplies);
Run(PulledOnScreenNeverMovesTheSavedSpot);
Run(TheBarKeepsItsHome);
Run(HomeSurvivesAReloadThroughTheStore);
}
finally
{
@ -328,6 +331,152 @@ namespace PanelLayoutTests
NoTempFiles(root);
}
// ── where a docked window draws versus its home (UI/PanelPlacement, 2026-11-12) ──
//
// 2026-11-12, reported: "a few of the panels still move around on reload and login (shortcuts, our own
// toolbar)". The Shortcuts bar sits in the bottom-right corner (a fit-height plugin window: its
// height follows its content), the toolbar's size follows its icons, rows and text size. Before,
// a placement pulled onto a smaller screen, or for a taller first frame, was what the open saved
// (ImGuiPanelHost.Apply -> Persist(entry.Pos)) and what the bar's size step saved, and only a
// display change ever undid it. Numbers are the live layout's (1600x900 client).
private static readonly System.Numerics.Vector2 Full = new(1600, 900);
private static System.Numerics.Vector2 V(float x, float y) => new(x, y);
private static void PulledOnScreenNeverMovesTheSavedSpot()
{
Case("placement: a pull onto the screen is drawn, never the home");
Eq(HomePlace.OnScreen(V(1301, 811), V(299, 89), Full), V(1301, 811), "flush in the bottom-right corner fits as saved");
Eq(HomePlace.OnScreen(V(1301, 811), V(299, 120), Full), V(1301, 780), "taller than saved: pulled up by the difference");
Eq(HomePlace.OnScreen(V(1700, -5), V(100, 50), Full), V(1500, 0), "off the right and top: onto the screen");
Eq(HomePlace.OnScreen(V(1301, 811), V(299, 89), V(0, 0)), V(1301, 811), "the display not known yet: drawn at its home");
Eq(HomePlace.OnScreen(V(50, 50), V(2000, 1000), Full), V(0, 0), "bigger than the display: its top-left corner");
Check(HomePlace.Near(V(1319.6f, 811), V(1320, 811)) && !HomePlace.Near(V(1319, 811), V(1320, 811)), "Near is half a pixel");
Case("placement: login on a client smaller for a moment");
var p = new HomePlace();
p.Set(V(1301, 811), V(299, 89), V(800, 600));
Eq(p.Drawn, V(501, 511), "on 800x600 it draws inside the screen");
Check(p.Pulled, "...and knows it was pulled");
Eq(p.Home, V(1301, 811), "the home (what the open saves) is still the saved spot");
Check(p.Fit(V(299, 89), Full), "the client grows: drawn again");
Eq(p.Drawn, V(1301, 811), "back in the corner");
Check(!p.Pulled, "...not pulled any more");
Check(!p.Fit(V(299, 89), Full), "nothing changed: nothing to do");
Case("placement: a fit-height window, a taller then a shorter first frame");
p = new HomePlace();
p.Set(V(1301, 811), V(299, 89), Full);
Check(!p.Pulled, "saved flush in the corner at its height: as saved");
Check(p.Fit(V(299, 120), Full), "a taller frame (a key row, a bigger draw size) at the bottom edge");
Eq(p.Drawn, V(1301, 780), "pulled up while it is taller");
Eq(p.Home, V(1301, 811), "the home doesn't move");
Check(p.Fit(V(299, 50), Full), "one line tall ('Your shortcuts show once you're in the world.')");
Eq(p.Drawn, V(1301, 811), "back at its home");
p.Fit(V(299, 89), Full);
Eq(p.Drawn, V(1301, 811), "its real height: where the player left it");
Case("placement: the saved row's height is stale (fit heights aren't saved)");
p = new HomePlace();
p.Set(V(1301, 811), V(299, 120), Full); // the row says 120, the content is 89
Eq(p.Drawn, V(1301, 780), "the first frame at the saved 120 is pulled up");
p.Fit(V(299, 89), Full);
Eq(p.Drawn, V(1301, 811), "fitted to 89 a frame later: back in the corner");
Eq(p.Home, V(1301, 811), "the home was never the pulled spot");
Case("placement: the player's drag is the new home");
p.MoveTo(V(900, 700), V(299, 89), Full);
Eq(p.Home, V(900, 700), "dragged: that is the home");
Eq(p.Drawn, V(900, 700), "...and where it draws");
p.MoveTo(V(1301, 811), V(299, 89), Full);
p.Fit(V(299, 89), V(1280, 720));
Eq(p.Drawn, V(981, 631), "a smaller client later pulls it in");
Eq(p.Home, V(1301, 811), "...and keeps the player's spot");
Case("placement: the load line says where and why");
p = new HomePlace();
p.Set(V(1301, 811), V(299, 89), V(800, 600));
string line = p.Describe("Shortcuts", "its saved place");
Check(line.Contains("Shortcuts placed at (501,511) 299x89 from its saved place (1301,811)", StringComparison.Ordinal)
&& line.Contains("pulled onto the 800x600 display", StringComparison.Ordinal), $"a pulled placement: {line}");
p = new HomePlace();
p.Set(V(1301, 811), V(299, 89), Full);
line = p.Describe("Shortcuts", "its saved place");
Check(line.EndsWith("on the 1600x900 display: as saved.", StringComparison.Ordinal), $"as saved: {line}");
p = new HomePlace();
p.Set(V(148, 0), V(0, 0), V(0, 0));
line = p.Describe("the bar", "its saved bar row");
Check(line.StartsWith("the bar placed at (148,0) from its saved bar row (148,0)", StringComparison.Ordinal)
&& line.Contains("isn't known yet", StringComparison.Ordinal), $"no size, no display yet: {line}");
p = new HomePlace();
p.Set(V(1301, 811), V(299, 89), Full);
p.Fit(V(299, 120), Full);
line = p.DescribePull("Shortcuts");
Check(line.Contains("(1301,780)", StringComparison.Ordinal) && line.Contains("home (1301,811) at 299x120", StringComparison.Ordinal)
&& line.Contains("Not saved", StringComparison.Ordinal), $"the pull line: {line}");
Check(!new HomePlace().Fit(V(10, 10), Full), "a window never placed has nothing to fit");
}
private static void TheBarKeepsItsHome()
{
Case("the toolbar: icons that come in as plugins load near the right edge");
var bar = new HomePlace();
bar.Set(V(1450, 0), V(0, 0), Full); // the size isn't known before its first frame
Eq(bar.Drawn, V(1450, 0), "first frame at its bar row");
bar.Fit(V(120, 53), Full);
Eq(bar.Drawn, V(1450, 0), "the engine's icons fit");
Check(bar.Fit(V(260, 53), Full), "plugin windows add icons: wider than the room left");
Eq(bar.Drawn, V(1340, 0), "pulled left while it is that wide");
Eq(bar.Home, V(1450, 0), "the bar row's spot is kept (the old _sizeWatch saved the pull)");
bar.Fit(V(140, 79), Full);
Eq(bar.Drawn, V(1450, 0), "fewer icons a row (three rows): back where the player left it");
Case("the toolbar: a text size step and a smaller client");
bar.Fit(V(150, 400), V(1600, 300));
Eq(bar.Drawn, V(1450, 0), "taller than a short client: its top stays at 0");
bar.Fit(V(150, 60), V(1024, 768));
Eq(bar.Drawn, V(874, 0), "a narrower client: pulled in");
bar.Fit(V(150, 60), Full);
Eq(bar.Drawn, V(1450, 0), "the client back to full size: back home");
}
private static void HomeSurvivesAReloadThroughTheStore()
{
Case("placement through panel_state.txt: what an open saves, read back by the next load");
string root = NewDir("placement");
string file = Path.Combine(root, "layouts", "s", "a", "panel_state.txt");
Directory.CreateDirectory(Path.GetDirectoryName(file)!);
File.WriteAllText(file, "bar=1450,0\r\npanel.Shortcuts=open,1301,811,299,89,docked,0,0\r\n");
PanelStateStore.SwitchTo(file, flushCurrent: false);
// The load: a client 800x600 for a moment (or a first frame taller than saved).
Check(PanelStateStore.TryGetPanel("Shortcuts", out var saved), "the row is read");
var place = new HomePlace();
place.Set(V((float)saved.Left, (float)saved.Top), V((float)saved.Width, (float)saved.Height), V(800, 600));
Check(place.Pulled, "drawn pulled in");
// ImGuiPanelHost.Persist (the open's save) writes the home:
PanelStateStore.SetPanel("Shortcuts", new PanelStateStore.PanelEntry(true, place.Home.X, place.Home.Y, saved.Width, saved.Height));
Check(File.ReadAllText(file).Contains("panel.Shortcuts=open,1301,811,299,89", StringComparison.Ordinal), "the file keeps the corner");
Check(place.Drawn != place.Home, "(the drawn spot, which the open wrote before, is somewhere else)");
// The bar's pull isn't written at all; only a drag is.
var bar = new HomePlace();
var row = PanelStateStore.BarPosition!.Value;
bar.Set(V((float)row.Left, (float)row.Top), V(0, 0), Full);
bar.Fit(V(260, 53), Full);
Check(bar.Pulled, "the bar is pulled left");
// The next load (a hot reload): the same file, read again.
PanelStateStore.SwitchTo(file, flushCurrent: false);
Check(PanelStateStore.TryGetPanel("Shortcuts", out var again) && again.Left == 1301 && again.Top == 811, "reloaded: Shortcuts in the corner");
Eq(PanelStateStore.BarPosition, ((double)1450, (double)0), "reloaded: the bar where its row says");
var next = new HomePlace();
next.Set(V((float)again.Left, (float)again.Top), V((float)again.Width, (float)again.Height), Full);
Eq(next.Drawn, V(1301, 811), "and drawn there");
NoTempFiles(root);
}
// ── the session: when to switch, when panels may draw ───────────────
private static readonly LayoutOwner WhoA = PanelLayoutPolicy.Owner(ServerOne, CharA)!;

View file

@ -42,6 +42,8 @@
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PluginManifestGate.cs" Link="Engine\PluginManifestGate.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PluginPathDedupe.cs" Link="Engine\PluginPathDedupe.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PluginFilePrefetchList.cs" Link="Engine\PluginFilePrefetchList.cs" />
<!-- v97: the confirmation arm's flag and argument check (the SDK must use the engine's flag). -->
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\ConfirmationArmPolicy.cs" Link="Engine\ConfirmationArmPolicy.cs" />
</ItemGroup>
</Project>

View file

@ -63,6 +63,7 @@ internal static class Program
Run(nameof(WebPanelStructsMatch), WebPanelStructsMatch);
Run(nameof(WebPanelCodesMatch), WebPanelCodesMatch);
Run(nameof(HasWebPanel_FalseOnOldOrPartialTable), HasWebPanel_FalseOnOldOrPartialTable);
Run(nameof(ConfirmationLeaveBelow_SdkMatchesEngine), ConfirmationLeaveBelow_SdkMatchesEngine);
Run(nameof(ManifestAttributeDrivesRuntimeMinimum), ManifestAttributeDrivesRuntimeMinimum);
Run(nameof(DedupeSamePathTwice), DedupeSamePathTwice);
Run(nameof(DedupeCaseAndSlashes), DedupeCaseAndSlashes);
@ -690,6 +691,59 @@ internal static class Program
Eq(live.NavigateWebPanel(1, ""), (int)WebPanelResult.BadArgs, "navigate empty URL: BadArgs");
}
// v97: ArmConfirmation's leave-below flag (no table change). The SDK's flag is the engine's, the Has*
// needs Version >= 97 and both v85 slots, a bad minimum is refused before the engine is called, and an
// engine before v97 (v85's argument check) refuses the flag as bad arguments.
private static unsafe void ConfirmationLeaveBelow_SdkMatchesEngine()
{
Eq(RynthCoreHost.ConfirmationArmFlags.LeaveBelow, RynthCore.Engine.Compatibility.ConfirmationArmPolicy.ArmFlagLeaveBelow, "SDK flag = engine flag");
Eq(PluginContractVersion.ConfirmationLeaveBelow, 97u, "ConfirmationLeaveBelow is 97 (96 is reserved)");
Check(PluginContractVersion.ConfirmationLeaveBelow <= PluginContractVersion.Current, "ConfirmationLeaveBelow at or below current");
IntPtr x = (IntPtr)0xDEAD;
RynthCoreHost Host(uint version, IntPtr arm, IntPtr last)
=> new RynthCoreHost(new RynthCoreApiNative { Version = version, ArmConfirmationFn = arm, GetLastConfirmationFn = last });
Check(Host(96, x, x).HasConfirmationAnswers, "v96: one-shot answers");
Check(!Host(96, x, x).HasConfirmationLeaveBelow, "v96: no leave-below");
Check(!Host(97, IntPtr.Zero, x).HasConfirmationLeaveBelow, "v97, Arm slot zero: false");
Check(!Host(97, x, IntPtr.Zero).HasConfirmationLeaveBelow, "v97, GetLast slot zero: false");
Check(Host(97, x, x).HasConfirmationLeaveBelow, "v97, both slots: true");
// Refused before the (garbage) slot is called.
Eq(Host(97, x, x).ArmConfirmationLeaveBelow(5, 0, 60_000), -3, "minimum 0: bad arguments");
Eq(Host(97, x, x).ArmConfirmationLeaveBelow(5, 101, 60_000), -3, "minimum 101: bad arguments");
IntPtr oldArm = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int, int>)&OldEngineArm;
IntPtr newArm = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int, int>)&NewEngineArm;
_lastArmMin = 0;
Eq(Host(96, oldArm, x).ArmConfirmationLeaveBelow(5, 100, 60_000), -3, "an engine before v97 refuses the flag");
Eq(Host(97, newArm, x).ArmConfirmationLeaveBelow(5, 100, 60_000), 1, "a v97 engine arms it");
Eq(_lastArmMin, 100 | 0x100, "the minimum reaches the engine with the flag");
Eq(Host(97, newArm, x).ArmConfirmation(5, 100, 15_000), 1, "a one-shot arm on a v97 engine, as before");
Eq(RynthCoreHost.ConfirmationOutcome.AcceptedSticky, 5, "outcome 5: the sticky arm's Yes (ABI)");
// The sticky disarm: the flag with timeout 0 on a v97 engine; nothing on an older one (whose disarm
// would clear the one-shot arm instead; the garbage slot shows it is not called).
_lastArmMin = 0;
Eq(Host(97, newArm, x).DisarmConfirmationLeaveBelow(5), 1, "v97: sticky disarm");
Eq(_lastArmMin, 0x100, "sent as the flag alone");
Eq(Host(96, x, x).DisarmConfirmationLeaveBelow(5), 0, "v96: not called");
Eq(Host(97, x, x).ArmConfirmationLeaveBelow(5, 100, 0), -3, "a zero timeout is not a disarm here");
}
private static int _lastArmMin;
// ConfirmationResponder.Arm's checks before v97.
[System.Runtime.InteropServices.UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
private static int OldEngineArm(uint type, int minPercent, int timeoutMs)
=> timeoutMs <= 0 ? 1 : type == 0 || minPercent < 0 || minPercent > 100 || timeoutMs > 120_000 ? -3 : 1;
// v97: the engine's own check.
[System.Runtime.InteropServices.UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
private static int NewEngineArm(uint type, int minPercent, int timeoutMs)
{
_lastArmMin = minPercent;
return timeoutMs <= 0 ? 1 : RynthCore.Engine.Compatibility.ConfirmationArmPolicy.Validate(type, minPercent, timeoutMs, out _, out _);
}
// v79: the SDK's copies of the training structs must be the engine's, byte for byte.
private static void TrainingStructsMirror()
{

View file

@ -0,0 +1,301 @@
Display//Show Target Stamina / Mana
Display//RynthAi Dashboard Look
Display//Insert Key Releases the UI
Display//Borderless Windowed
Display/Window and HUD Layout/Remember Open Windows and Positions
Display/Window and HUD Layout/Panel Layout Per Character
Display/Window and HUD Layout/Layout for New Characters
Display/Window and HUD Layout/Reset This Character's Layout
Display/Window and HUD Layout/Remember Game Window Position
Display/Window and HUD Layout/Save Layout Now
Display/Colour Theme/Theme
Display/Colour Theme/Save colours as
Display/Colour Theme/Saved scheme
Display/Colour Theme/Accent
Display/Colour Theme/Highlight
Display/Colour Theme/Background
Display/Colour Theme/Title bars
Display/Colour Theme/Buttons
Display/Colour Theme/Borders
Display/Colour Theme/Text
Display/Colour Theme/Muted text
Display/Colour Theme/Reset Colours
Display/Text Size (in-game panels)/All Panels
Display/Text Size (in-game panels)/Toolbar
Display/Text Size (in-game panels)/Toolbar Rows
Display/Text Size (in-game panels)/Toolbar Icons Per Row
Display/Text Size (in-game panels)/Size Each Panel Separately
Display/Text Size (in-game panels)/RynthAi Dashboard
Display/Text Size (in-game panels)/Meta
Display/Text Size (in-game panels)/Damage
Display/Text Size (in-game panels)/Settings
Display/Text Size (in-game panels)/Monsters
Display/Text Size (in-game panels)/Nav
Display/Text Size (in-game panels)/Items
Display/Text Size (in-game panels)/Lua
Display/Text Size (in-game panels)/Radar
Display/Text Size (in-game panels)/Chat Filters
Display/Text Size (in-game panels)/RynthNav
Display/Text Size (in-game panels)/Vision
Display/Text Size (in-game panels)/Status
Display/Text Size (in-game panels)/Log
Display/Text Size (in-game panels)/Tracker
Display/Item Info/Describe Items When Selected
Display/Item Info/Item Info Options
UI/Radar/Hide retail radar
UI/Power Bar/Hide retail power bar
UI/Vitals/Hide retail vitals bar
UI/Vitals/Lock your vitals plate
UI/Vitals/Grey out what debuffs take
UI/Toolbar/Hide retail toolbar
UI/Toolbar/Shortcut bar
UI/Toolbar/Shortcut bar size
UI/Toolbar/Game panel buttons
UI/Toolbar/Game panel buttons size
UI/Toolbar/Selection
UI/Toolbar/Selection size
UI/Toolbar/Day/Night timer
UI/Toolbar/Day/Night timer size
UI/Toolbar/Shortcut bar 2
UI/Toolbar/Shortcut bar 2 size
UI/Toolbar/Shortcut bar 3
UI/Toolbar/Shortcut bar 3 size
UI/Toolbar/Shortcut bar 4
UI/Toolbar/Shortcut bar 4 size
Misc//Enable FPS Limit
Misc//Focused FPS
Misc//Background FPS
Misc//Video patch
Misc//Frame cap while patched
Misc//Close Client on Server Disconnect
Misc//Background Identify
Misc//Hold reloads while in the world
Misc//Give up holding after (min)
Misc//Auto Cram
Misc//Peace Mode When Idle
Misc//Weapons Back After Heals
Misc//Start Macro On Login
Misc//Patrol On Login
Misc//Resume Meta After Reload
Misc//Escape Acid and Lava
Misc//Yield to VTank
Misc//Enable Raycasting
Misc/Missile Arc Velocities (m/s)/Use Arcs for Missile LoS
Misc/Missile Arc Velocities (m/s)/Bow
Misc/Missile Arc Velocities (m/s)/Crossbow
Misc/Missile Arc Velocities (m/s)/Atlatl
Misc/Missile Arc Velocities (m/s)/Magic Arc
Misc/Missile Arc Velocities (m/s)/Arc Clearance (m)
Misc/Missile Arc Velocities (m/s)/LoS Debug Log
Misc/Monster Blacklist/Attempts Before Blacklist
Misc/Monster Blacklist/Blacklist Timeout (sec)
Misc/Monster Blacklist/No Progress Timeout (sec)
Misc/Give Queue/Give Interval (ms)
Recharge/In Combat — target within Monster Range (%)/Heal At
Recharge/In Combat — target within Monster Range (%)/Re-stam At
Recharge/In Combat — target within Monster Range (%)/Re-stam To
Recharge/In Combat — target within Monster Range (%)/Get Mana At
Recharge/Idle Top-Off — no targets in range (%)/Top HP
Recharge/Idle Top-Off — no targets in range (%)/Top Stam
Recharge/Idle Top-Off — no targets in range (%)/Top Mana
Recharge/Kits & Potions/Use Potions
Recharge/Kits & Potions/Use Buff Items
Recharge/Kits & Potions/Make Field Rations Below
Recharge/Kits & Potions/Use Kits In Magic Mode
Recharge/Kits & Potions/Peace Mode For Kits
Recharge/Kits & Potions/Emergency Heal At
Recharge/Kits & Potions/Stamina To Health At
Recharge/Kits & Potions/Stamina To Health Min Stamina
Recharge/Kits & Potions/Kit Min Success %
Recharge/Kits & Potions/Stamina Kit Min Success %
Recharge/Safety Stops/Stop Macro On Death
Recharge/Safety Stops/Stop Macro On No Components
Recharge/Safety Stops/Recall When Low On Components
Recharge/Safety Stops/Low Tapers At
Recharge/Safety Stops/Low Scarabs At
Recharge/Safety Stops/Stop Macro When Pack Full
Recharge/On Death/Recall On Death
Recharge/On Death/Recall Spell
Recharge/On Death/Recall Item
Recharge/Helper Settings (%) — NOT WIRED YET/Heal Others
Recharge/Helper Settings (%) — NOT WIRED YET/Re-stam Others
Recharge/Helper Settings (%) — NOT WIRED YET/Infuse Others
Melee Combat/Attack Power & Height/Use Recklessness
Melee Combat/Attack Power & Height/Melee Auto Power
Melee Combat/Attack Power & Height/Melee Power %
Melee Combat/Attack Power & Height/Melee Attack Height
Melee Combat/Attack Power & Height/Missile Auto Power
Melee Combat/Attack Power & Height/Missile Power %
Melee Combat/Attack Power & Height/Missile Attack Height
Melee Combat/Variable Power (monster rules)/Variable Min %
Melee Combat/Variable Power (monster rules)/Variable Max %
Melee Combat/Hitting the Environment/Missile Response
Melee Combat/Hitting the Environment/Hits to trip
Melee Combat/Hitting the Environment/Window (s)
Melee Combat/Hitting the Environment/Move closer by (m)
Melee Combat/Hitting the Environment/Closest (m)
Melee Combat/Hitting the Environment/Skip target (s)
Melee Combat/Pull Away (Kite)/Pull Distance (m)
Melee Combat/Pull Away (Kite)/Tag Before Fleeing
Melee Combat/Pull Away (Kite)/Use Native Attack
Melee Combat/Pull Away (Kite)/Summon Pets
Melee Combat/Pull Away (Kite)/Pet Min Monsters
Melee Combat/Pull Away (Kite)/Pet Range
Spell Combat/War/Void Casting Settings/Buff Spell Interval (ms)
Spell Combat/War/Void Casting Settings/Attack Spell Delay (ms)
Spell Combat/War/Void Casting Settings/Cast Dispel Self
Spell Combat/War/Void Casting Settings/Use Dispel Items
Spell Combat/War/Void Casting Settings/Auto Fellowship Management
Spell Combat/War/Void Casting Settings/Open fellowship on create
Spell Combat/War/Void Casting Settings/M. Charges When Off
Spell Combat/Ring Spell Override/Min Ring Targets
Spell Combat/Blast Spell Override/Blast Range (yd)
Spell Combat/Blast Spell Override/Min Blast Targets
Spell Combat/Wall Spell Override/Wall Range (yd)
Spell Combat/Wall Spell Override/Min Wall Targets
Spell Combat/Hitting the Environment/Magic Response
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 1
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 2
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 3
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 4
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 5
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 6
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 7
Spell Combat/Spell Difficulty (Min Buffed Skill)/Level 8
Ranges/Standard Ranges (Yards)/Monster Range
Ranges/Standard Ranges (Yards)/Ring Range
Ranges/Standard Ranges (Yards)/Approach Range
Ranges/Standard Ranges (Yards)/Disengage Range
Ranges/Combat Targeting/Targeting
Ranges/Combat Targeting/Target Lock
Ranges/Combat Targeting/Fight the monster I select
Ranges/Corpse Acquisition (Yards)/Corpse Max (yd)
Ranges/Corpse Acquisition (Yards)/Corpse Min (yd)
Navigation//Boost Nav Priority
Navigation//Nav point reach (yd)
Navigation/Infinite Leaftide/Vaulted Dungeons
Navigation/Nav Marker Display/Breadcrumbs
Navigation/Nav Marker Display/Route Overlay
Navigation/Nav Marker Display/Ring Thickness
Navigation/Nav Marker Display/Line Thickness
Navigation/Nav Marker Display/Height Offset
Navigation/Nav Marker Display/Slope Sink
Navigation/Nav Marker Display/Show Terrain Passability
Navigation/Nav Marker Display/Waypoint Labels
Navigation/Nav Marker Display/Guide Line
Navigation/Doors/Open Doors While Navigating
Navigation/Doors/Door Detection Range (yd)
Navigation/Doors/Only Doors On My Path
Navigation/Doors/Auto-Unlock Doors
Navigation/Getting Back On Route/Go To Closest Waypoint
Navigation/Dungeon Patrol/Coverage
Navigation/Dungeon Patrol/Sight Distance (yd)
Navigation/Dungeon Patrol/Skip Dead Ends Up To (cells)
Navigation/Dungeon Patrol/Avoid Lava/Acid Floors
Navigation/Dungeon Patrol/Distance From Walls (yd)
Navigation/Dungeon Patrol/Walk Into Rooms From (yd)
Navigation/Outdoor Hunt/Hunt Range (yd)
Navigation/Outdoor Hunt/Hunt Radius (yd)
Navigation/Outdoor Hunt/Go for
Navigation/Steering/Stop & Turn Angle
Navigation/Steering/Resume Run Angle
Navigation/Steering/Dead Zone
Navigation/Steering/Sweep Detect Mult
Navigation/Steering/Lookahead (yd)
Navigation/Steering/Turn Rate (deg/s)
Navigation/Steering/Post-Portal Delay (s)
Navigation/Tier 2 Tuning/Speed
Navigation/Tier 2 Tuning/Walk Within (yd)
Navigation/Tier 2 Tuning/Stop Distance (yd)
Navigation/Tier 2 Tuning/Reissue Timeout (ms)
Navigation/Tier 2 Tuning/Max Range (yd)
Navigation/Tier 2 Tuning/Max Landblock Dist
Buffing//Enable Buffing
Buffing//Buff Profiles
Buffing//Rebuff When Idle
Buffing//Rebuff With (seconds left)
Buffing//Also Refresh Under (seconds left)
Buffing//Cast buffs even when an item gives them
Buffing//Buffs Left Out
Buffing/Protections (untick to skip)/Armor
Buffing/Protections (untick to skip)/Fire Protection
Buffing/Protections (untick to skip)/Cold Protection
Buffing/Protections (untick to skip)/Acid Protection
Buffing/Protections (untick to skip)/Lightning Protection
Buffing/Protections (untick to skip)/Blade Protection
Buffing/Protections (untick to skip)/Piercing Protection
Buffing/Protections (untick to skip)/Bludgeoning Protection
Buffing/Banes (untick to skip)/Impenetrability
Buffing/Banes (untick to skip)/Flame Bane
Buffing/Banes (untick to skip)/Frost Bane
Buffing/Banes (untick to skip)/Acid Bane
Buffing/Banes (untick to skip)/Lightning Bane
Buffing/Banes (untick to skip)/Blade Bane
Buffing/Banes (untick to skip)/Piercing Bane
Buffing/Banes (untick to skip)/Bludgeoning Bane
Buffing/Buff Difficulty (Min Buffed Skill)/Level 1
Buffing/Buff Difficulty (Min Buffed Skill)/Level 2
Buffing/Buff Difficulty (Min Buffed Skill)/Level 3
Buffing/Buff Difficulty (Min Buffed Skill)/Level 4
Buffing/Buff Difficulty (Min Buffed Skill)/Level 5
Buffing/Buff Difficulty (Min Buffed Skill)/Level 6
Buffing/Buff Difficulty (Min Buffed Skill)/Level 7
Buffing/Buff Difficulty (Min Buffed Skill)/Level 8
Crafting/Missile Ammo Crafting/Enable Missile Crafting
Looting//Enable Looting
Looting//Boost Loot Priority
Looting//Loot Only Rare Corpses
Looting//Learn Unknown Spells
Looting//Pickup with macro off
Looting//Leave the chest open
Looting//Stop Looting When Pack Full
Looting//Jump When Looting
Looting//Jump Height
Looting//Loot Items On Ground
Looting/Corpse Ownership/Loot From
Looting/Corpse Ownership/Recover My Corpse
Looting/Corpse Ownership/Travel Back To My Corpse
Looting/Corpse Ownership/Where Is My Corpse
Looting/Corpse Ownership/Go To My Corpse
Looting/Corpse Ownership/Stop Going To My Corpse
Looting/Inventory Management/Enable Autostack
Looting/Inventory Management/Enable Autocram
Looting/Inventory Management/Unbox Aetheria When Idle
Looting/Inventory Management/Unbox Aetheria Now
Looting/Inventory Management/Combine Salvage Bags
Looting/Inventory Management/Combine Bags During Salvage
Looting/Inventory Management/Tidy Packs Now
Looting/Inventory Management/Floating HUDs
Looting/Inventory Management/Salvage Without The Panel
Looting/Loot Timers (ms)/Optimized defaults
Looting/Loot Timers (ms)/Inter-Item Delay
Looting/Loot Timers (ms)/Content Settle
Looting/Loot Timers (ms)/Empty Corpse Wait
Looting/Loot Timers (ms)/Closing Delay
Looting/Loot Timers (ms)/Assess Window
Looting/Loot Timers (ms)/Loot Retry Timeout
Looting/Loot Timers (ms)/Corpse Open Retry
Looting/Loot Timers (ms)/Corpse Timeout
Looting/Salvage Timers (ms) - First / Fast/Open (First)
Looting/Salvage Timers (ms) - First / Fast/Open (Fast)
Looting/Salvage Timers (ms) - First / Fast/Add Item (First)
Looting/Salvage Timers (ms) - First / Fast/Add Item (Fast)
Looting/Salvage Timers (ms) - First / Fast/Salvage Click
Looting/Salvage Timers (ms) - First / Fast/Result (First)
Looting/Salvage Timers (ms) - First / Fast/Result (Fast)
Vendoring/AutoVendor/Enabled
Vendoring/AutoVendor/Test Mode (only print what it would do)
Vendoring/AutoVendor/Buy
Vendoring/AutoVendor/Sell
Vendoring/AutoVendor/Only Sell From Main Pack
Vendoring/AutoVendor/Show Merchant Info
Vendoring/AutoVendor/Think When Finished
Vendoring//ub vendor open/Tries
Vendoring//ub vendor open/Time Between Tries (ms)
Diagnostics/Logging & Debugging/Debug to chat
Diagnostics/Logging & Debugging/Daily RynthAi log file
Diagnostics/Logging & Debugging/Log Folder
Diagnostics/Logging & Debugging/Old Log Files
Diagnostics/UI Frame Cost/Time the UI frame's parts
Diagnostics/UI Frame Cost/Slow frame (ms)
Diagnostics/UI Frame Cost/Breakdown

View file

@ -0,0 +1,265 @@
using System.Collections;
using System.Reflection;
namespace SettingsLayoutTests
{
// Reaches RynthCore.Engine's internal settings schema and QuickSettings by reflection. See the csproj.
internal static class Program
{
private static int _fails, _asserts;
private static void Check(bool cond, string msg)
{
_asserts++;
if (!cond) { _fails++; Console.WriteLine($" [FAIL] {msg}"); }
}
private const BindingFlags All = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
private static Assembly _engine = null!;
private static Type _schema = null!, _quick = null!;
private static IList Tabs => (IList)_schema.GetField("Tabs", All)!.GetValue(null)!;
private static string Name(object tab) => (string)tab.GetType().GetProperty("Name")!.GetValue(tab)!;
private static IList Rows(object tab) => (IList)tab.GetType().GetProperty("Rows")!.GetValue(tab)!;
private static string Label(object row) => (string?)row.GetType().GetProperty("Label")!.GetValue(row) ?? "";
private static string Kind(object row) => row.GetType().GetProperty("Kind")!.GetValue(row)!.ToString()!;
private static string? KeyOf(object row) => (string?)_quick.GetMethod("KeyOf", All)!.Invoke(null, new[] { row });
private static object? RowOf(string key) => _quick.GetMethod("RowOf", All)!.Invoke(null, new object[] { key });
private static IEnumerable<string> AllKeys()
{
foreach (object tab in Tabs)
foreach (object row in Rows(tab))
if (KeyOf(row) is { } key) yield return key;
}
private static int Main(string[] args)
{
_engine = Assembly.Load("RynthCore.Engine");
_schema = _engine.GetType("RynthCore.Engine.UI.Data.SettingsSchema", throwOnError: true)!;
_quick = _engine.GetType("RynthCore.Engine.UI.QuickSettings", throwOnError: true)!;
// -dump <file>: every pin key of this build's layout, one per line (how OldPinKeys.txt was made).
if (args.Length == 2 && args[0] == "-dump")
{
File.WriteAllLines(args[1], AllKeys());
Console.WriteLine($"wrote {AllKeys().Count()} keys to {args[1]}");
return 0;
}
TabList();
OldPins();
OldTabNames();
Moves();
HuntAndDirtyFighting();
return Finish();
}
// ── Hunt On Login and the Dirty Fighting rotation (rows added 2026-11-11, after the regroup) ──────
private static void HuntAndDirtyFighting()
{
Type settings = _engine.GetType("RynthCore.Engine.UI.Data.RynthAiSettings", throwOnError: true)!;
Type ctxType = _engine.GetType("RynthCore.Engine.UI.Data.RynthAiSettingsJsonContext", throwOnError: true)!;
object ctx = ctxType.GetProperty("Default", All)!.GetValue(null)!;
var info = (System.Text.Json.Serialization.Metadata.JsonTypeInfo)ctxType.GetProperty("RynthAiSettings", All)!.GetValue(ctx)!;
object Parse(string json) => System.Text.Json.JsonSerializer.Deserialize(json, info)!;
object? P(object s, string name) => settings.GetProperty(name, All)!.GetValue(s);
object? Row(string tab, string label)
{
foreach (object t in Tabs)
if (Name(t) == tab)
foreach (object r in Rows(t))
if (Label(r).Trim() == label) return r;
return null;
}
bool Visible(object row, object s) => (bool)row.GetType().GetMethod("IsVisible")!.Invoke(row, new[] { s })!;
double Get(object row, object s) => (double)((Delegate)row.GetType().GetProperty("Get")!.GetValue(row)!).DynamicInvoke(s)!;
void Set(object row, object s, double v) => ((Delegate)row.GetType().GetProperty("Set")!.GetValue(row)!).DynamicInvoke(s, v);
object? hunt = Row("General", "Hunt On Login"), patrol = Row("General", "Patrol On Login");
object? rot = Row("Combat", "Dirty Fighting rotation"), order = Row("Combat", "Effect order"), then = Row("Combat", "Then attack");
Check(hunt != null && patrol != null, "General has Patrol On Login and Hunt On Login");
Check(rot != null && order != null && then != null, "Combat has the Dirty Fighting rotation, its order and its Then attack");
if (hunt == null || patrol == null || rot == null || order == null || then == null) return;
Check(KeyOf(hunt) == "General/Starting Up/Hunt On Login", $"Hunt On Login sits under Starting Up (got {KeyOf(hunt)})");
Check(KeyOf(rot) == "Combat/Attack Power & Height/Dirty Fighting rotation", $"the rotation sits under Attack Power & Height (got {KeyOf(rot)})");
// A RynthAi that doesn't send them: the rows hide, and nothing is claimed.
object older = Parse("{\"PatrolOnLogin\":true}");
Check(!Visible(hunt, older) && !Visible(rot, older) && !Visible(order, older) && !Visible(then, older), "hidden for a RynthAi that doesn't send them");
Check(P(older, "HuntOnLogin") == null && P(older, "DfHeightRotation") == null, "...and their values stay null (a save leaves them alone)");
// One or the other, as RynthAi keeps them.
object s1 = Parse("{\"PatrolOnLogin\":true,\"HuntOnLogin\":false}");
Check(Visible(hunt, s1) && Get(hunt, s1) == 0, "Hunt On Login shows once RynthAi sends it");
Set(hunt, s1, 1);
Check((bool?)P(s1, "HuntOnLogin") == true && (bool)P(s1, "PatrolOnLogin")! == false, "ticking Hunt On Login clears Patrol On Login");
Set(patrol, s1, 1);
Check((bool)P(s1, "PatrolOnLogin")! && (bool?)P(s1, "HuntOnLogin") == false, "ticking Patrol On Login clears Hunt On Login");
Set(patrol, s1, 0);
Check(!(bool)P(s1, "PatrolOnLogin")! && (bool?)P(s1, "HuntOnLogin") == false, "unticking one leaves the other as it was");
object s2 = Parse("{\"PatrolOnLogin\":false}");
Set(patrol, s2, 1);
Check(P(s2, "HuntOnLogin") == null, "Patrol On Login with a RynthAi that has no Hunt On Login sends no Hunt On Login");
// The rotation: its two choices show while it's on; RynthAi's values both ways.
object d = Parse("{\"DfHeightRotation\":false,\"DfHeightOrder\":\"HML\",\"DfDefaultHeight\":-1}");
Check(Visible(rot, d) && !Visible(order, d) && !Visible(then, d), "the rotation shows; its order and Then attack only while it's on");
Set(rot, d, 1);
Check((bool?)P(d, "DfHeightRotation") == true && Visible(order, d) && Visible(then, d), "on: the order and Then attack show");
Check(Get(order, d) == 0 && Get(then, d) == 0, "HML is the first order; -1 is 'Attack Height setting'");
Set(order, d, 5);
Set(then, d, 3);
Check((string?)P(d, "DfHeightOrder") == "LMH" && (int?)P(d, "DfDefaultHeight") == 2, "the last order is LMH; High is 2");
object d2 = Parse("{\"DfHeightRotation\":true,\"DfHeightOrder\":\"mlh\",\"DfDefaultHeight\":0}");
Check(Get(order, d2) == 3 && Get(then, d2) == 1, "RynthAi's MLH (any case) and Low (0) read back as theirs");
var items = (string[])order.GetType().GetProperty("Items")!.GetValue(order)!;
Check(items.Length == 6 && items[0] == "High, Medium, Low" && items[5] == "Low, Medium, High", "the order choices read as RynthAi's window shows them");
}
// ── The tabs, in order, and the sidebar's groups ───────────────────────────────
private static void TabList()
{
string[] want =
{
"Interface", "Game Client", "Hotkeys",
"General", "Recharge", "Combat", "Spell Combat", "Ranges", "Navigation", "Buffing", "Looting", "Inventory", "Vendoring",
"Diagnostics",
};
string[] got = Tabs.Cast<object>().Select(Name).ToArray();
Check(got.SequenceEqual(want), $"the tabs, in order (got {string.Join(", ", got)})");
var groups = new List<string>();
foreach (object tab in Tabs)
if (tab.GetType().GetProperty("Group")!.GetValue(tab) is string g) groups.Add(Name(tab) + "=" + g);
Check(groups.SequenceEqual(new[] { "Interface=RynthCore · this PC", "General=RynthAi · saved in the profile", "Diagnostics=Support" }),
$"the sidebar's three group headings sit over Interface, General and Diagnostics (got {string.Join("; ", groups)})");
// Every pinnable row has its own key (a duplicate would make two rows one pin).
var keys = AllKeys().ToList();
Check(keys.Count == keys.Distinct(StringComparer.OrdinalIgnoreCase).Count(),
"no two pinnable rows share a pin key: " + string.Join(", ", keys.GroupBy(k => k, StringComparer.OrdinalIgnoreCase).Where(g => g.Count() > 1).Select(g => g.Key)));
// No tab starts or ends on an empty heading, and no tab is empty.
foreach (object tab in Tabs)
{
IList rows = Rows(tab);
Check(rows.Count > 0, $"{Name(tab)} has rows");
if (rows.Count == 0) continue;
Check(Kind(rows[rows.Count - 1]!) is not ("Section" or "Spacer"), $"{Name(tab)} doesn't end on a heading or a spacer");
}
}
// ── Every pin of the old layout still finds its row ───────────────────────────
private static void OldPins()
{
string file = Path.Combine(AppContext.BaseDirectory, "OldPinKeys.txt");
Check(File.Exists(file), "OldPinKeys.txt is beside the test");
if (!File.Exists(file)) return;
string[] old = File.ReadAllLines(file).Where(l => l.Trim().Length > 0).ToArray();
Check(old.Length > 250, $"OldPinKeys.txt holds the old layout's keys ({old.Length})");
MethodInfo? migrate = _quick.GetMethod("MigrateKey", All);
Check(migrate != null, "QuickSettings.MigrateKey exists");
if (migrate == null) return;
string? Migrate(string k) => (string?)migrate.Invoke(null, new object[] { k });
// Rows taken out of the panel on purpose (their values stay in the payload).
var gone = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"Misc//Auto Cram", // the same switch as Inventory > Packs > Enable Autocram
"Recharge/Helper Settings (%) — NOT WIRED YET/Heal Others", // inert sliders: hidden until they do something
"Recharge/Helper Settings (%) — NOT WIRED YET/Re-stam Others",
"Recharge/Helper Settings (%) — NOT WIRED YET/Infuse Others",
};
int moved = 0;
foreach (string key in old)
{
string? now = Migrate(key);
if (gone.Contains(key))
{
// Auto Cram's pin goes to the one Autocram switch left; the inert sliders' pins go nowhere.
if (key == "Misc//Auto Cram") Check(now != null && RowOf(now) is { } r && Label(r) == "Enable Autocram", $"{key} -> Enable Autocram (got {now})");
else Check(now == null, $"{key}: its row is gone, so the pin leads nowhere (got {now})");
continue;
}
// Labels and sections can hold '/', so the old key must end with the row's whole label.
object? row = now == null ? null : RowOf(now);
Check(row != null && key.EndsWith("/" + Label(row).Trim(), StringComparison.Ordinal) && now!.EndsWith("/" + Label(row).Trim(), StringComparison.Ordinal),
$"{key} -> the row with the same label (got {now ?? "nothing"})");
if (now != null && !string.Equals(now, key, StringComparison.OrdinalIgnoreCase)) moved++;
}
Check(moved > 80, $"a good share of the old keys moved ({moved})");
// The owner's two pins (2026-11-11), by name.
Check(Migrate("Misc//Video patch") == "Game Client/Performance/Video patch", "Misc//Video patch -> Game Client/Performance/Video patch");
Check(Migrate("Spell Combat/Ring Spell Override/Min Ring Targets") == "Spell Combat/Ring Spell Override/Min Ring Targets", "a pin that didn't move stays as it is");
Check(Migrate("Nowhere/At All/Nothing") == null, "a key no layout ever had leads nowhere (kept in the file, not drawn)");
}
// ── /rc settings <old name> still opens the tab ───────────────────────────────
private static void OldTabNames()
{
MethodInfo? find = _schema.GetMethod("FindTab", All);
Check(find != null, "SettingsSchema.FindTab exists");
if (find == null) return;
string? Find(string n) => find.Invoke(null, new object[] { n }) is { } t ? Name(t) : null;
foreach (var (from, to) in new[]
{
("Display", "Interface"), ("ui", "Interface"), ("misc", "General"), ("Melee Combat", "Combat"), ("melee", "Combat"),
("Crafting", "Combat"), ("interface", "Interface"), ("game client", "Game Client"), ("inventory", "Inventory"),
("buffing", "Buffing"), ("Hotkeys", "Hotkeys"), ("Diagnostics", "Diagnostics"),
})
Check(Find(from) == to, $"'{from}' opens {to} (got {Find(from) ?? "nothing"})");
Check(Find("No Such Tab") == null, "an unknown name opens nothing");
}
// ── Where a few rows went (the ones other code finds by tab or label) ─────────
private static void Moves()
{
string? Where(string label)
{
foreach (object tab in Tabs)
foreach (object row in Rows(tab))
if (Label(row).Trim() == label && KeyOf(row) is { } k) return k;
return null;
}
foreach (var (label, key) in new[]
{
("Hide retail radar", "Interface/Hide The Game's Own/Hide retail radar"),
("Lock your vitals plate", "Interface/Your Vitals/Lock your vitals plate"),
("Borderless Windowed", "Game Client/Game Window/Borderless Windowed"),
("Insert Key Releases the UI", "Hotkeys//Insert Key Releases the UI"),
("Enable FPS Limit", "Game Client/Performance/Enable FPS Limit"),
("Close Client on Server Disconnect", "Game Client/Disconnects And Updates/Close Client on Server Disconnect"),
("Vaulted Dungeons", "General/Server Features/Vaulted Dungeons"),
("Auto Fellowship Management", "General/Fellowship/Auto Fellowship Management"),
("Stop Macro On Death", "General/Safety Stops/Stop Macro On Death"),
("Recall On Death", "General/On Death/Recall On Death"),
("Buff Spell Interval (ms)", "Buffing//Buff Spell Interval (ms)"),
("Use Buff Items", "Buffing//Use Buff Items"),
("Targeting", "Combat/Targeting/Targeting"),
("Attempts Before Blacklist", "Combat/Targeting/Attempts Before Blacklist"),
("Enable Raycasting", "Combat/Line Of Sight/Enable Raycasting"),
("Magic Response", "Combat/Hitting the Environment/Magic Response"),
("Enable Missile Crafting", "Combat/Missile Ammo Crafting/Enable Missile Crafting"),
("Enable Autostack", "Inventory/Packs/Enable Autostack"),
("Give Interval (ms)", "Inventory/Giving And Trading/Give Interval (ms)"),
("Describe Items When Selected", "Inventory/Item Info/Describe Items When Selected"),
("Monster Range", "Ranges/Standard Ranges (Yards)/Monster Range"),
("Corpse Max (yd)", "Ranges/Corpse Acquisition (Yards)/Corpse Max (yd)"),
("Coverage", "Navigation/Dungeon Patrol/Coverage"),
})
Check(Where(label) == key, $"{label} is at {key} (got {Where(label) ?? "nothing"})");
Check(Where("Auto Cram") == null, "the duplicate Auto Cram row is gone (Inventory > Packs > Enable Autocram stays)");
Check(Where("Heal Others") == null, "the inert Helper sliders are hidden");
}
private static int Finish()
{
Console.WriteLine(_fails == 0 ? $"PASS ({_asserts} checks)" : $"FAIL: {_fails} of {_asserts} checks");
return _fails == 0 ? 0 : 1;
}
}
}

View file

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the Settings panel's layout (2026-11-11 regroup: Display + UI became Interface, Misc
became General, Melee Combat became Combat, the Crafting tab folded into Combat, and Game Client and
Inventory were added). OldPinKeys.txt is every pin key ("Tab/Section/Label", UI/QuickSettings.cs) the
layout before the regroup had, dumped from that build with dotnet run -c Release -dump OldPinKeys.txt.
Each one must still lead to its row, so a player's My settings drawer keeps its pins, and the old tab
names must still open their tab (/rc settings misc).
The engine has no test seam for SettingsData.cs (it pulls in the whole ImGui layer), so this references
the built engine assembly and reaches the internal types by reflection. x86, like the engine: needs the
x86 .NET runtime (C:\Program Files (x86)\dotnet).
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<Platforms>x86</Platforms>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>SettingsLayoutTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\RynthCore.Engine\RynthCore.Engine.csproj" />
<None Include="OldPinKeys.txt" CopyToOutputDirectory="PreserveNewest" Condition="Exists('OldPinKeys.txt')" />
</ItemGroup>
</Project>

View file

@ -13,7 +13,7 @@ namespace RynthCore.Engine.UI
namespace TrackerSettingsTests
{
// Offline tests for the Tracker's settings file. See the csproj. TrackerSettings loads once per
// process, so the order matters: an old-style file first, then saves.
// process, so the order matters: an old-style file first, then saves; other files go through Parse.
internal static class Program
{
private static int _fails, _asserts;
@ -67,6 +67,83 @@ namespace TrackerSettingsTests
Check(!TrackerSettings.TextOnly, "Text only is off at once");
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
Check(!doc.RootElement.GetProperty("textOnly").GetBoolean(), "Text only off is saved");
// 2026-11-12: full click-through and hidden stats.
// The old file had neither: click-through off, every stat shown.
Check(!TrackerSettings.ClickThrough, "an old file (no clickThrough) leaves click-through off");
Check(TrackerSettings.HiddenIds.Length == 0, "an old file (no hidden) shows every stat");
foreach (TrackerStat s in TrackerSettings.Stats)
Check(!TrackerSettings.IsLabelHidden(s.Label), $"{s.Label} shown by default");
// Click-through on: saved with the rest.
TrackerSettings.SetTextOnly(true);
TrackerSettings.SetClickThrough(true);
Check(TrackerSettings.ClickThrough, "click-through is on at once");
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
{
Check(doc.RootElement.GetProperty("clickThrough").GetBoolean(), "click-through on is saved");
Check(doc.RootElement.GetProperty("textOnly").GetBoolean(), "saving click-through keeps Text only");
Check(doc.RootElement.GetProperty("bgAlpha").GetInt32() == 40, "saving click-through keeps the opacity");
}
// Hiding stats: by id, the version goes up, saved in the table's order, the rest kept.
int v0 = TrackerSettings.HiddenVersion;
TrackerSettings.SetHidden("deaths", true);
TrackerSettings.SetHidden("lum5m", true);
Check(TrackerSettings.HiddenVersion > v0, "hiding a stat bumps HiddenVersion");
Check(TrackerSettings.IsLabelHidden("Deaths") && TrackerSettings.IsLabelHidden("Lum/5m"), "hidden by their labels");
Check(!TrackerSettings.IsLabelHidden("XP"), "XP still shown");
int v1 = TrackerSettings.HiddenVersion;
TrackerSettings.SetHidden("deaths", true);
Check(TrackerSettings.HiddenVersion == v1, "hiding a hidden stat again changes nothing");
TrackerSettings.SetHidden("nonsense", true);
Check(TrackerSettings.HiddenVersion == v1 && !TrackerSettings.IsHidden("nonsense"), "an unknown id is not hidden");
Check(TrackerSettings.IsLabelHidden("Some new row") == false, "a label not in the table is shown");
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
{
var arr = doc.RootElement.GetProperty("hidden").EnumerateArray().Select(e => e.GetString()).ToArray();
Check(arr.SequenceEqual(new[] { "lum5m", "deaths" }), $"hidden saved in order (got [{string.Join(",", arr)}])");
Check(doc.RootElement.GetProperty("clickThrough").GetBoolean(), "saving hidden keeps click-through");
}
TrackerSettings.SetHidden("deaths", false);
Check(!TrackerSettings.IsLabelHidden("Deaths"), "a stat shown again");
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 1, "showing a stat is saved");
TrackerSettings.ShowAll();
Check(TrackerSettings.HiddenIds.Length == 0, "Show all clears the hidden set");
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 0, "Show all is saved");
TrackerSettings.SetClickThrough(false);
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
Check(!doc.RootElement.GetProperty("clickThrough").GetBoolean(), "click-through off is saved");
// The stat ids are unique and every TrackerSource label is in the table.
Check(TrackerSettings.Stats.Select(s => s.Id).Distinct().Count() == TrackerSettings.Stats.Length, "stat ids unique");
Check(TrackerSettings.Stats.Select(s => s.Label).Distinct().Count() == TrackerSettings.Stats.Length, "stat labels unique");
foreach (string label in new[] { "Session", "XP/hr", "Lum/hr", "Lum/5m", "Pass/hr", "Rad/hr", "Kls/hr", "XP", "Lum", "Pass-up", "Rad", "Kills", "XP/kl", "Deaths" })
Check(TrackerSettings.StatId(label) != label, $"{label} has a stat id");
// Parse: round trip of ToJson, old files, bad values.
var full = TrackerSettings.Parse(TrackerSettings.ToJson(77, true, true, new[] { "kills", "session", "rad" }));
Check(full.BgAlpha == 77 && full.TextOnly && full.ClickThrough, "Parse(ToJson) keeps opacity, Text only, click-through");
Check(full.Hidden.SequenceEqual(new[] { "session", "rad", "kills" }), "Parse(ToJson) keeps hidden, in table order");
var old = TrackerSettings.Parse("{\"bgAlpha\":100,\"textOnly\":true}");
Check(old.BgAlpha == 100 && old.TextOnly && !old.ClickThrough && old.Hidden.Length == 0, "an old file parses with the new defaults");
var empty = TrackerSettings.Parse("{}");
Check(empty.BgAlpha == 0xCC && !empty.TextOnly && !empty.ClickThrough && empty.Hidden.Length == 0, "an empty file is all defaults");
var bad = TrackerSettings.Parse("{\"bgAlpha\":\"x\",\"textOnly\":1,\"clickThrough\":\"yes\",\"hidden\":\"deaths\"}");
Check(bad.BgAlpha == 0xCC && !bad.TextOnly && !bad.ClickThrough && bad.Hidden.Length == 0, "values of the wrong kind are ignored");
var mixed = TrackerSettings.Parse("{\"bgAlpha\":999,\"clickThrough\":true,\"hidden\":[\"deaths\",5,null,\"bogus\",\"deaths\",\"xp\",{}]}");
Check(mixed.BgAlpha == 255, "an opacity over 255 is clamped");
Check(mixed.ClickThrough, "a good key beside bad ones is still read");
Check(mixed.Hidden.SequenceEqual(new[] { "xp", "deaths" }), $"only known string ids kept, once (got [{string.Join(",", mixed.Hidden)}])");
var notObject = TrackerSettings.Parse("[1,2]");
Check(notObject.BgAlpha == 0xCC && notObject.Hidden.Length == 0, "a file that is not an object is all defaults");
using (var doc = JsonDocument.Parse(TrackerSettings.ToJson(10, false)))
{
Check(!doc.RootElement.GetProperty("clickThrough").GetBoolean(), "ToJson defaults click-through off");
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 0, "ToJson defaults to nothing hidden");
}
}
catch (Exception ex)
{

View file

@ -3,7 +3,8 @@
<!--
Offline checks for the Tracker panel's settings file (src\RynthCore.Engine\UI\TrackerSettings.cs,
compiled in with a synchronous UiBackgroundWriter stub): the defaults with no file, an old file
without "textOnly", and that background opacity and Text only both survive a save. Uses
without "textOnly", and that background opacity, Text only, click-through and the hidden stats
all survive a save; bad values are ignored (TrackerSettings.Parse). Uses
RYNTHCORE_TRACKER_SETTINGS (a temp file); never touches %APPDATA%\RynthCore.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->

View file

@ -23,6 +23,9 @@ internal static class Program
CostsOnTheRealTable(t);
AffordableMatchesALinearScan(t);
RaiseChecks(t);
MaxAfterUntrainAndRetrain(t);
MaxAcrossTheSpecializedSwitch(t);
MaxNeverAsksPastTheTop(t);
}
TrainChecks();
ParserRefusesJunk();
@ -54,8 +57,7 @@ internal static class Program
if (raw == null) return null;
bool ok = TrainingCosts.TryParseXpTable(raw, out XpTableData t);
Check(ok, "XpTable parses");
Console.WriteLine($" ranks: attributes {t.AttributeXp.Length - 1}, vitals {t.VitalXp.Length - 1}, trained {t.TrainedXp.Length - 1}, specialized {t.SpecializedXp.Length - 1}, levels {t.LevelXp.Length - 1}");
return ok ? t : null;
Console.WriteLine($" ranks: attributes {t.AttributeXp.Length - 1}, vitals {t.VitalXp.Length - 1}, trained {t.TrainedXp.Length - 1}, specialized {t.SpecializedXp.Length - 1}, levels {t.LevelXp.Length - 1}"); return ok ? t : null;
}
private static void TableShape(XpTableData t)
@ -163,6 +165,154 @@ internal static class Program
Check(TrainingCosts.CheckRaise(a, 50, a[51], long.MaxValue, 1, 0, out _) == RaiseStatus.NotRaisable, "spent already covers the next rank (cost 0) -> NotRaisable, nothing sent");
}
// ── Max after untrain / train again, and across trained <-> specialized ──
//
// A model of ACE's own rules (Player_Skills.cs): UntrainSkill / UnspecializeSkill / ResetSkill
// refund ExperienceSpent and zero ranks and XP; TrainSkill (credits) starts at rank 0 with nothing
// spent; SpecializeSkill at the temple keeps the XP and re-ranks it on the specialized table
// (CalcSkillRank); HandleActionRaiseSkill / SpendSkillXp refuse, without a word, an amount over the
// unassigned XP or over ExperienceLeft (table[top] - spent, never below 0) and otherwise spend it all.
private sealed class AceSkill
{
public uint[]? Table; // null = untrained
public uint Ranks, Spent;
}
private static uint AceRank(uint[] table, uint spent)
{
for (int i = table.Length - 1; i >= 0; i--) if (spent >= table[i]) return (uint)i;
return 0;
}
private static bool AceRaise(AceSkill k, ref long unassigned, long amount)
{
if (k.Table == null || amount <= 0 || amount > uint.MaxValue || amount > unassigned) return false;
if (k.Ranks >= k.Table.Length - 1) return false; // IsMaxRank
long left = Math.Max(0L, (long)k.Table[^1] - k.Spent); // ExperienceLeft
if (amount > left) return false;
unassigned -= amount;
k.Spent += (uint)amount;
k.Ranks = AceRank(k.Table, k.Spent);
return true;
}
private static void AceUntrain(AceSkill k, ref long unassigned)
{
unassigned += k.Spent;
k.Table = null; k.Ranks = 0; k.Spent = 0;
}
/// <summary>The panel's Max on the numbers the client shows, sent to the model server. True when it was taken.</summary>
private static bool PanelMax(AceSkill k, ref long unassigned, out MaxRaisePlan plan)
{
plan = TrainingCosts.PlanMax(k.Table!, k.Ranks, k.Spent, unassigned);
return plan.Ranks > 0 && AceRaise(k, ref unassigned, plan.Cost);
}
private static void MaxAfterUntrainAndRetrain(XpTableData t)
{
Section("Max after untrain -> train again (ACE: XP refunded, back at rank 0 with nothing spent)");
uint[] tr = t.TrainedXp;
int top = tr.Length - 1;
// A maxed trained skill, untrained and trained again: the refund buys every rank back in one Max.
var k = new AceSkill { Table = tr, Ranks = (uint)top, Spent = tr[top] };
long xp = 50_000_000;
Check(TrainingCosts.IsMax(tr, k.Ranks) && TrainingCosts.PlanMax(tr, k.Ranks, k.Spent, xp) is { Ranks: 0, RanksLeft: 0, Missing: 0 },
"before: at the top, Max has nothing to buy");
AceUntrain(k, ref xp);
k.Table = tr; // trained again with credits
Check(k.Ranks == 0 && k.Spent == 0 && xp == 50_000_000 + tr[top], "untrain refunded the XP; trained again at rank 0, nothing spent");
bool sent = PanelMax(k, ref xp, out MaxRaisePlan p);
Check(p.ReachesTop && p.Ranks == top && p.Cost == tr[top] && p.Missing == 0,
$"Max from rank 0 offers all {top} ranks for {tr[top]:N0} XP (got +{p.Ranks}, {p.Cost:N0})");
Check(p.Cost <= uint.MaxValue, "rank 0 to the top fits one 32-bit raise");
Check(sent && k.Ranks == top && TrainingCosts.IsMax(tr, k.Ranks), "the server takes it: the skill is at the top again");
MaxRaisePlan after = TrainingCosts.PlanMax(tr, k.Ranks, k.Spent, xp);
Check(after.Ranks == 0 && after.RanksLeft == 0 && TrainingCosts.CostOf(tr, k.Ranks, k.Spent, 1) == -1,
"at the true top it still shows max (nothing left, +1 prices -1)");
// Partly raised (rank 150 and some way to 151), untrained, trained again: the refund alone buys rank 150 back and more.
uint part = tr[150] + (tr[151] - tr[150]) / 3;
k = new AceSkill { Table = tr, Ranks = 150, Spent = part };
xp = 0;
AceUntrain(k, ref xp);
k.Table = tr;
sent = PanelMax(k, ref xp, out p);
Check(sent && p.Ranks == 150 && k.Ranks == 150 && k.Spent == tr[150] && xp == part - tr[150],
$"refund only: Max buys the 150 ranks back exactly (+{p.Ranks}); the rest stays unassigned ({xp:N0})");
Check(!p.ReachesTop && p.Missing == tr[top] - (long)part && p.RanksLeft == top,
$"and says it stops short: {p.Missing:N0} more XP for the top");
// Specialized and maxed, untrained (temple: specialized -> trained -> untrained), trained again with
// credits: the trained top costs more than the specialized one, so the refund alone falls short.
uint[] sp = t.SpecializedXp;
k = new AceSkill { Table = sp, Ranks = (uint)(sp.Length - 1), Spent = sp[^1] };
xp = 0;
AceUntrain(k, ref xp);
k.Table = tr;
p = TrainingCosts.PlanMax(tr, 0, 0, xp);
Check(!p.ReachesTop && p.Ranks < top && p.Missing == (long)tr[top] - sp[^1],
$"specialized max refunded ({sp[^1]:N0}) and trained again: Max (+{p.Ranks} of {top}), {p.Missing:N0} XP short of the trained top");
sent = PanelMax(k, ref xp, out _);
Check(sent && k.Ranks == p.Ranks, "that partial Max is taken as offered");
xp += p.Missing;
sent = PanelMax(k, ref xp, out p);
Check(sent && p.ReachesTop && TrainingCosts.IsMax(tr, k.Ranks), "with the missing XP the next Max reaches the top");
}
private static void MaxAcrossTheSpecializedSwitch(XpTableData t)
{
Section("Max across trained <-> specialized (the table follows the skill's class)");
uint[] tr = t.TrainedXp, sp = t.SpecializedXp;
Check(TrainingCosts.TableFor(t, 3, 2) == tr && TrainingCosts.TableFor(t, 3, 3) == sp, "class 2 -> trained table, class 3 -> specialized");
// Temple specialize: the XP stays, the ranks are counted again on the specialized table.
uint spent = tr[150] + 12_345;
var k = new AceSkill { Table = sp, Ranks = AceRank(sp, spent), Spent = spent };
Check(k.Ranks > 150 && sp[k.Ranks] <= spent && (k.Ranks + 1 >= sp.Length || sp[k.Ranks + 1] > spent),
$"trained rank 150 specialized: rank {k.Ranks} on the specialized table, XP kept");
long xp = long.MaxValue / 4;
MaxRaisePlan p = TrainingCosts.PlanMax(sp, k.Ranks, k.Spent, xp);
Check(p.ReachesTop && p.Cost == sp[^1] - (long)spent, $"Max prices the rest on the specialized table ({p.Cost:N0} XP)");
Check(PanelMax(k, ref xp, out _) && TrainingCosts.IsMax(sp, k.Ranks), "the server takes it: specialized top");
// A trained skill raised past the specialized top, then specialized: already at the top (ACE's ExperienceLeft is 0).
spent = tr[^1];
k = new AceSkill { Table = sp, Ranks = AceRank(sp, spent), Spent = spent };
p = TrainingCosts.PlanMax(sp, k.Ranks, k.Spent, xp);
Check(TrainingCosts.IsMax(sp, k.Ranks) && p.Ranks == 0 && p.RanksLeft == 0, "trained XP over the specialized top: shows max, Max buys nothing");
// Unspecialize (refund, trained at rank 0): priced on the trained table from rank 0.
k = new AceSkill { Table = sp, Ranks = (uint)(sp.Length - 1), Spent = sp[^1] };
xp = tr[^1];
AceUntrain(k, ref xp);
k.Table = tr;
Check(PanelMax(k, ref xp, out p) && p.ReachesTop && p.Ranks == tr.Length - 1 && TrainingCosts.IsMax(tr, k.Ranks),
"unspecialized (XP refunded, trained at rank 0): Max from the trained table reaches the top");
}
private static void MaxNeverAsksPastTheTop(XpTableData t)
{
Section("Max never asks the server for more than it allows");
var rnd = new Random(1112);
bool allTaken = true, neverOver = true;
foreach (var (_, tab) in Tables(t))
for (int i = 0; i < 500; i++)
{
uint r = (uint)rnd.Next(0, tab.Length - 1);
uint spent = tab[r] + (uint)rnd.Next(0, (int)Math.Min(int.MaxValue, tab[r + 1] - tab[r]));
long xp = rnd.Next(3) switch { 0 => rnd.Next(), 1 => (long)rnd.Next() * 3, _ => long.MaxValue / 4 };
MaxRaisePlan p = TrainingCosts.PlanMax(tab, r, spent, xp);
if (p.Cost > Math.Max(0L, (long)tab[^1] - spent) || p.Cost > xp) neverOver = false;
var k = new AceSkill { Table = tab, Ranks = r, Spent = spent };
if (p.Ranks > 0 && !AceRaise(k, ref xp, p.Cost)) allTaken = false;
}
Check(neverOver, "2,000 states: Max's XP is within the unassigned XP and the XP left to the top");
Check(allTaken, "and the server model takes every one of them");
}
private static void TrainChecks()
{
Section("the checks before a train is sent (CheckTrain)");

View file

@ -47,8 +47,8 @@ namespace VaultedSettingTests
// The schema row.
object? nav = null;
foreach (object t in (IEnumerable)schemaType.GetField("Tabs", All)!.GetValue(null)!)
if ((string)t.GetType().GetProperty("Name")!.GetValue(t)! == "Navigation") nav = t;
Check(nav != null, "a Navigation tab");
if ((string)t.GetType().GetProperty("Name")!.GetValue(t)! == "General") nav = t;
Check(nav != null, "a General tab (the row moved there from Navigation on 2026-11-11)");
if (nav == null) return Finish();
string label = (string)schemaType.GetField("VaultedDungeonsLabel", All)!.GetValue(null)!;
@ -56,7 +56,7 @@ namespace VaultedSettingTests
var matches = new List<object>();
foreach (object r in (IEnumerable)nav.GetType().GetProperty("Rows")!.GetValue(nav)!)
if ((string?)r.GetType().GetProperty("Label")!.GetValue(r) == label) matches.Add(r);
Check(matches.Count == 1, "exactly one Vaulted Dungeons row, under Navigation");
Check(matches.Count == 1, "exactly one Vaulted Dungeons row, under General");
if (matches.Count != 1) return Finish();
object row = matches[0];

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the Settings > Navigation "Vaulted Dungeons" row (2026-10-18; the keeper is
Offline checks for the Settings > General "Vaulted Dungeons" row (2026-10-18, on Navigation until 2026-11-11; the keeper is
Silentkelpie's, RynthSuite PR 12): the mirror of RynthAi's EnableVaultedDungeons master switch in
UI\Data\SettingsData.cs. Nothing is claimed until RynthAi sends the value (an older RynthAi omits
it: the row stays hidden and a save sends null, which RynthAi leaves alone); the row edits only