RynthCore as of 2026-11-08 (internal 9297e93): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:45 -05:00
commit c68204f160
99 changed files with 5032 additions and 185 deletions

View file

@ -94,6 +94,8 @@ internal static class Program
("panels", "panels open 0x1F", "panels open"),
("panels", "panels toggle 12", "panels open twelve"),
("panels", "panels", "panels open 1 2"),
("title", "title 42", "title banana"),
("title", "title 7", "title"),
("rl", "rl", "rl now"),
("rl", "reload", "reload now"),
("inventory", "inv", "inv now"),

View file

@ -34,6 +34,8 @@
<Compile Include="..\..\src\RynthCore.Engine\UI\Panels\RynthChatPresets.cs" Link="Engine\RynthChatPresets.cs" />
<!-- 2026-10-19: re-reading the shared rynthchat_settings.json when another client saved it. -->
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\SharedFileWatch.cs" Link="Engine\SharedFileWatch.cs" />
<!-- 2026-11-05: a plugin's own colour for a line it writes (RynthAi's Info text colour). -->
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\ChatOwnColors.cs" Link="Engine\ChatOwnColors.cs" />
</ItemGroup>
</Project>

View file

@ -7,6 +7,8 @@ namespace RynthCore.Engine.Compatibility
{
public static int Lines;
public static void UI(string message) { Lines++; }
public static readonly System.Collections.Generic.List<string> InfoLines = new();
public static void Info(string message) { Lines++; InfoLines.Add(message); }
}
}

View file

@ -65,6 +65,10 @@ internal static class Program
HighlightBand();
HighlightJson();
HighlightOldReader();
OwnColorPrecedence();
OwnColorQueue();
OwnColorCommand();
SlowRulesNeedStrikes();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
@ -86,6 +90,47 @@ internal static class Program
Console.WriteLine($" FAIL [{_case}] {what}");
}
// The owner, 2026-11-07: "chat filter too slow and getting skipped all the time", with eight
// plain-text rules. The clock timed them, so a busy PC (several game clients) made any rule
// "too slow". Now rules that can run non-backtracking (linear time) have no timeout and are
// never skipped; the rest need SlowStrikesToSkip slow readings within the window.
private static void SlowRulesNeedStrikes()
{
Case("plain text and simple regex rules run linear and are never too slow; others need 3 strikes");
foreach (var (mode, pattern) in new[] { (ChatMatchMode.Regex, "In portal Space"), (ChatMatchMode.Regex, "You've earned"),
(ChatMatchMode.Contains, "Keep (really)"), (ChatMatchMode.Regex, "^You (evade|evaded) .*!$") })
{
var r = new ChatFilterRule { Pattern = pattern, Mode = mode };
r.Recompile();
Check(r.Compiled != null && r.Linear, $"'{pattern}' ({mode}) compiles linear");
Check(r.Compiled?.MatchTimeout == Regex.InfiniteMatchTimeout, $"'{pattern}': no match timeout to trip");
}
var plain = new ChatFilterRule { Pattern = "In portal Space", Tab = "Junk" };
plain.Recompile();
var router = new ChatRouter(new[] { plain }, null, "", countHits: false);
Check(router.Evaluate("In portal Space", "Chat", 0, null).InHome == false, "the linear rule still routes the line");
// A backreference needs backtracking: the timed compile, exactly as before.
var back = new ChatFilterRule { Pattern = @"^(\w)(a+)+\1$", Action = ChatRuleAction.Hide };
back.Recompile();
Check(back.Compiled != null && !back.Linear, "a backreference compiles with backtracking");
Check(back.Compiled?.MatchTimeout == TimeSpan.FromMilliseconds(ChatFilterRule.TimeoutMs), "...with the 15 ms timeout");
string evil = "b" + new string('a', 40) + "!"; // (a+)+ backtracks exponentially before failing
var r2 = new ChatRouter(new[] { back }, null, "", countHits: false);
int bumps = ChatModel.FilterBumps;
r2.Evaluate(evil, "Chat", 0, null);
Check(!back.Slow, "one timeout: a strike, still used");
r2.Evaluate(evil, "Chat", 0, null);
Check(!back.Slow, "two: still used");
Check(RynthCore.Engine.Compatibility.RynthLog.InfoLines.Any(l => l.Contains("2 of 3 before it is skipped")), "each strike is logged");
r2.Evaluate(evil, "Chat", 0, null);
Check(back.Slow, "three within the window: skipped until edited");
Check(ChatModel.FilterBumps == bumps + 1, "the kept lines are re-routed once, when it is skipped");
back.Recompile();
Check(!back.Slow && back.SlowStrikes == 0, "an edit (recompile) clears it and its strikes");
}
/// <summary>What a rule compiled to before match modes (ChatFilterRule.Recompile, 2026-09-29).</summary>
private static Regex? Before(string pattern, out string? error)
{
@ -435,6 +480,95 @@ internal static class Program
Check(!ChatLineColors.AnySet && ChatLineColors.Resolve(null, "fellowship", "Chat") == OldChannelArgb("Chat"), "reset all: as before");
}
// 2026-11-05: a plugin's own colour for a line (RynthAi's Info text colour, ChatOwnColors.cs):
// the line keeps its chat type and tab; only its colour changes.
private const string ItemLine = "[RynthAi Item] Blunt Crossbow (Pierce Crossbow), Gold, Craft 6";
private const uint Orange = 0xFFEE921E;
private static void OwnColorPrecedence()
{
Case("own colour: below a rule's, above kind, tab, retail and built-in");
ChatLineColors.ResetAll();
bool retail = ChatLineColors.RetailColors;
ChatLineColors.RetailColors = true;
const uint Rule = 0xFFABCDEF, Mine = 0xFF102030;
Check(ChatLineColors.ResolveLine(null, null, null, "Items", 0x12) == OldChannelArgb("Items"), "none: an Items line keeps its teal (as before)");
Check(ChatLineColors.ResolveLine(null, null, "tell", "Chat", 0x03) == ChatLineColors.Resolve(null, "tell", "Chat", 0x03), "none: exactly Resolve");
Check(ChatLineColors.ResolveLine(null, Orange, null, "Items", 0x01) == Orange, "own colour beats the Items tab's built-in");
Check(ChatLineColors.ResolveLine(null, Orange, null, "System", 0x05) == Orange, "and AC's own colour for the type");
ChatLineColors.Set("tab:Items", Mine);
ChatLineColors.Set("allegiance", Mine);
Check(ChatLineColors.ResolveLine(null, Orange, null, "Items", 0x01) == Orange, "and a tab colour the user set");
Check(ChatLineColors.ResolveLine(null, Orange, "allegiance", "Chat", 0x12) == Orange, "and a kind colour the user set");
Check(ChatLineColors.ResolveLine(Rule, Orange, null, "Items", 0x01) == Rule, "a rule's line colour still wins");
ChatLineColors.ResetAll();
ChatLineColors.RetailColors = retail;
}
private static void OwnColorQueue()
{
Case("own colour: matched by text and type, once, oldest first; refused and stale lines forgotten");
var q = new ChatOwnColorQueue();
Check(q.Take(ItemLine, 0x12, 0) == null, "nothing waiting: null");
q.Expect(ItemLine + "\r\n", 0x12, 0x00EE921E, 1000);
Check(q.Count == 1, "one waiting");
Check(q.Take(ItemLine, 0x01, 1100) == null, "another chat type: not it");
Check(q.Take(ItemLine + " more", 0x12, 1100) == null, "other text: not it");
Check(q.Take(ItemLine, 0x12, 1100) == Orange, "CR/LF trimmed like WriteToChat; made opaque");
Check(q.Take(ItemLine, 0x12, 1200) == null, "used up: the same text again is drawn as usual");
q.Expect(ItemLine, 0x12, 0xFF111111, 2000);
q.Expect(ItemLine, 0x12, 0xFF222222, 2001);
Check(q.Take(ItemLine, 0x12, 2100) == 0xFF111111 && q.Take(ItemLine, 0x12, 2100) == 0xFF222222, "two of the same line: in order");
q.Expect(ItemLine, 0x12, Orange, 3000);
q.Forget(ItemLine, 0x12);
Check(q.Count == 0 && q.Take(ItemLine, 0x12, 3100) == null, "a line WriteToChat refused colours nothing");
q.Expect(ItemLine, 0x12, Orange, 4000);
Check(q.Take(ItemLine, -1, 4100) == Orange, "a RynthChat without chat types (-1) matches by text");
q.Expect(ItemLine, 0x12, Orange, 5000);
Check(q.Take(ItemLine, 0x12, 5000 + ChatOwnColorQueue.LineTtlMs + 1) == null && q.Count == 0, "a line nobody picked up in time is forgotten");
for (int i = 0; i < ChatOwnColorQueue.MaxLines + 10; i++) q.Expect("line " + i, 0x01, Orange, 6000);
Check(q.Count == ChatOwnColorQueue.MaxLines, $"at most {ChatOwnColorQueue.MaxLines} wait");
Check(q.Take("line 0", 0x01, 6001) == null && q.Take("line 10", 0x01, 6001) == Orange, "the oldest went first");
var q2 = new ChatOwnColorQueue();
string longLine = new string('x', 1500);
q2.Expect(longLine, 0x01, Orange, 0);
Check(q2.Take(longLine[..ChatOwnColorQueue.MaxArrivingChars], 0x01, 1) == Orange, "a line AC cut at 1,024 characters matches by its start");
q2.Expect(ItemLine, 0x01, Orange, 0);
Check(q2.Take(ItemLine[..20], 0x01, 1) == null, "a short line never matches by its start");
var q3 = new ChatOwnColorQueue();
q3.Expect("\r\n", 0x01, Orange, 0);
q3.Expect("", 0x01, Orange, 0);
Check(q3.Count == 0, "an empty line is never noted");
}
private static void OwnColorCommand()
{
Case("own colour: SendPluginCommand(\"RynthCore.Chat\", \"nextcolor\", ...) arms the next WriteToChat");
Check(ChatOwnColors.CommandTarget == "RynthCore.Chat" && ChatOwnColors.NextColorAction == "nextcolor", "the names RynthAi sends");
Check(ChatOwnColors.TakeArmed(0) == null, "nothing armed: null");
Check(ChatOwnColors.HandlePluginCommand("nextcolor", "#EE921E", 100), "understood");
Check(ChatOwnColors.TakeArmed(150) == Orange, "the next WriteToChat takes it");
Check(ChatOwnColors.TakeArmed(160) == null, "only the next one");
Check(ChatOwnColors.HandlePluginCommand("NEXTCOLOR", " ee921e ", 200) && ChatOwnColors.TakeArmed(200) == Orange, "any case, no #, spaces");
Check(ChatOwnColors.HandlePluginCommand("nextcolor", "#EE921E", 300) && ChatOwnColors.TakeArmed(300 + ChatOwnColors.ArmWindowMs + 1) == null,
"armed too long ago: dropped");
Check(ChatOwnColors.HandlePluginCommand("nextcolor", "#EE921E", 400) && ChatOwnColors.HandlePluginCommand("nextcolor", "none", 401)
&& ChatOwnColors.TakeArmed(402) == null, "\"none\" disarms");
Check(!ChatOwnColors.HandlePluginCommand("nextcolor", "orange", 500) && ChatOwnColors.TakeArmed(500) == null, "a bad colour: refused, nothing armed");
Check(!ChatOwnColors.HandlePluginCommand("colour", "#EE921E", 600), "an unknown action: refused");
ChatOwnColors.HandlePluginCommand("nextcolor", "#EE921E", 700);
uint? other = null;
var t = new Thread(() => other = ChatOwnColors.TakeArmed(700));
t.Start(); t.Join();
Check(other == null && ChatOwnColors.TakeArmed(700) == Orange, "armed per thread: another plugin thread's line isn't coloured");
}
private static void LineColorJson()
{
Case("line colours: lineColors in rynthchat_settings.json");

View file

@ -8,6 +8,7 @@ namespace RynthCore.Engine.Compatibility
{
public static int Lines;
public static void UI(string message) { Lines++; }
public static void Info(string message) { Lines++; }
}
}

View file

@ -11,6 +11,9 @@
Also (2026-10-31) src\RynthCore.Engine\ImGui\MonsterHud\HealthProbe.cs: which unselected plate the HUD asks
the server's health for next (the server streams only the queried target), and which 0x01C0 replies are the
probe's (kept from plugins) versus the selection's / a plugin's.
And (2026-11-07) src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudData.cs: the server reading plugin API v93
GetMonsterHealth hands out (probe replies included, estimates never) and its age, read from other threads;
HudFeedStub.cs stands in for the combat text's feed.
All compiled in; no game, no engine.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
@ -26,6 +29,7 @@
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\CleaveHealth.cs" Link="Engine\CleaveHealth.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\HealthProbe.cs" Link="Engine\HealthProbe.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudData.cs" Link="Engine\MonsterHudData.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\ObjectFreshness.cs" Link="Engine\ObjectFreshness.cs" />
</ItemGroup>

View file

@ -0,0 +1,10 @@
// A stand-in for src\RynthCore.Engine\ImGui\MonsterHud\HudFeed.cs, the combat text's feed, so
// MonsterHudData.cs compiles here without the ImGui HUD. It only counts what it is told.
namespace RynthCore.Engine.ImGuiBackend.Hud;
internal static class HudFeed
{
public static int HealthCalls;
public static void OnHealth(uint id, float prev, float ratio, uint max) => HealthCalls++;
}

View file

@ -20,6 +20,9 @@ internal static class Program
Run("health probe: the stalest fight plate first, never-read plates nearest first", ProbeStalestAndNearest);
Run("health probe: nothing due (fresh, dead, no id) sends nothing", ProbeNothingDue);
Run("health probe: a probe's replies are the HUD's; the owner's and plugins' are theirs", ProbeReplies);
Run("plugin reading (v93): the server's last ratio and its age; never an estimate", PluginReadingServerOnly);
Run("plugin reading (v93): a probe reply is recorded for plugins to read, while it still isn't theirs as an event", PluginReadingProbeReply);
Run("plugin reading (v93): safe to read from another thread while the game thread records", PluginReadingThreads);
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
return _failed == 0 ? 0 : 1;
}
@ -209,4 +212,93 @@ internal static class Program
HealthProbe.Reset();
Check(!HealthProbe.IsProbeReply(0x114, 5100) && !HealthProbe.TryGetOwner(out _), "reset (logout) forgets everything");
}
// ── Plugin API v93 GetMonsterHealth (MonsterHudData.TryGetServerHealth) ──
private static long Ms(double ms) => (long)(ms * System.Diagnostics.Stopwatch.Frequency / 1000.0);
private static void PluginReadingServerOnly()
{
MonsterHudData.Clear();
long t0 = System.Diagnostics.Stopwatch.GetTimestamp();
Check(!MonsterHudData.TryGetServerHealth(0x40, t0, out float r, out uint age) && r == -1f && age == uint.MaxValue,
"never read: false, -1, max age");
Check(!MonsterHudData.TryGetServerHealth(0, t0, out _, out _), "id 0: false");
MonsterHudData.RecordHealth(0x40, 0.6f, 0, 0);
long recorded = System.Diagnostics.Stopwatch.GetTimestamp();
Check(MonsterHudData.TryGetServerHealth(0x40, recorded + Ms(2500), out r, out age) && Near(r, 0.6f),
$"the server's 60% (got {r:0.000})");
Check(age >= 2500 && age < 2600, $"2.5 s old (got {age} ms)");
// The plates' estimate from the player's own hit shows on the plate, not in the plugin reading.
MonsterHudData.RecordHealth(0x40, 0.3f, 0, 0, estimated: true);
Check(MonsterHudData.TryGetHealth(0x40, out HealthObservation h) && Near(h.Ratio, 0.3f) && h.Estimated, "the plate shows the estimate");
Check(MonsterHudData.TryGetServerHealth(0x40, recorded + Ms(3000), out r, out age) && Near(r, 0.6f) && age >= 3000,
$"the reading stays the server's 60% and keeps its age (got {r:0.000}, {age} ms)");
// An estimate on a plate the server never read: nothing for plugins.
MonsterHudData.RecordHealth(0x41, 0.8f, 0, 0, estimated: true);
Check(!MonsterHudData.TryGetServerHealth(0x41, recorded, out _, out _), "estimate only: false");
// The next server reading replaces it.
MonsterHudData.RecordHealth(0x41, 0.45f, 450, 1000);
Check(MonsterHudData.TryGetServerHealth(0x41, System.Diagnostics.Stopwatch.GetTimestamp(), out r, out age) && Near(r, 0.45f) && age < 100,
$"server 45%, fresh (got {r:0.000}, {age} ms)");
// A dead monster reads 0 (the plugin decides what that means for it).
MonsterHudData.RecordHealth(0x42, 0f, 0, 0);
Check(MonsterHudData.TryGetServerHealth(0x42, System.Diagnostics.Stopwatch.GetTimestamp(), out r, out _) && r == 0f, "dead: 0");
// A clock behind the reading never gives a negative or wrapped age; a very old one saturates.
Check(MonsterHudData.TryGetServerHealth(0x41, 0, out _, out age) && age == 0, $"now before the reading: 0 ms (got {age})");
Check(MonsterHudData.TryGetServerHealth(0x41, recorded + Ms(60.0 * 24 * 3600 * 1000), out _, out age) && age == uint.MaxValue,
$"60 days: saturates (got {age})");
MonsterHudData.Clear();
Check(!MonsterHudData.TryGetServerHealth(0x41, recorded, out _, out _), "logout clears it");
}
private static void PluginReadingProbeReply()
{
// PluginManager.QueueUpdateHealth records every 0x01C0 in MonsterHudData first, then drops a probe's
// reply from the plugins' UpdateHealth queue: the reading is there, the event is not.
MonsterHudData.Clear();
HealthProbe.Reset();
HealthProbe.NoteQuery(0x10); // the fight target owns the stream
HealthProbe.NoteProbe(0x20, 1000); // the plates probe a monster someone else is fighting
MonsterHudData.RecordHealth(0x20, 0.25f, 0, 0);
Check(HealthProbe.IsProbeReply(0x20, 1100), "the reply is the probe's (kept from plugins as an event)");
Check(MonsterHudData.TryGetServerHealth(0x20, System.Diagnostics.Stopwatch.GetTimestamp(), out float r, out _) && Near(r, 0.25f),
$"... and its 25% is readable by id (got {r:0.000})");
HealthProbe.Reset();
MonsterHudData.Clear();
}
private static void PluginReadingThreads()
{
MonsterHudData.Clear();
int bad = 0;
long reads = 0;
using var stop = new CancellationTokenSource();
var reader = Task.Run(() =>
{
while (!stop.IsCancellationRequested)
for (uint id = 1; id <= 64; id++)
{
if (MonsterHudData.TryGetServerHealth(id, out float r, out _) && (r < 0f || r > 1f || float.IsNaN(r)))
Interlocked.Increment(ref bad);
Interlocked.Increment(ref reads);
}
});
// The game thread's side, including a full table's wholesale clear (2048 entries).
for (int round = 0; round < 40; round++)
for (uint id = 1; id <= 2100; id++)
MonsterHudData.RecordHealth(id, (id % 100) / 100f, 0, 0, estimated: (id & 3) == 0);
stop.Cancel();
reader.Wait();
Check(bad == 0, $"every reading in range ({bad} bad)");
Check(Interlocked.Read(ref reads) > 0, "the reader ran");
MonsterHudData.Clear();
}
}

View file

@ -35,6 +35,9 @@ internal static class Program
Missing();
Words();
Percents();
XpPerKill();
CorpseTime();
ShieldTaken();
Console.WriteLine($"DamageRowStatsTests: {_checks} checks, {_failed} failed.");
return _failed == 0 ? 0 : 1;
}
@ -99,4 +102,113 @@ internal static class Program
Eq(DamageRowStats.Percent(9, 200), "4.5%", "one decimal below 10%");
Eq(DamageRowStats.Percent(7, 3), "100%", "clamped");
}
private static void XpPerKill()
{
// An older RynthAi sends no xp/xk: nothing new on the line or in the tip.
DamageRowStats old = Row(Full)!;
Eq((old.Xp, old.XpKills, old.XpPerKill), (0L, 0, 0L), "no xp/xk: 0");
Check(!old.Line().Contains("XP/kill"), "no xp/xk: no XP/kill on the line");
Check(!old.Tip().Contains("XP:"), "no xp/xk: no XP in the tip");
DamageRowStats s = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3}}")!;
Eq((s.Xp, s.XpKills, s.XpPerKill), (3703701L, 3, 1234567L), "xp and xk read");
Eq(s.Line(), "XP/kill 1,234,567 · It evades 23% (14/61)", "XP/kill leads the line, thousands");
Check(s.Tip().Contains("XP: 3,703,701 from 3 kills, 1,234,567 per kill."), "tip: XP " + s.Tip());
Eq(Row("{\"mstats\":{\"xp\":5,\"xk\":2}}")!.XpPerKill, 3L, "rounded (2.5 up)");
Eq(Row("{\"mstats\":{\"xp\":10,\"xk\":3}}")!.XpPerKill, 3L, "rounded (3.33 down)");
Eq(Row("{\"mstats\":{\"k\":1,\"xp\":900,\"xk\":1}}")!.Line(), "XP/kill 900", "a kill with XP alone: the line shows XP/kill");
Check(Row("{\"mstats\":{\"k\":1,\"xp\":900,\"xk\":1}}")!.Tip().Contains("from 1 kill,"), "one kill");
Eq(Row("{\"mstats\":{\"k\":2,\"xp\":900,\"xk\":0}}")!.Line(), "", "xk 0: no XP/kill");
Eq(Row("{\"mstats\":{\"k\":2,\"xp\":-50,\"xk\":-1}}")!.Line(), "", "negative xp/xk read as 0");
Check(Row("{\"mstats\":{\"xp\":0,\"xk\":0}}") == null, "xp/xk all zero: no line");
Eq(Row("{\"mstats\":{\"xp\":50000000000,\"xk\":2}}")!.Line(), "XP/kill 25,000,000,000", "XP past an int");
}
private static void CorpseTime()
{
// An older RynthAi sends no cd/cn: nothing new.
DamageRowStats old = Row(Full)!;
Eq((old.CorpseMs, old.CorpseKills), (0, 0), "no cd/cn: 0");
Check(!old.Line().Contains("Death animation"), "no cd/cn: no death animation on the line");
Check(!old.Tip().Contains("Corpse appears"), "no cd/cn: no corpse in the tip");
DamageRowStats s = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3,\"cd\":2140,\"cn\":3}}")!;
Eq((s.CorpseMs, s.CorpseKills), (2140, 3), "cd and cn read");
Eq(s.Line(), "XP/kill 1,234,567 · It evades 23% (14/61) · Death animation 2.1 s", "death animation last, after the rates");
Eq(Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"at\":120,\"yev\":50,\"ysp\":8,\"yrs\":1,\"k\":3,\"cd\":2140,\"cn\":3}}")!.Line(),
"It evades 23% (14/61) · You evade 42% (50/120) · You resist 13% (1/8) · Death animation 2.1 s", "far right, after You evade / You resist");
Check(s.Tip().Contains("Corpse appears 2.1 s after the kill (over 3 kills)."), "tip: corpse " + s.Tip());
Eq(Row("{\"mstats\":{\"k\":1,\"cd\":2140,\"cn\":1}}")!.Line(), "Death animation 2.1 s", "death animation alone (no XP sent)");
Check(Row("{\"mstats\":{\"k\":1,\"cd\":900,\"cn\":1}}")!.Tip().Contains("(over 1 kill)."), "one kill");
Check(Row("{\"mstats\":{\"cd\":1500,\"cn\":2}}") != null, "a timed corpse alone is something");
// Rounding to one decimal.
Eq(Row("{\"mstats\":{\"cd\":2150,\"cn\":1}}")!.CorpseSeconds, "2.2", "2.15 s rounds up");
Eq(Row("{\"mstats\":{\"cd\":2149,\"cn\":1}}")!.CorpseSeconds, "2.1", "2.149 s rounds down");
Eq(Row("{\"mstats\":{\"cd\":3000,\"cn\":1}}")!.CorpseSeconds, "3.0", "whole seconds keep the decimal");
Eq(Row("{\"mstats\":{\"cd\":40,\"cn\":1}}")!.CorpseSeconds, "0.0", "under 50 ms");
Eq(Row("{\"mstats\":{\"cd\":12345,\"cn\":1}}")!.Line(), "Death animation 12.3 s", "over ten seconds");
// Bad values.
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000,\"cn\":0}}")!.Line(), "", "cn 0: no corpse");
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000}}")!.Line(), "", "cd without cn: no corpse");
Eq(Row("{\"mstats\":{\"k\":2,\"cd\":2000,\"cn\":-4}}")!.Line(), "", "negative cn read as 0");
Eq(Row("{\"mstats\":{\"cd\":-500,\"cn\":2}}")!.Line(), "Death animation 0.0 s", "negative cd read as 0");
Eq(Row("{\"mstats\":{\"cd\":\"2000\",\"cn\":2}}")!.Line(), "Death animation 0.0 s", "text cd read as 0");
Eq(Row("{\"mstats\":{\"k\":1,\"cd\":2000,\"cn\":1.5}}")!.Line(), "", "fractional cn read as 0");
Check(Row("{\"mstats\":{\"cd\":0,\"cn\":0}}") == null, "cd/cn all zero: no line");
}
// RynthAi 2026-11-08: the hits it landed by shield and facing (learned across logins).
private const string Split =
"{\"mstats\":{\"hsf\":19,\"dsf\":209,\"msf\":11,\"hsb\":1,\"dsb\":274,\"msb\":274,\"hnf\":54,\"dnf\":2916,\"mnf\":80}}";
private static void ShieldTaken()
{
// An older RynthAi sends no cells: nothing new.
DamageRowStats old = Row(Full)!;
Check(!old.HasShieldTaken, "no cells: none");
Check(!old.Line().Contains("Hits taken"), "no cells: nothing on the line");
Check(!old.Tip().Contains("Shield up"), "no cells: nothing in the tip");
// Cells alone (nothing since login): a row of its own, the session's numbers left out.
DamageRowStats? s = Row(Split);
Check(s != null, "the cells alone are something");
if (s == null) return;
Check(!s.HasSession, "no session numbers");
Eq((s.ShieldCells[0].Hits, s.ShieldCells[0].Total, s.ShieldCells[0].Max), (19, 209L, 11L), "shield front read");
Eq(s.ShieldCells[1].Hits, 1, "shield behind read");
Eq(s.ShieldCells[2].Hits, 0, "a missing cell is 0");
Eq((s.ShieldHits(true), s.ShieldHits(false)), (20, 54), "hits each way");
Eq(Math.Round(s.ShieldAvg(true), 2), 24.15, "shield mean over every facing ((209 + 274) / 20)");
Eq(s.Line(), "Hits taken: shield 24 avg (front 95%), no shield 54 avg", "the line");
string tip = s.Tip();
Check(!tip.Contains("Since you logged in"), "no session block: " + tip);
Check(tip.Contains("Shield up: 20 hits, avg 24 - front 19 hits, avg 11, max 11; behind 1 hit, avg 274, max 274; facing unknown -."),
"tip: shield cells: " + tip);
Check(tip.Contains("No shield: 54 hits, avg 54 - front 54 hits, avg 54, max 80; behind -; facing unknown -."), "tip: no shield cells");
Check(tip.Contains("within 90 degrees of your facing"), "tip: ACE's rule");
// With the session's numbers: the cells after XP/kill, the death animation last.
DamageRowStats both = Row("{\"mstats\":{\"sw\":61,\"ev\":14,\"k\":3,\"xp\":3703701,\"xk\":3,\"cd\":2140,\"cn\":3,"
+ "\"hsf\":2,\"dsf\":20,\"msf\":12,\"hnb\":1,\"dnb\":60,\"mnb\":60}}")!;
Eq(both.Line(), "XP/kill 1,234,567 · Hits taken: shield 10 avg (front 100%), no shield 60 avg · It evades 23% (14/61) · Death animation 2.1 s",
"after XP/kill, before the rates; death animation last");
Check(both.Tip().StartsWith("Since you logged in") && both.Tip().Contains("\n\nDamage it did to you, learned across logins:"),
"tip: the session first, then the cells");
// One side only, and facing never measured.
Eq(Row("{\"mstats\":{\"hnf\":3,\"dnf\":150,\"mnf\":60}}")!.Line(), "Hits taken: no shield 50 avg", "no shield only");
Eq(Row("{\"mstats\":{\"hsu\":4,\"dsu\":40,\"msu\":12}}")!.Line(), "Hits taken: shield 10 avg (facing unknown)", "facing never measured");
Eq(Row("{\"mstats\":{\"hsf\":1,\"dsf\":5,\"hsu\":3,\"dsu\":15}}")!.Line(), "Hits taken: shield 5 avg (front 100%)",
"front share over the measured ones only");
// Bad values.
Check(Row("{\"mstats\":{\"hsf\":0,\"dsf\":50}}") == null, "damage without hits: nothing");
Check(Row("{\"mstats\":{\"hsf\":-3,\"dsf\":50}}") == null, "negative hits read as 0");
Eq(Row("{\"mstats\":{\"hsf\":2,\"dsf\":-50}}")!.Line(), "Hits taken: shield 0 avg (front 100%)", "negative damage read as 0");
Check(Row("{\"mstats\":{\"hsf\":1.5,\"dsf\":50}}") == null, "fractional hits read as 0");
}
}

View file

@ -25,6 +25,9 @@
report names the plugin call the pump is inside; PluginShutdownGate:
plugins are shut down only once the pump stopped (plus source scans
of EngineLifecycle's step order and ShutdownAll's gate)
NativeAttackRearm.cs the native attack clears a stuck attack-in-progress flag (after a stance
change, or 2 s with no swing) and only goes out in Melee/Missile (plus
a source scan of ClientCombatHooks / CombatModeHooks using it)
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
@ -56,6 +59,7 @@
<Compile Include="..\..\src\RynthCore.Engine\ImGui\FontPixels.cs" Link="Engine\FontPixels.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Net\IdRequester.cs" Link="Engine\IdRequester.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Plugins\PumpGuards.cs" Link="Engine\PumpGuards.cs" />
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\NativeAttackRearm.cs" Link="Engine\NativeAttackRearm.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,119 @@
using RynthCore.Engine.Compatibility;
namespace EngineRobustnessTests;
/// <summary>
/// The native attack's stuck attack-in-progress flag (Compatibility/NativeAttackRearm.cs), from
/// the 2026-11-06 wedge: a buff-wand swap mid-fight, then 37 minutes of native attacks the client
/// queued behind a flag no AttackDone would ever clear (the regular attack fought at once). Plus a
/// source scan that ClientCombatHooks and CombatModeHooks use the rule where it matters.
/// </summary>
internal static partial class Program
{
private static void RunNativeAttackRearmTests()
{
RearmAfterStanceChange();
RearmWhenStale();
RearmLeavesASwingAlone();
RearmWithoutTheAttackingFlag();
RearmModes();
RearmSourceScan();
}
private static void RearmAfterStanceChange()
{
_case = "native re-arm: after a stance change";
long since = 0;
// Back in Melee after the Staff: the flag set, no swing, the mode changed since the last native attack.
var v = NativeAttackRearm.Judge(inProgress: true, serverSwinging: false, stanceChangedSinceLastSend: true, 1000, ref since);
Check(v == NativeAttackRearm.Verdict.AfterStanceChange, $"cleared at the first native attack, got {v}");
Check(since == 0, "no stuck clock left running");
// The same with the flag clear: nothing to do.
v = NativeAttackRearm.Judge(false, false, true, 1000, ref since);
Check(v == NativeAttackRearm.Verdict.Leave, "flag clear: left alone");
}
private static void RearmWhenStale()
{
_case = "native re-arm: stale";
long since = 0;
var v = NativeAttackRearm.Judge(true, false, false, 10_000, ref since);
Check(v == NativeAttackRearm.Verdict.Leave && since == 10_000, "first sight: the clock starts, no clear (a request can be on its way)");
v = NativeAttackRearm.Judge(true, false, false, 10_000 + NativeAttackRearm.StuckMs - 1, ref since);
Check(v == NativeAttackRearm.Verdict.Leave, "under 2 s: still left");
v = NativeAttackRearm.Judge(true, false, false, 10_000 + NativeAttackRearm.StuckMs, ref since);
Check(v == NativeAttackRearm.Verdict.Stale, $"2 s with no swing: cleared, got {v}");
Check(since == 0, "the clock starts over");
// The answer comes in between: the clock resets.
since = 0;
NativeAttackRearm.Judge(true, false, false, 20_000, ref since);
NativeAttackRearm.Judge(false, false, false, 20_500, ref since); // AttackDone cleared it
Check(since == 0, "the flag cleared by the server: clock reset");
v = NativeAttackRearm.Judge(true, false, false, 22_100, ref since);
Check(v == NativeAttackRearm.Verdict.Leave, "set again later: a fresh 2 s");
}
private static void RearmLeavesASwingAlone()
{
_case = "native re-arm: a swing in progress";
long since = 0;
for (long t = 0; t <= 10_000; t += 500)
{
var v = NativeAttackRearm.Judge(true, serverSwinging: true, stanceChangedSinceLastSend: t == 0, t, ref since);
Check(v == NativeAttackRearm.Verdict.Leave, $"the server swinging (CommenceAttack, no AttackDone yet) at {t} ms: left alone");
}
Check(since == 0, "no stuck clock while it swings");
}
private static void RearmWithoutTheAttackingFlag()
{
_case = "native re-arm: attacking flag unknown";
long since = 0;
var v = NativeAttackRearm.Judge(true, serverSwinging: null, stanceChangedSinceLastSend: true, 0, ref since);
Check(v == NativeAttackRearm.Verdict.AfterStanceChange, "the stance rule still applies");
for (long t = 0; t <= 20_000; t += 1000)
{
v = NativeAttackRearm.Judge(true, null, false, t, ref since);
Check(v == NativeAttackRearm.Verdict.Leave, $"no stale clear at {t} ms: a swing can't be told from a stuck flag");
}
}
private static void RearmModes()
{
_case = "native re-arm: modes";
Check(NativeAttackRearm.AttackMode(2) && NativeAttackRearm.AttackMode(4), "Melee and Missile attack");
Check(!NativeAttackRearm.AttackMode(1) && !NativeAttackRearm.AttackMode(8), "Peace and Magic don't (the native attack is refused there)");
Check(NativeAttackRearm.DisarmFor(1) && NativeAttackRearm.DisarmFor(8), "Peace and Magic disarm a left-over attack");
Check(!NativeAttackRearm.DisarmFor(2) && !NativeAttackRearm.DisarmFor(4), "Melee and Missile keep it");
}
private static void RearmSourceScan()
{
_case = "native re-arm: source scan";
string? compat = FindRepoDir(Path.Combine("src", "RynthCore.Engine", "Compatibility"));
Check(compat != null, "found src\\RynthCore.Engine\\Compatibility by walking up");
if (compat == null) return;
string hooks = File.ReadAllText(Path.Combine(compat, "ClientCombatHooks.cs"));
int body = hooks.IndexOf("public static bool NativeAttack(", StringComparison.Ordinal);
int guard = hooks.IndexOf("NativeAttackRearm.AttackMode(mode)", body, StringComparison.Ordinal);
int rearm = hooks.IndexOf("RearmIfStuck(cs);", body, StringComparison.Ordinal);
int start = hooks.IndexOf("_startAttackRequest(cs);", body, StringComparison.Ordinal);
int stamp = hooks.IndexOf("_modeChangesAtLastSend = CombatModeHooks.ModeChanges;", body, StringComparison.Ordinal);
Check(body >= 0 && guard > body && rearm > guard && start > rearm,
"NativeAttack: the mode guard, then the re-arm, then StartAttackRequest");
Check(stamp > start, "the mode-change count is taken after the attack went out");
string mode = File.ReadAllText(Path.Combine(compat, "CombatModeHooks.cs"));
int detour = mode.IndexOf("private static void SetCombatModeDetour(", StringComparison.Ordinal);
int request = mode.IndexOf("public static unsafe bool RequestCombatMode(", StringComparison.Ordinal);
Check(detour >= 0 && mode.IndexOf("ClientCombatHooks.DisarmOutOfAttackStance(", detour, StringComparison.Ordinal) > detour,
"the SetCombatMode detour disarms a left-over attack");
int trampoline = request >= 0 ? mode.IndexOf("_originalSetCombatMode(combatSystem, combatMode, 1);", request, StringComparison.Ordinal) : -1;
int disarm = trampoline >= 0 ? mode.IndexOf("ClientCombatHooks.DisarmOutOfAttackStance(", trampoline, StringComparison.Ordinal) : -1;
Check(trampoline > request && disarm > trampoline && disarm < detour,
"RequestCombatMode (the trampoline skips the detour) disarms too");
}
}

View file

@ -53,6 +53,8 @@ internal static partial class Program
RunShutdownOrderTests();
RunReloadStallTests();
RunNativeAttackRearmTests();
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
return _failed == 0 ? 0 : 1;
}

View file

@ -219,8 +219,15 @@ internal static class Program
Check(HotkeyRules.Check(ok with { InWorld = false }, f1) == HotkeyGate.NotInWorld, "character select: no");
Check(HotkeyRules.Check(ok with { GameFocused = false }, f1) == HotkeyGate.NotFocused, "another app in front: no");
Check(HotkeyRules.Check(ok with { RynthTextFocus = true }, ctrlW) == HotkeyGate.RynthTyping, "RynthCore text box: no, even Ctrl combos");
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, f1) == HotkeyGate.AcTyping, "AC chat typing: no, even F keys");
Check(HotkeyRules.Check(ok with { AcTextFocus = true, RynthTextFocus = true }, f1) == HotkeyGate.RynthTyping, "ours first");
// 2026-11-06 (owner): an F key types nothing, so it fires while a chat entry has the keys.
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, f1) == HotkeyGate.Fire, "AC chat typing: an F key still fires");
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, new KeyCombo(VK_F12, HotkeyMods.Shift | HotkeyMods.Ctrl)) == HotkeyGate.Fire,
"AC chat typing: an F key with modifiers still fires");
Check(HotkeyRules.Check(ok with { RynthTextFocus = true }, f1) == HotkeyGate.Fire, "RynthCore text box: an F key still fires");
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, w) == HotkeyGate.AcTyping, "AC chat typing: a letter is held");
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, ctrlW) == HotkeyGate.AcTyping, "AC chat typing: Ctrl combos are held (copy, paste)");
Check(HotkeyRules.Check(ok with { AcTextFocus = true }, altNum) == HotkeyGate.AcTyping, "AC chat typing: Alt combos are held");
Check(HotkeyRules.Check(ok with { AcTextFocus = true, RynthTextFocus = true }, w) == HotkeyGate.RynthTyping, "ours first");
var unknown = ok with { AcTextFocus = null };
Check(HotkeyRules.Check(unknown, w) == HotkeyGate.AcUnknownTextKey, "AC focus unknown: a letter could be typing");

View file

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the Items faces' "No buff" shield toggle: ItemsPanel.WeaponEntry must read
RynthAi's "noBuff" (sent for every entry; null from an older RynthAi), show the toggle on shield
entries only, and write the field back only when it holds a value. Reaches the internal types by
reflection (the engine has no test seam). x86, like the engine: needs the x86 .NET runtime.
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>ItemsNoBuffTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\RynthCore.Engine\RynthCore.Engine.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,79 @@
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using System.Text.RegularExpressions;
namespace ItemsNoBuffTests
{
// The engine half of the shield "No buff" toggle, against what RynthAi's Items bridge writes
// (ItemsBridgePayload: PascalCase names, "noBuff" on every weapon entry) and reads
// (case-insensitive; noBuff applied for Action "Shield" entries only, absent = unchanged).
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 string Ns = "RynthCore.Engine.UI.Panels.";
private const BindingFlags All = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
private static int Main()
{
Assembly engine = Assembly.Load("RynthCore.Engine");
Type ctxType = engine.GetType(Ns + "ItemsPanelJsonContext", throwOnError: true)!;
object ctx = ctxType.GetProperty("Default", All)!.GetValue(null)!;
var info = (JsonTypeInfo)ctxType.GetProperty("Payload", All)!.GetValue(ctx)!;
Type payloadType = engine.GetType(Ns + "ItemsPanel+Payload", throwOnError: true)!;
Type entryType = engine.GetType(Ns + "ItemsPanel+WeaponEntry", throwOnError: true)!;
List<object> Weapons(object payload) =>
((System.Collections.IEnumerable)payloadType.GetProperty("Weapons", All)!.GetValue(payload)!).Cast<object>().ToList();
bool? NoBuff(object e) => (bool?)entryType.GetProperty("NoBuff", All)!.GetValue(e);
bool Shows(object e) => (bool)entryType.GetProperty("ShowsNoBuff", All)!.GetValue(e)!;
string Name(object e) => (string)entryType.GetProperty("Name", All)!.GetValue(e)!;
// --- RynthAi -> engine (the shape RynthAi's BuildItemsJson writes)
const string fromPlugin = "{\n \"Weapons\": [\n" +
" { \"Id\": 1, \"Name\": \"Sword\", \"Action\": \"Weapon\", \"Element\": \"Slash\", \"Kind\": \"Melee\", \"KeepBuffed\": false, \"noBuff\": true },\n" +
" { \"Id\": 2, \"Name\": \"Kite Shield\", \"Action\": \"Shield\", \"Element\": \"Shield\", \"Kind\": \"Shield\", \"KeepBuffed\": true, \"noBuff\": false },\n" +
" { \"Id\": 3, \"Name\": \"Rose Shield\", \"Action\": \"Shield\", \"Element\": \"Shield\", \"Kind\": \"Shield\", \"KeepBuffed\": false, \"noBuff\": true },\n" +
" { \"Id\": 4, \"Name\": \"Buckler\", \"Action\": \"Weapon\", \"Element\": \"Shield\", \"Kind\": \"Shield\", \"noBuff\": true }\n" +
" ],\n \"MissingIds\": []\n}";
object p = JsonSerializer.Deserialize(fromPlugin, info)!;
var w = Weapons(p);
Check(w.Count == 4, "four entries read");
Check(NoBuff(w[0]) == true && NoBuff(w[1]) == false && NoBuff(w[2]) == true, "noBuff is read per entry");
Check(!Shows(w[0]), "a weapon row: no toggle (RynthAi ignores noBuff on weapons)");
Check(Shows(w[1]) && Shows(w[2]), "a shield row (Action Shield): the toggle");
Check(!Shows(w[3]), "a shield filed as a Weapon (Kind Shield, Action Weapon): no toggle (RynthAi ignores it there)");
// --- An older RynthAi: no field -> no toggle, nothing written back
object old = JsonSerializer.Deserialize("{\"Weapons\":[{\"Id\":2,\"Name\":\"Kite Shield\",\"Action\":\"Shield\",\"Element\":\"Shield\"}]}", info)!;
object oldShield = Weapons(old)[0];
Check(NoBuff(oldShield) == null, "an older RynthAi: noBuff is null");
Check(!Shows(oldShield), "and the shield row has no toggle");
string oldBack = JsonSerializer.Serialize(old, info);
Check(!oldBack.Contains("noBuff"), "and the save carries no noBuff (RynthAi keeps its saved value): " + oldBack);
Check(!oldBack.Contains("ShowsNoBuff"), "the face-only ShowsNoBuff is not on the wire");
// --- Engine -> RynthAi: the toggle flipped and saved
entryType.GetProperty("NoBuff", All)!.SetValue(w[1], true); // what the faces' click does
entryType.GetProperty("NoBuff", All)!.SetValue(w[2], false);
string back = JsonSerializer.Serialize(p, info);
Check(Regex.IsMatch(back, "\"id\":2,[^}]*\"noBuff\":true"), "the Kite Shield goes back noBuff true: " + back);
Check(Regex.IsMatch(back, "\"id\":3,[^}]*\"noBuff\":false"), "the Rose Shield goes back noBuff false");
Check(Regex.IsMatch(back, "\"id\":1,[^}]*\"noBuff\":true"), "a weapon's value is round-tripped untouched (RynthAi ignores it)");
Check(Regex.Matches(back, "\"action\":\"Shield\"").Count == 2 && Name(w[1]) == "Kite Shield", "names and actions round-trip");
// The field name is exactly what RynthAi's ItemRule.NoBuff ([JsonPropertyName("noBuff")]) reads.
var attr = entryType.GetProperty("NoBuff", All)!.GetCustomAttribute<System.Text.Json.Serialization.JsonPropertyNameAttribute>();
Check(attr?.Name == "noBuff", "the wire name is noBuff");
Console.WriteLine(_fails == 0 ? $"All {_asserts} checks passed." : $"{_fails} of {_asserts} checks FAILED.");
return _fails == 0 ? 0 : 1;
}
}
}

View file

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the Settings > Navigation > Outdoor Hunt "Go for" row (2026-11-08): the mirror
of RynthAi's OutdoorHuntPick (0 = Nearest monster, 1 = Biggest pack, 2 = Most XP) 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
that property and keeps it within the three choices.
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>OutdoorHuntPickTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\RynthCore.Engine\RynthCore.Engine.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,110 @@
using System.Collections;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
namespace OutdoorHuntPickTests
{
// Reaches RynthCore.Engine's internal settings mirror 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 string Ns = "RynthCore.Engine.UI.Data.";
private const BindingFlags All = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
private static int Main()
{
Assembly engine = Assembly.Load("RynthCore.Engine");
Type settingsType = engine.GetType(Ns + "RynthAiSettings", throwOnError: true)!;
Type ctxType = engine.GetType(Ns + "RynthAiSettingsJsonContext", throwOnError: true)!;
Type schemaType = engine.GetType(Ns + "SettingsSchema", throwOnError: true)!;
PropertyInfo? prop = settingsType.GetProperty("OutdoorHuntPick", All);
Check(prop != null && prop.PropertyType == typeof(int?), "the mirror has a nullable int OutdoorHuntPick (RynthAi's payload name)");
if (prop == null) return Finish();
object ctx = ctxType.GetProperty("Default", All)!.GetValue(null)!;
var info = (JsonTypeInfo)ctxType.GetProperty("RynthAiSettings", All)!.GetValue(ctx)!;
object Parse(string json) => JsonSerializer.Deserialize(json, info)!;
// What a payload carries: nothing from an older RynthAi, the value from a newer one.
object fresh = Activator.CreateInstance(settingsType, nonPublic: true)!;
Check(prop.GetValue(fresh) == null, "a fresh mirror holds no value");
Check(prop.GetValue(Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":0}")) == null, "a RynthAi without it: absent (null)");
for (int v = 0; v <= 2; v++)
Check((int?)prop.GetValue(Parse("{\"OutdoorHuntPick\":" + v + "}")) == v, $"RynthAi sends {v}");
// A save sends exactly what the mirror holds: unset stays null (RynthAi leaves its setting alone).
Check(JsonSerializer.Serialize(fresh, info).Contains("\"OutdoorHuntPick\":null"), "an unset mirror saves null");
Check(JsonSerializer.Serialize(Parse("{\"OutdoorHuntPick\":2}"), info).Contains("\"OutdoorHuntPick\":2"), "Most XP saves 2");
// The schema row, under Navigation, beside Hunt Range / Hunt Radius.
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 (nav == null) return Finish();
var labels = new List<string>();
object? row = null;
int matches = 0;
foreach (object r in (IEnumerable)nav.GetType().GetProperty("Rows")!.GetValue(nav)!)
{
string label = (string?)r.GetType().GetProperty("Label")!.GetValue(r) ?? "";
labels.Add(label);
if (label == "Go for") { row = r; matches++; }
}
Check(matches == 1, "exactly one Go for row, under Navigation");
int radius = labels.IndexOf("Hunt Radius (yd)"), goFor = labels.IndexOf("Go for");
Check(radius >= 0 && goFor == radius + 1, "right after Hunt Radius");
if (row == null) return Finish();
Type rt = row.GetType();
Check(rt.GetProperty("Kind")!.GetValue(row)!.ToString() == "Combo", "a combo");
var items = (string[])rt.GetProperty("CurrentItems")!.GetValue(row)!;
Check(items.SequenceEqual(new[] { "Nearest monster", "Biggest pack", "Most XP" }), "the three choices, in RynthAi's order");
string tip = (string?)rt.GetProperty("Tooltip")!.GetValue(row) ?? "";
Check(tip.Contains("Nearest monster: the closest one, as before."), "tooltip: nearest");
Check(tip.Contains("Biggest pack: the most monsters together"), "tooltip: biggest pack");
Check(tip.Contains("Most XP: the pack worth the most experience, learned from your kills"), "tooltip: most XP");
var get = (Delegate)rt.GetProperty("Get")!.GetValue(row)!;
var set = (Delegate)rt.GetProperty("Set")!.GetValue(row)!;
MethodInfo visible = rt.GetMethod("IsVisible")!;
Check(!(bool)visible.Invoke(row, new[] { fresh })!, "hidden while RynthAi hasn't sent the value");
Check(!(bool)visible.Invoke(row, new[] { Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":0}") })!,
"hidden for a RynthAi with Hunt Range but no Go for");
object near = Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntPick\":0}");
Check((bool)visible.Invoke(row, new[] { near })!, "shown once RynthAi sends it");
Check((double)get.DynamicInvoke(near)! == 0, "Nearest monster reads 0");
set.DynamicInvoke(near, 2.0);
Check((int?)prop.GetValue(near) == 2, "choosing Most XP sets 2");
set.DynamicInvoke(near, 1.0);
Check((int?)prop.GetValue(near) == 1, "choosing Biggest pack sets 1");
set.DynamicInvoke(near, 7.0);
Check((int?)prop.GetValue(near) == 2, "an out-of-range pick is kept within the choices");
Check((double)get.DynamicInvoke(Parse("{\"OutdoorHuntPick\":9}"))! == 2, "an unknown value from a newer RynthAi reads as the last choice");
Check((double)get.DynamicInvoke(Parse("{\"OutdoorHuntPick\":-3}"))! == 0, "a negative value reads Nearest monster");
// Picking changes nothing else in the payload.
object before = Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":150,\"OutdoorHuntPick\":0}");
set.DynamicInvoke(before, 1.0);
string after = JsonSerializer.Serialize(before, info);
Check(after.Contains("\"OutdoorHuntRange\":60") && after.Contains("\"OutdoorHuntRadius\":150") && after.Contains("\"OutdoorHuntPick\":1"),
"Hunt Range and Hunt Radius ride along unchanged");
return Finish();
}
private static int Finish()
{
Console.WriteLine(_fails == 0 ? $"All {_asserts} checks passed." : $"{_fails} of {_asserts} checks FAILED.");
return _fails == 0 ? 0 : 1;
}
}
}

View file

@ -62,6 +62,9 @@ namespace PanelLayoutTests
Run(TwoSessionsNeverShareAFile);
Run(TwoClientsNeverWriteEachOthersFiles);
Run(AutoSaveRules);
Run(IdentityFromThePlayerWhenTheLaunchHasNone);
Run(HotReloadWithTheNameNotKnownYet);
Run(TheDefaultIsOnlyReadInUse);
Run(CommandReplies);
}
finally
@ -617,16 +620,139 @@ namespace PanelLayoutTests
private static void AutoSaveRules()
{
Case("automatic imgui.ini saves");
Check(PanelLayoutPolicy.MayAutoSaveIni(characterLayout: true, perCharacter: true, inWorld: true, contextHeldCharacter: true), "a character's layout: always saved");
Check(PanelLayoutPolicy.MayAutoSaveIni(true, true, inWorld: false, contextHeldCharacter: true), "...also at a logout's last save");
Check(PanelLayoutPolicy.MayAutoSaveIni(false, perCharacter: false, inWorld: true, contextHeldCharacter: true), "the setting off: the shared default is saved, as before");
Check(PanelLayoutPolicy.MayAutoSaveIni(false, perCharacter: false, inWorld: false, contextHeldCharacter: false), "the setting off, at character select: saved, as before");
Check(PanelLayoutPolicy.MayAutoSaveIni(false, true, inWorld: true, contextHeldCharacter: false), "in the world with no character name (the default in use): saved, as before");
Check(!PanelLayoutPolicy.MayAutoSaveIni(false, true, inWorld: false, contextHeldCharacter: false),
"character select with the setting on: the default isn't written (it could undo another client's /rc layout default)");
Check(!PanelLayoutPolicy.MayAutoSaveIni(false, true, inWorld: false, contextHeldCharacter: true), "the default after a character logged out: not saved (its windows would leak into it)");
Check(!PanelLayoutPolicy.MayAutoSaveIni(false, true, inWorld: true, contextHeldCharacter: true), "the default in the world after a character's layout was used: not saved");
Case("saves of the layout in use (imgui.ini and panel_state.txt)");
Check(PanelLayoutPolicy.MaySaveLayoutInUse(characterLayout: true, perCharacter: true), "a character's layout: always saved");
Check(PanelLayoutPolicy.MaySaveLayoutInUse(false, perCharacter: false), "the setting off: the shared default is saved, as before");
Check(!PanelLayoutPolicy.MaySaveLayoutInUse(false, perCharacter: true),
"the setting on: the default is never saved (character select, a client that doesn't know its character yet, Save Layout Now)");
string why = PanelLayoutPolicy.DefaultReadOnlyText(inWorld: true);
Check(why.Contains(PanelLayoutPolicy.ReasonText(DefaultReason.NoCharacterName), StringComparison.Ordinal) && why.Contains("/rc layout default", StringComparison.Ordinal),
"Save Layout Now on the default says why and what writes it");
Check(PanelLayoutPolicy.DefaultReadOnlyText(false).Contains(PanelLayoutPolicy.ReasonText(DefaultReason.NotInWorld), StringComparison.Ordinal), "...at character select too");
}
// ── 2026-11-05: a client launched with no character picked ─────────────
private static void IdentityFromThePlayerWhenTheLaunchHasNone()
{
Case("the key: the launch context's name, else the player's own");
Eq(PanelLayoutPolicy.Identity(ServerOne, CharA, CharB), WhoA, "the launch context names one: that one (the key the other per-character files use)");
Eq(PanelLayoutPolicy.Identity(ServerOne, "", CharB), WhoB, "the launch context names none: the player in the world");
Eq(PanelLayoutPolicy.Identity(ServerOne, " ", " " + CharB + " "), WhoB, "a blank launch name is none; the player's name is trimmed");
Check(PanelLayoutPolicy.Identity(ServerOne, "", "") == null, "neither known: no owner");
Check(PanelLayoutPolicy.Identity(ServerOne, null, null) == null, "nothing at all: no owner");
}
private static void HotReloadWithTheNameNotKnownYet()
{
// The live log (2026-11-05): "SessionState: recorded login session ... character=''" at the hot
// reload, then "switched to the PC-wide default layout" and nothing later; that client saved
// its places into the shared files all session.
Case("hot reload, recorded with no name: waits for the player's name, never the default first");
var s = new PanelLayoutSession();
const long login = 70_000;
Check(s.Tick(login, true, true, login, identityRecorded: true, null) == null, "recorded without a name: no switch yet (the player's name is on its way)");
Check(!s.ReadyToDraw(login + 16, true, login), "...and the panels wait");
Check(s.Tick(login + 500, true, true, login, true, null) == null, "still waiting half a second in");
LayoutSwitch? sw = s.Tick(login + 800, true, true, login, true, WhoA);
Check(sw is { } a && Equals(a.To, WhoA) && !a.FlushFrom, "the player's name read: straight to the character's layout, nothing written out");
s.MarkApplied(sw!.Value.Gen);
Check(s.ReadyToDraw(login + 816, true, login), "applied: the panels draw, in the character's places");
Case("hot reload, the name later than the wait: the default only read, then the character's");
var late = new PanelLayoutSession();
Check(late.Tick(login, true, true, login, true, null) == null, "recorded without a name: waiting");
sw = late.Tick(login + PanelLayoutPolicy.IdentityWaitMs, true, true, login, true, null);
Check(sw is { } d && d.To == null && !d.FlushFrom, "the wait over, no name: the default, so the panels can draw");
Check(!PanelLayoutPolicy.MaySaveLayoutInUse(characterLayout: sw!.Value.To != null, perCharacter: true),
"...but nothing auto-saves into it (no default auto-save from a client in the world)");
late.MarkApplied(sw.Value.Gen);
Check(late.ReadyToDraw(login + PanelLayoutPolicy.IdentityWaitMs + 1, true, login), "the panels draw with it meanwhile");
Check(late.Tick(login + PanelLayoutPolicy.IdentityWaitMs + 16, true, true, login, true, null) == null, "no name yet: nothing more");
sw = late.Tick(login + PanelLayoutPolicy.IdentityWaitMs + 2000, true, true, login, true, WhoA);
Check(sw is { } c && Equals(c.To, WhoA) && c.From == null && !c.FlushFrom,
"the name known later: the switch to the character's layout, the default not written out");
Check(late.ReadyToDraw(login + PanelLayoutPolicy.IdentityWaitMs + 2001, true, login), "the panels keep drawing while it loads");
late.MarkApplied(sw!.Value.Gen);
Eq(late.AppliedLayout, WhoA, "the character's layout is in use for the rest of the session");
Check(PanelLayoutPolicy.MaySaveLayoutInUse(late.AppliedLayout != null, true), "...and its saves go to the character's files");
Check(late.Tick(login + PanelLayoutPolicy.IdentityWaitMs + 3000, true, true, login, true, WhoA) == null, "no switch back");
Case("a relogin in the same client: the new login waits for its own name again");
sw = late.Tick(200_000, true, false, 0, true, null);
Check(sw is { } o && o.To == null && o.FlushFrom, "logout: the character's written out, the default (read only) at character select");
late.MarkApplied(sw!.Value.Gen);
const long relogin = 300_000;
Check(late.Tick(relogin, true, true, relogin, true, null) == null, "the new login, no name yet: waiting");
sw = late.Tick(relogin + 400, true, true, relogin, true, WhoB);
Check(sw is { } r && Equals(r.To, WhoB), "the other character's name: its layout");
}
private static void TheDefaultIsOnlyReadInUse()
{
Case("PanelStateStore: the PC-wide default is only read with the setting on");
string root = NewDir("readonly");
string def = Path.Combine(root, "panel_state.txt");
File.WriteAllText(def, "# default\r\nbar=1,2\r\npanel.Shortcuts=open,10,20,300,120,docked,0,0\r\n");
byte[] defBytes = File.ReadAllBytes(def);
string a = Path.Combine(root, "layouts", "s", "a", "panel_state.txt");
Directory.CreateDirectory(Path.GetDirectoryName(a)!);
File.WriteAllText(a, "# A\r\npanel.Shortcuts=open,900,700,300,120,docked,0,0\r\n");
PanelStateStore.ReadOnlyPath = def;
try
{
PanelStateStore.SwitchTo(def, flushCurrent: false);
PanelStateStore.SetPanel("Shortcuts", new PanelStateStore.PanelEntry(true, 55, 66, 300, 120));
PanelStateStore.SetBarPosition(3, 4);
Eq(File.ReadAllBytes(def), defBytes, "a moved window and the bar on the default: not written");
Check(PanelStateStore.TryGetPanel("Shortcuts", out var moved) && moved.Left == 55, "...kept in memory while it is in use");
PanelStateStore.Flush();
Eq(File.ReadAllBytes(def), defBytes, "Save Layout Now doesn't write it either");
PanelStateStore.SwitchTo(a, flushCurrent: true);
Eq(File.ReadAllBytes(def), defBytes, "switching away (even asked to write out what it leaves) doesn't write it");
Check(PanelStateStore.TryGetPanel("Shortcuts", out var mine) && mine.Left == 900, "the character's layout: its own place, not the moves made on the default");
Case("a plugin window registered after the switch gets its saved place, and its moves are saved");
// PluginWindows registers its windows seconds after the login (the manifests); the store
// holds every row of the file whether a window is registered or not.
Check(PanelStateStore.TryGetPanel("Late Window", out _) == false, "not in the file: nothing saved yet");
File.WriteAllText(a, "# A\r\npanel.Shortcuts=open,900,700,300,120,docked,0,0\r\npanel.Toolbar=open,400,10,500,40,docked,0,0\r\n");
PanelStateStore.SwitchTo(a, flushCurrent: false);
Check(PanelStateStore.TryGetPanel("Toolbar", out var tb) && tb.Open && tb.Left == 400 && tb.Top == 10,
"a window registered after the switch reads its saved place and open state from the character's layout");
PanelStateStore.SetPanel("Toolbar", tb with { Left = 420, Top = 12 });
Check(File.ReadAllText(a).Contains("panel.Toolbar=open,420,12,", StringComparison.Ordinal), "its move is saved to the character's file");
Check(File.ReadAllText(a).Contains("panel.Shortcuts=open,900,700,", StringComparison.Ordinal), "...with the other windows' rows kept");
Eq(File.ReadAllBytes(def), defBytes, "...and the default untouched");
Case("a layout switch and plugin windows: they follow the new layout like engine panels");
const WindowKind plugin = WindowKind.PluginWindow, engine = WindowKind.EnginePanel, script = WindowKind.ScriptWindow;
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, shown: false, remember: true, saved: true, savedOpen: true), SwitchStep.Open,
"registered (on the old layout) but not open, the new layout has it open: it opens there");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, shown: true, remember: true, saved: true, savedOpen: false), SwitchStep.Close,
"opened from the old layout, the new one has it closed: it closes (not saved over)");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, true, true, saved: true, savedOpen: true), SwitchStep.Place, "open in both: it moves to the new layout's place");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, true, true, saved: false, savedOpen: false), SwitchStep.PlaceAndSave,
"new to the layout: placed, and saved there so it comes back there");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, false, true, saved: false, savedOpen: false), SwitchStep.Leave, "not open, not in the layout: left alone");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, false, remember: false, true, true), SwitchStep.Leave, "Remember Open Windows off: not opened");
Eq(PanelLayoutPolicy.StepAtSwitch(plugin, true, remember: false, true, false), SwitchStep.Place, "...nor closed");
Eq(PanelLayoutPolicy.StepAtSwitch(engine, false, true, true, true), SwitchStep.Open, "an engine panel: the same");
Eq(PanelLayoutPolicy.StepAtSwitch(engine, true, true, true, false), SwitchStep.Close, "...both ways");
Eq(PanelLayoutPolicy.StepAtSwitch(script, false, true, true, true), SwitchStep.Leave, "a script window opens when its script says, not from the layout");
Eq(PanelLayoutPolicy.StepAtSwitch(script, true, true, true, false), SwitchStep.Place, "...and stays open (it moves)");
Case("the setting off: the default is saved, as before");
PanelStateStore.ReadOnlyPath = null;
PanelStateStore.SwitchTo(def, flushCurrent: false);
PanelStateStore.SetBarPosition(5, 6);
Check(File.ReadAllText(def).Contains("bar=5,6", StringComparison.Ordinal), "no read-only mark: the shared file is written");
}
finally
{
PanelStateStore.ReadOnlyPath = null;
}
NoTempFiles(root);
}
private static void CommandReplies()

View file

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for src\RynthCore.Engine\ImGui\MonsterHud\PlateSightRules.cs (2026-11-04, problem
report R-20261105-020337-67aa: nameplates and NPC labels drew, and took clicks, through walls):
given the camera's cell, the player's cell, the visible-cell list, "sees outside", AC's draw
stamp on the object's room and the doorways, does a plate or label show? Anything unknown shows
(today's behaviour). The AC-side facts (offsets, the stamp, the pattern) are checked against
acclient.exe by tools\plate_sight_check.py.
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>PlateSightTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\PlateSightRules.cs" Link="Engine\PlateSightRules.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,274 @@
using RynthCore.Engine.ImGuiBackend.Hud;
namespace PlateSightTests;
/// <summary>
/// PlateSightRules: does a nameplate or name label show for an object, given what AC's cells say
/// (2026-11-04, report R-20261105-020337-67aa: labels drew, and took clicks, through walls)?
/// </summary>
internal static class Program
{
// One landblock (0xC6A9: the town of the report) with a shop and its neighbours.
private const uint Shop = 0xC6A90161; // the viewer's room (the report's cell): sees outside
private const uint ShopBack = 0xC6A90162; // another room of the shop, in its visible list
private const uint ShopUpstairs = 0xC6A90163; // in the visible list too
private const uint NextDoor = 0xC6A90170; // another building's room: not visible from the shop
private const uint Street = 0xC6A90029; // an outdoor land cell
private const uint Street2 = 0xC6A9002A;
private const uint Dungeon = 0x01D90105; // a dungeon room: doesn't see outside
private const uint DungeonNear = 0x01D90106;
private const uint DungeonFar = 0x01D90140;
private static readonly uint[] ShopVisible = { Shop, ShopBack, ShopUpstairs };
private static readonly uint[] DungeonVisible = { Dungeon, DungeonNear };
private static int _checks, _failed;
private static string _case = "";
private static int Main()
{
CellIds();
Stamps();
Rects();
NothingKnownShows();
OwnRoomsAlwaysShow();
BothOutdoorsUnchanged();
IndoorsTheCellList();
IndoorsTheDrawStamp();
IndoorsOutdoorObjects();
DungeonsSeeNothingOutside();
OutdoorsLookingIntoBuildings();
CoarseIsTheCellListsOnly();
TheReport();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL PLATE SIGHT TESTS PASSED." : $"{_failed} FAILED.");
return _failed == 0 ? 0 : 1;
}
private static SightQuery InShop(uint obj, bool onScreen = true) => new()
{
ViewerCell = Shop, PlayerCell = Shop, ViewerSeesOutside = SightFact.Yes,
ViewerVisible = ShopVisible, VisibleKnown = true, ObjectCell = obj, OnScreen = onScreen,
};
private static SightQuery InDungeon(uint obj, bool onScreen = true) => new()
{
ViewerCell = Dungeon, PlayerCell = Dungeon, ViewerSeesOutside = SightFact.No,
ViewerVisible = DungeonVisible, VisibleKnown = true, ObjectCell = obj, OnScreen = onScreen,
};
private static SightQuery OnStreet(uint obj, bool onScreen = true) => new()
{
ViewerCell = Street, PlayerCell = Street, ViewerSeesOutside = SightFact.Yes,
ViewerVisible = ReadOnlySpan<uint>.Empty, VisibleKnown = true, ObjectCell = obj, OnScreen = onScreen,
};
private static void CellIds()
{
Case("cell ids: land cells are outdoors, 0x0100 and up are EnvCells");
Check(!PlateSightRules.IsIndoor(Street) && !PlateSightRules.IsIndoor(0xC6A90001) && !PlateSightRules.IsIndoor(0xC6A90040), "0x0001-0x0040 outdoors");
Check(!PlateSightRules.IsIndoor(0xC6A900FF), "0x00FF outdoors");
Check(PlateSightRules.IsIndoor(0xC6A90100) && PlateSightRules.IsIndoor(Shop) && PlateSightRules.IsIndoor(0x01D9FFFD), "0x0100.. indoors");
}
private static void Stamps()
{
Case("draw stamps: drawn since the sample, wrapping at 2^32");
Check(PlateSightRules.DrawnSince(101, 100), "one newer");
Check(PlateSightRules.DrawnSince(5000, 100), "many newer (several DrawCells passes a frame)");
Check(!PlateSightRules.DrawnSince(100, 100), "the sample itself is not newer");
Check(!PlateSightRules.DrawnSince(99, 100), "older");
Check(!PlateSightRules.DrawnSince(0, 100), "never drawn (a new cell starts at 0)");
Check(PlateSightRules.DrawnSince(0x10, 0xFFFFFFF0), "across the wrap");
Check(!PlateSightRules.DrawnSince(0xFFFFFFF0, 0x10), "older across the wrap");
}
private static void Rects()
{
Case("screen rects: overlap, touching, the margin");
Check(PlateSightRules.Overlaps(10, 10, 20, 20, 15, 15, 30, 30, 0), "overlapping");
Check(PlateSightRules.Overlaps(10, 10, 20, 20, 20, 0, 30, 30, 0), "touching edges count");
Check(!PlateSightRules.Overlaps(10, 10, 20, 20, 25, 10, 30, 20, 0), "apart");
Check(PlateSightRules.Overlaps(10, 10, 20, 20, 25, 10, 30, 20, 6), "apart by less than the margin");
Check(PlateSightRules.Overlaps(15, 0, 15, 40, 10, 10, 20, 20, 0), "a head-to-feet line through the rect");
}
private static void NothingKnownShows()
{
Case("nothing known: today's behaviour (the plate shows)");
var q = new SightQuery { ObjectCell = NextDoor, OnScreen = true, ObjectCellDrawn = SightFact.No };
Check(PlateSightRules.Show(in q), "no viewer cell");
q = InShop(0);
Check(PlateSightRules.Show(in q), "no object cell");
q = InShop(0x00000161);
Check(PlateSightRules.Show(in q), "an object cell without a landblock");
q = InShop(NextDoor);
q.VisibleKnown = false;
q.ViewerVisible = ReadOnlySpan<uint>.Empty;
Check(PlateSightRules.Show(in q), "visible list unreadable, no stamp: shows");
q = InShop(Street);
q.ViewerSeesOutside = SightFact.Unknown;
Check(PlateSightRules.Show(in q), "viewer's sees-outside unreadable: an outdoor object shows");
}
private static void OwnRoomsAlwaysShow()
{
Case("the viewer's and the player's own cells always show");
SightQuery q = InShop(Shop);
q.ObjectCellDrawn = SightFact.No; // even a stale "not drawn"
Check(PlateSightRules.Show(in q), "the viewer's room");
q = InShop(NextDoor);
q.PlayerCell = NextDoor; // third person: the camera is in another room
q.ObjectCellDrawn = SightFact.No;
Check(PlateSightRules.Show(in q), "the player's room");
q = InDungeon(Dungeon, onScreen: false);
Check(PlateSightRules.Show(in q), "the dungeon room you stand in");
}
private static void BothOutdoorsUnchanged()
{
Case("viewer and object outdoors: no change (no terrain or building occlusion)");
SightQuery q = OnStreet(Street2);
Check(PlateSightRules.Show(in q), "on screen");
q = OnStreet(Street2, onScreen: false);
Check(PlateSightRules.Show(in q), "pinned to the edge");
q = OnStreet(0xC7A90001);
Check(PlateSightRules.Show(in q), "the next landblock");
}
private static void IndoorsTheCellList()
{
Case("indoors, no draw stamp: only the cells in the viewer's visible list");
SightQuery q = InShop(ShopBack);
Check(PlateSightRules.Show(in q), "a room in the list");
q = InShop(ShopUpstairs, onScreen: false);
Check(PlateSightRules.Show(in q), "a room in the list, off screen");
q = InShop(NextDoor);
Check(!PlateSightRules.Show(in q), "another building's room: hidden");
q = InShop(NextDoor, onScreen: false);
Check(!PlateSightRules.Show(in q), "another building's room, pinned to the edge: hidden");
q = InDungeon(DungeonFar);
Check(!PlateSightRules.Show(in q), "a dungeon room not visible from here: hidden");
q = InDungeon(DungeonNear);
Check(PlateSightRules.Show(in q), "a dungeon room visible from here: shows");
}
private static void IndoorsTheDrawStamp()
{
Case("on screen: AC's draw stamp on the object's room decides");
SightQuery q = InShop(ShopBack);
q.ObjectCellDrawn = SightFact.No;
Check(!PlateSightRules.Show(in q), "in the list but AC didn't draw it (behind the wall): hidden");
q.ObjectCellDrawn = SightFact.Yes;
Check(PlateSightRules.Show(in q), "drawn: shows");
q = InShop(NextDoor);
q.ObjectCellDrawn = SightFact.Yes;
Check(PlateSightRules.Show(in q), "drawn wins over the list (seen out the door and through another)");
q = InDungeon(DungeonNear);
q.ObjectCellDrawn = SightFact.No;
Check(!PlateSightRules.Show(in q), "the next dungeon room around the corner: hidden");
Case("off screen (pinned by Keep on screen): the stamp is ignored, the list decides");
q = InShop(ShopBack, onScreen: false);
q.ObjectCellDrawn = SightFact.No; // AC skips rooms outside the view
Check(PlateSightRules.Show(in q), "a visible room off to the side keeps its pinned plate");
q = InShop(NextDoor, onScreen: false);
q.ObjectCellDrawn = SightFact.Yes;
Check(!PlateSightRules.Show(in q), "off screen, not in the list: hidden");
}
private static void IndoorsOutdoorObjects()
{
Case("from inside a building that sees outside: outdoor objects need a drawn doorway on screen");
SightQuery q = InShop(Street);
q.InDoorway = SightFact.Yes;
Check(PlateSightRules.Show(in q), "seen through the door: shows");
q.InDoorway = SightFact.No;
Check(!PlateSightRules.Show(in q), "behind the shop's wall: hidden");
q.InDoorway = SightFact.Unknown;
Check(PlateSightRules.Show(in q), "doorways not worked out: shows");
q = InShop(Street, onScreen: false);
q.InDoorway = SightFact.No;
Check(PlateSightRules.Show(in q), "pinned to the edge: the cell rule (sees outside) shows it");
}
private static void DungeonsSeeNothingOutside()
{
Case("from a cell that doesn't see outside, nothing outdoors shows");
SightQuery q = InDungeon(Street);
Check(!PlateSightRules.Show(in q), "on screen");
q.InDoorway = SightFact.Yes;
Check(!PlateSightRules.Show(in q), "even with a (stale) doorway answer");
q = InDungeon(Street, onScreen: false);
Check(!PlateSightRules.Show(in q), "pinned to the edge");
}
private static void OutdoorsLookingIntoBuildings()
{
Case("from outdoors, objects inside buildings and dungeons");
SightQuery q = OnStreet(Shop);
q.ObjectCellDrawn = SightFact.Yes;
Check(PlateSightRules.Show(in q), "the shop's room drawn through its doorway: shows");
q.ObjectCellDrawn = SightFact.No;
Check(!PlateSightRules.Show(in q), "not drawn (door out of view, walls): hidden");
q = OnStreet(Shop, onScreen: false);
q.ObjectSeesOutside = SightFact.Yes;
Check(PlateSightRules.Show(in q), "off screen, a room that sees outside: shows");
q.ObjectSeesOutside = SightFact.No;
Check(!PlateSightRules.Show(in q), "off screen, a sealed room / dungeon: hidden");
q.ObjectSeesOutside = SightFact.Unknown;
Check(PlateSightRules.Show(in q), "off screen, unknown: shows");
q = OnStreet(Dungeon);
q.ObjectSeesOutside = SightFact.No;
Check(!PlateSightRules.Show(in q), "a dungeon room below the town, no stamp: hidden");
}
private static void CoarseIsTheCellListsOnly()
{
Case("the 4 Hz scan: the cell lists only (no stamp, no doorway)");
Check(PlateSightRules.ShowCoarse(Shop, Shop, SightFact.Yes, ShopVisible, true, ShopBack), "a visible room");
Check(!PlateSightRules.ShowCoarse(Shop, Shop, SightFact.Yes, ShopVisible, true, NextDoor), "another building's room");
Check(PlateSightRules.ShowCoarse(Shop, Shop, SightFact.Yes, ShopVisible, true, Street), "outdoors from a shop that sees outside");
Check(!PlateSightRules.ShowCoarse(Dungeon, Dungeon, SightFact.No, DungeonVisible, true, Street), "outdoors from a dungeon");
Check(!PlateSightRules.ShowCoarse(Dungeon, Dungeon, SightFact.No, DungeonVisible, true, DungeonFar), "a dungeon room out of sight");
Check(PlateSightRules.ShowCoarse(Dungeon, Dungeon, SightFact.No, ReadOnlySpan<uint>.Empty, false, DungeonFar), "list unreadable: shows");
Check(PlateSightRules.ShowCoarse(Street, Street, SightFact.Yes, ReadOnlySpan<uint>.Empty, true, Shop), "outdoors: a building's room is left to the frame check");
Check(PlateSightRules.ShowCoarse(0, 0, SightFact.Unknown, ReadOnlySpan<uint>.Empty, false, NextDoor), "no viewer: shows");
}
private static void TheReport()
{
// R-20261105-020337-67aa: indoors in cell 0xC6A90161 buying components; NPC and monster labels through walls.
Case("the report: in a town shop, only what can be seen keeps a label");
SightQuery vendor = InShop(Shop);
Check(PlateSightRules.Show(in vendor), "the vendor in your room");
SightQuery backRoom = InShop(ShopBack);
backRoom.ObjectCellDrawn = SightFact.Yes;
Check(PlateSightRules.Show(in backRoom), "an NPC in the back room, seen through the inner door");
SightQuery nextDoor = InShop(NextDoor);
nextDoor.ObjectCellDrawn = SightFact.No;
Check(!PlateSightRules.Show(in nextDoor), "an NPC in the building next door");
SightQuery behindWall = InShop(Street);
behindWall.InDoorway = SightFact.No;
Check(!PlateSightRules.Show(in behindWall), "a monster in the street behind the shop's wall");
SightQuery outTheDoor = InShop(Street2);
outTheDoor.InDoorway = SightFact.Yes;
Check(PlateSightRules.Show(in outTheDoor), "an NPC in the street, seen out of the open door");
}
private static void Case(string name)
{
_case = name;
Console.WriteLine($"- {name}");
}
private static void Check(bool ok, string what)
{
_checks++;
if (ok) return;
_failed++;
Console.WriteLine($" FAIL [{_case}] {what}");
}
}

View file

@ -59,6 +59,8 @@ namespace PlateSizingTests
HealthRefreshDefaultsOn();
HealthRefreshRoundTripAndClamp();
HideBehindWallsDefaultsOnAndRoundTrips();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL PLATE SIZING TESTS PASSED." : $"{_failed} FAILED.");
@ -588,6 +590,35 @@ namespace PlateSizingTests
// ── refresh others' health (HealthProbe) ────────────────────────────
// ── hide behind walls (2026-11-04, report R-20261105-020337-67aa) ─────
private static void HideBehindWallsDefaultsOnAndRoundTrips()
{
Case("hide behind walls: on by default and from a file before it; off round-trips; Reset all restores it");
S.ResetToDefaults();
Check(S.HideBehindWalls, "on by default (the fixed behaviour)");
string[] lines = Written();
Check(lines.Contains("hideBehindWalls=1"), "hideBehindWalls=1 written");
Check(S.Describe().Contains("hide behind walls on"), "the status line names it");
string[] old = lines.Where(l => !l.StartsWith("hideBehindWalls=", StringComparison.Ordinal)).ToArray();
Check(old.Length == lines.Length - 1, "the old file lacks exactly the one key");
S.HideBehindWalls = false;
S.ResetToDefaults(); // the loader starts from the defaults
S.ApplyLines(old);
Check(S.HideBehindWalls, "on after loading the old file");
S.HideBehindWalls = false;
string[] off = Written();
Check(off.Contains("hideBehindWalls=0"), "hideBehindWalls=0 written");
S.ResetToDefaults();
S.ApplyLines(off);
Check(!S.HideBehindWalls, "off after reload");
Check(off.SequenceEqual(Written()), "identical text after a reload");
Check(S.Describe().Contains("hide behind walls off"), "the status line says off");
S.ResetToDefaults();
Check(S.HideBehindWalls, "Reset all: on");
}
private static void HealthRefreshDefaultsOn()
{
Case("refresh others' health: on at 1 s by default, and after loading a file from before it");

View file

@ -603,11 +603,11 @@ internal static class Program
Eq(RynthCore.PluginSdk.TrainingInfoFlags.Busy, RynthCore.Engine.Plugins.TrainingInfoFlags.Busy, "info flag bits");
Eq(RynthCore.PluginSdk.TrainingEntryFlags.Trainable, RynthCore.Engine.Plugins.TrainingEntryFlags.Trainable, "entry flag bits");
// The three v79 slots follow v78's, then v80's two and v81's GetMergeStackResultFn (v82-v91 follow:
// eleven slots to v89, then v90's thirteen and v91's two).
var names = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(26).TakeLast(6).ToArray();
// eleven slots to v89, then v90's thirteen, v91's two and v93's one).
var names = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(27).TakeLast(6).ToArray();
Check(names.SequenceEqual(new[] { "GetTrainingInfoFn", "RaiseFn", "TrainSkillFn", "GetContainerOrderFn", "PutItemInContainerFn", "GetMergeStackResultFn" }),
"v79, v80 then v81 slots last: " + string.Join(",", names));
var sdkNames = typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(26).TakeLast(6).ToArray();
var sdkNames = typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(27).TakeLast(6).ToArray();
Check(sdkNames.SequenceEqual(names), "SDK v79, v80 and v81 slots in the same order");
}
@ -618,6 +618,15 @@ internal static class Program
{
var all = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).ToArray();
var sdkAll = typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).ToArray();
// v93: the monster plates' health readings end the table (2026-11-07), right after v91's two.
Check(all.Last() == "GetMonsterHealthFn", "v93 slot last: " + all.Last());
Check(sdkAll.Last() == "GetMonsterHealthFn", "SDK v93 slot last: " + sdkAll.Last());
Eq((int)Marshal.OffsetOf<RynthCore.PluginSdk.RynthCoreApiNative>("GetMonsterHealthFn"),
(int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>("GetMonsterHealthFn"), "GetMonsterHealthFn offset");
Eq((int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>("GetMonsterHealthFn"),
(int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>("GetAmbientLightFn") + IntPtr.Size, "GetMonsterHealthFn right after GetAmbientLightFn");
all = all.SkipLast(1).ToArray();
sdkAll = sdkAll.SkipLast(1).ToArray();
// v91: the ambient light floor's two slots end the table (2026-10-27); the checks after these are
// on the table before them.
string[] v91 = { "SetAmbientLightFloorFn", "GetAmbientLightFn" };

View file

@ -9,6 +9,9 @@
- the log tail: last N lines, the byte cap (keeps the end, starts at a line), a last line
still being written, CRLF, an empty / missing file, the rotated .old topping up a short
current log, and reading while another thread keeps appending (as the engine does);
- the per-client log's rotation chain (src\RynthCore.Engine\LogRotation.cs, compiled in): .old is
always the newest, older copies shift to .old.1 ... .old.N-1, the cap and a smaller cap, held
handles (share-delete readers vs an editor without it), and the 7-day pruner's rule;
- hiding the account (login) name, the Windows user name (profile paths) and the PC name;
- the cooldown arithmetic, the endpoint override rules, and reading the server's answers.
Optional: (double dash) server http://127.0.0.1:18097/report posts real bodies to a local copy
@ -27,6 +30,7 @@
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\Report\ProblemReportCore.cs" Link="Engine\ProblemReportCore.cs" />
<Compile Include="..\..\src\RynthCore.Engine\LogRotation.cs" Link="Engine\LogRotation.cs" />
</ItemGroup>
</Project>

View file

@ -2,6 +2,7 @@ using System.IO.Compression;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using RynthCore.Engine;
using RynthCore.Engine.Report;
namespace ProblemReportTests;
@ -30,6 +31,10 @@ internal static class Program
TailCrlfAndEdges();
TailTopsUpFromOld();
TailWhileWriting();
RotationShifts();
RotationCap();
RotationHeldHandles();
RotationPruneRule();
AccountHidden();
Cooldown();
Endpoint();
@ -292,6 +297,156 @@ internal static class Program
Check(!full.IncludesOld, "a full current log doesn't touch .old");
}
// ── Log rotation chain (src\RynthCore.Engine\LogRotation.cs) ────────────
private static string RotDir(string name)
{
string dir = Path.Combine(_tmp, name);
Directory.CreateDirectory(dir);
return dir;
}
private static string? ReadOrNull(string path) => File.Exists(path) ? File.ReadAllText(path) : null;
private static void RotationShifts()
{
Case("rotation: copies shift down, .old is always the newest");
string active = Path.Combine(RotDir("rot-shift"), "RynthCore.4242.log");
for (int gen = 1; gen <= 5; gen++)
{
File.WriteAllText(active, "gen " + gen);
Eq(LogRotation.Rotate(active, 8), LogRotation.Outcome.Moved, $"rotation {gen} moves the live file");
Check(!File.Exists(active), $"rotation {gen}: the live file is gone (the next line starts a new one)");
Eq(ReadOrNull(active + ".old"), "gen " + gen, $"rotation {gen}: .old is the newest");
}
Eq(ReadOrNull(active + ".old.1"), "gen 4", ".old.1 = the one before");
Eq(ReadOrNull(active + ".old.4"), "gen 1", ".old.4 = the oldest so far");
Check(!File.Exists(active + ".old.5"), "nothing past what was rotated");
Eq(LogRotation.CopyPath(active, 0), active + ".old", "copy 0 is .old");
Eq(LogRotation.CopyPath(active, 3), active + ".old.3", "copy 3 is .old.3");
Case("rotation: mtimes stay oldest-last (soak_scorecard sorts by them)");
DateTime prev = DateTime.MaxValue;
bool ordered = true;
for (int i = 0; i <= 4; i++)
{
string p = LogRotation.CopyPath(active, i);
File.SetLastWriteTime(p, DateTime.Now.AddMinutes(-10 * i)); // as a real run would leave them
}
File.WriteAllText(active, "gen 6");
LogRotation.Rotate(active, 8);
for (int i = 0; i <= 5; i++)
{
DateTime t = File.GetLastWriteTime(LogRotation.CopyPath(active, i));
if (t > prev) ordered = false;
prev = t;
}
Check(ordered, "each older copy keeps its older last-write time");
}
private static void RotationCap()
{
Case("rotation: the cap drops the oldest");
string active = Path.Combine(RotDir("rot-cap"), "RynthCore.77.log");
for (int gen = 1; gen <= 12; gen++)
{
File.WriteAllText(active, "gen " + gen);
LogRotation.Rotate(active, 8);
}
Eq(ReadOrNull(active + ".old"), "gen 12", ".old = newest");
Eq(ReadOrNull(active + ".old.7"), "gen 5", ".old.7 = oldest kept");
Check(!File.Exists(active + ".old.8"), "no .old.8 (8 copies: .old + .old.1-.old.7)");
Eq(Directory.GetFiles(Path.GetDirectoryName(active)!, "RynthCore.77.log.old*").Length, 8, "exactly 8 copies on disk");
Case("rotation: a smaller cap trims leftovers from a larger one");
LogRotation.Rotate(active, 8); // no live file: nothing happens
File.WriteAllText(active, "gen 13");
Eq(LogRotation.Rotate(active, 3), LogRotation.Outcome.Moved, "rotates");
Eq(ReadOrNull(active + ".old"), "gen 13", ".old = newest");
Eq(ReadOrNull(active + ".old.1"), "gen 12", ".old.1");
Eq(ReadOrNull(active + ".old.2"), "gen 11", ".old.2 = oldest kept");
Check(!File.Exists(active + ".old.3") && !File.Exists(active + ".old.7"), "everything past .old.2 deleted");
Case("rotation: keep 1 is the old behaviour (only .old)");
File.WriteAllText(active, "gen 14");
LogRotation.Rotate(active, 1);
Eq(ReadOrNull(active + ".old"), "gen 14", ".old replaced by the newest");
Eq(Directory.GetFiles(Path.GetDirectoryName(active)!, "RynthCore.77.log.old*").Length, 1, "one copy");
Case("rotation: clamps and gaps");
Eq(LogRotation.ClampKeepCopies(0), 1, "0 -> 1");
Eq(LogRotation.ClampKeepCopies(-5), 1, "negative -> 1");
Eq(LogRotation.ClampKeepCopies(500), LogRotation.MaxKeepCopies, "huge -> max");
Eq(LogRotation.DefaultKeepCopies, 8, "default 8");
string g = Path.Combine(RotDir("rot-gap"), "RynthCore.5.log");
File.WriteAllText(g + ".old", "a");
File.WriteAllText(g + ".old.3", "c"); // .old.1 / .old.2 missing (deleted by hand)
File.WriteAllText(g + ".old.x", "keep me"); // not a numbered copy
File.WriteAllText(g, "live");
LogRotation.Rotate(g, 8);
Eq(ReadOrNull(g + ".old"), "live", "gap: .old newest");
Eq(ReadOrNull(g + ".old.1"), "a", "gap: .old -> .old.1");
Eq(ReadOrNull(g + ".old.4"), "c", "gap: .old.3 -> .old.4");
Eq(ReadOrNull(g + ".old.x"), "keep me", "a non-numbered name is left alone");
Eq(LogRotation.Rotate(Path.Combine(_tmp, "rot-gap", "nope.log"), 8), LogRotation.Outcome.Missing, "no live file: Missing");
}
private static void RotationHeldHandles()
{
Case("rotation: handles readers hold (share delete) don't stop it");
string active = Path.Combine(RotDir("rot-held"), "RynthCore.9.log");
File.WriteAllText(active + ".old", "previous");
File.WriteAllText(active, "current");
// The launcher's wedge check and the problem report hold the log open with ReadWrite | Delete.
using (var launcher = new FileStream(active, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
using (var report = new FileStream(active + ".old", FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
{
Eq(LogRotation.Rotate(active, 8), LogRotation.Outcome.Moved, "moved with both held");
}
Eq(ReadOrNull(active + ".old"), "current", ".old = newest");
Eq(ReadOrNull(active + ".old.1"), "previous", "the held .old shifted to .old.1");
Case("rotation: a .old held without delete sharing falls back like before");
File.WriteAllText(active, "next");
using (var editor = new FileStream(active + ".old", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
LogRotation.Outcome o = LogRotation.Rotate(active, 8);
// .old can be neither moved nor deleted, so the live file can't take its name: it is emptied.
Eq(o, LogRotation.Outcome.Truncated, "live file emptied, as the old code did");
Eq(ReadOrNull(active), "", "live log is empty, not growing");
}
Eq(ReadOrNull(active + ".old"), "current", "the held .old is untouched");
Eq(ReadOrNull(active + ".old.2"), "previous", "older copies still shifted");
}
private static void RotationPruneRule()
{
Case("prune: names and pids");
Eq(LogRotation.PidOf("RynthCore.1234.log"), (int?)1234, "live log");
Eq(LogRotation.PidOf("RynthCore.1234.log.old"), (int?)1234, ".old");
Eq(LogRotation.PidOf("RynthCore.1234.log.old.7"), (int?)1234, ".old.7");
Eq(LogRotation.PidOf("RynthCore.log"), (int?)null, "shared log");
Eq(LogRotation.PidOf("RynthCore.1234.log.bak"), (int?)null, "other suffix");
Eq(LogRotation.PidOf("RynthCore.abc.log"), (int?)null, "not a pid");
Eq(LogRotation.PidOf("RynthCore.1234.log.old.x"), (int?)null, "non-numbered copy");
Case("prune: what the 7-day pruner deletes");
DateTime cutoff = new DateTime(2026, 11, 1);
DateTime old = cutoff.AddDays(-1), fresh = cutoff.AddDays(1);
Func<int, bool> live = pid => pid == 500;
const string self = "RynthCore.100.log", shared = "RynthCore.log";
Check(LogRotation.ShouldPrune("RynthCore.300.log.old.5", self, shared, old, cutoff, live), "a dead client's old .old.5 goes");
Check(LogRotation.ShouldPrune("RynthCore.300.log", self, shared, old, cutoff, live), "a dead client's old .log goes");
Check(!LogRotation.ShouldPrune("RynthCore.300.log.old.5", self, shared, fresh, cutoff, live), "a recent copy stays");
Check(!LogRotation.ShouldPrune("RynthCore.500.log.old.7", self, shared, old, cutoff, live), "a running client's old copy stays");
Check(!LogRotation.ShouldPrune("RynthCore.500.log", self, shared, old, cutoff, live), "a running client's live log stays");
Check(!LogRotation.ShouldPrune("RynthCore.100.log", self, shared, old, cutoff, live), "our own live log stays");
Check(!LogRotation.ShouldPrune("RynthCore.100.log.old.3", self, shared, old, cutoff, live), "our own copies stay");
Check(LogRotation.ShouldPrune("RynthCore.1000.log.old", self, shared, old, cutoff, live), "pid 1000 isn't pid 100's file");
Check(!LogRotation.ShouldPrune("RynthCore.log", self, shared, old, cutoff, live), "the shared log stays");
Check(LogRotation.ShouldPrune("RynthCore.300.log.bak", self, shared, old, cutoff, live), "other names: age alone, as before");
}
private static void TailWhileWriting()
{
Case("tail: file being appended to");

View file

@ -46,12 +46,14 @@ namespace RadarSettingsTests
Run("NameAndSizeFileRoundTrip", () => NameAndSizeFileRoundTrip(root));
Run("StyleKeysClampAndIgnore", StyleKeysClampAndIgnore);
Run("WorldMapBackdropSettings", () => WorldMapBackdropSettings(root));
Run("RangeRings", () => RangeRings(root)); // after FileRoundTrip: a file from before keeps the defaults
Run("RoundRadarAndClipping", () => RoundRadarAndClipping(root));
Run("ClickThroughWheelZoom", () => ClickThroughWheelZoom(root));
Run("SelectionSettingsSave", () => SelectionSettingsSave(root));
Run("WhichMarkerIsSelected", WhichMarkerIsSelected);
Run("SelectionEdgeArrow", SelectionEdgeArrow);
Run("SelectionLabelPlacement", SelectionLabelPlacement);
Run("ClickThroughDotPressNeverMoves", ClickThroughDotPressNeverMoves);
}
finally
{
@ -248,6 +250,47 @@ namespace RadarSettingsTests
Check(!st.TryLoad("color.monster", "FFFF0000"), "colour keys are not ours");
Check(!st.TryLoad("zoom", "2"), "plain keys are not ours");
}
// The range rings (2026-11-06): Monster Range on and Ring Range off by default, a settings file
// from before (FileRoundTrip's, no ring lines) leaves them so, both save under their keys, and
// the ring is range x zoom pixels round you, drawn only while some of it is on the picture.
private static void RangeRings(string root)
{
Check(RadarSettingsStore.ShowMonsterRangeRing, "Monster Range ring on by default (and after loading an older file)");
Check(!RadarSettingsStore.ShowRingRangeRing, "Ring Range ring off by default");
string saved = Path.Combine(root, "rings.txt");
Environment.SetEnvironmentVariable("RYNTHCORE_RADAR_SETTINGS", saved);
RadarSettingsStore.ShowMonsterRangeRing = false;
RadarSettingsStore.ShowRingRangeRing = true;
RadarSettingsStore.Save();
string text = File.ReadAllText(saved).Replace("\r\n", "\n");
Check(text.Contains("monsterRangeRing=0\n"), "saved monsterRangeRing=0");
Check(text.Contains("ringRangeRing=1\n"), "saved ringRangeRing=1");
RadarSettingsStore.ShowMonsterRangeRing = true;
RadarSettingsStore.ShowRingRangeRing = false;
RadarSettingsStore.Save();
text = File.ReadAllText(saved).Replace("\r\n", "\n");
Check(text.Contains("monsterRangeRing=1\n") && text.Contains("ringRangeRing=0\n"), "saved the defaults back");
Check(RadarRangeRing.RadiusPx(50, 1.5f) == 75f, "50 yd at 1.5 px/yd: 75 px");
Check(RadarRangeRing.RadiusPx(5, 6f) == 30f, "5 yd at the closest zoom: 30 px");
Check(RadarRangeRing.RadiusPx(50, 0.1f) == 25f, "zoom under 0.5 counts as 0.5, as the projection");
Check(RadarRangeRing.RadiusPx(50, float.NaN) == 25f, "a NaN zoom counts as 0.5");
Check(RadarRangeRing.RadiusPx(0, 2f) == 0f && RadarRangeRing.RadiusPx(-3, 2f) == 0f, "no range: no ring");
Check(RadarRangeRing.RadiusPx(double.NaN, 2f) == 0f, "a NaN range: no ring");
var min = new System.Numerics.Vector2(100, 100);
var max = new System.Numerics.Vector2(300, 300);
var mid = new System.Numerics.Vector2(200, 200);
Check(RadarRangeRing.Shows(75f, mid, min, max, null), "inside the square");
Check(RadarRangeRing.Shows(120f, mid, min, max, null), "past the sides, the corners still cross it");
Check(!RadarRangeRing.Shows(142f, mid, min, max, null), "past the corners (141.4 px): nothing to draw");
Check(!RadarRangeRing.Shows(3f, mid, min, max, null), "too small to draw");
Check(!RadarRangeRing.Shows(float.NaN, mid, min, max, null), "NaN radius: nothing");
var circle = new RoundMask(mid, 100);
Check(RadarRangeRing.Shows(100f, mid, min, max, circle), "round: on the edge");
Check(!RadarRangeRing.Shows(101f, mid, min, max, circle), "round: past the circle, nothing to draw");
}
// The world map backdrop: off by default, and its switch and strength save under their keys.
private static void WorldMapBackdropSettings(string root)
{
@ -270,6 +313,25 @@ namespace RadarSettingsTests
// The round radar: the setting saves, and the geometry cuts shapes to the circle.
// Docked click-through with "Mouse wheel still zooms" (2026-10-29): the wheel over the radar is
// the radar's, everywhere else and in every other case it stays the game's.
// 2026-11-04 (Discord): with click-through on, holding on a dot moved the radar. A press may move
// it only with click-through off, Ctrl held when it began, or popped out; decided at the press.
private static void ClickThroughDotPressNeverMoves()
{
Check(RadarDrag.PressMoves(false, false, false), "click-through off: a press drags");
Check(!RadarDrag.PressMoves(true, false, false), "click-through on, no Ctrl (a dot press): stays put");
Check(RadarDrag.PressMoves(true, true, false), "click-through on, Ctrl held: drags");
Check(RadarDrag.PressMoves(true, false, true), "popped out: always interactive, drags");
var d = new RadarDrag();
Check(d.Update(false, true, false, false), "no press yet: nothing to stop (the item isn't active)");
Check(!d.Update(true, true, false, false), "dot press under click-through: no move");
Check(!d.Update(false, true, true, false), "Ctrl pressed mid-hold: still no move");
Check(!d.Update(false, false, false, false), "click-through switched off mid-hold: still no move");
Check(d.Update(true, true, true, false), "next press with Ctrl: moves");
Check(d.Update(false, true, false, false), "Ctrl let go mid-drag: keeps moving");
Check(d.Update(true, false, false, false), "click-through off: moves");
}
private static void ClickThroughWheelZoom(string root)
{
Check(!RadarSettingsStore.ClickThroughWheelZoom, "off by default");

View file

@ -1,14 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the radar's per-kind show boxes (RadarSettingsStore.ShowFlag / ShowKind)
Offline checks for the radar's range rings (RadarRangeRing.cs: their boxes, defaults, file keys,
and the ring's radius, range x zoom, and when it shows), and for the radar's per-kind show boxes (RadarSettingsStore.ShowFlag / ShowKind)
the marker kinds (RadarKind) the RynthAi snapshot sends, and the per-kind marker size /
name label settings (MarkerStyleSettings). src\RynthCore.Engine\UI\Panels\
RadarSettingsStore.cs and UI\Data\RadarSnapshotJson.cs are compiled in, with a synchronous
UiBackgroundWriter stub. Every kind must have its own box, Corpses off must hide your corpses
too, unknown kinds stay hidden, a plugin-shaped snapshot filters per box, and every box must
round-trip through the settings file. The selected-object highlight (RadarSelection.cs): which
marker is the selected one, when it clears, the edge arrow and label maths, and its settings. Uses RYNTHCORE_RADAR_SETTINGS (temp files); never
marker is the selected one, when it clears, the edge arrow and label maths, and its settings. Which
presses may move the radar (RadarDrag.cs: never a dot press under click-through without Ctrl). Uses RYNTHCORE_RADAR_SETTINGS (temp files); never
touches %LOCALAPPDATA%\RynthCore.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
@ -25,9 +27,11 @@
<Compile Include="..\..\src\RynthCore.Engine\UI\Panels\RadarSettingsStore.cs" Link="Engine\RadarSettingsStore.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\RadarSnapshotJson.cs" Link="Engine\RadarSnapshotJson.cs" />
<Compile Include="..\..\src\RynthCore.Engine\UI\Panels\MarkerStyleSettings.cs" Link="Engine\MarkerStyleSettings.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\Panels\RadarRangeRing.cs" Link="Engine\RadarRangeRing.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\Panels\CircleClip.cs" Link="Engine\CircleClip.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\Panels\RadarWheel.cs" Link="Engine\RadarWheel.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\Panels\RadarSelection.cs" Link="Engine\RadarSelection.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\Panels\RadarDrag.cs" Link="Engine\RadarDrag.cs" />
</ItemGroup>
</Project>

View file

@ -42,6 +42,9 @@ namespace SelfPlateTests
TicksAndDuration();
CategoryZeroStandsAlone();
ShortArraysAndHugeExpiry();
IconsCarryTheirSpells();
AddSpellLimits();
TooltipText();
SelfIconSizeSetting();
SelfPlateAt100IsTheOldPlate();
@ -338,6 +341,61 @@ namespace SelfPlateTests
Check(c == 2, "an empty destination still counts");
}
// ── Hover tooltip (2026-11-07) ───────────────────────────────────────
private static uint[] Spells(DebuffIcon ic)
{
var s = new uint[ic.SpellCount];
for (int i = 0; i < s.Length; i++) s[i] = ic.SpellAt(i);
return s;
}
private static void IconsCarryTheirSpells()
{
Case("each icon carries the spell heading each category it merges (the tooltip names them)");
int c = Run(new[] { new E(3, 80, 2), new E(4, 25, 4), new E(2, 30, 110) }, out var ic);
Check(c == 2, $"two icons (got {c})");
Check(ic[0].Kind == DebuffKind.VulnFire && Spells(ic[0]).SequenceEqual(new uint[] { 2 }), "fire vuln: spell 2 (" + string.Join(",", Spells(ic[0])) + ")");
Check(ic[1].Kind == DebuffKind.Attributes && Spells(ic[1]).OrderBy(x => x).SequenceEqual(new uint[] { 3, 4 }),
"attributes: spells 3 and 4 (" + string.Join(",", Spells(ic[1])) + ")");
c = Run(new[] { new E(1, 20, 116), new E(10, 50, 116) }, out ic);
Check(c == 1 && Spells(ic[0]).SequenceEqual(new uint[] { 10 }), "one category: the spell that lasts longest (10)");
Run(new[] { new E(100, 600, 50), new E(0x8001, 30, 0) }, out ic);
Check(ic[0].SpellCount == 0, "no icon, no spells");
}
private static void AddSpellLimits()
{
Case("AddSpell: skips 0 and repeats, holds at most MaxSpells");
var ic = new DebuffIcon();
ic.AddSpell(0); ic.AddSpell(7); ic.AddSpell(7);
Check(ic.SpellCount == 1 && ic.SpellAt(0) == 7, "0 and the repeat skipped");
for (uint s = 20; s < 30; s++) ic.AddSpell(s);
Check(ic.SpellCount == DebuffIcon.MaxSpells, $"capped at {DebuffIcon.MaxSpells} (got {ic.SpellCount})");
Check(Spells(ic).SequenceEqual(new uint[] { 7, 20, 21, 22 }), "first ones kept: " + string.Join(",", Spells(ic)));
Check(ic.SpellAt(-1) == 0 && ic.SpellAt(9) == 0, "out of range reads 0");
}
private static void TooltipText()
{
Case("tooltip wording: kind, what it does, the spells, when the first ends");
string t = DebuffTip.Text(DebuffKind.VulnFire, new[] { "Fire Vulnerability Other VII" }, 1, 83, estimated: true, self: false);
Check(t == "Fire vulnerability\nTakes more fire damage.\n Fire Vulnerability Other VII\nEnds in about 1:23", "monster fire vuln:\n" + t);
t = DebuffTip.Text(DebuffKind.VulnFire, new[] { "Fire Vulnerability Other VII" }, 1, 42, estimated: false, self: true);
Check(t.Contains("You take more fire damage.") && t.EndsWith("Ends in 42 s"), "yours: 'You take', exact time:\n" + t);
t = DebuffTip.Text(DebuffKind.Attributes, new[] { "Weakness Other VII", "Feeblemind Other VII" }, 6, 30, true, false);
Check(t.Contains("\n Weakness Other VII\n Feeblemind Other VII\n and 4 more\n") && t.EndsWith("First one ends in about 30 s"),
"stack of 6, two names known:\n" + t);
t = DebuffTip.Text(DebuffKind.Imperil, Array.Empty<string>(), 1, 0, true, false);
Check(t == "Imperil\nArmor lowered: physical hits land harder.", "no names (spell table not loaded), no time:\n" + t);
foreach (DebuffKind k in Enum.GetValues<DebuffKind>())
Check(DebuffTip.Title(k).Length > 0 && DebuffTip.Effect(k, false).Length > 0 && DebuffTip.Effect(k, true).Length > 0, $"{k} has words");
Check(DebuffTip.Time(0.2) == "1 s" && DebuffTip.Time(58.5) == "59 s" && DebuffTip.Time(59.5) == "1:00" && DebuffTip.Time(3725) == "1:02:05",
$"times: {DebuffTip.Time(0.2)} {DebuffTip.Time(58.5)} {DebuffTip.Time(59.5)} {DebuffTip.Time(3725)}");
Check(DebuffTip.More(1) == "1 more debuff than fits in the row." && DebuffTip.More(3) == "3 more debuffs than fit in the row.", "+N wording");
Check(DebuffTip.Others.StartsWith("Debuffed by someone else\n"), "others marker wording");
}
// ── Your debuff icon size (2026-10-28) ──────────────────────────────
private static void SelfIconSizeSetting()

View file

@ -31,6 +31,7 @@
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\HealthProbe.cs" Link="Engine\HealthProbe.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\DebuffIcon.cs" Link="Engine\DebuffIcon.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\SelfDebuffs.cs" Link="Engine\SelfDebuffs.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\DebuffTip.cs" Link="Engine\DebuffTip.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\PlateMetrics.cs" Link="Engine\PlateMetrics.cs" />
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\VitalLoss.cs" Link="Engine\VitalLoss.cs" />
</ItemGroup>

139
tools/plate_sight_check.py Normal file
View file

@ -0,0 +1,139 @@
#!/usr/bin/env python3
"""
Offline check of the AC facts behind the nameplates' "behind walls" rule
(src/RynthCore.Engine/Compatibility/AcCellSight.cs, 2026-11-04, problem report
R-20261105-020337-67aa) against an acclient.exe. Read-only: maps the file, runs nothing.
pe_pattern.py CHECK already proves the embedded CEnvCell::GetDrawnThisFrame pattern is
unique and lands on its VA. This checks the layout the engine reads, so a different
client build fails here instead of hiding plates in game:
* CEnvCell::GetDrawnThisFrame compares cell+0x130 with [device global]+0xB0, and
SetDrawnThisFrame writes that stamp to cell+0x130 (the same global);
* PView::DrawCells adds 1 to [global]+0xB0 before it draws, RenderDeviceD3D::Flip
adds 1 to its own +0xB0, and DrawEnvCell marks the cell before drawing it;
* CPhysicsObj::enter_cell stores the cell at +0x90 and the cell's +0x28 id at +0x4C;
* SmartBox::RenderNormalMode reads the viewer cell id at +0x0C and the viewer cell's
seen_outside through [+0x50]+0xE8;
* PView::DrawInside hands the cell's +0xE0 / +0xE4 (visible-cell list) to add_views;
* PView::ClipPortals walks the portal count at +0x108 and the array at +0x10C;
* D3DPolyRender::DrawPortalPolyInternal reads the polygon's point count at +0x0E;
* CCellPortal::UnPack stores 0xFFFFFFFF as the other cell of a doorway to outside;
* CEnvCell::UnPack stores seen_outside (flags & 1) at +0xE8 (this-0x30 frame: +0xB8).
Usage: python tools/plate_sight_check.py ["<path-to-acclient.exe>"]
Exit 0 = every check passed.
"""
import os
import struct
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from pe_pattern import read_window, matches # noqa: E402
DEFAULT_CLIENT = r"C:\Turbine\Asheron's Call\acclient.exe"
N = None
fails = 0
def check(ok, msg):
global fails
print(("ok " if ok else "FAIL ") + msg)
if not ok:
fails += 1
def main():
path = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_CLIENT
if not os.path.exists(path):
print(f"acclient.exe not found: {path}")
return 2
W, BASE = read_window(path)
def at(va, n):
o = va - BASE
return W[o:o + n]
def body_has(va, needle, span=0x200):
return W.find(bytes(needle), va - BASE, va - BASE + span) >= 0
# CEnvCell::GetDrawnThisFrame: mov eax,[ecx+130h]; mov ecx,[global]; cmp eax,[ecx+0B0h]; sete al; ret
pat = [0x8B, 0x81, 0x30, 0x01, 0x00, 0x00, 0x8B, 0x0D, N, N, N, N,
0x3B, 0x81, 0xB0, 0x00, 0x00, 0x00, 0x0F, 0x94, 0xC0, 0xC3]
ms = matches(W, pat, limit=4)
check(len(ms) == 1, f"GetDrawnThisFrame pattern unique ({len(ms)} match)")
if len(ms) != 1:
return 1
get_drawn = BASE + ms[0]
g = struct.unpack_from("<I", W, ms[0] + 8)[0]
print(f" GetDrawnThisFrame @ 0x{get_drawn:08X}, render device global 0x{g:08X}")
gb = list(struct.pack("<I", g))
# SetDrawnThisFrame (right after it): mov eax,[global]; mov edx,[eax+0B0h]; mov [ecx+130h],edx; ret
set_drawn = get_drawn + 0x20
check(at(set_drawn, 18) == bytes([0xA1] + gb + [0x8B, 0x90, 0xB0, 0, 0, 0, 0x89, 0x91, 0x30, 0x01, 0, 0, 0xC3]),
f"SetDrawnThisFrame @ 0x{set_drawn:08X} writes [global]+0xB0 to cell+0x130")
# CPhysicsPart's twin reads +0DCh from the same global (proves the stamp is the device's, shared).
twin = [0x8B, 0x81, 0xDC, 0x00, 0x00, 0x00, 0x8B, 0x0D] + gb + [0x3B, 0x81, 0xB0, 0, 0, 0, 0x0F, 0x94, 0xC0, 0xC3]
check(len(matches(W, twin, limit=4)) == 1, "CPhysicsPart::GetDrawnThisFrame compares the same device stamp")
# PView::DrawCells: mov eax,[global]; mov ecx,[eax+0B0h]; add esp,4; inc ecx; mov [eax+0B0h],ecx
draw_cells = 0x005A5950
check(body_has(draw_cells, [0xA1] + gb + [0x8B, 0x88, 0xB0, 0, 0, 0, 0x83, 0xC4, 0x04, 0x41, 0x89, 0x88, 0xB0, 0, 0, 0], 0x80),
"PView::DrawCells adds 1 to the device stamp before drawing")
# DrawEnvCell: mov esi,[esp+8]; mov ecx,esi; call GetDrawnThisFrame; test al,al; jnz; mov ecx,esi; call SetDrawnThisFrame
dec = 0x005A0280
ok = at(dec, 7) == bytes([0x56, 0x8B, 0x74, 0x24, 0x08, 0x8B, 0xCE]) and at(dec + 7, 1) == b"\xE8"
rel1 = struct.unpack_from("<i", W, dec + 8 - BASE)[0]
rel2 = struct.unpack_from("<i", W, dec + 0x17 - BASE)[0]
check(ok and dec + 12 + rel1 == get_drawn and dec + 0x1B + rel2 == set_drawn,
"DrawEnvCell tests GetDrawnThisFrame and calls SetDrawnThisFrame before drawing")
# Flip, after Present: mov eax,[esi+0B0h]; inc eax; pop edi; mov [esi+0B0h],eax (the device's own stamp)
flip = 0x005A0F60
check(body_has(flip, [0x8B, 0x86, 0xB0, 0, 0, 0, 0x40, 0x5F, 0x89, 0x86, 0xB0, 0, 0, 0], 0x100),
"RenderDeviceD3D::Flip adds 1 to +0xB0")
# CPhysicsObj::enter_cell: mov eax,[ebx+28h]; mov [esi+4Ch],eax ... mov [esi+90h],ebx
ec = 0x005119A0
check(body_has(ec, [0x8B, 0x43, 0x28, 0x89, 0x46, 0x4C], 0x80) and body_has(ec, [0x89, 0x9E, 0x90, 0x00, 0x00, 0x00], 0x90),
"CPhysicsObj::enter_cell: cell id from cell+0x28 to +0x4C, cell pointer to +0x90")
# SmartBox::RenderNormalMode: mov ecx,[esi+0Ch] (viewer cell id) ... mov edx,[esi+50h]; mov ecx,[edx+0E8h]
rnm = 0x00453B40
check(body_has(rnm, [0x8B, 0x4E, 0x0C], 0x40) and body_has(rnm, [0x8B, 0x56, 0x50, 0x8B, 0x8A, 0xE8, 0, 0, 0], 0x60),
"SmartBox::RenderNormalMode: viewer cell id +0x0C, viewer cell +0x50, its seen_outside +0xE8")
# PView::DrawInside: mov eax,[esi+0E4h]; xor ecx,ecx; mov cx,[esi+0E0h] (add_views' arguments)
di = 0x005A6970
check(body_has(di, [0x8B, 0x86, 0xE4, 0, 0, 0, 0x33, 0xC9, 0x66, 0x8B, 0x8E, 0xE0, 0, 0, 0], 0x80),
"PView::DrawInside hands the visible-cell list (+0xE0 count, +0xE4 ids) to add_views")
# PView::ClipPortals: mov ecx,[ebp+108h] (portal count) ... mov esi,[ebp+10Ch] (portal array)
cp = 0x005A6630
check(body_has(cp, [0x8B, 0x8D, 0x08, 0x01, 0, 0], 0x40) and body_has(cp, [0x8B, 0xB5, 0x0C, 0x01, 0, 0], 0x80),
"PView::ClipPortals: portal count +0x108, CCellPortal array +0x10C")
# D3DPolyRender::DrawPortalPolyInternal: mov al,[ebp+0Eh] (point count); mov eax,[ebp+0]; mov ecx,[eax+esi*4]
dp = 0x0059CCA0
check(body_has(dp, [0x8A, 0x45, 0x0E], 0x40) and body_has(dp, [0x8B, 0x45, 0x00, 0x8B, 0x0C, 0xB0, 0xD9, 0x01], 0x60),
"DrawPortalPolyInternal: CPolygon point count byte +0x0E, CVertex* array at +0, x first")
# CCellPortal::UnPack: test dl,4; ... mov dword [esi],0FFFFFFFFh (a doorway to the outside)
cu = 0x0053C810
check(body_has(cu, [0xF6, 0xC2, 0x04], 0x60) and body_has(cu, [0xC7, 0x06, 0xFF, 0xFF, 0xFF, 0xFF], 0x60),
"CCellPortal::UnPack: a doorway to outside has other cell 0xFFFFFFFF")
# CEnvCell::UnPack: and ecx,1; mov [esi+0B8h],ecx (this-0x30: +0xE8 seen_outside)
eu = 0x0052E0D0
check(body_has(eu, [0x83, 0xE1, 0x01, 0x89, 0x8E, 0xB8, 0, 0, 0], 0x40),
"CEnvCell::UnPack stores seen_outside (flags & 1) at +0xE8")
print()
print("PASS" if fails == 0 else f"{fails} FAILED")
return 0 if fails == 0 else 1
if __name__ == "__main__":
sys.exit(main())

View file

@ -62,9 +62,11 @@ def _secs(line: str):
def pid_log_groups():
"""Map pid -> [its log files sorted oldest-first], covering rotations
(RynthCore.<pid>.log plus .log.old / .log.N). The engine rotates at ~5 MB:
right after a rotation the live .log is a tiny fragment and the soak's
history is in .log.old, so scoring only .log would miss the whole run.
(RynthCore.<pid>.log plus .log.old and the older .log.old.1 ... .log.old.N,
LogRotation.cs). The engine rotates at ~5 MB: right after a rotation the
live .log is a tiny fragment and the soak's history is in the .old copies,
so scoring only .log would miss the whole run. Rotation keeps each copy's
last-write time, so sorting by mtime puts them in order.
Each pid is analyzed over its concatenated files in chronological order."""
groups = {}
for f in glob.glob(os.path.join(LOG_DIR, "RynthCore.*.log*")):