Snapshot for release 2026.10.28.1 (internal de8d80b)

This commit is contained in:
Tom Bohar 2026-10-28 06:36:37 -04:00
commit 8728446a27
46 changed files with 2522 additions and 259 deletions

View file

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the ambient light floor's pure part (2026-10-27, plugin API v91):
src\RynthCore.Engine\D3D9\AmbientLightPolicy.cs, compiled in. Per channel the brighter of
AC's ambient and the floor, AC's alpha byte kept, the floor's alpha ignored, floor 0 = AC's
colour unchanged, never darker than AC's. No AC, no files.
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>AmbientLightTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\D3D9\AmbientLightPolicy.cs" Link="Engine\AmbientLightPolicy.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,110 @@
using RynthCore.Engine.D3D9;
namespace AmbientLightTests;
/// <summary>The ambient light floor's colour rule (AmbientLightPolicy, plugin API v91).</summary>
internal static class Program
{
private static int _checks, _failed;
private static string _case = "";
// What AC sets in a dungeon: SetWorldAmbientLight(0.2, white) = 51 per channel, alpha 0xFF.
private const uint Dungeon = 0xFF333333;
private static int Main()
{
NoFloorPassesThrough();
FloorLiftsADungeon();
NeverDarker();
PerChannel();
AlphaBytes();
FloorRgb();
Exhaustive();
Console.WriteLine(_failed == 0 ? $"PASS ({_checks} assertions)" : $"FAIL ({_failed} of {_checks} assertions)");
return _failed == 0 ? 0 : 1;
}
private static void Case(string name) { _case = name; Console.WriteLine("ok " + name); }
private static void Check(bool ok, string what)
{
_checks++;
if (ok) return;
_failed++;
Console.WriteLine($"FAIL {_case}: {what}");
}
private static void Eq(uint got, uint want, string what) =>
Check(got == want, $"{what}: got 0x{got:X8}, want 0x{want:X8}");
private static void NoFloorPassesThrough()
{
Case("NoFloorPassesThrough");
foreach (uint c in new uint[] { 0, Dungeon, 0xFFFFFFFF, 0x00123456, 0x80FEDCBA })
{
Eq(AmbientLightPolicy.Apply(c, 0), c, $"floor 0 keeps 0x{c:X8}");
// A floor with only an alpha byte is no floor (D3D ignores the ambient's alpha).
Eq(AmbientLightPolicy.Apply(c, 0xFF000000), c, $"alpha-only floor keeps 0x{c:X8}");
}
}
private static void FloorLiftsADungeon()
{
Case("FloorLiftsADungeon");
Eq(AmbientLightPolicy.Apply(Dungeon, 0x808080), 0xFF808080, "50 % grey over AC's 20 %");
Eq(AmbientLightPolicy.Apply(Dungeon, 0xFFFFFF), 0xFFFFFFFF, "full white");
// A floor at or below AC's own changes nothing.
Eq(AmbientLightPolicy.Apply(Dungeon, 0x333333), Dungeon, "floor equal to AC's");
Eq(AmbientLightPolicy.Apply(Dungeon, 0x202020), Dungeon, "floor below AC's");
}
private static void NeverDarker()
{
Case("NeverDarker");
// Outdoors at noon AC's ambient is bright: a dungeon-sized floor leaves it alone.
Eq(AmbientLightPolicy.Apply(0xFFC8C8B4, 0x808080), 0xFFC8C8B4, "noon stays noon");
Eq(AmbientLightPolicy.Apply(0xFFFFFFFF, 0x010101), 0xFFFFFFFF, "white stays white");
}
private static void PerChannel()
{
Case("PerChannel");
// A warm floor over grey: red and green lifted, blue AC's where AC's is brighter.
Eq(AmbientLightPolicy.Apply(Dungeon, 0xA08C20), 0xFFA08C33, "warm torch tint");
// A blue-ish AC colour (night sky) under a white floor: each channel the brighter.
Eq(AmbientLightPolicy.Apply(0xFF102060, 0x404040), 0xFF404060, "night sky under grey");
}
private static void AlphaBytes()
{
Case("AlphaBytes");
Eq(AmbientLightPolicy.Apply(0x00333333, 0xFF808080), 0x00808080, "AC's alpha 00 kept, floor's FF ignored");
Eq(AmbientLightPolicy.Apply(0x7F333333, 0x00808080), 0x7F808080, "AC's alpha 7F kept, floor's 00 ignored");
}
private static void FloorRgb()
{
Case("FloorRgb");
Eq(AmbientLightPolicy.FloorRgb(0xFF808080), 0x00808080, "alpha dropped");
Eq(AmbientLightPolicy.FloorRgb(0xFF000000), 0, "alpha only = no floor");
Eq(AmbientLightPolicy.FloorRgb(0x00010203), 0x00010203, "colour kept");
}
private static void Exhaustive()
{
Case("Exhaustive");
// Every channel pair: the result is max(a, b), and the other channels are untouched.
int bad = 0;
for (uint a = 0; a < 256; a += 5)
for (uint b = 0; b < 256; b += 3)
{
uint client = 0xFF000000 | (a << 16) | (7u << 8) | 9u;
uint floor = (b << 16) | 1u;
uint got = AmbientLightPolicy.Apply(client, floor);
uint want = 0xFF000000 | (Math.Max(a, b) << 16) | (7u << 8) | 9u;
if (got != want) bad++;
}
Check(bad == 0, $"{bad} red pairs wrong");
}
}

View file

@ -57,6 +57,7 @@ internal static class Program
LineColorTags();
LineColorKinds();
LineColorDefaultsUnchanged();
LineColorRetail();
LineColorPrecedence();
LineColorJson();
@ -339,8 +340,9 @@ internal static class Program
private static void LineColorDefaultsUnchanged()
{
Case("line colours: with nothing set every line looks as before");
Case("line colours: with nothing set and Retail colours off every line looks as before");
ChatLineColors.ResetAll();
ChatLineColors.RetailColors = false;
Check(!ChatLineColors.AnySet && ChatLineColors.ToJson() == null, "nothing set");
var kinds = ChatLineColors.ChatKinds.Concat(ChatLineColors.ChannelKinds).Select(k => k.Key)
.Append("chan:Wiki").Append(null).ToArray();
@ -355,6 +357,46 @@ internal static class Program
Check(ChatLineColors.EffectiveArgb(k) == OldChannelArgb(k.Tab), $"{k.Label} shows its tab's colour");
foreach (ChatColorKind k in ChatLineColors.TabKinds)
Check(ChatLineColors.EffectiveArgb(k) == OldChannelArgb(k.Tab), $"tab {k.Label} shows its built-in colour");
foreach (string tab in AllTabsAndOdd)
Check(ChatLineColors.Resolve(null, null, tab, 0x07) == OldChannelArgb(tab), $"a magic line in '{tab}' with Retail colours off");
ChatLineColors.RetailColors = true;
}
private static void LineColorRetail()
{
Case("line colours: Retail colours give each kind of line AC's own colour");
ChatLineColors.ResetAll();
Check(ChatLineColors.RetailColors, "on by default");
const uint Magic = 0xFF3FBFFF, Combat = 0xFFFF3F3F, TellIn = 0xFFFFFF3F, White = 0xFFFFFFFF, Purple = 0xFFFF7FFF;
Check(ChatLineColors.Resolve(null, null, "Combat", 0x07) == Magic, "magic (0x07): light blue");
Check(ChatLineColors.Resolve(null, null, "Combat", 0x11) == Magic, "spellcasting (0x11): light blue");
Check(ChatLineColors.Resolve(null, null, "Combat", 0x06) == Combat, "combat (0x06): red");
Check(ChatLineColors.Resolve(null, null, "Combat", 0x15) == Combat, "combat enemy (0x15): red");
Check(ChatLineColors.Resolve(null, null, "Combat", 0x16) == 0xFFF57572, "combat self (0x16): light red");
Check(ChatLineColors.Resolve(null, "tell", "Chat", 0x03) == TellIn, "a tell: yellow");
Check(ChatLineColors.Resolve(null, "say", "Chat", 0x02) == White, "speech: white");
Check(ChatLineColors.Resolve(null, null, "System", 0x05) == Purple, "system: purple");
Check(ChatLineColors.Resolve(null, "allegiance", "Chat", 0x12) == 0xFFEE921E, "allegiance: orange");
Check(ChatLineColors.RetailArgb(0x21) != null && ChatLineColors.RetailArgb(0x22) == null && ChatLineColors.RetailArgb(-1) == null,
"the table covers 0x00-0x21");
Check(ChatLineColors.Resolve(null, null, "Combat", -1) == OldChannelArgb("Combat"), "an unknown type: the tab's colour");
Check(ChatLineColors.Resolve(null, null, "Other", 0x40) == OldChannelArgb("Other"), "a type past the table: the tab's colour");
Check(ChatLineColors.Resolve(null, null, "Rynth", 0x05) == OldChannelArgb("Rynth"), "a Rynth line keeps its amber");
Check(ChatLineColors.Resolve(null, null, "Items", 0x02) == OldChannelArgb("Items"), "an Items line keeps its teal");
ChatColorKind say = ChatLineColors.ChatKinds.First(k => k.Key == "say");
Check(ChatLineColors.EffectiveArgb(say) == White, "the settings show an unset Say as AC's white");
ChatColorKind general = ChatLineColors.ChannelKinds.First(k => k.Key == "chan:General");
Check(ChatLineColors.EffectiveArgb(general) == 0xFFFF9696, "and an unset channel as AC's channel pink");
const uint Mine = 0xFF102030, TabMine = 0xFF405060, Rule = 0xFF708090;
ChatLineColors.Set("tell", Mine);
Check(ChatLineColors.Resolve(null, "tell", "Chat", 0x03) == Mine, "a kind colour the user set wins");
ChatLineColors.Set("tab:Combat", TabMine);
Check(ChatLineColors.Resolve(null, null, "Combat", 0x07) == TabMine, "a tab colour the user set wins over AC's");
Check(ChatLineColors.EffectiveArgb(ChatLineColors.ChatKinds.First(k => k.Key == "emote")) == 0xFFD2D2C8, "other tabs' kinds still AC's (emote grey)");
Check(ChatLineColors.Resolve(Rule, "tell", "Chat", 0x03) == Rule, "a rule's colour wins over everything");
ChatLineColors.ResetAll();
}
private static void LineColorPrecedence()

View file

@ -170,6 +170,34 @@ namespace CombatSettingsTests
rule.GetProperty("AttackPower")!.SetValue(r3, "Variable");
Check(!(bool)equal.Invoke(null, new object[] { Lst(r1), Lst(r3) })!, "a changed Power is a change (it is saved)");
// ── The monster rule: the Void debuffs (2026-10-27) ─────────────────────────
string[] voidFields = { "Corrosion", "Corruption", "DestructiveCurse", "WeakeningCurse", "FesteringCurse" };
var voidDefs = ((string Field, string Label, string Tip)[])damage.GetField("VoidDebuffDefs", All)!.GetValue(null)!;
Check(voidDefs.Select(d => d.Field).SequenceEqual(voidFields), "the Void debuffs are spelled as RynthAi's MonsterRule fields");
MethodInfo getT = rule.GetMethod("GetToggle", All)!, setT = rule.GetMethod("SetToggle", All)!;
object allVoid = Activator.CreateInstance(rule, nonPublic: true)!;
foreach (string f in voidFields)
{
object off = Activator.CreateInstance(rule, nonPublic: true)!, on = Activator.CreateInstance(rule, nonPublic: true)!;
Check(!(bool)getT.Invoke(off, new object[] { f })!, f + " is off on a new rule");
setT.Invoke(on, new object[] { f, true });
setT.Invoke(allVoid, new object[] { f, true });
Check((bool)rule.GetProperty(f)!.GetValue(on)! && (bool)getT.Invoke(on, new object[] { f })!, f + " is a toggle on its own property");
Check(!(bool)equal.Invoke(null, new object[] { Lst(off), Lst(on) })!, f + " changed is a change (it is saved)");
}
MethodInfo marks = damage.GetMethod("DebuffMarks", All)!;
Check((string)marks.Invoke(null, new[] { allVoid })! == "CRDWH", "the Damage panel marks them C R D W H");
MethodInfo copy = damage.GetMethod("CopyOfDefault", All)!;
object copied = copy.Invoke(null, new[] { allVoid, "Drudge" })!;
Check(voidFields.All(f => (bool)rule.GetProperty(f)!.GetValue(copied)!), "a monster's own rule starts with Default's Void debuffs");
// RynthAi keeps its own Void switches when the panel's JSON has no "Corrosion": key
// (an older engine), so this engine must write exactly that.
var panelJson = (System.Text.Json.Serialization.JsonSerializerContext)engine.GetType("RynthCore.Engine.UI.Panels.MonstersPanelJsonContext", throwOnError: true)!
.GetProperty("Default", All)!.GetValue(null)!;
string ruleJson = JsonSerializer.Serialize((object)Lst(allVoid), listType, panelJson);
foreach (string f in voidFields)
Check(ruleJson.Contains($"\"{f}\":true"), $"the panel sends \"{f}\":true");
return Finish();
}

View file

@ -6,8 +6,12 @@
Compatibility\AcKeymapText.cs is compiled in as is, with Hotkeys\HotkeyModel.cs: reading the
groups and bindings, the modifier bits from MetaKeys, key names (AC's spellings, aliases matched),
binding a key so it comes off every other action in the game's groups (never the text-editing
ones), unbinding, a new group when there is none, and the CRLF text round trip. Also runs on a
copy of the player's own Normal.keymap in memory when there is one; never writes it.
ones), unbinding, a new group when there is none, and the CRLF text round trip. And (2026-10-27)
the change every other client makes to its own keys: the edits recorded in "<keymap>.rynthcore" and
read back, made to a client with different keys of its own (they stay, the change lands, a key
that clashed comes off), twice = nothing, all or nothing, other MetaKeys numbers, an older
engine's marker, what is pending after a hot reload. Also runs on a copy of the player's own
Normal.keymap in memory when there is one; never writes it.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>

View file

@ -105,6 +105,17 @@ internal static class Program
Unbind();
RoundTrip();
Describe();
Take();
Mods();
ChangesRoundTrip();
FollowKeepsOwnKeys();
FollowTwiceIsNothing();
FollowAllOrNothing();
FollowOtherMetaNumbers();
FollowRecordedGroup();
OlderMarker();
PendingAndReload();
ChangesBadLines();
RealFile();
Console.WriteLine($"{_passed} passed, {_failed} failed.");
return _failed == 0 ? 0 : 1;
@ -275,6 +286,251 @@ internal static class Program
Eq(AcKeymapText.Describe("LOGOUT"), "LOGOUT", "all capitals");
}
private static void Take()
{
List<string> lines = Lines();
List<AcKeymapText.Line> t = AcKeymapText.Take(lines, 0, "DIK_F5", 0);
Check(t.Count == 1 && t[0].Action == "ToggleSpellbookPanel", "F5 taken off the spellbook");
Eq(AcKeymapText.Uses(lines, 0, "DIK_F5", 0).Count, 0, "nothing has F5");
Eq(AcKeymapText.Take(lines, 0, "DIK_HOME", 0).Count, 0, "Home: only a text group has it");
Eq(Of(lines, "CursorStartOfLine").Count, 1, "the chat box keeps Home");
Eq(AcKeymapText.GroupOf(lines, "UseQuickSlot_1", 0, "DIK_1", 2), "QuickslotCommands", "Ctrl+1's group");
Eq(AcKeymapText.GroupOf(lines, "UseQuickSlot_1", 0, "DIK_2", 0), "", "a key the action hasn't");
}
private static void Mods()
{
List<string> lines = Lines();
Eq(AcKeymapText.ModsOf(lines, 0), "", "no modifiers");
Eq(AcKeymapText.ModsOf(lines, 2), "DIK_LCONTROL|DIK_RCONTROL", "Ctrl by its names");
Eq(AcKeymapText.ModsOf(lines, 3), "DIK_LSHIFT+DIK_LCONTROL|DIK_RCONTROL", "Shift+Ctrl");
Eq(AcKeymapText.ModsOf(lines, 4), "DIK_LMENU|DIK_RMENU", "Alt (DIK_RALT read as DIK_RMENU)");
Eq(AcKeymapText.ModsOf(lines, 0x10), "DIMOFS_BUTTON3", "a mouse button as a metakey");
Eq(AcKeymapText.ModsOf(lines, 0x8), "0x00000008", "a bit no metakey names: the raw mask");
foreach (uint m in new uint[] { 0, 2, 3, 4, 0x10, 0x8, 0x16 })
Check(AcKeymapText.TryMaskOf(lines, AcKeymapText.ModsOf(lines, m), out uint back, out _) && back == m, $"mask 0x{m:X} back from its names");
List<string> noAlt = Lines(Sample.Replace(" 3 [ 0 DIK_LMENU ]\r\n", "").Replace(" 3 [ 0 DIK_RALT ]\r\n", ""));
Check(!AcKeymapText.TryMaskOf(noAlt, "DIK_LMENU|DIK_RMENU", out _, out string err) && err.Contains("DIK_LMENU"), "a keymap without Alt: can't");
}
// What AcKeymapLive's changer records for a bind it made (the same calls), as one change.
private static AcKeymapText.Edit BindEdit(List<string> lines, string action, string dik, uint meta)
{
Check(AcKeymapText.Bind(lines, action, 0, dik, meta, out _, out string err), $"changer: bind {action} {dik} ({err})");
return new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, action, 0, AcKeymapText.Canonical(dik), AcKeymapText.ModsOf(lines, meta),
AcKeymapText.GroupOf(lines, action, 0, dik, meta));
}
private static AcKeymapText.Change One(long stamp, int pid, params AcKeymapText.Edit[] edits) => new(stamp, pid, edits.ToList());
private static List<AcKeymapText.Change> RoundTrip(List<AcKeymapText.Change> log)
{
List<AcKeymapText.Change> back = AcKeymapText.ParseChanges(AcKeymapText.FormatChanges(log), out bool older);
Check(!older, "a log isn't an older marker");
return back;
}
private static void ChangesRoundTrip()
{
var log = new List<AcKeymapText.Change>
{
One(1000, 11, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "UseQuickSlot_10", 0, "DIK_F5", "", "QuickslotCommands")),
One(2000, 12, new AcKeymapText.Edit(AcKeymapText.EditKind.Unbind, "UseQuickSlot_1", 0, "DIK_1", "DIK_LCONTROL|DIK_RCONTROL"),
new AcKeymapText.Edit(AcKeymapText.EditKind.Take, "", 1, "DIMOFS_BUTTON3", "0x00000008")),
};
string text = AcKeymapText.FormatChanges(log);
Check(text.StartsWith(AcKeymapText.ChangesHeader + "\r\n"), "the log starts with its header");
Check(text.Contains("\r\n2000 12 take - 1 DIMOFS_BUTTON3 0x00000008 -\r\n"), "a take line: " + text);
List<AcKeymapText.Change> back = RoundTrip(log);
Eq(back.Count, 2, "two changes back");
Check(back.Count == 2 && back[0].Stamp == 1000 && back[0].Pid == 11 && back[0].Edits.SequenceEqual(log[0].Edits), "the first, edit for edit");
Check(back.Count == 2 && back[1].Edits.SequenceEqual(log[1].Edits), "the second (two edits, in order)");
// Newest, the next stamp (past another clock's), keeping the newest few.
Eq(AcKeymapText.Newest(back), 2000L, "newest stamp");
Eq(AcKeymapText.NextStamp(back, 5000), 5000L, "now when it is later");
Eq(AcKeymapText.NextStamp(back, 1500), 2001L, "past the newest when now is earlier");
Eq(AcKeymapText.NextStamp(new List<AcKeymapText.Change>(), 7), 7L, "an empty log: now");
var kept = new List<AcKeymapText.Change>();
for (int i = 1; i <= 70; i++) kept = AcKeymapText.Append(kept, One(i, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Take, "", 0, "DIK_F1", "")), 64);
Check(kept.Count == 64 && kept[0].Stamp == 7 && kept[^1].Stamp == 70, "the newest 64 kept");
Eq(RoundTrip(kept).Count, 64, "a full log reads back");
// Out of order in the file: read by stamp.
string swapped = AcKeymapText.ChangesHeader + "\r\n"
+ "300 5 take - 0 DIK_F2 - -\r\n"
+ "100 6 take - 0 DIK_F3 - -\r\n";
List<AcKeymapText.Change> s = AcKeymapText.ParseChanges(swapped, out _);
Check(s.Count == 2 && s[0].Stamp == 100 && s[1].Stamp == 300, "by stamp");
}
// The player's report: keys changed in Configure Keyboard in one client (unsaved, in memory) came back when
// another client changed a key, because every other client loaded the whole file. Now each makes the edits to
// its own keys (AC writes them out: here, its own text).
private static string ClientB() => Sample
.Replace(" ToggleSpellbookPanel [ \"\" [ 0 DIK_F5 ] ]", " ToggleSpellbookPanel [ \"\" [ 0 DIK_F6 ] ]\r\n ToggleMapPanel [ \"\" [ 0 DIK_F5 ] ]")
.Replace(" ToggleOptionsPanel [ \"\" [ 0 DIK_F11 ] ]", " ToggleOptionsPanel [ \"\" [ 0 DIK_F12 ] ]")
.Replace(" UseQuickSlot_5 [ \"\" [ 0 DIK_5 ] ]\r\n", "");
private static List<AcKeymapText.Change> ChangesByA()
{
List<string> a = Lines(); // client A, the changer: its keys (saved first), then its edits
var log = new List<AcKeymapText.Change>();
log = AcKeymapText.Append(log, One(100, 1, BindEdit(a, "UseQuickSlot_10", "DIK_F5", 0)), 64);
log = AcKeymapText.Append(log, One(200, 1, BindEdit(a, "UseQuickSlot_2", "DIK_1", 2)), 64);
Check(AcKeymapText.Unbind(a, "MovementForward", 0, "DIK_UPARROW", 0), "changer: Up off forward");
log = AcKeymapText.Append(log, One(300, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Unbind, "MovementForward", 0, "DIK_UPARROW", "")), 64);
// A command's key ("/rdef use 20" on Alt+5): off every game action.
AcKeymapText.Take(a, 0, "DIK_5", 4);
log = AcKeymapText.Append(log, One(400, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Take, "", 0, "DIK_5", AcKeymapText.ModsOf(a, 4))), 64);
return RoundTrip(log); // as the follower reads it from "<keymap>.rynthcore"
}
private static void FollowKeepsOwnKeys()
{
List<AcKeymapText.Change> log = ChangesByA();
Eq(log.Count, 4, "four changes recorded");
List<string> b = Lines(ClientB());
List<AcKeymapText.Change> pending = AcKeymapText.Pending(log, 50, 2);
Eq(pending.Count, 4, "client B has all four to make");
Eq(AcKeymapText.ApplyChanges(b, pending, out string err), 1, "client B makes them (" + err + ")");
// The change landed.
List<AcKeymapText.Line> s10 = Of(b, "UseQuickSlot_10");
Check(s10.Count == 1 && s10[0].Dik == "DIK_F5" && s10[0].Meta == 0 && s10[0].Group == "QuickslotCommands", "B: slot 10 has F5");
List<AcKeymapText.Line> s2 = Of(b, "UseQuickSlot_2");
Check(s2.Count == 1 && s2[0].Dik == "DIK_1" && s2[0].Meta == 2, "B: slot 2 has Ctrl+1");
// A key that conflicted in B's own keys came off.
Eq(Of(b, "ToggleMapPanel").Count, 0, "B: its map panel lost F5 to slot 10");
List<AcKeymapText.Line> s1 = Of(b, "UseQuickSlot_1");
Check(s1.Count == 1 && s1[0].Meta == 0, "B: slot 1 lost Ctrl+1, keeps 1");
Eq(Of(b, "UseQuickSlot_14").Count, 0, "B: Alt+5 taken for the command");
List<AcKeymapText.Line> fwd = Of(b, "MovementForward");
Check(fwd.Count == 1 && fwd[0].Dik == "DIK_W", "B: forward lost Up, keeps W");
// B's own keys, different from A's and never in the file, stayed.
List<AcKeymapText.Line> book = Of(b, "ToggleSpellbookPanel");
Check(book.Count == 1 && book[0].Dik == "DIK_F6", "B: its spellbook stays on F6 (A's was F5)");
List<AcKeymapText.Line> opts = Of(b, "ToggleOptionsPanel");
Check(opts.Count == 1 && opts[0].Dik == "DIK_F12", "B: its options stay on F12 (A's was F11)");
Eq(Of(b, "UseQuickSlot_5").Count, 0, "B: slot 5's key it deleted stays deleted");
Eq(Of(b, "CopyText").Count, 1, "B: copy keeps Ctrl+C");
}
private static void FollowTwiceIsNothing()
{
List<AcKeymapText.Change> log = ChangesByA();
List<string> b = Lines(ClientB());
Eq(AcKeymapText.ApplyChanges(b, log, out _), 1, "made once");
var after = new List<string>(b);
Eq(AcKeymapText.ApplyChanges(b, log, out string err), 0, "made again: nothing to do (" + err + ")");
Check(after.SequenceEqual(b), "the text is the same");
// The changer itself (its keys hold every edit): nothing either.
List<string> a = Lines();
AcKeymapText.ApplyChanges(a, log, out _);
var a1 = new List<string>(a);
Eq(AcKeymapText.ApplyChanges(a, log, out _), 0, "the changer's own keys: nothing to do");
Check(a1.SequenceEqual(a), "the changer's text is the same");
}
private static void FollowAllOrNothing()
{
// The second edit can't be made (an action with no group): the first isn't made either.
List<string> b = Lines(ClientB());
var before = new List<string>(b);
var log = new List<AcKeymapText.Change>
{
One(100, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "UseQuickSlot_10", 0, "DIK_F5", "")),
One(200, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "SomeNewAction", 0, "DIK_F7", "")),
};
Check(AcKeymapText.ApplyChanges(b, log, out string err) == -1 && err.Contains("SomeNewAction"), "can't: the error names it (" + err + ")");
Check(before.SequenceEqual(b), "the keys as they were (no part made)");
// A modifier this keymap hasn't: can't, keys as they were.
var alt = new List<AcKeymapText.Change> { One(100, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "UseQuickSlot_3", 0, "DIK_3", "DIK_LWIN")) };
Check(AcKeymapText.ApplyChanges(b, alt, out _) == -1 && before.SequenceEqual(b), "an unknown modifier: can't, nothing made");
}
private static void FollowOtherMetaNumbers()
{
// B's keymap numbers Ctrl 3 and Alt 2: A's Ctrl+1 is still Ctrl+1 there (mask 0x4, not 0x2).
string swappedMeta = ClientB()
.Replace(" 2 [ 0 DIK_LCONTROL ]\r\n 2 [ 0 DIK_RCONTROL ]\r\n 3 [ 0 DIK_LMENU ]\r\n 3 [ 0 DIK_RALT ]",
" 2 [ 0 DIK_LMENU ]\r\n 2 [ 0 DIK_RALT ]\r\n 3 [ 0 DIK_LCONTROL ]\r\n 3 [ 0 DIK_RCONTROL ]")
.Replace("[ 0 DIK_1 ] 0x00000002 ]", "[ 0 DIK_1 ] 0x00000004 ]")
.Replace("[ 0 DIK_C ] 0x00000002 ]", "[ 0 DIK_C ] 0x00000004 ]")
.Replace("[ 0 DIK_5 ] 0x00000004 ]", "[ 0 DIK_5 ] 0x00000002 ]");
List<string> b = Lines(swappedMeta);
Check(AcKeymapText.TryMeta(b, HotkeyMods.Ctrl, out uint ctrl, out _) && ctrl == 4, "B's Ctrl is 0x4");
Eq(AcKeymapText.ApplyChanges(b, ChangesByA(), out string err), 1, "B makes A's changes (" + err + ")");
List<AcKeymapText.Line> s2 = Of(b, "UseQuickSlot_2");
Check(s2.Count == 1 && s2[0].Meta == 4, "B: slot 2 has Ctrl+1 by B's numbers");
List<AcKeymapText.Line> s1 = Of(b, "UseQuickSlot_1");
Check(s1.Count == 1 && s1[0].Meta == 0, "B: slot 1 lost Ctrl+1 (its 0x4)");
Eq(Of(b, "UseQuickSlot_14").Count, 0, "B: Alt+5 (its 0x2) taken");
}
private static void FollowRecordedGroup()
{
// B has no line for the action and it has no default group: the changer's group is where it goes.
List<string> b = Lines(ClientB());
var log = new List<AcKeymapText.Change>
{ One(100, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "ToggleInventoryPanel", 0, "DIK_I", "", "UICommands")) };
Eq(AcKeymapText.ApplyChanges(b, RoundTrip(log), out string err), 1, "bound in the recorded group (" + err + ")");
List<AcKeymapText.Line> inv = Of(b, "ToggleInventoryPanel");
Check(inv.Count == 1 && inv[0].Group == "UICommands", "in UICommands");
// A recorded text group is never used for a game key.
List<string> c = Lines(ClientB());
var bad = new List<AcKeymapText.Change>
{ One(100, 1, new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, "ToggleInventoryPanel", 0, "DIK_I", "", "EditControls")) };
Eq(AcKeymapText.ApplyChanges(c, bad, out _), -1, "a text group recorded: no group, can't");
}
private static void OlderMarker()
{
// What an older RynthCore wrote: the keymap's time alone. Known as older, nothing to make.
List<AcKeymapText.Change> l = AcKeymapText.ParseChanges("638652816000000000", out bool older);
Check(older && l.Count == 0, "an older marker: older, no changes");
l = AcKeymapText.ParseChanges("638652816000000000\r\n", out older);
Check(older && l.Count == 0, "with a line end too");
l = AcKeymapText.ParseChanges("", out older);
Check(!older && l.Count == 0, "empty: nothing, not older");
l = AcKeymapText.ParseChanges("something else\r\n1 2 take - 0 DIK_F1 - -", out older);
Check(!older && l.Count == 0, "not a log: nothing");
l = AcKeymapText.ParseChanges("RynthCore keymap changes 1\r\n1 2 take - 0 DIK_F1 - -", out older);
Check(!older && l.Count == 0, "a version before 2: nothing");
l = AcKeymapText.ParseChanges("RynthCore keymap changes 3\r\n1 2 take - 0 DIK_F1 - -", out older);
Check(!older && l.Count == 1, "a later version: the lines it can read");
}
private static void PendingAndReload()
{
List<AcKeymapText.Change> log = ChangesByA();
// The changer (pid 1) never makes its own again; another client what's past what it made.
Eq(AcKeymapText.Pending(log, 0, 1).Count, 0, "the changer's own: none");
Eq(AcKeymapText.Pending(log, 200, 2).Count, 2, "past 200: two");
// After a hot reload the engine starts at what the last one made (its newest): nothing again.
Eq(AcKeymapText.Pending(log, AcKeymapText.Newest(log), 2).Count, 0, "after a reload: nothing made again");
// A client started after them: none (AC loaded the file with them); one started before: all.
Eq(AcKeymapText.Pending(log, 350, 3).Count, 1, "started at 350: the one after");
// An empty change is never pending.
var empty = new List<AcKeymapText.Change> { new(500, 4, new List<AcKeymapText.Edit>()) };
Eq(AcKeymapText.Pending(empty, 0, 2).Count, 0, "an empty change: nothing");
}
private static void ChangesBadLines()
{
// A change with a line this version can't read is left out whole; the others stay.
string text = AcKeymapText.ChangesHeader + "\r\n"
+ "100 1 bind UseQuickSlot_1 0 DIK_F1 - QuickslotCommands\r\n"
+ "200 1 bind UseQuickSlot_2 0 DIK_F2 - -\r\n"
+ "200 1 rebind UseQuickSlot_2 0 DIK_F3 - -\r\n"
+ "300 1 take - 0 DIK_F4 - -\r\n"
+ "300 1 take - 0 DIK_F4\r\n"
+ "400 1 unbind UseQuickSlot_4 0 DIK_F4 DIK_LCONTROL|DIK_RCONTROL -\r\n"
+ "garbage\r\n"
+ "500 1 bind Bad-Name 0 DIK_F5 - -\r\n"
+ "# a note\r\n";
List<AcKeymapText.Change> l = AcKeymapText.ParseChanges(text, out _);
Check(l.Count == 2 && l[0].Stamp == 100 && l[1].Stamp == 400, "only the whole, readable changes: " + string.Join(",", l.Select(c => c.Stamp)));
Check(l.Count == 2 && l[1].Edits[0].Mods == "DIK_LCONTROL|DIK_RCONTROL", "the modifiers kept");
}
private static void RealFile()
{
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Asheron's Call", "Normal.keymap");

View file

@ -601,12 +601,12 @@ internal static class Program
Eq((int)Marshal.OffsetOf<RynthCore.PluginSdk.TrainingEntryNative>(f.Name), (int)Marshal.OffsetOf<RynthCore.Engine.Plugins.TrainingEntryNative>(f.Name), "TrainingEntryNative." + f.Name + " offset");
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-v90 follow:
// eleven slots to v89, then v90's thirteen).
var names = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(24).TakeLast(6).ToArray();
// 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();
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(24).TakeLast(6).ToArray();
var sdkNames = typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(26).TakeLast(6).ToArray();
Check(sdkNames.SequenceEqual(names), "SDK v79, v80 and v81 slots in the same order");
}
@ -617,6 +617,18 @@ 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();
// 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" };
Check(all.TakeLast(v91.Length).SequenceEqual(v91), "v91 slots last: " + string.Join(",", all.TakeLast(v91.Length)));
Check(sdkAll.TakeLast(v91.Length).SequenceEqual(v91), "SDK v91 slots last: " + string.Join(",", sdkAll.TakeLast(v91.Length)));
foreach (string slot in v91)
Eq((int)Marshal.OffsetOf<RynthCore.PluginSdk.RynthCoreApiNative>(slot),
(int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>(slot), slot + " offset");
Eq((int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>("SetAmbientLightFloorFn"),
(int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>("DropTargetFn") + IntPtr.Size, "SetAmbientLightFloorFn right after DropTargetFn");
all = all.SkipLast(v91.Length).ToArray();
sdkAll = sdkAll.SkipLast(v91.Length).ToArray();
// v90: the frameless-window slots and the settings drawers end the table; the checks after these
// are on the table before them.
string[] v90 = { "PanelDragWithLastItemFn", "SetPanelPopOutFn", "PanelTextSizeFn", "RenderSettingsDrawerFn",

View file

@ -0,0 +1,344 @@
using System.Globalization;
using RynthCore.Engine.ImGuiBackend.Hud;
namespace RynthCore.Engine.UI
{
/// <summary>Stub: counts saves, never runs them (no file I/O in the tests).</summary>
internal static class UiBackgroundWriter
{
public static int Enqueued;
public static void Enqueue(string label, Action work) => Enqueued++;
}
}
namespace SelfPlateTests
{
using S = MonsterHudSettings;
/// <summary>Your own plate's look switches, the lock from Follow mode, and the "Debuffs on you" selection.</summary>
internal static class Program
{
private static int _checks, _failed;
private static string _case = "";
private static int Main()
{
LookDefaultsOn();
OldFileLoadsThemOn();
EachToggleRoundTrips();
ResetTurnsThemBackOn();
UnlockFromFixed();
UnlockFromFollowFixesIt();
LockFromFollowStaysFollow();
HarmfulOnly();
CooldownsAndZeroIdsDropped();
ExpiredAndEndlessDropped();
NoServerTimeOrNoSnapshot();
SameCategoryMerges();
KindMergesCategories();
KindOrder();
OverflowCount();
TicksAndDuration();
CategoryZeroStandsAlone();
ShortArraysAndHugeExpiry();
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL SELF PLATE TESTS PASSED." : $"{_failed} FAILED.");
return _failed == 0 ? 0 : 1;
}
// ── settings ─────────────────────────────────────────────────────────
private static (string Key, Func<bool> Get, Action<bool> Set)[] Toggles => new (string, Func<bool>, Action<bool>)[]
{
("selfBarTrack", () => S.SelfBarTrack, v => S.SelfBarTrack = v),
("selfBarChip", () => S.SelfBarChip, v => S.SelfBarChip = v),
("selfTextOutline", () => S.SelfTextOutline, v => S.SelfTextOutline = v),
("selfNumberBand", () => S.SelfNumberBand, v => S.SelfNumberBand = v),
("selfDebuffs", () => S.SelfDebuffs, v => S.SelfDebuffs = v),
};
private static string[] Written()
{
var sw = new StringWriter(CultureInfo.InvariantCulture);
S.WriteAll(sw);
return sw.ToString().Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(l => l.TrimEnd('\r')).ToArray();
}
private static void LookDefaultsOn()
{
Case("defaults: the four look switches and Debuffs on you are on (the look before they existed)");
foreach (var t in Toggles) Check(t.Get(), $"{t.Key} defaults on");
string[] lines = Written();
foreach (var t in Toggles) Check(lines.Contains(t.Key + "=1"), $"{t.Key}=1 written");
}
private static void OldFileLoadsThemOn()
{
Case("a file from 2026.10.27.1 (no new keys) loads them on, and its other values");
// That release's file = today's lines without the five new keys.
S.ResetToDefaults();
S.SelfNumbers = true; S.Scale = 1.4f; S.SelfPlacement = SelfPlacement.Follow; S.SelfLocked = false;
string[] old = Written().Where(l => !Toggles.Any(t => l.StartsWith(t.Key + "=", StringComparison.Ordinal))).ToArray();
Check(old.Length == Written().Length - Toggles.Length, "the old file lacks exactly the five keys");
S.ResetToDefaults();
S.ApplyLines(old);
foreach (var t in Toggles) Check(t.Get(), $"{t.Key} on after loading the old file");
Check(S.SelfNumbers && MathF.Abs(S.Scale - 1.4f) < 0.001f && S.SelfPlacement == SelfPlacement.Follow && !S.SelfLocked,
"the old file's own values still load");
S.ResetToDefaults();
S.ApplyLines(new[] { "# RynthCore monster nameplates", "selfPlate=1", "selfNumbers=1" });
foreach (var t in Toggles) Check(t.Get(), $"{t.Key} on after a hand-written two-line file");
S.ResetToDefaults();
}
private static void EachToggleRoundTrips()
{
Case("each switch saves off and loads off, alone, and back on");
var toggles = Toggles;
foreach (var t in toggles)
{
S.ResetToDefaults();
t.Set(false);
string[] lines = Written();
Check(lines.Contains(t.Key + "=0"), $"{t.Key}=0 written");
S.ResetToDefaults();
S.ApplyLines(lines);
Check(!t.Get(), $"{t.Key} off after reload");
foreach (var o in toggles)
if (o.Key != t.Key) Check(o.Get(), $"{o.Key} still on when only {t.Key} is off");
Check(S.ShowDebuffs && S.Enabled, $"monster plates' switches untouched by {t.Key}");
t.Set(true);
S.ApplyLines(Written());
Check(t.Get(), $"{t.Key} back on");
}
Case("all off together round-trips; write -> apply -> write is stable");
foreach (var t in toggles) t.Set(false);
string[] first = Written();
S.ResetToDefaults();
S.ApplyLines(first);
foreach (var t in toggles) Check(!t.Get(), $"{t.Key} off");
Check(first.SequenceEqual(Written()), "identical text after a reload");
Check(S.Describe().Contains("debuffs on you off") && S.Describe().Contains("text outline off"), "status line names them");
S.ResetToDefaults();
}
private static void ResetTurnsThemBackOn()
{
Case("Reset all to defaults turns them back on");
foreach (var t in Toggles) t.Set(false);
S.ResetToDefaults();
foreach (var t in Toggles) Check(t.Get(), $"{t.Key} on after reset");
}
private static void UnlockFromFixed()
{
Case("unlock a fixed plate: stays fixed, unlocked, movable; nothing saved by the setter");
S.ResetToDefaults();
int saves = RynthCore.Engine.UI.UiBackgroundWriter.Enqueued;
Check(!S.SelfMovable, "locked by default");
bool switched = S.SetSelfLocked(false);
Check(!switched, "no placement switch");
Check(S.SelfPlacement == SelfPlacement.Fixed && !S.SelfLocked && S.SelfMovable, "fixed, unlocked, movable");
S.SetSelfLocked(true);
Check(S.SelfLocked && !S.SelfMovable, "locked again");
Check(RynthCore.Engine.UI.UiBackgroundWriter.Enqueued == saves, "the setter queues no save (callers save)");
}
private static void UnlockFromFollowFixesIt()
{
Case("unlock a plate that follows you: fixed on screen at its saved spot, then movable");
S.ResetToDefaults();
S.SelfPlacement = SelfPlacement.Follow;
S.SelfFixedX = 0.3f; S.SelfFixedY = 0.2f;
Check(!S.SelfMovable, "a following plate isn't movable");
bool switched = S.SetSelfLocked(false);
Check(switched, "reports the switch to fixed");
Check(S.SelfPlacement == SelfPlacement.Fixed && !S.SelfLocked && S.SelfMovable, "fixed and unlocked");
Check(S.SelfFixedX == 0.3f && S.SelfFixedY == 0.2f, "the saved spot is kept");
S.ResetToDefaults();
}
private static void LockFromFollowStaysFollow()
{
Case("lock while following: stays following");
S.ResetToDefaults();
S.SelfPlacement = SelfPlacement.Follow;
S.SelfLocked = false;
bool switched = S.SetSelfLocked(true);
Check(!switched && S.SelfPlacement == SelfPlacement.Follow && S.SelfLocked, "still follows, locked");
S.ResetToDefaults();
}
// ── Debuffs on you: selection ───────────────────────────────────────
private const long Freq = 1000; // ticks per second in these checks
private const long Now = 5_000_000; // Stopwatch ticks
private const double ServerNow = 100_000;
// Fake spell table: harmful spells only (as PortalSpellTable keeps), with a kind and a base length.
private static readonly Dictionary<uint, (DebuffKind Kind, float Dur)> Harmful = new()
{
[1] = (DebuffKind.Imperil, 60f),
[2] = (DebuffKind.VulnFire, 45f),
[3] = (DebuffKind.Attributes, 120f),
[4] = (DebuffKind.Attributes, 90f),
[5] = (DebuffKind.MagicYield, 30f),
[6] = (DebuffKind.Skills, 240f),
[7] = (DebuffKind.Dot, 20f),
[8] = (DebuffKind.Movement, 50f),
[9] = (DebuffKind.VulnCold, 45f),
[10] = (DebuffKind.Imperil, 75f),
[0x8001] = (DebuffKind.Other, 10f), // would be harmful, but ids from 0x8000 are cooldowns
};
private static bool Lookup(uint id, out DebuffKind kind, out float dur)
{
if (Harmful.TryGetValue(id, out var h)) { kind = h.Kind; dur = h.Dur; return true; }
kind = DebuffKind.Other; dur = 0;
return false;
}
/// <summary>One snapshot entry: spell id, seconds left (server time), spell category.</summary>
private readonly record struct E(uint Id, double Left, uint Cat);
private static int Run(E[] entries, out DebuffIcon[] icons, int dstLen = 5, double serverNow = ServerNow, int? n = null)
{
var ids = entries.Select(e => e.Id).ToArray();
var exp = entries.Select(e => e.Left >= SelfDebuffs.NoEnd ? double.MaxValue : serverNow + e.Left).ToArray();
var cats = entries.Select(e => e.Cat).ToArray();
icons = new DebuffIcon[dstLen];
return SelfDebuffs.Select(ids, exp, cats, n ?? entries.Length, serverNow, Now, Freq, Lookup, icons);
}
private static void HarmfulOnly()
{
Case("harmful only: buffs (not in the table) never show");
int c = Run(new[] { new E(100, 600, 50), new E(1, 30, 116), new E(200, 900, 51) }, out var ic);
Check(c == 1, $"one icon (got {c})");
Check(ic[0].Kind == DebuffKind.Imperil && ic[0].Stack == 1, "the Imperil");
c = Run(new[] { new E(100, 600, 50), new E(200, 900, 51) }, out _);
Check(c == 0, "buffs alone: no row");
}
private static void CooldownsAndZeroIdsDropped()
{
Case("cooldowns (0x8000+) and id 0 are dropped");
int c = Run(new[] { new E(0x8001, 30, 0), new E(0, 30, 116), new E(2, 30, 110) }, out var ic);
Check(c == 1 && ic[0].Kind == DebuffKind.VulnFire, $"only the fire vuln (got {c})");
}
private static void ExpiredAndEndlessDropped()
{
Case("expired entries and ones that never end (vitae, item spells) are dropped");
int c = Run(new[] { new E(1, -1, 116), new E(2, 0, 110), new E(3, 1e13, 2), new E(5, 10, 42) }, out var ic);
Check(c == 1 && ic[0].Kind == DebuffKind.MagicYield, $"only the live Magic Yield (got {c})");
var ids = new uint[] { 1 };
var exp = new[] { double.NaN };
var cats = new uint[] { 116 };
Check(SelfDebuffs.Select(ids, exp, cats, 1, ServerNow, Now, Freq, Lookup, new DebuffIcon[5]) == 0, "NaN expiry dropped");
}
private static void NoServerTimeOrNoSnapshot()
{
Case("no server time yet, or no snapshot (-1): no row");
Check(Run(new[] { new E(1, 30, 116) }, out _, serverNow: 0) == 0, "server time 0");
Check(Run(new[] { new E(1, 30, 116) }, out _, n: -1) == 0, "count -1 (CopyPlayerStatMods: nothing valid)");
Check(Run(Array.Empty<E>(), out _) == 0, "empty snapshot");
}
private static void SameCategoryMerges()
{
Case("one per category: two Imperils in category 116 are one icon, lasting to the later end");
int c = Run(new[] { new E(1, 20, 116), new E(10, 50, 116) }, out var ic);
Check(c == 1, $"one icon (got {c})");
Check(ic[0].Stack == 1, "a stack of one (one category)");
Check(ic[0].Expiry == Now + 50 * Freq, $"ends with the later one (got {ic[0].Expiry - Now})");
Check(ic[0].Duration == 75f, "that one's length");
c = Run(new[] { new E(10, 50, 116), new E(1, 20, 116) }, out ic);
Check(c == 1 && ic[0].Expiry == Now + 50 * Freq && ic[0].Duration == 75f, "same result in the other order");
}
private static void KindMergesCategories()
{
Case("one per kind: two attribute debuffs (categories 2 and 4) are one icon, stack 2, soonest end");
int c = Run(new[] { new E(3, 80, 2), new E(4, 25, 4) }, out var ic);
Check(c == 1 && ic[0].Kind == DebuffKind.Attributes, $"one Attributes icon (got {c})");
Check(ic[0].Stack == 2, $"stack 2 (got {ic[0].Stack})");
Check(ic[0].Expiry == Now + 25 * Freq && ic[0].Duration == 90f, "the soonest end and its length");
}
private static void KindOrder()
{
Case("icons in kind order (the monster row's), whatever the snapshot order");
int c = Run(new[] { new E(6, 100, 20), new E(1, 30, 116), new E(9, 30, 106), new E(2, 30, 110), new E(5, 30, 42) }, out var ic);
Check(c == 5, $"five icons (got {c})");
var want = new[] { DebuffKind.VulnFire, DebuffKind.VulnCold, DebuffKind.Imperil, DebuffKind.MagicYield, DebuffKind.Skills };
Check(ic.Select(i => i.Kind).SequenceEqual(want), "fire, cold, Imperil, Magic Yield, skills: " + string.Join(", ", ic.Select(i => i.Kind)));
}
private static void OverflowCount()
{
Case("more kinds than fit: the count includes the rest (+N), the first by kind are kept");
var all = new[]
{
new E(8, 30, 78), new E(7, 10, 600), new E(6, 100, 20), new E(1, 30, 116),
new E(9, 30, 106), new E(2, 30, 110), new E(5, 30, 42),
};
int c = Run(all, out var ic);
Check(c == 7, $"count 7 (got {c})");
var want = new[] { DebuffKind.VulnFire, DebuffKind.VulnCold, DebuffKind.Imperil, DebuffKind.MagicYield, DebuffKind.Movement };
Check(ic.Select(i => i.Kind).SequenceEqual(want), "the five first kinds: " + string.Join(", ", ic.Select(i => i.Kind)));
}
private static void TicksAndDuration()
{
Case("server seconds left -> Stopwatch ticks from now; length from the table");
Run(new[] { new E(5, 12.5, 42) }, out var ic);
Check(ic[0].Expiry == Now + 12_500, $"12.5 s -> 12500 ticks (got {ic[0].Expiry - Now})");
Check(ic[0].Duration == 30f, "Magic Yield's 30 s");
}
private static void CategoryZeroStandsAlone()
{
Case("no category recorded: each spell stands alone");
int c = Run(new[] { new E(3, 40, 0), new E(4, 60, 0) }, out var ic);
Check(c == 1 && ic[0].Stack == 2, $"two spells, one Attributes icon, stack 2 (got {c}, {ic[0].Stack})");
c = Run(new[] { new E(3, 40, 0), new E(3, 60, 0) }, out ic);
Check(c == 1 && ic[0].Stack == 1 && ic[0].Expiry == Now + 60 * Freq, "the same spell twice is one entry");
}
private static void ShortArraysAndHugeExpiry()
{
Case("a count past the arrays is clamped; a huge (but finite) end doesn't overflow");
var ids = new uint[] { 1, 2 };
var exp = new[] { ServerNow + 30, ServerNow + 9e11 };
var cats = new uint[] { 116, 110 };
var dst = new DebuffIcon[5];
int c = SelfDebuffs.Select(ids, exp, cats, 999, ServerNow, Now, Freq, Lookup, dst);
Check(c == 2, $"two icons (got {c})");
Check(dst.Take(2).All(i => i.Expiry > Now), "both end after now");
c = SelfDebuffs.Select(ids, exp, cats, 2, ServerNow, Now, Freq, Lookup, Array.Empty<DebuffIcon>());
Check(c == 2, "an empty destination still counts");
}
// ── harness ─────────────────────────────────────────────────────────
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

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for your own RynthVision plate's options (2026-10-27, a player on Discord: "how do I unlock and
move the vitals bar", "options to turn off the shadow things", "debuffs on you as icons"):
src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudSettings.cs - the four look switches (track, damage trail,
text outline, number band) and "Debuffs on you" default on, an older nameplate_settings.txt without them
loads them on, each round-trips; SetSelfLocked (Settings > UI > Vitals, Vision, /rv plates self unlock)
fixes a following plate on screen when it unlocks it;
src\RynthCore.Engine\ImGui\MonsterHud\SelfDebuffs.cs (+ DebuffIcon.cs) - which spells on you get an icon:
harmful only, cooldowns / expired / never-ending entries dropped, one per category (the last to end),
one icon per kind (count + soonest end), kind order, "+N" overflow, server time to Stopwatch ticks.
All compiled in; no game, no engine. No file I/O: the background writer is a stub that never runs its work.
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>SelfPlateTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\ImGui\MonsterHud\MonsterHudSettings.cs" Link="Engine\MonsterHudSettings.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" />
</ItemGroup>
</Project>