feat: SK backlog from test through 2026.11.22.48 (Trade Shop + inventory/loot/chat/nav)
Squash of test/main-merge-2026-10-25 onto aelrynth main 2026.11.19.1 for the standing sk PR. Includes Trade Shop Storefront, loot checklist editor, chat routing, window placements, and related engine work. See Changelog/2026-11-22-sk-backlog-test-merge.md.
This commit is contained in:
parent
3fafd29133
commit
c6e8bb8dbf
438 changed files with 39545 additions and 1271 deletions
25
tools/AcGraphicsPrefsTests/AcGraphicsPrefsTests.csproj
Normal file
25
tools/AcGraphicsPrefsTests/AcGraphicsPrefsTests.csproj
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
Offline checks for RynthAi's Settings > Graphics model (2026-10-17):
|
||||
src\RynthCore.Engine\Graphics\AcGraphicsPrefs.cs, compiled in (it is shared with the launcher).
|
||||
graphics.json round-trips as a profile per account; one account's save leaves the others alone;
|
||||
the 2026.10.18.1 shared set is ignored; the window mode drives Display.FullScreen; applying to a
|
||||
UserPreferences.ini replaces keys in
|
||||
place, adds missing keys and sections, leaves every other line alone, and writes nothing when
|
||||
nothing changed. Works on temp files only. 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>AcGraphicsPrefsTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\src\RynthCore.Engine\Graphics\AcGraphicsPrefs.cs" Link="Engine\AcGraphicsPrefs.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
140
tools/AcGraphicsPrefsTests/Program.cs
Normal file
140
tools/AcGraphicsPrefsTests/Program.cs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
// Offline checks for Graphics/AcGraphicsPrefs.cs (RynthAi Settings > Graphics). See the .csproj.
|
||||
using RynthCore.Graphics;
|
||||
|
||||
int failures = 0, checks = 0;
|
||||
void Check(bool ok, string what)
|
||||
{
|
||||
checks++;
|
||||
if (ok) return;
|
||||
failures++;
|
||||
Console.WriteLine("FAIL " + what);
|
||||
}
|
||||
|
||||
string dir = Path.Combine(Path.GetTempPath(), "AcGraphicsPrefsTests-" + Environment.ProcessId);
|
||||
Directory.CreateDirectory(dir);
|
||||
try
|
||||
{
|
||||
// ── Per-account profiles: each account's own; FullScreen follows the mode ──
|
||||
string kelpie = AcGraphicsPrefs.AccountKey("InfiniteLeaftide", "silentkelpie");
|
||||
string storm = AcGraphicsPrefs.AccountKey("InfiniteLeaftide", "SilentStorm");
|
||||
Check(kelpie == "infiniteleaftide|silentkelpie" && storm == "infiniteleaftide|silentstorm", "account key is server|account, lower case");
|
||||
Check(AcGraphicsPrefs.AccountKey("", "X") == "" && AcGraphicsPrefs.AccountKey("S", " ") == "", "no key without server and account");
|
||||
|
||||
var kcfg = new AcGraphicsConfig { WindowMode = AcGraphicsPrefs.ModeFullScreen };
|
||||
kcfg.Values[AcGraphicsPrefs.ResolutionId] = "1280x720";
|
||||
var scfg = new AcGraphicsConfig { WindowMode = AcGraphicsPrefs.ModeBorderlessFill };
|
||||
scfg.Values["Render.TextureFiltering"] = "Anisotropic";
|
||||
var all = new AcGraphicsProfiles();
|
||||
all.Put(kelpie, kcfg);
|
||||
all.Put(storm, scfg);
|
||||
all.Put("x|y", new AcGraphicsConfig());
|
||||
Check(all.Accounts.Count == 2, "an empty profile isn't kept");
|
||||
|
||||
Dictionary<string, string> forKelpie = all.For(kelpie).IniValues();
|
||||
Check(forKelpie[AcGraphicsPrefs.FullScreenId] == "True" && forKelpie[AcGraphicsPrefs.ResolutionId] == "1280x720",
|
||||
"Kelpie's profile: full screen at 1280x720");
|
||||
Dictionary<string, string> forStorm = all.For(storm).IniValues();
|
||||
Check(forStorm[AcGraphicsPrefs.FullScreenId] == "False" && !forStorm.ContainsKey(AcGraphicsPrefs.ResolutionId),
|
||||
"Storm's profile: borderless, no resolution of Kelpie's");
|
||||
Check(forStorm["Render.TextureFiltering"] == "Anisotropic", "render values pass through");
|
||||
Check(all.For("infiniteleaftide|nobody").IniValues().Count == 0, "an account without a profile writes nothing");
|
||||
|
||||
// ── graphics.json round-trip; another account's entry survives a save ──
|
||||
string json = Path.Combine(dir, "graphics.json");
|
||||
all.Save(json);
|
||||
AcGraphicsProfiles back = AcGraphicsProfiles.Load(json);
|
||||
Check(back.For(kelpie).WindowMode == AcGraphicsPrefs.ModeFullScreen && back.For(kelpie).Values[AcGraphicsPrefs.ResolutionId] == "1280x720",
|
||||
"Kelpie's profile round-trips");
|
||||
Check(back.For(storm).Values["render.texturefiltering"] == "Anisotropic", "Storm's profile round-trips (ids case-insensitive)");
|
||||
Check(!File.Exists(json + "." + Environment.ProcessId + ".tmp"), "no temp file left");
|
||||
|
||||
// A client edits only its own account: load, put, save (as AcGraphics.QueueSave does).
|
||||
AcGraphicsProfiles onDisk = AcGraphicsProfiles.Load(json);
|
||||
AcGraphicsConfig k2 = onDisk.For(kelpie).Clone();
|
||||
k2.Values.Remove(AcGraphicsPrefs.ResolutionId);
|
||||
onDisk.Put(kelpie, k2);
|
||||
onDisk.Save(json);
|
||||
AcGraphicsProfiles after = AcGraphicsProfiles.Load(json);
|
||||
Check(!after.For(kelpie).Values.ContainsKey(AcGraphicsPrefs.ResolutionId), "Kelpie's change saved");
|
||||
Check(after.For(storm).WindowMode == AcGraphicsPrefs.ModeBorderlessFill, "Storm's profile untouched by Kelpie's save");
|
||||
|
||||
// The 2026.10.18.1 single shared set is ignored (it made every client fight over one resolution).
|
||||
File.WriteAllText(json, "{\"values\":{\"Display.Resolution\":\"1760x990\"},\"windowMode\":\"Windowed\",\"characters\":{}}");
|
||||
Check(AcGraphicsProfiles.Load(json).Accounts.Count == 0, "old global graphics.json is not applied to anyone");
|
||||
File.WriteAllText(json, "{\"accounts\":{\"a|b\":{\"windowMode\":\"Bogus\",\"values\":{}}}}");
|
||||
Check(AcGraphicsProfiles.Load(json).Accounts.Count == 0, "unknown mode dropped; empty profile not kept");
|
||||
|
||||
// ── Resolution parsing ──
|
||||
Check(AcGraphicsPrefs.TryParseResolution("1760x990", out int w, out int h) && w == 1760 && h == 990, "parses 1760x990");
|
||||
Check(!AcGraphicsPrefs.TryParseResolution("800", out _, out _) && !AcGraphicsPrefs.TryParseResolution("100x50", out _, out _),
|
||||
"rejects junk and tiny sizes");
|
||||
Check(AcGraphicsPrefs.FormatFloat(0.891) == "0.89", "floats as AC writes them");
|
||||
|
||||
// ── Applying to UserPreferences.ini ──
|
||||
string ini = Path.Combine(dir, "UserPreferences.ini");
|
||||
File.WriteAllText(ini,
|
||||
"[Render]\r\nFieldOfView=160.00\r\nTextureFiltering=Bilinear\r\n[Net]\r\nComputeUniquePort=True\r\n[Display]\r\nResolution=1760x990\r\nFullScreen=False\r\n");
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
["Render.TextureFiltering"] = "Anisotropic",
|
||||
["Display.Resolution"] = "1920x1080",
|
||||
["Display.FullScreen"] = "False",
|
||||
["Render.MultiPassAlpha"] = "False",
|
||||
["Camera.Stiffness"] = "0.50",
|
||||
};
|
||||
List<string> changed = AcPrefsIni.Apply(ini, values);
|
||||
Dictionary<string, string> now = AcPrefsIni.Read(ini);
|
||||
Check(changed.Count == 4 && !changed.Contains("Display.FullScreen"), "only changed keys are reported");
|
||||
Check(now["Render.TextureFiltering"] == "Anisotropic" && now["Display.Resolution"] == "1920x1080", "keys replaced in place");
|
||||
Check(now["Render.MultiPassAlpha"] == "False", "missing key added to its section");
|
||||
Check(now["Camera.Stiffness"] == "0.50", "missing section added");
|
||||
Check(now["Render.FieldOfView"] == "160.00" && now["Net.ComputeUniquePort"] == "True", "other keys untouched");
|
||||
string[] lines = File.ReadAllLines(ini);
|
||||
int renderAt = Array.IndexOf(lines, "[Render]"), netAt = Array.IndexOf(lines, "[Net]");
|
||||
int mpaAt = Array.IndexOf(lines, "MultiPassAlpha=False");
|
||||
Check(mpaAt > renderAt && mpaAt < netAt, "added key sits inside [Render]");
|
||||
|
||||
DateTime stamp = File.GetLastWriteTimeUtc(ini);
|
||||
Thread.Sleep(30);
|
||||
Check(AcPrefsIni.Apply(ini, values).Count == 0 && File.GetLastWriteTimeUtc(ini) == stamp, "no write when nothing changed");
|
||||
|
||||
string fresh = Path.Combine(dir, "sub", "UserPreferences.ini");
|
||||
AcPrefsIni.Apply(fresh, new Dictionary<string, string> { ["Display.Resolution"] = "1280x720" });
|
||||
Check(AcPrefsIni.Read(fresh)["Display.Resolution"] == "1280x720", "creates a missing file");
|
||||
|
||||
// ── Which INI files: the game folder's first (the one this install's clients use) ──
|
||||
string gameDir = Path.Combine(dir, "game");
|
||||
Directory.CreateDirectory(gameDir);
|
||||
string gameIni = Path.Combine(gameDir, "UserPreferences.ini");
|
||||
Check(AcGraphicsPrefs.IniPaths(gameDir)[0] != gameIni || File.Exists(gameIni), "no game-folder INI: listed only as the fallback");
|
||||
File.WriteAllText(gameIni, "[Display]\r\nResolution=1760x990\r\n");
|
||||
List<string> paths = AcGraphicsPrefs.IniPaths(gameDir);
|
||||
Check(paths.Count >= 1 && paths[0] == gameIni, "game folder's INI comes first when it exists");
|
||||
Check(paths.TrueForAll(File.Exists), "only existing files listed when the game folder has one");
|
||||
|
||||
// ── Every Render setting has sane metadata ──
|
||||
foreach (AcGraphicsSetting s in AcGraphicsPrefs.RenderSettings)
|
||||
{
|
||||
Check(s.Section == "Render" && s.Key.Length > 0 && s.Label.Length > 0, $"{s.Id}: section, key, label");
|
||||
if (s.Kind == AcGraphicsKind.Choice) Check(s.Choices is { Length: > 1 }, $"{s.Id}: has choices");
|
||||
if (s.Kind == AcGraphicsKind.Float) Check(s.Max > s.Min && s.Step > 0, $"{s.Id}: slider range");
|
||||
}
|
||||
Check(AcGraphicsPrefs.WindowModeIds.Length == AcGraphicsPrefs.WindowModeLabels.Length, "a label per window mode");
|
||||
|
||||
// ── Memory risk: Adaptive degrade off with a far draw distance (2026-10-18) ──
|
||||
Check(AcGraphicsPrefs.MemoryRisk("False", "Extreme", null).StartsWith("Warning"), "risk: degrade off, Extreme scenery");
|
||||
Check(AcGraphicsPrefs.MemoryRisk("false", null, "High").Length > 0, "risk: degrade off, High landscape (any case)");
|
||||
Check(AcGraphicsPrefs.MemoryRisk("False", "Medium", "Medium").Length == 0, "no risk: degrade off, Medium distances");
|
||||
Check(AcGraphicsPrefs.MemoryRisk("True", "Extreme", "Extreme").Length == 0, "no risk: degrade on");
|
||||
Check(AcGraphicsPrefs.MemoryRisk(null, "Extreme", "Extreme").Length == 0, "no risk: degrade at AC's default");
|
||||
Check(AcGraphicsPrefs.MemoryRisk("False", null, null).Length == 0, "no risk: distances at AC's default");
|
||||
foreach (string id in new[] { AcGraphicsPrefs.AutomaticDegradesId, AcGraphicsPrefs.SceneryDrawDistanceId, AcGraphicsPrefs.LandscapeDrawDistanceId })
|
||||
Check(Array.Exists(AcGraphicsPrefs.RenderSettings, s => s.Id == id), $"{id} is a Render setting");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { Directory.Delete(dir, recursive: true); } catch { }
|
||||
}
|
||||
|
||||
Console.WriteLine(failures == 0 ? $"PASS ({checks} checks)" : $"{failures} FAILURE(S) of {checks} checks");
|
||||
return failures == 0 ? 0 : 1;
|
||||
|
|
@ -259,6 +259,7 @@ internal static class Program
|
|||
yield return ("Tools", l.Tools);
|
||||
yield return ("Modern", l.Modern);
|
||||
yield return ("Vault", l.Vault);
|
||||
yield return ("Shop", l.Shop);
|
||||
yield return ("Remote", l.Remote);
|
||||
yield return ("Sort", l.Sort);
|
||||
yield return ("Count", l.Count);
|
||||
|
|
@ -278,6 +279,7 @@ internal static class Program
|
|||
Check(present[i - 1].Slot.Right <= present[i].Slot.X + 0.001f,
|
||||
$"{tag}: {present[i - 1].Name} does not overlap {present[i].Name} ({present[i - 1].Slot.Right} vs {present[i].Slot.X})");
|
||||
Eq(l.Vault.Present, vault, $"{tag}: Vault present iff the server has it");
|
||||
Check(l.Shop.Present, $"{tag}: Trade Shop Storefront is on the bar");
|
||||
bool extrasShown = l.Mode is TitleExtrasMode.Text or TitleExtrasMode.Icons;
|
||||
Eq(l.Remote.Present && l.Sort.Present && l.Count.Present && l.GInv.Present, extrasShown, $"{tag}: all four related buttons or none");
|
||||
Eq(l.More.Present, l.Mode == TitleExtrasMode.Menu, $"{tag}: the more button iff Menu mode");
|
||||
|
|
@ -325,9 +327,11 @@ internal static class Program
|
|||
Eq(InventoryTitleLayout.Compute(276f * 1.5f, 1.5f, true, 130f * 1.5f).Mode, TitleExtrasMode.Menu, "retail at 1.5x + Vault: more menu");
|
||||
|
||||
// The case from the review: 190 px of text buttons used to push Vault to x=-44 at 300 / scale 1.
|
||||
// Trade Shop sits left of Vault; title room is a bit tighter than the pre-Shop layout (~100 px).
|
||||
var r = InventoryTitleLayout.Compute(276f, 1f, true, 130f);
|
||||
Check(r.Vault.X > 100f && r.Vault.Right <= r.Smaller.X, $"Vault sits just left of the toggles at retail width (x={r.Vault.X})");
|
||||
Check(r.TitleWidth >= 100f, $"and the title keeps {r.TitleWidth} px at retail width");
|
||||
Check(r.Shop.Present && r.Shop.Right <= r.Vault.X, $"Shop sits left of Vault (x={r.Shop.X})");
|
||||
Check(r.TitleWidth >= 80f, $"and the title keeps {r.TitleWidth} px at retail width");
|
||||
|
||||
// Everything is relative to the bar: scaling the bar scales the positions (whole-pixel rounding aside).
|
||||
var a = InventoryTitleLayout.Compute(276f, 1f, true, 130f);
|
||||
|
|
@ -350,8 +354,10 @@ internal static class Program
|
|||
Check(l.TitleWidth >= 0f, $"w={barW}: title width never negative");
|
||||
}
|
||||
// Far too narrow for the toggles: Vault is clamped at the left edge, never negative; no related buttons.
|
||||
// Trade Shop is dropped so it does not pile on top of the pinned Vault.
|
||||
var tiny = InventoryTitleLayout.Compute(60f, 1f, true, 130f);
|
||||
Check(tiny.Vault.Present && tiny.Vault.X == 0f, "a 60 px bar: Vault pinned at x=0, not negative");
|
||||
Check(!tiny.Shop.Present, "a 60 px bar: Trade Shop dropped (no room left of Vault)");
|
||||
Eq(tiny.Mode, TitleExtrasMode.None, "a 60 px bar: no related buttons");
|
||||
Check(tiny.TitleWidth >= 0f, "a 60 px bar: title width not negative");
|
||||
var noVault = InventoryTitleLayout.Compute(60f, 1f, false, 130f);
|
||||
|
|
@ -408,6 +414,7 @@ internal static class Program
|
|||
yield return ("Close", h.Close);
|
||||
yield return ("Classic", h.Classic);
|
||||
yield return ("Vault", h.Vault);
|
||||
yield return ("Shop", h.Shop);
|
||||
yield return ("Remote", h.Remote);
|
||||
yield return ("Sort", h.Sort);
|
||||
yield return ("Count", h.Count);
|
||||
|
|
@ -417,32 +424,32 @@ internal static class Program
|
|||
|
||||
private static void HeaderVault()
|
||||
{
|
||||
Console.WriteLine("Modern header: the Vault button");
|
||||
Console.WriteLine("Modern header: Vault + Trade Shop Storefront");
|
||||
|
||||
// Without a vault the plan is exactly the old one, so the header is unchanged off Aelrynth.
|
||||
// Without a vault, ChooseHeader still reserves Trade Shop (24 px) before the related buttons.
|
||||
foreach (float free in new[] { -30f, 0f, 10f, 24f, 40f, 90f, 100f, 130f, 300f })
|
||||
foreach (float cw in new[] { 0f, 30f, 50f, 80f })
|
||||
{
|
||||
var plan = InventoryTitleLayout.ChooseHeader(free, cw, vault: false);
|
||||
TitleExtrasMode old = InventoryTitleLayout.ChooseHeaderExtras(free, cw, out bool oldCount);
|
||||
Check(!plan.Vault && plan.Extras == old && plan.ShowCount == oldCount, $"no vault: same as ChooseHeaderExtras (free {free}, count {cw})");
|
||||
TitleExtrasMode old = InventoryTitleLayout.ChooseHeaderExtras(free - InventoryTitleLayout.HeaderShopW, cw, out bool oldCount);
|
||||
Check(!plan.Vault && plan.Extras == old && plan.ShowCount == oldCount, $"no vault: Shop reserved then ChooseHeaderExtras (free {free}, count {cw})");
|
||||
}
|
||||
|
||||
// With a vault the Vault takes its 24 px first; the rest shares what is left.
|
||||
// With a vault: Vault + Shop take 48 px first; the rest shares what is left.
|
||||
const float reservedVaultShop = 24f + 24f; // HeaderVaultW + HeaderShopW
|
||||
Eq(InventoryTitleLayout.ChooseHeader(300f, 50f, true).Extras, TitleExtrasMode.Icons, "lots of room + vault: four icons");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(96f + 60f + 24f - 1f, 50f, true).Extras, TitleExtrasMode.Menu, "one px short of icons + vault: the menu");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(96f + 60f + 24f, 50f, true).Extras, TitleExtrasMode.Icons, "icons + count + vault just fit");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(24f + 24f + 60f, 50f, true).Extras, TitleExtrasMode.Menu, "vault + menu + count");
|
||||
var tight = InventoryTitleLayout.ChooseHeader(24f + 24f, 50f, true);
|
||||
Check(tight.Vault && tight.Extras == TitleExtrasMode.Menu && !tight.ShowCount, "vault + menu, the count text dropped");
|
||||
var tiny = InventoryTitleLayout.ChooseHeader(24f, 50f, true);
|
||||
Check(tiny.Vault && tiny.Extras == TitleExtrasMode.None && !tiny.ShowCount, "room for the vault only: no menu, no count");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(96f + 60f + reservedVaultShop - 1f, 50f, true).Extras, TitleExtrasMode.Menu, "one px short of icons + vault + shop: the menu");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(96f + 60f + reservedVaultShop, 50f, true).Extras, TitleExtrasMode.Icons, "icons + count + vault + shop just fit");
|
||||
Eq(InventoryTitleLayout.ChooseHeader(reservedVaultShop + 24f + 60f, 50f, true).Extras, TitleExtrasMode.Menu, "vault + shop + menu + count");
|
||||
var tight = InventoryTitleLayout.ChooseHeader(reservedVaultShop + 24f, 50f, true);
|
||||
Check(tight.Vault && tight.Extras == TitleExtrasMode.Menu && !tight.ShowCount, "vault + shop + menu, the count text dropped");
|
||||
var tiny = InventoryTitleLayout.ChooseHeader(reservedVaultShop, 50f, true);
|
||||
Check(tiny.Vault && tiny.Extras == TitleExtrasMode.None && !tiny.ShowCount, "room for vault + shop only: no menu, no count");
|
||||
foreach (float free in new[] { 20f, 0f, -40f, float.NaN, float.NegativeInfinity })
|
||||
Check(InventoryTitleLayout.ChooseHeader(free, 50f, true).Vault, $"the Vault is kept whatever the room ({free})");
|
||||
|
||||
// Every supported width (the panel's minimum is 140 px) and a range of left-hand text widths:
|
||||
// the Vault is present, inside the header, clear of the other buttons, and nothing drawn right of the
|
||||
// pyreals overlaps anything else. Without a vault the geometry is the one the header always had.
|
||||
// Vault (when asked) and Shop are present, inside the header, clear of the other buttons.
|
||||
int checkedLayouts = 0;
|
||||
for (float w = 140f; w <= 800f; w += 1f)
|
||||
foreach (float leftEnd in new[] { 80f, 120f, 150f, 200f })
|
||||
|
|
@ -467,6 +474,8 @@ internal static class Program
|
|||
Check(ok, $"{tag}: buttons inside the header and not overlapping");
|
||||
|
||||
Check(h.Plan.Vault == vault && h.Vault.Present == vault, $"{tag}: the Vault button exists exactly when asked for");
|
||||
Check(h.Shop.Present && h.Shop.W >= 22f, $"{tag}: Trade Shop Storefront is always present");
|
||||
Check(h.Shop.Right <= (vault ? h.Vault.X : h.Classic.X) + 0.001f, $"{tag}: Shop sits left of Vault/Classic");
|
||||
if (vault)
|
||||
{
|
||||
Check(h.Vault.Right <= h.Classic.X + 0.001f && h.Vault.X >= 0f, $"{tag}: Vault sits left of the Classic button, inside the header");
|
||||
|
|
@ -478,30 +487,31 @@ internal static class Program
|
|||
else
|
||||
{
|
||||
Check(h.Classic.X == w - 46 && h.Close.X == w - 22, $"{tag}: Close / Classic where they always were");
|
||||
if (h.Plan.Extras == TitleExtrasMode.Icons) Check(h.GInv.X == w - 46 - 24 && h.Remote.X == w - 46 - 96, $"{tag}: the four icons where they always were");
|
||||
if (h.Plan.Extras == TitleExtrasMode.Menu) Check(h.More.X == w - 46 - 24, $"{tag}: the menu button where it always was");
|
||||
Check(h.Shop.X == w - 46 - 24, $"{tag}: Shop right beside Classic when there is no Vault");
|
||||
if (h.Plan.Extras == TitleExtrasMode.Icons) Check(h.GInv.X == h.Shop.X - 24 && h.Remote.X == h.Shop.X - 96, $"{tag}: the four icons start left of Shop");
|
||||
if (h.Plan.Extras == TitleExtrasMode.Menu) Check(h.More.X == h.Shop.X - 24, $"{tag}: the menu button sits left of Shop");
|
||||
}
|
||||
// Related buttons / count never reach back over the pyreals when there was room for them.
|
||||
TitleSlot? leftmost = h.Plan.Extras == TitleExtrasMode.Icons ? h.Remote : h.Plan.Extras == TitleExtrasMode.Menu ? h.More : null;
|
||||
if (leftmost is { } lm)
|
||||
Check(lm.X >= leftEnd + 4f - 0.001f, $"{tag}: related buttons start clear of the pyreals text");
|
||||
if (h.Plan.ShowCount)
|
||||
Check(h.CountX + cw <= (leftmost?.X ?? (vault ? h.Vault.X : h.Classic.X)) + 0.001f, $"{tag}: the count text sits left of the buttons");
|
||||
Check(h.CountX + cw <= (leftmost?.X ?? h.Shop.X) + 0.001f, $"{tag}: the count text sits left of the buttons");
|
||||
}
|
||||
Check(checkedLayouts > 10000, $"swept the layouts ({checkedLayouts})");
|
||||
|
||||
// At the retail width (302 px) and the usual left-hand text the Vault is a button, and so are the
|
||||
// rest that fit: a worked example.
|
||||
// At the retail width (302 px) and the usual left-hand text: Vault, Shop, and the menu that fits.
|
||||
var r = InventoryHeaderLayout.Compute(302f, 150f, 50f, vault: true);
|
||||
Check(r.Vault.Present && r.Vault.X == 302f - 46 - 24, "302 px: Vault right beside the Classic button");
|
||||
Check(r.Shop.Present && r.Shop.X == r.Vault.X - 24, "302 px: Shop left of Vault");
|
||||
Eq(r.Plan.Extras, TitleExtrasMode.Menu, "302 px with a vault: related panels fold into the menu");
|
||||
Check(r.More.Present && r.More.Right <= r.Vault.X, "...left of the Vault");
|
||||
Check(r.More.Present && r.More.Right <= r.Shop.X, "...left of Shop");
|
||||
var wide = InventoryHeaderLayout.Compute(600f, 150f, 50f, vault: true);
|
||||
Eq(wide.Plan.Extras, TitleExtrasMode.Icons, "600 px with a vault: four icons");
|
||||
Check(wide.Vault.X == 600f - 46 - 24 && wide.GInv.X == wide.Vault.X - 24, "...the icons start just left of the Vault");
|
||||
Check(wide.Vault.X == 600f - 46 - 24 && wide.Shop.X == wide.Vault.X - 24 && wide.GInv.X == wide.Shop.X - 24, "...icons start just left of Shop");
|
||||
|
||||
// Garbage in, no crash and the Vault still present.
|
||||
// Garbage in, no crash and the Vault / Shop still present.
|
||||
var bad = InventoryHeaderLayout.Compute(float.NaN, float.NaN, float.NaN, vault: true);
|
||||
Check(bad.Vault.Present, "NaN sizes: the Vault slot exists (the caller never draws a header this small)");
|
||||
Check(bad.Vault.Present && bad.Shop.Present, "NaN sizes: Vault and Shop slots exist (the caller never draws a header this small)");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,9 @@ internal static class Program
|
|||
("actionstate", "actions", "actionstate now"),
|
||||
("unlockactions", "unlock", "unlockactions now"),
|
||||
("vitals", "hud", "vitals now"),
|
||||
// 2026-11-01: the test branch's verbs, now in the list.
|
||||
("borderless", "borderless on", "borderless frob"),
|
||||
("radar", "radar", "radar now"),
|
||||
("layout", "layout", "layout frob"),
|
||||
("layout", "layout reset confirm", "layout reset now"),
|
||||
("layout", "layout default", "layout default now"),
|
||||
|
|
@ -154,6 +157,9 @@ internal static class Program
|
|||
private static readonly (string Verb, string Valid, string Invalid, string Who)[] Handled =
|
||||
{
|
||||
("vendor", "vendor list", "vendor frob", "VendorTrade: '[RC] /rc vendor list | info | ...'"),
|
||||
("chatlinkprobe", "chatlinkprobe 30", "chatlinkprobe frob", "ChatLinkProbe.Command: its usage"),
|
||||
("switchchar", "switchchar Kelpie", "switchchar", "CharacterCaptureHooks.RequestSwitch: says a name is needed"),
|
||||
("window", "window reset", "window frob", "the window usage (a failure)"),
|
||||
("ui", "ui list", "ui frob", "HandleUiCommand: its usage"),
|
||||
("discord", "discord status", "discord frob", "ChatDiscord.HandleCommand: its usage"),
|
||||
("plates", "plates status", "plates frob", "HandlePlatesCommand: the plates usage"),
|
||||
|
|
@ -211,8 +217,9 @@ internal static class Program
|
|||
Check(unknown.Problem!.Contains(v.Name, StringComparison.Ordinal), $"the list names {v.Name}");
|
||||
ChatVerbCheck bare = ChatCommandReplies.Check("");
|
||||
Check(bare.Verb == null && bare.Problem != null && bare.Problem.StartsWith("Usage: /rc <command>.", StringComparison.Ordinal), "'/rc' alone: the usage and the list");
|
||||
Check(ChatCommandReplies.Check("window save").Problem!.StartsWith("Unknown command '/rc window'", StringComparison.Ordinal),
|
||||
"'/rc window save' (sent by /ub window save) is not an engine verb, and now says so");
|
||||
// The test branch's /rc window (reset | save | fill) is an engine verb: '/rc window save' (also what
|
||||
// /ub window save sends) runs it. Before 2026-11-01 the list lacked it and answered "Unknown command".
|
||||
Check(ChatCommandReplies.Check("window save") is { Problem: null, Verb.Name: "window" }, "'/rc window save' runs the engine's window verb");
|
||||
Check(ChatCommandReplies.Check(" SKILLS Show ").Problem == null, "case and spaces as IsVerb takes them");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
<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" />
|
||||
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\ChatSettingsMerge.cs" Link="Engine\ChatSettingsMerge.cs" />
|
||||
<Compile Include="..\..\src\RynthCore.Engine\UI\Data\ChatReplyTab.cs" Link="Engine\ChatReplyTab.cs" />
|
||||
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\ServerCommandFallback.cs" Link="Engine\ServerCommandFallback.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>
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ internal static class Program
|
|||
LineColorRetail();
|
||||
LineColorPrecedence();
|
||||
LineColorJson();
|
||||
SettingsMergeOnSave();
|
||||
CommandReplyInTypedTab();
|
||||
FshipListNotFiltered();
|
||||
ServerCommandsWithoutChatTarget();
|
||||
HighlightRouting();
|
||||
HighlightPrecedence();
|
||||
HighlightBand();
|
||||
|
|
@ -80,12 +84,144 @@ internal static class Program
|
|||
return _failed == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-23, two days into a session: rule after rule was "too slow ... skipped
|
||||
/// until edited", even "^\[RynthNet] Silentstorm connected\.$" - a pause of the thread during an
|
||||
/// easy match. A timed-out match now runs once more before a rule is judged slow, and a slow rule
|
||||
/// is tried again after 10 minutes (doubling per strike, at most 4 hours); an edit still resets it.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-24: filters kept "losing". Every client saves the whole shared
|
||||
/// rynthchat_settings.json; one that hadn't picked up another client's change (chat window
|
||||
/// closed, so it never polled) wrote its stale rules back over it. A save now merges with the
|
||||
/// file per setting: what this client changed since its base wins, the rest is the file's.
|
||||
/// </summary>
|
||||
private static void SettingsMergeOnSave()
|
||||
{
|
||||
Case("settings merge: a save never undoes another client's rules");
|
||||
const string baseJson = "{\"version\":2,\"fontSize\":10,\"activeChannel\":\"All\",\"filters\":[{\"pattern\":\"old\"}],\"presets\":[{\"id\":\"a\",\"enabled\":true}]}";
|
||||
// Another client added a rule and turned a standard filter off.
|
||||
const string theirs = "{\"version\":2,\"fontSize\":10,\"activeChannel\":\"Loot\",\"filters\":[{\"pattern\":\"old\"},{\"pattern\":\"new\"}],\"presets\":[]}";
|
||||
// This client (stale) only changed its font size and tab.
|
||||
const string mine = "{\"version\":2,\"fontSize\":12,\"activeChannel\":\"Combat\",\"filters\":[{\"pattern\":\"old\"}],\"presets\":[{\"id\":\"a\",\"enabled\":true}]}";
|
||||
|
||||
string merged = ChatSettingsMerge.Merge(baseJson, mine, theirs);
|
||||
using (var doc = JsonDocument.Parse(merged))
|
||||
{
|
||||
JsonElement root = doc.RootElement;
|
||||
Check(root.GetProperty("filters").GetArrayLength() == 2, "the other client's new rule survives");
|
||||
Check(root.GetProperty("presets").GetArrayLength() == 0, "the other client's preset change survives");
|
||||
Check(root.GetProperty("fontSize").GetInt32() == 12, "this client's own change is saved");
|
||||
Check(root.GetProperty("activeChannel").GetString() == "Combat", "this client's tab is its own");
|
||||
}
|
||||
|
||||
// This client edited the rules too: its list wins (one setting), the other client's font stays.
|
||||
const string theirsFont = "{\"version\":2,\"fontSize\":14,\"activeChannel\":\"All\",\"filters\":[{\"pattern\":\"old\"}],\"presets\":[{\"id\":\"a\",\"enabled\":true}]}";
|
||||
const string mineRules = "{\"version\":2,\"fontSize\":10,\"activeChannel\":\"All\",\"filters\":[{\"pattern\":\"mine\"}],\"presets\":[{\"id\":\"a\",\"enabled\":true}]}";
|
||||
using (var doc = JsonDocument.Parse(ChatSettingsMerge.Merge(baseJson, mineRules, theirsFont)))
|
||||
{
|
||||
Check(doc.RootElement.GetProperty("filters")[0].GetProperty("pattern").GetString() == "mine", "this client's rule edit is saved");
|
||||
Check(doc.RootElement.GetProperty("fontSize").GetInt32() == 14, "the other client's font size stays");
|
||||
}
|
||||
|
||||
// A setting only the other client has (newer build), and one this client removed.
|
||||
const string theirsExtra = "{\"version\":2,\"fontSize\":10,\"filters\":[{\"pattern\":\"old\"}],\"presets\":[{\"id\":\"a\",\"enabled\":true}],\"activeChannel\":\"All\",\"lineColors\":{\"x\":1}}";
|
||||
const string mineNoPresets = "{\"version\":2,\"fontSize\":10,\"activeChannel\":\"All\",\"filters\":[{\"pattern\":\"old\"}]}";
|
||||
using (var doc = JsonDocument.Parse(ChatSettingsMerge.Merge(baseJson, mineNoPresets, theirsExtra)))
|
||||
{
|
||||
Check(doc.RootElement.TryGetProperty("lineColors", out _), "a setting only the other client wrote is kept");
|
||||
Check(!doc.RootElement.TryGetProperty("presets", out _), "a setting this client removed stays removed");
|
||||
}
|
||||
|
||||
Check(ChatSettingsMerge.Merge(baseJson, mine, baseJson) == mine, "nobody else saved: this client's text as is");
|
||||
Check(ChatSettingsMerge.Merge(null, mine, theirs) == mine, "no base (first save): this client's text");
|
||||
Check(ChatSettingsMerge.Merge(baseJson, mine, "{ cut-off") == mine, "a broken file is never merged in");
|
||||
Check(ChatSettingsMerge.Merge(baseJson, mine, null) == mine, "no file: this client's text");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-24: /fship typed on another tab "didn't show": its replies are System
|
||||
/// lines, shown only under All and System. A command sent from the box now puts the System and
|
||||
/// Rynth lines of the next few seconds in the tab it was typed in too.
|
||||
/// </summary>
|
||||
private static void CommandReplyInTypedTab()
|
||||
{
|
||||
Case("command replies: shown in the tab the command was typed in");
|
||||
Check(ChatReplyTab.IsCommand("/fship"), "/fship is a command");
|
||||
Check(ChatReplyTab.IsCommand("/bank d p 10k"), "a command with arguments");
|
||||
Check(ChatReplyTab.IsCommand("@help"), "an @ command");
|
||||
Check(!ChatReplyTab.IsCommand("/tell Bob, hi"), "/tell is chat");
|
||||
Check(!ChatReplyTab.IsCommand("/f hello fellows"), "/f is chat");
|
||||
Check(!ChatReplyTab.IsCommand("/a hello"), "/a is chat");
|
||||
Check(!ChatReplyTab.IsCommand("hello"), "plain text is chat");
|
||||
Check(!ChatReplyTab.IsCommand("/"), "a lone slash");
|
||||
|
||||
var reply = new ChatReplyTab();
|
||||
reply.NoteSent("/fship", "Chat", nowMs: 1000);
|
||||
Check(reply.TabFor("System", automated: false, nowMs: 1200) == "Chat", "the server's reply also shows in Chat");
|
||||
Check(reply.TabFor("Rynth", automated: false, nowMs: 1200) == "Chat", "a plugin's reply too");
|
||||
Check(reply.TabFor("Combat", automated: false, nowMs: 1200) == null, "combat lines stay where they are");
|
||||
Check(reply.TabFor("System", automated: true, nowMs: 1200) == null, "a plugin's own poll reply isn't copied");
|
||||
Check(reply.TabFor("System", automated: false, nowMs: 1000 + ChatReplyTab.WindowMs + 1) == null, "only for a few seconds");
|
||||
|
||||
var fromAll = new ChatReplyTab();
|
||||
fromAll.NoteSent("/fship", "All", nowMs: 1000);
|
||||
Check(fromAll.TabFor("System", false, 1200) == null, "typed in All: it already shows there");
|
||||
|
||||
var fromSystem = new ChatReplyTab();
|
||||
fromSystem.NoteSent("/fship", "System", nowMs: 1000);
|
||||
Check(fromSystem.TabFor("System", false, 1200) == null, "typed in System: already there");
|
||||
Check(fromSystem.TabFor("Rynth", false, 1200) == "System", "a plugin reply still follows to System");
|
||||
|
||||
var chat = new ChatReplyTab();
|
||||
chat.NoteSent("/tell Bob, hi", "Combat", nowMs: 1000);
|
||||
Check(chat.TabFor("System", false, 1200) == null, "a /tell marks nothing");
|
||||
}
|
||||
|
||||
private static void Case(string name)
|
||||
{
|
||||
_case = name;
|
||||
Console.WriteLine("- " + name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-30: /fship list showed nowhere in RynthChat. ILT's reply (flight
|
||||
/// recorder, chat type 0): a dashed rule, "[FSHIP]: Fellowships in your area:", one line per
|
||||
/// fellowship, a dashed rule. No standard filter (every one on) may hide it.
|
||||
/// </summary>
|
||||
private static void FshipListNotFiltered()
|
||||
{
|
||||
string[] reply =
|
||||
{
|
||||
"---------------------------",
|
||||
"[FSHIP]: Fellowships in your area:",
|
||||
" 'But the lum is so good' led by Io (Leader not in area)",
|
||||
"No fellowships found in your area.",
|
||||
};
|
||||
foreach (var p in RynthCore.Engine.UI.Panels.RynthChatPresets.All)
|
||||
foreach (string line in reply)
|
||||
Check(!p.Matches(line, "System"), $"fship list: standard filter '{p.Id}' leaves \"{line.Trim()}\" alone");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2026-10-30: with no chat target captured yet, a server command goes out as "@command"
|
||||
/// (ACE runs it as the "/command"); AC's own commands and chat still need the chat bar.
|
||||
/// </summary>
|
||||
private static void ServerCommandsWithoutChatTarget()
|
||||
{
|
||||
static string? At(string c) => RynthCore.Engine.Compatibility.ServerCommandFallback.TryAsServerCommand(c, out string? a) ? a : null;
|
||||
Check(At("/fship list") == "@fship list", "/fship list -> @fship list");
|
||||
Check(At(" /bank ") == "@bank", "/bank -> @bank (trimmed)");
|
||||
Check(At("/myquests") == "@myquests", "/myquests -> @myquests");
|
||||
Check(At("/f hello all") == null, "/f is fellowship chat: the chat bar");
|
||||
Check(At("/tell Bob, hi") == null, "/tell: the chat bar");
|
||||
Check(At("/framerate") == null, "/framerate is AC's own");
|
||||
Check(At("/LOC") == null, "/loc is AC's own (any case)");
|
||||
Check(At("hello") == null, "plain text isn't a command");
|
||||
Check(At("/") == null && At("/1") == null, "no command word");
|
||||
Check(At("/fship add Bjørn") == null, "non-ASCII stays on the chat bar");
|
||||
}
|
||||
|
||||
private static void Check(bool ok, string what)
|
||||
{
|
||||
_checks++;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ internal static unsafe class Program
|
|||
InitImGui();
|
||||
ScrollChecks();
|
||||
HistoryChecks();
|
||||
AutomatedChecks();
|
||||
Memory();
|
||||
Cpu();
|
||||
Console.WriteLine();
|
||||
|
|
@ -466,6 +467,54 @@ internal static unsafe class Program
|
|||
Console.WriteLine($" {(ok ? "ok " : "FAIL")} {what}: {detail}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automated system text (2026-10-19): RynthChat marks it ("auto"), and the router shows it in
|
||||
/// the System tab only, unless a rule placed it or the setting is off.
|
||||
/// </summary>
|
||||
private static void AutomatedChecks()
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Automated system text checks:");
|
||||
const int Broadcast = 0x00, Say = 0x02, AdminTell = 0x1F, Notice = 0x1A;
|
||||
var router = new ChatRouter(Array.Empty<ChatFilterRule>(), null, "Drakkon", countHits: false, automatedToSystem: true);
|
||||
var line = new ChatLine(1, "08:00:00", "System", Broadcast, null, "Dynamic_1_ANND! - 1 solves (1719432000)\"Dynamic\" 1 0") { Automated = true };
|
||||
ChatRoute route = router.Evaluate(line, null);
|
||||
Check("an automated line shows in System only", route.ShowsIn("System", "System") && !route.ShowsIn("All", "System"), "");
|
||||
var other = new ChatLine(2, "08:00:00", "Other", Notice, null, "flagone") { Automated = true };
|
||||
ChatRoute r2 = router.Evaluate(other, null);
|
||||
Check("an automated line from another channel goes to System, not All or Other",
|
||||
r2.ShowsIn("System", "Other") && !r2.ShowsIn("All", "Other") && !r2.ShowsIn("Other", "Other"), "");
|
||||
var plain = new ChatLine(3, "08:00:00", "System", Broadcast, null, "You feel a chill.");
|
||||
Check("a line not marked automated still shows under All", router.Evaluate(plain, null).ShowsIn("All", "System"), "");
|
||||
var off = new ChatRouter(Array.Empty<ChatFilterRule>(), null, "Drakkon", countHits: false, automatedToSystem: false);
|
||||
Check("setting off: automated lines show under All", off.Evaluate(line, null).ShowsIn("All", "System"), "");
|
||||
var move = new ChatFilterRule { Pattern = "solves", Tab = "Quests", Action = ChatRuleAction.Move };
|
||||
move.Recompile();
|
||||
var ruled = new ChatRouter(new[] { move }, null, "Drakkon", countHits: false, automatedToSystem: true);
|
||||
ChatRoute r3 = ruled.Evaluate(line, null);
|
||||
Check("a rule that moves it still decides first", r3.ShowsIn("Quests", "System") && !r3.ShowsIn("System", "System"), "");
|
||||
#if HAVE_RYNTHCHAT
|
||||
Check("classifier: /myquests and /qb lines are automated (system types only)",
|
||||
RynthCore.Plugin.RynthChat.ChatClassifier.IsAutomatedText("bigflag00001 - 3 solves (1719432000)\"Q\" -1 0", Broadcast)
|
||||
&& RynthCore.Plugin.RynthChat.ChatClassifier.IsAutomatedText("Your current quest bonus count: 15,234", Broadcast)
|
||||
&& RynthCore.Plugin.RynthChat.ChatClassifier.IsAutomatedText("Welcome to Asheron's Call\n powered by ACEmulator", Broadcast)
|
||||
&& !RynthCore.Plugin.RynthChat.ChatClassifier.IsAutomatedText("bigflag00001 - 3 solves (1719432000)\"Q\" -1 0", Say)
|
||||
&& !RynthCore.Plugin.RynthChat.ChatClassifier.IsAutomatedText("Your current quest bonus count: 1", AdminTell), "");
|
||||
var b = new RynthCore.Plugin.RynthChat.ChatBuffer(100);
|
||||
b.Add("Welcome back, the server restarts at noon.", Broadcast, loginBurst: true);
|
||||
b.Add("Bob says, \"hi\"", Say, loginBurst: true);
|
||||
b.Add("An admin tells you, \"hello\"", AdminTell, loginBurst: true);
|
||||
b.Add("You feel a chill.", Broadcast, loginBurst: false);
|
||||
b.Add("qbflagthree", Notice);
|
||||
bool markedWrong = b.NoteEaten("not the newest line");
|
||||
bool marked = b.NoteEaten("qbflagthree");
|
||||
bool[] autos = JsonSerializer.Deserialize(b.BuildJson(0), RynthChatJsonContext.Default.RynthChatLineDtoArray)!.Select(d => d.Auto).ToArray();
|
||||
Check("buffer: login-burst system text is automated; speech, an admin's tell and later text aren't",
|
||||
autos.Length == 5 && autos[0] && !autos[1] && !autos[2] && !autos[3], string.Join(",", autos));
|
||||
Check("buffer: an eaten line is marked when it is the newest; other text isn't", marked && !markedWrong && autos[4], "");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>ChatHistory's arithmetic and RynthChat's resizable ring (newest kept, seq untouched).</summary>
|
||||
private static void HistoryChecks()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,21 @@ namespace RynthCore.Engine.Compatibility
|
|||
}
|
||||
}
|
||||
|
||||
namespace RynthCore.Engine.UI.Panels
|
||||
{
|
||||
/// <summary>The standard filters ChatRouter checks after the rules: none enabled here.</summary>
|
||||
internal static class RynthChatPresets
|
||||
{
|
||||
internal sealed class Preset
|
||||
{
|
||||
internal string Tab { get; } = "";
|
||||
internal string Label { get; } = "";
|
||||
}
|
||||
|
||||
internal static Preset? FirstMatch(string text, string channel) => null;
|
||||
}
|
||||
}
|
||||
|
||||
namespace RynthCore.Engine.UI.Data
|
||||
{
|
||||
internal static class ChatModel
|
||||
|
|
|
|||
24
tools/DatShareSlotTests/DatShareSlotTests.csproj
Normal file
24
tools/DatShareSlotTests/DatShareSlotTests.csproj
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
Offline checks for src\RynthCore.Engine\Compatibility\LazyImportSlotScanner.cs (2026-10-15):
|
||||
the 2025 ACClient.exe resolves kernel32!CreateFileW into a private slot on first use and opens
|
||||
its DAT files through it, so the DAT share hook has to find that slot as well as the import
|
||||
slots. Synthetic images cover the stub shape and the near misses that must not match; when the
|
||||
2025 client is on this PC (or RYNTH_ACCLIENT points at one) its real slot is checked too.
|
||||
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>DatShareSlotTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\LazyImportSlotScanner.cs" Link="Engine\LazyImportSlotScanner.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
241
tools/DatShareSlotTests/Program.cs
Normal file
241
tools/DatShareSlotTests/Program.cs
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
using System.Text;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
|
||||
namespace DatShareSlotTests;
|
||||
|
||||
/// <summary>
|
||||
/// LazyImportSlotScanner: finds the private CreateFileW slot the 2025 ACClient.exe fills on first
|
||||
/// use. Without it the DAT share hook missed every DAT open and a second client failed with
|
||||
/// "Can't open the data files" (2026-10-15).
|
||||
/// </summary>
|
||||
internal static class Program
|
||||
{
|
||||
private static int _checks, _failed;
|
||||
private static string _case = "";
|
||||
|
||||
// Synthetic image layout: headers, .text at 0x1000 (code), .rdata at 0x2000 (strings + slots).
|
||||
private const uint ImageBase = 0x00400000;
|
||||
private const uint TextRva = 0x1000;
|
||||
private const uint DataRva = 0x2000;
|
||||
private const int ImageSize = 0x3000;
|
||||
private const uint DllRva = DataRva + 0x10;
|
||||
private const uint NameRva = DataRva + 0x40;
|
||||
private const uint SlotRva = DataRva + 0x100;
|
||||
|
||||
private static int Main()
|
||||
{
|
||||
ReadsSections();
|
||||
FindsTheStub();
|
||||
UnresolvedOrResolvedSlotIsFoundTheSame();
|
||||
RejectsJmpThroughAnotherSlot();
|
||||
RejectsAnotherDll();
|
||||
RejectsNameAsTailOfLongerName();
|
||||
RejectsBrokenStubShape();
|
||||
OtherFunctionHasNoSlot();
|
||||
Real2025Client();
|
||||
|
||||
Console.WriteLine($"{_checks} check(s), {_failed} failed.");
|
||||
return _failed == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
private static void Check(bool ok, string what)
|
||||
{
|
||||
_checks++;
|
||||
if (ok) return;
|
||||
_failed++;
|
||||
Console.WriteLine($"[FAIL] {_case}: {what}");
|
||||
}
|
||||
|
||||
// ── synthetic image ──────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A minimal PE32 header with .text and .rdata, plus "kernel32.dll" and the name.</summary>
|
||||
private static byte[] NewImage(string functionName = "CreateFileW", string dllName = "kernel32.dll")
|
||||
{
|
||||
var img = new byte[ImageSize];
|
||||
const int pe = 0x80;
|
||||
BitConverter.TryWriteBytes(img.AsSpan(0x3C), pe);
|
||||
Encoding.ASCII.GetBytes("PE\0\0").CopyTo(img, pe);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(pe + 6), (ushort)2); // NumberOfSections
|
||||
BitConverter.TryWriteBytes(img.AsSpan(pe + 20), (ushort)0xE0); // SizeOfOptionalHeader
|
||||
BitConverter.TryWriteBytes(img.AsSpan(pe + 24), (ushort)0x10B); // PE32
|
||||
int table = pe + 24 + 0xE0;
|
||||
WriteSection(img, table, ".text", TextRva, 0x1000, 0x60000020);
|
||||
WriteSection(img, table + 40, ".rdata", DataRva, 0x1000, 0x40000040);
|
||||
Encoding.ASCII.GetBytes(dllName + "\0").CopyTo(img, DllRva);
|
||||
Encoding.ASCII.GetBytes(functionName + "\0").CopyTo(img, NameRva);
|
||||
return img;
|
||||
}
|
||||
|
||||
private static void WriteSection(byte[] img, int at, string name, uint rva, uint size, uint flags)
|
||||
{
|
||||
Encoding.ASCII.GetBytes(name.PadRight(8, '\0')).CopyTo(img, at);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(at + 8), size);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(at + 12), rva);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(at + 16), size);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(at + 20), rva);
|
||||
BitConverter.TryWriteBytes(img.AsSpan(at + 36), flags);
|
||||
}
|
||||
|
||||
/// <summary>Writes the stub at <paramref name="stubRva"/>, the same bytes the 2025 client has.</summary>
|
||||
private static void WriteStub(byte[] img, uint stubRva, uint slotVa, uint nameVa, uint dllVa, uint jmpSlotVa)
|
||||
{
|
||||
var code = new List<byte>();
|
||||
code.Add(0x68); code.AddRange(BitConverter.GetBytes(0x00405BB3u)); // push fallback
|
||||
code.Add(0xFF); code.Add(0x35); code.AddRange(BitConverter.GetBytes(0x00906788u)); // push [handle cache]
|
||||
code.Add(0x68); code.AddRange(BitConverter.GetBytes(slotVa));
|
||||
code.Add(0x68); code.AddRange(BitConverter.GetBytes(nameVa));
|
||||
code.Add(0x68); code.AddRange(BitConverter.GetBytes(dllVa));
|
||||
code.Add(0xE8); code.AddRange(BitConverter.GetBytes(0xFFD4CD41u)); // call resolver
|
||||
code.Add(0xFF); code.Add(0x25); code.AddRange(BitConverter.GetBytes(jmpSlotVa)); // jmp [slot]
|
||||
code.CopyTo(img, (int)stubRva);
|
||||
}
|
||||
|
||||
private static List<LazyImportSlot> Scan(byte[] img, string function = "CreateFileW") =>
|
||||
LazyImportSlotScanner.FindSlots(img, ImageBase, LazyImportSlotScanner.ReadSections(img), "kernel32.dll", function);
|
||||
|
||||
// ── cases ────────────────────────────────────────────────────────────────
|
||||
|
||||
private static void ReadsSections()
|
||||
{
|
||||
_case = "sections";
|
||||
var s = LazyImportSlotScanner.ReadSections(NewImage());
|
||||
Check(s.Count == 2, $"two sections, got {s.Count}");
|
||||
Check(s.Count == 2 && s[0].Name == ".text" && s[0].Executable && s[0].Rva == TextRva, ".text is code at 0x1000");
|
||||
Check(s.Count == 2 && s[1].Name == ".rdata" && !s[1].Executable && s[1].Rva == DataRva, ".rdata is data at 0x2000");
|
||||
Check(LazyImportSlotScanner.ReadSections(new byte[0x100]).Count == 0, "no PE signature: nothing");
|
||||
}
|
||||
|
||||
private static void FindsTheStub()
|
||||
{
|
||||
_case = "stub";
|
||||
var img = NewImage();
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
var found = Scan(img);
|
||||
Check(found.Count == 1, $"one slot, got {found.Count}");
|
||||
Check(found.Count == 1 && found[0].SlotVa == ImageBase + SlotRva, $"slot 0x{ImageBase + SlotRva:X8}");
|
||||
Check(found.Count == 1 && found[0].StubVa == ImageBase + TextRva + 0x20, $"stub at 0x{ImageBase + TextRva + 0x20:X8}, got 0x{(found.Count == 1 ? found[0].StubVa : 0):X8}");
|
||||
}
|
||||
|
||||
private static void UnresolvedOrResolvedSlotIsFoundTheSame()
|
||||
{
|
||||
_case = "slot contents";
|
||||
var img = NewImage();
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
BitConverter.TryWriteBytes(img.AsSpan((int)SlotRva), ImageBase + TextRva + 0x20); // still points at its stub
|
||||
Check(Scan(img).Count == 1, "unresolved (slot points at the stub)");
|
||||
BitConverter.TryWriteBytes(img.AsSpan((int)SlotRva), 0x76ACEA10u); // resolved to kernel32
|
||||
Check(Scan(img).Count == 1, "resolved (slot points into kernel32)");
|
||||
}
|
||||
|
||||
private static void RejectsJmpThroughAnotherSlot()
|
||||
{
|
||||
_case = "jmp slot";
|
||||
var img = NewImage();
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva + 8);
|
||||
Check(Scan(img).Count == 0, "the jmp must go through the slot the stub fills");
|
||||
}
|
||||
|
||||
private static void RejectsAnotherDll()
|
||||
{
|
||||
_case = "dll";
|
||||
var img = NewImage(dllName: "user32.dll");
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
Check(Scan(img).Count == 0, "a stub resolving from user32.dll is not kernel32's CreateFileW");
|
||||
var upper = NewImage(dllName: "KERNEL32.DLL");
|
||||
WriteStub(upper, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
Check(Scan(upper).Count == 1, "the DLL name matches in any case");
|
||||
}
|
||||
|
||||
private static void RejectsNameAsTailOfLongerName()
|
||||
{
|
||||
_case = "longer name";
|
||||
var img = NewImage(functionName: "MyCreateFileW");
|
||||
// Points at the "CreateFileW" tail of "MyCreateFileW".
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva + 2, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
Check(Scan(img).Count == 0, "\"MyCreateFileW\" is not CreateFileW");
|
||||
}
|
||||
|
||||
private static void RejectsBrokenStubShape()
|
||||
{
|
||||
_case = "shape";
|
||||
var img = NewImage();
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
img[TextRva + 0x20 + 26] = 0x90; // the call becomes a nop
|
||||
Check(Scan(img).Count == 0, "no call to the resolver: not a stub");
|
||||
|
||||
var outside = NewImage();
|
||||
WriteStub(outside, TextRva + 0x20, 0x12345678, ImageBase + NameRva, ImageBase + DllRva, 0x12345678);
|
||||
Check(Scan(outside).Count == 0, "a slot outside the image is never written");
|
||||
|
||||
var atStart = NewImage();
|
||||
WriteStub(atStart, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
// A lone push of the name at the very start of .text has no stub around it.
|
||||
atStart[TextRva] = 0x68;
|
||||
BitConverter.TryWriteBytes(atStart.AsSpan((int)TextRva + 1), ImageBase + NameRva);
|
||||
Check(Scan(atStart).Count == 1, "a lone push of the name is skipped, the real stub still found");
|
||||
}
|
||||
|
||||
private static void OtherFunctionHasNoSlot()
|
||||
{
|
||||
_case = "other function";
|
||||
var img = NewImage();
|
||||
WriteStub(img, TextRva + 0x20, ImageBase + SlotRva, ImageBase + NameRva, ImageBase + DllRva, ImageBase + SlotRva);
|
||||
Check(Scan(img, "CreateFileA").Count == 0, "only the named function's slot is returned");
|
||||
}
|
||||
|
||||
// ── the real client ──────────────────────────────────────────────────────
|
||||
|
||||
private static void Real2025Client()
|
||||
{
|
||||
_case = "ACClient.exe 0.0.11.6096";
|
||||
string? path = Environment.GetEnvironmentVariable("RYNTH_ACCLIENT");
|
||||
if (string.IsNullOrEmpty(path))
|
||||
path = @"C:\Turbine\Asheron's Call-ryn\ACClient.exe";
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine($" skip: {path} not found (set RYNTH_ACCLIENT to check a client)");
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] mapped = MapImage(File.ReadAllBytes(path), out uint imageBase);
|
||||
var sections = LazyImportSlotScanner.ReadSections(mapped);
|
||||
var w = LazyImportSlotScanner.FindSlots(mapped, imageBase, sections, "kernel32.dll", "CreateFileW");
|
||||
var a = LazyImportSlotScanner.FindSlots(mapped, imageBase, sections, "kernel32.dll", "CreateFileA");
|
||||
Console.WriteLine($" {path}: CreateFileW slots {string.Join(", ", w.Select(s => $"0x{s.SlotVa:X8} (stub 0x{s.StubVa:X8})"))}; CreateFileA slots {a.Count}");
|
||||
|
||||
// Read from the running client on 2026-10-15: slot 0x00837374 held kernel32!CreateFileW.
|
||||
if (imageBase == 0x00400000 && FileVersion(path) == "00.00.11.6096")
|
||||
{
|
||||
Check(w.Count == 1 && w[0].SlotVa == 0x00837374, "the CreateFileW slot is 0x00837374");
|
||||
Check(w.Count == 1 && w[0].StubVa == 0x006B8D00, "filled by the stub at 0x006B8D00");
|
||||
Check(a.Count == 0, "CreateFileA is a normal import, no private slot");
|
||||
}
|
||||
}
|
||||
|
||||
private static string FileVersion(string path) =>
|
||||
System.Diagnostics.FileVersionInfo.GetVersionInfo(path).FileVersion ?? "";
|
||||
|
||||
/// <summary>Lays a PE file out the way the loader maps it (headers, then each section at its RVA).</summary>
|
||||
private static byte[] MapImage(byte[] file, out uint imageBase)
|
||||
{
|
||||
int pe = BitConverter.ToInt32(file, 0x3C);
|
||||
int opt = pe + 24;
|
||||
imageBase = BitConverter.ToUInt32(file, opt + 28);
|
||||
uint sizeOfImage = BitConverter.ToUInt32(file, opt + 56);
|
||||
uint sizeOfHeaders = BitConverter.ToUInt32(file, opt + 60);
|
||||
var img = new byte[sizeOfImage];
|
||||
Array.Copy(file, img, Math.Min(sizeOfHeaders, (uint)file.Length));
|
||||
int count = BitConverter.ToUInt16(file, pe + 6);
|
||||
int table = opt + BitConverter.ToUInt16(file, pe + 20);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int h = table + 40 * i;
|
||||
uint rva = BitConverter.ToUInt32(file, h + 12);
|
||||
uint rawSize = BitConverter.ToUInt32(file, h + 16);
|
||||
uint raw = BitConverter.ToUInt32(file, h + 20);
|
||||
uint n = Math.Min(rawSize, Math.Min(sizeOfImage - rva, (uint)file.Length - raw));
|
||||
Array.Copy(file, raw, img, rva, n);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
|
@ -255,7 +255,8 @@ namespace EngineSettingsTests
|
|||
Eq(after.GetProperty("EnableImGuiShell").GetBoolean(), false, "EnableImGuiShell kept");
|
||||
Eq(after.GetProperty("DecalBridge").GetString(), "On", "DecalBridge On kept");
|
||||
foreach (JsonProperty p in before.EnumerateObject())
|
||||
Check(after.TryGetProperty(p.Name, out JsonElement kept) && JsonElement.DeepEquals(kept, p.Value), $"unchanged key {p.Name} keeps the file's value");
|
||||
if (p.Name != "DisabledUiHooks")
|
||||
Check(after.TryGetProperty(p.Name, out JsonElement kept) && JsonElement.DeepEquals(kept, p.Value), $"unchanged key {p.Name} keeps the file's value");
|
||||
foreach (string key in new[] { "EnablePlugins", "EnableDatShareHook", "EnableAvaloniaOverlay", "EnableD3D9Hook", "EnableEngine", "EngineHookCount", "EnableHangMinidump", "PreventIdleLogoff" })
|
||||
Check(after.TryGetProperty(key, out _) == before.TryGetProperty(key, out _), $"owned key {key} not added or dropped by an unrelated save");
|
||||
|
||||
|
|
@ -271,6 +272,17 @@ namespace EngineSettingsTests
|
|||
Eq(after.GetProperty("EnableImGuiBackend").GetBoolean(), false, "EnableImGuiBackend saved");
|
||||
Check(after.TryGetProperty("EnableDcompOverlay", out _) && after.TryGetProperty("LauncherWindow", out _), "launcher keys survive a second save");
|
||||
Eq(after.GetProperty("DisabledUiHooks").GetArrayLength(), 1, "first save's DisabledUiHooks kept");
|
||||
|
||||
// Two clients: one saved EnableImGuiBackend=false above; "another client" now turns the
|
||||
// shell back on in the file. A later save of a different key here must not put the
|
||||
// stale EnableImGuiShell back (the last-writer-wins reset of 2026-10-16).
|
||||
var doc = System.Text.Json.Nodes.JsonNode.Parse(File.ReadAllText(path))!.AsObject();
|
||||
doc["EnableImGuiShell"] = true;
|
||||
File.WriteAllText(path, doc.ToJsonString());
|
||||
(exit, output) = RunChild(path, "hook-off", "AnotherHook");
|
||||
Eq(exit, 0, "third child exit code (" + output.Trim() + ")");
|
||||
after = ReadJson(path);
|
||||
Eq(after.GetProperty("EnableImGuiShell").GetBoolean(), true, "another client's EnableImGuiShell survives this client's save");
|
||||
}
|
||||
|
||||
private static void SaveRoundTripsOwnedKeys()
|
||||
|
|
@ -937,14 +949,23 @@ namespace EngineSettingsTests
|
|||
Eq(DecideSave(true, true, true, LogoutRect, InGame, ref pending, t0).Action, AcWindowPlacementRule.SaveAction.LoginShrink, "Save Layout Now on the login-size window: refused");
|
||||
}
|
||||
|
||||
// Source guard: every SetWindowPos on the AC window keeps AC's size (R-20261115-160655-1201).
|
||||
// Source guard: AC's window is never given a size of its own (R-20261115-160655-1201: a restored smaller
|
||||
// window crops the picture and leaves the HUD out of reach). Upstream keeps the size with SWP_NOSIZE. The
|
||||
// test branch's AcWindowChrome (2026-11-17 merge) sizes the window on purpose (Borderless Fills Monitor, a
|
||||
// framed window sized for the resolution), so the guard there is: one SetWindowPos (MoveTo), a restore that
|
||||
// takes only the saved position with the size from AC's resolution, and borderless sized from the
|
||||
// resolution or the monitor.
|
||||
private static void AcWindowChromeNeverResizes()
|
||||
{
|
||||
string source = File.ReadAllText(FindUp(Path.Combine("src", "RynthCore.Engine", "UI", "AcWindowChrome.cs")));
|
||||
var calls = Regex.Matches(source, @"^\s*(?:=>\s*)?SetWindowPos\(hwnd,[^;]*;", RegexOptions.Multiline | RegexOptions.Singleline);
|
||||
Check(calls.Count >= 2, $"found the SetWindowPos calls ({calls.Count})");
|
||||
foreach (Match m in calls)
|
||||
Check(m.Value.Contains("SwpNosize"), "SetWindowPos keeps AC's size: " + Regex.Replace(m.Value.Trim(), @"\s+", " "));
|
||||
Check(calls.Count >= 1, $"found the SetWindowPos calls ({calls.Count})");
|
||||
Check(Regex.IsMatch(source, @"private static void MoveTo\(IntPtr hwnd, RECT r\) =>\s*SetWindowPos\(hwnd,"), "the only window move is MoveTo");
|
||||
Check(calls.Count == 1, $"no SetWindowPos outside MoveTo ({calls.Count})");
|
||||
Match restore = Regex.Match(source, @"private static void TryRestorePlacement\(IntPtr hwnd\)\s*\{(?<body>.*?)\n \}", RegexOptions.Singleline);
|
||||
Check(restore.Success, "found TryRestorePlacement");
|
||||
Check(restore.Groups["body"].Value.Contains("TryFramedSizeForResolution("), "the restore's size comes from AC's resolution, not the saved rect");
|
||||
Check(source.Contains("BorderlessAtResolution(") && source.Contains("IsLoginScreenSize("), "borderless sized from the resolution; the login-screen size never restored");
|
||||
}
|
||||
|
||||
private static void PlacementFilesArePerClient()
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ namespace LootAddWireTests
|
|||
// The op codes the popup labels are the SDK's LootItemAttributeOp.
|
||||
MethodInfo label = opsType.GetMethod("Label", All)!;
|
||||
string L(int op) => (string)label.Invoke(null, new object[] { op })!;
|
||||
Check(L(0) == ">=" && L(1) == "=" && L(2) == "<=" && L(3) == "not", "numeric / named ops label as >= = <= not");
|
||||
Check(L(0) == "at least" && L(1) == "is" && L(2) == "at most" && L(3) == "is not", "numeric / named ops label as words (2026-11-07)");
|
||||
Check(L(4) == "has any" && L(5) == "any" && L(6) == "has all", "flag ops: has any, any, has all");
|
||||
Check(L(10) == "exact" && L(11) == "or better" && L(12) == "any tier", "spell ops label as exact / or better / any tier");
|
||||
|
||||
// ── An older RynthAi: no checklist -> the popup keeps its T11 box ───────────
|
||||
|
|
|
|||
22
tools/PanelStateTests/PanelStateTests.csproj
Normal file
22
tools/PanelStateTests/PanelStateTests.csproj
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
Offline checks for which window-layout file a client uses (src\RynthCore.Engine\UI\PanelStatePath.cs,
|
||||
compiled in): panel_state.<server>.<character>.txt from the launch context's ServerName and
|
||||
TargetCharacter, unsafe characters as "_", and the shared panel_state.txt when the character
|
||||
isn't known. No files, no ImGui. 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>PanelStateTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelStatePath.cs" Link="Engine\PanelStatePath.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
54
tools/PanelStateTests/Program.cs
Normal file
54
tools/PanelStateTests/Program.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using RynthCore.Engine.UI;
|
||||
|
||||
namespace PanelStateTests;
|
||||
|
||||
// Offline tests for the per-character window-layout file name. 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 static void Eq<T>(T actual, T expected, string msg) =>
|
||||
Check(EqualityComparer<T>.Default.Equals(actual, expected), $"{msg}: expected '{expected}', got '{actual}'");
|
||||
|
||||
private static int Main()
|
||||
{
|
||||
FileNames();
|
||||
LaunchContext();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(_fails == 0 ? $"PASS ({_asserts} checks)" : $"FAIL ({_fails} of {_asserts} checks failed)");
|
||||
return _fails == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
/// <summary>Silentkelpie 2026-10-24: each character keeps its own layout, so another client's moves don't reset it.</summary>
|
||||
private static void FileNames()
|
||||
{
|
||||
Console.WriteLine("FileNames");
|
||||
Eq(PanelStatePath.FileNameFor("Infinite Leaftide", "Silentkelpie"), "panel_state.infinite_leaftide.silentkelpie.txt", "server and character");
|
||||
Eq(PanelStatePath.FileNameFor("ILT", "Sir O'Brien-Smith"), "panel_state.ilt.sir_o_brien_smith.txt", "spaces, apostrophe and dash become one _");
|
||||
Eq(PanelStatePath.FileNameFor("", "Silentkelpie"), "panel_state.silentkelpie.txt", "no server: character only");
|
||||
Eq(PanelStatePath.FileNameFor("ILT", ""), PanelStatePath.SharedFileName, "no character: the shared file");
|
||||
Eq(PanelStatePath.FileNameFor(null, null), PanelStatePath.SharedFileName, "nothing known: the shared file");
|
||||
Eq(PanelStatePath.FileNameFor("ILT", " *** "), PanelStatePath.SharedFileName, "a name of only symbols: the shared file");
|
||||
Eq(PanelStatePath.FileNameFor("ILT", "Sílentkelpie"), "panel_state.ilt.s_lentkelpie.txt", "non-ASCII letters become _");
|
||||
string longName = new string('a', 80);
|
||||
Eq(PanelStatePath.FileNameFor("x", longName), $"panel_state.x.{new string('a', PanelStatePath.MaxPartLength)}.txt", "a long name is cut");
|
||||
Eq(PanelStatePath.FileNameFor("ILT", "Silentkelpie"), PanelStatePath.FileNameFor("ilt", "SILENTKELPIE"), "case doesn't make a second file");
|
||||
}
|
||||
|
||||
private static void LaunchContext()
|
||||
{
|
||||
Console.WriteLine("LaunchContext");
|
||||
var parsed = PanelStatePath.ParseLaunchContext("{\"ProcessId\":5392,\"AccountName\":\"acct\",\"ServerName\":\" ILT \",\"TargetCharacter\":\"Silentkelpie\"}");
|
||||
Eq(parsed.Server, "ILT", "server, trimmed");
|
||||
Eq(parsed.Character, "Silentkelpie", "character");
|
||||
Eq(PanelStatePath.ParseLaunchContext("{\"ServerName\":\"ILT\"}").Character, "", "no character");
|
||||
Eq(PanelStatePath.ParseLaunchContext("{\"TargetCharacter\":42}").Character, "", "a non-string character");
|
||||
Eq(PanelStatePath.ParseLaunchContext("{ cut-off").Character, "", "a broken file");
|
||||
Eq(PanelStatePath.ParseLaunchContext("[1,2]").Character, "", "not an object");
|
||||
Eq(PanelStatePath.ParseLaunchContext(null).Character, "", "no file");
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ internal static class Program
|
|||
Run(nameof(ServerBlockRejectsBadIds), ServerBlockRejectsBadIds);
|
||||
Run(nameof(ServerHostMatching), ServerHostMatching);
|
||||
Run(nameof(ServerGateKeepsOnlyTheHostsPlugin), ServerGateKeepsOnlyTheHostsPlugin);
|
||||
Run(nameof(ServerGateUnclaimedHost), ServerGateUnclaimedHost);
|
||||
Run(nameof(ServerGateFailsOpen), ServerGateFailsOpen);
|
||||
Run(nameof(ServerGatePlanFromFiles), ServerGatePlanFromFiles);
|
||||
Run(nameof(SdkApiVersionCannotDrift), SdkApiVersionCannotDrift);
|
||||
Run(nameof(TrainingStructsMirror), TrainingStructsMirror);
|
||||
|
|
@ -525,7 +525,7 @@ internal static class Program
|
|||
Eq(PluginManifestGate.SelectServerPlugins(list, "leafdawn.hopto.org", true, log).Count, 0, "LoadAllServerPlugins keeps every one");
|
||||
}
|
||||
|
||||
private static void ServerGateUnclaimedHost()
|
||||
private static void ServerGateFailsOpen()
|
||||
{
|
||||
var list = new List<PluginCandidate>
|
||||
{
|
||||
|
|
@ -534,7 +534,7 @@ internal static class Program
|
|||
};
|
||||
var log = new List<string>();
|
||||
Eq(PluginManifestGate.SelectServerPlugins(list, "", false, log).Count, 0, "no connect host: all load");
|
||||
Eq(PluginManifestGate.SelectServerPlugins(list, "10.0.0.5", false, log).Count, 2, "a host nobody lists: none load now (late load by world name or a pick)");
|
||||
Eq(PluginManifestGate.SelectServerPlugins(list, "10.0.0.5", false, log).Count, 0, "a host nobody lists: all load");
|
||||
Check(log.Any(l => l.Contains("none lists host 10.0.0.5")), "said why");
|
||||
}
|
||||
|
||||
|
|
@ -608,8 +608,8 @@ internal static class Program
|
|||
(int)Marshal.OffsetOf<RynthCore.PluginSdk.RynthCoreApiNative>(prev) + IntPtr.Size, "SDK " + slot + " right after " + prev);
|
||||
prev = slot;
|
||||
}
|
||||
Eq(typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(4).Last(), "GetMonsterHealthFn", "engine table: GetMonsterHealthFn precedes the four");
|
||||
Eq(typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(4).Last(), "GetMonsterHealthFn", "SDK table: GetMonsterHealthFn precedes the four");
|
||||
Eq(typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(2 + 4).Last(), "GetMonsterHealthFn", "engine table: GetMonsterHealthFn precedes the four (v98's two placement slots follow them)");
|
||||
Eq(typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(2 + 4).Last(), "GetMonsterHealthFn", "SDK table: GetMonsterHealthFn precedes the four (v98's two placement slots follow them)");
|
||||
}
|
||||
|
||||
private static void StructMirror(Type engine, Type sdk, int size)
|
||||
|
|
@ -758,27 +758,36 @@ 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, v91's two, v93's one and v94's four).
|
||||
var names = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(31).TakeLast(6).ToArray();
|
||||
// eleven slots to v89, then v90's thirteen, v91's two, v93's one, v94's four and v98's two).
|
||||
var names = typeof(RynthCore.Engine.Plugins.RynthCoreAPI).GetFields().Select(f => f.Name).SkipLast(33).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(31).TakeLast(6).ToArray();
|
||||
var sdkNames = typeof(RynthCore.PluginSdk.RynthCoreApiNative).GetFields().Select(f => f.Name).SkipLast(33).TakeLast(6).ToArray();
|
||||
Check(sdkNames.SequenceEqual(names), "SDK v79, v80 and v81 slots in the same order");
|
||||
}
|
||||
|
||||
// v80: GetContainerOrder and PutItemInContainer come right before v81's slot, engine and SDK alike;
|
||||
// v81: GetMergeStackResult, then v82: SalvageDirect, v83's two and v84's GetObjectProperties last. The whole table has the same field names in the same
|
||||
// order on both sides, and the same size.
|
||||
// v81: GetMergeStackResult, v82: SalvageDirect, v83: the ghost-creature pair, v84: GetObjectProperties,
|
||||
// v85: the confirmation pair, v86: GetServerStateJson last.
|
||||
// The whole table has the same field names in the same order on both sides, and the same size.
|
||||
private static void ContainerOrderSlots()
|
||||
{
|
||||
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();
|
||||
// v94: the web panel's four slots end the table; the checks after these are on the table before them.
|
||||
// v98: the per-character window placements end the table (2026-10-26; v91 on the test branch, v94 after
|
||||
// upstream's v93, v98 after upstream's v94-v97, 2026-11-14); upstream's v94 web panel slots right before them.
|
||||
string[] v98 = { "GetWindowPlacementFn", "SetWindowPlacementFn" };
|
||||
Check(all.TakeLast(v98.Length).SequenceEqual(v98), "v98 slots last: " + string.Join(",", all.TakeLast(v98.Length)));
|
||||
Check(sdkAll.TakeLast(v98.Length).SequenceEqual(v98), "SDK v98 slots last: " + string.Join(",", sdkAll.TakeLast(v98.Length)));
|
||||
foreach (string slot in v98)
|
||||
Eq((int)Marshal.OffsetOf<RynthCore.PluginSdk.RynthCoreApiNative>(slot),
|
||||
(int)Marshal.OffsetOf<RynthCore.Engine.Plugins.RynthCoreAPI>(slot), slot + " offset");
|
||||
// v94: the web panel's four slots come right before them.
|
||||
string[] v94 = { "WebPanelOpenFn", "WebPanelNavigateFn", "WebPanelCloseFn", "WebPanelGetStateFn" };
|
||||
Check(all.TakeLast(v94.Length).SequenceEqual(v94), "v94 slots last: " + string.Join(",", all.TakeLast(v94.Length)));
|
||||
Check(sdkAll.TakeLast(v94.Length).SequenceEqual(v94), "SDK v94 slots last: " + string.Join(",", sdkAll.TakeLast(v94.Length)));
|
||||
all = all.SkipLast(v94.Length).ToArray();
|
||||
sdkAll = sdkAll.SkipLast(v94.Length).ToArray();
|
||||
Check(all.SkipLast(v98.Length).TakeLast(v94.Length).SequenceEqual(v94), "v94 slots before v98: " + string.Join(",", all.SkipLast(v98.Length).TakeLast(v94.Length)));
|
||||
Check(sdkAll.SkipLast(v98.Length).TakeLast(v94.Length).SequenceEqual(v94), "SDK v94 slots before v98: " + string.Join(",", sdkAll.SkipLast(v98.Length).TakeLast(v94.Length)));
|
||||
all = all.SkipLast(v98.Length + v94.Length).ToArray();
|
||||
sdkAll = sdkAll.SkipLast(v98.Length + v94.Length).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());
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ internal static class Program
|
|||
BarMenuHoverTiming();
|
||||
BarMenuReload();
|
||||
StackCheckAfterPluginDraw();
|
||||
RatesRises();
|
||||
RatesBank();
|
||||
RatesChat();
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
|
||||
|
|
@ -334,19 +337,6 @@ internal static class Program
|
|||
Check(load.Count == 1 && load[0] == "coldeve", "only the server forced On asks for its plugin");
|
||||
forces["coldeve"] = ServerForce.Off;
|
||||
Check(NotLoadedServers.ForcedOn(notLoaded, Force).Count == 0, "Off loads nothing");
|
||||
|
||||
// The connect host is nobody's (none load at start); the world name the server announces
|
||||
// loads its plugin late, unless that server is forced Off.
|
||||
var byWorld = new[]
|
||||
{
|
||||
new NotLoadedServer("frost", "Frosthaven", "RynthFrostACE", new[] { "Frosthaven*" }),
|
||||
new NotLoadedServer("coldeve", "Coldeve", "RynthColdeve", new[] { "Coldeve" }),
|
||||
};
|
||||
Check(NotLoadedServers.ToLoad(byWorld, Force, null).Count == 0, "before login: nothing loads by world name");
|
||||
var hit = NotLoadedServers.ToLoad(byWorld, Force, "Frosthaven PvE");
|
||||
Check(hit.Count == 1 && hit[0] == "frost", "the announced world name loads its server's plugin");
|
||||
Check(NotLoadedServers.ToLoad(byWorld, Force, "Coldeve").Count == 0, "a server forced Off isn't loaded by its world name");
|
||||
Check(NotLoadedServers.ToLoad(byWorld, Force, "Somewhere Else").Count == 0, "a world nobody lists loads nothing");
|
||||
}
|
||||
|
||||
private static void SelectionCurrentPick()
|
||||
|
|
@ -805,6 +795,79 @@ internal static class Program
|
|||
Check(!ImGuiStackState.WroteExpectedSize(Enumerable.Repeat((byte)0xCC, 64).ToArray(), 0xCC), "nothing written: off");
|
||||
}
|
||||
|
||||
// ── Session rates (status feed / Session Stats) ────────────────────
|
||||
|
||||
private static readonly DateTime T0 = new(2026, 10, 13, 12, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
/// <summary>XP and character luminance: only rises count, the first read is the baseline.</summary>
|
||||
private static void RatesRises()
|
||||
{
|
||||
Case("rates rises");
|
||||
var r = new SessionRates();
|
||||
Check(r.View(T0).Xp == 0 && r.View(T0).Seconds == 0, "zeros before the first sample");
|
||||
r.Sample(0, new SessionRatesSample(100, 5, null, null, null), T0);
|
||||
Check(r.Character == 0, "character 0 is ignored");
|
||||
|
||||
r.Sample(7, new SessionRatesSample(1_000, 50, null, null, null), T0);
|
||||
Check(r.View(T0).Xp == 0 && r.View(T0).Lum == 0, "first read is the baseline");
|
||||
r.Sample(7, new SessionRatesSample(4_000, 80, null, null, null), T0.AddMinutes(30));
|
||||
r.Sample(7, new SessionRatesSample(4_000, 10, null, null, null), T0.AddMinutes(45)); // spent 70 lum
|
||||
r.Sample(7, new SessionRatesSample(5_000, 30, null, null, null), T0.AddHours(1));
|
||||
SessionRatesView v = r.View(T0.AddHours(1));
|
||||
Check(v.Xp == 4_000, "xp is the sum of rises: " + v.Xp);
|
||||
Check(v.Lum == 50, "a spend moves the baseline, it doesn't take earnings back: " + v.Lum);
|
||||
Check(Math.Abs(v.XpPerHour - 4_000) < 0.001 && Math.Abs(v.LumPerHour - 50) < 0.001, "per hour over one hour");
|
||||
Check(r.View(T0).Seconds == 1, "a session is at least one second long");
|
||||
|
||||
r.Sample(8, new SessionRatesSample(9_000, 1, null, null, null), T0.AddHours(2));
|
||||
v = r.View(T0.AddHours(2));
|
||||
Check(r.Character == 8 && v.Xp == 0 && v.Lum == 0 && v.StartUtc == T0.AddHours(2), "a new character starts a new session");
|
||||
}
|
||||
|
||||
/// <summary>ACECustom's bank (9005) and Aelrynth's banked (9102) / drawn (9103) totals.</summary>
|
||||
private static void RatesBank()
|
||||
{
|
||||
Case("rates bank");
|
||||
var r = new SessionRates();
|
||||
r.Sample(1, new SessionRatesSample(null, 100, 1_000, null, null), T0);
|
||||
r.Sample(1, new SessionRatesSample(null, 100, 1_500, null, null), T0.AddMinutes(1));
|
||||
Check(r.View(T0.AddMinutes(1)).Lum == 500, "a bank rise is income");
|
||||
r.Sample(1, new SessionRatesSample(null, 400, 1_200, null, null), T0.AddMinutes(2));
|
||||
Check(r.View(T0.AddMinutes(2)).Lum == 500, "a withdrawal (bank down, character up) isn't income once the bank is tracked");
|
||||
|
||||
var a = new SessionRates();
|
||||
a.Sample(2, new SessionRatesSample(null, 10, null, 0, 0), T0);
|
||||
a.Sample(2, new SessionRatesSample(null, 10, null, 300, 0), T0.AddMinutes(1));
|
||||
Check(a.View(T0.AddMinutes(1)).Lum == 300, "auto-banked luminance was earned");
|
||||
a.Sample(2, new SessionRatesSample(null, 210, null, 300, 200), T0.AddMinutes(2));
|
||||
Check(a.View(T0.AddMinutes(2)).Lum == 300, "drawn luminance landing on the character isn't earned");
|
||||
a.Sample(2, new SessionRatesSample(null, 260, null, 300, 200), T0.AddMinutes(3));
|
||||
Check(a.View(T0.AddMinutes(3)).Lum == 350, "a real character rise after a draw still counts");
|
||||
}
|
||||
|
||||
/// <summary>Deposits and incoming transfers seen in chat aren't income; the marker expires.</summary>
|
||||
private static void RatesChat()
|
||||
{
|
||||
Case("rates chat");
|
||||
Check(SessionRates.TryMovedIntoBank("Deposited 1,234 luminance into your bank.", out long n) && n == 1_234, "a deposit line");
|
||||
Check(SessionRates.TryMovedIntoBank(" Received 50 luminance from Kelpie.", out n) && n == 50, "a transfer line, padded");
|
||||
Check(!SessionRates.TryMovedIntoBank("Kelpie tells you, \"Deposited 5 luminance\"", out _), "a quoted line isn't a deposit");
|
||||
Check(!SessionRates.TryMovedIntoBank("Deposited luminance", out _) && !SessionRates.TryMovedIntoBank(null, out _), "no amount, null");
|
||||
Check(!SessionRates.TryMovedIntoBank("Deposited 99999999999999999999 luminance", out _), "overflow is rejected");
|
||||
|
||||
var r = new SessionRates();
|
||||
r.Sample(1, new SessionRatesSample(null, 1_000, 0, null, null), T0);
|
||||
r.OnChat("Deposited 600 luminance", T0.AddSeconds(5));
|
||||
r.Sample(1, new SessionRatesSample(null, 400, 600, null, null), T0.AddSeconds(6));
|
||||
Check(r.View(T0.AddSeconds(6)).Lum == 0, "a deposit is moved money");
|
||||
r.Sample(1, new SessionRatesSample(null, 400, 700, null, null), T0.AddSeconds(7));
|
||||
Check(r.View(T0.AddSeconds(7)).Lum == 100, "the next bank rise after the deposit is income");
|
||||
|
||||
r.OnChat("Received 50 luminance from Someone", T0.AddSeconds(10));
|
||||
r.Sample(1, new SessionRatesSample(null, 400, 800, null, null), T0.AddSeconds(100));
|
||||
Check(r.View(T0.AddSeconds(100)).Lum == 200, "the marker expires after 60 seconds");
|
||||
}
|
||||
|
||||
// ── Harness ────────────────────────────────────────────────────────
|
||||
|
||||
private static void Case(string name)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
<!-- Installed server plugins the connect host left out: listed in the picker, loaded when forced On. -->
|
||||
<Compile Include="..\..\src\RynthCore.Engine\UI\Sections\NotLoadedServers.cs" Link="Engine\NotLoadedServers.cs" />
|
||||
<!-- The status feed's / Session Stats' XP and luminance session formula (pure). -->
|
||||
<Compile Include="..\..\src\RynthCore.Engine\Compatibility\SessionRates.cs" Link="Engine\SessionRates.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace SettingsLayoutTests
|
|||
{
|
||||
string[] want =
|
||||
{
|
||||
"Interface", "Game Client", "Hotkeys",
|
||||
"Interface", "Game Client", "Graphics", "Hotkeys", // Graphics: the test branch's per-account AC graphics profile
|
||||
"General", "Recharge", "Combat", "Spell Combat", "Ranges", "Navigation", "Buffing", "Looting", "Inventory", "Vendoring",
|
||||
"Diagnostics",
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue