diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs index 7869228..6044ed2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs @@ -211,6 +211,14 @@ internal sealed class HudController _combat.OnLogout(); } + /// + /// What the character carries, from a walk of the client's own pack contents (the loot step's + /// Keep # count reads the same). The cache's inventory set, kept up from object events, drifts over + /// a long session: after 10+ hours of macro the HUD showed 1 healing kit of 4 and 4 mana stones of + /// 6 (report R-20261103-125252-251c, 2026-11-03). + /// + private static IEnumerable Carried(WorldObjectCache cache) => cache.GetDirectInventory(); + /// Aggregates the pack by item name and refreshes pinned entries' icon / WCID. private void RebuildPack() { @@ -219,7 +227,7 @@ internal sealed class HudController var byName = new Dictionary(StringComparer.OrdinalIgnoreCase); var seen = new HashSet(); - foreach (var wo in cache.GetInventory()) + foreach (var wo in Carried(cache)) { if (wo == null || string.IsNullOrWhiteSpace(wo.Name)) continue; seen.Add(wo.Id); @@ -270,7 +278,7 @@ internal sealed class HudController if (entry.IsEmpty) return; var cache = _cache(); if (cache == null || !_host.HasUseObject) return; - var inv = cache.GetInventory().Where(w => w != null).ToList(); + var inv = Carried(cache).Where(w => w != null).ToList(); var wo = inv.FirstOrDefault(w => w.Name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase)) ?? (entry.Wcid != 0 ? inv.FirstOrDefault(w => Wcid(w) == entry.Wcid) : null); if (wo == null) { Chat($"[RynthAi] No {entry.Name} in your pack."); return; } @@ -280,7 +288,7 @@ internal sealed class HudController /// Carried item by object id, or null. private WorldObject? PackItem(int id) - => id == 0 ? null : _cache()?.GetInventory().FirstOrDefault(w => w != null && w.Id == id); + => id == 0 || _cache() is not WorldObjectCache cache ? null : Carried(cache).FirstOrDefault(w => w != null && w.Id == id); /// /// Remembers the last pack item selected in the game (native inventory, or the RynthCore diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs index f3508f5..24cbb79 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs @@ -333,10 +333,15 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Separator(); ImGui.Spacing(); - ImGui.Checkbox("Auto Cram", ref _settings.EnableAutocram); - if (ImGui.IsItemHovered()) + ImGui.BeginDisabled(_settings.AutoSortOn); + bool cramShown = _settings.EnableAutocram && !_settings.AutoSortOn; + if (ImGui.Checkbox("Auto Cram", ref cramShown)) _settings.EnableAutocram = cramShown; + ImGui.EndDisabled(); + if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) { - ImGui.SetTooltip("Automatically moves items from your main pack into side packs.\nNote: recently used weapons stay in the main pack."); + ImGui.SetTooltip(_settings.AutoSortOn + ? "Off while RynthSort's auto-sort is on: RynthSort keeps your packs sorted, and the two fight." + : "Automatically moves items from your main pack into side packs.\nNote: recently used weapons stay in the main pack."); } ImGui.Spacing(); @@ -1142,7 +1147,12 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Spacing(); ImGui.Text("Inventory Management"); ImGui.Checkbox("Enable Autostack", ref _settings.EnableAutostack); - ImGui.Checkbox("Enable Autocram", ref _settings.EnableAutocram); + ImGui.BeginDisabled(_settings.AutoSortOn); + bool cramShown2 = _settings.EnableAutocram && !_settings.AutoSortOn; + if (ImGui.Checkbox("Enable Autocram", ref cramShown2)) _settings.EnableAutocram = cramShown2; + ImGui.EndDisabled(); + if (_settings.AutoSortOn && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip("Off while RynthSort's auto-sort is on: RynthSort keeps your packs sorted, and the two fight."); ImGui.Checkbox("Combine Salvage Bags", ref _settings.EnableCombineSalvage); if (ImGui.IsItemHovered()) ImGui.SetTooltip("After the salvage queue empties, move same-name bags together so the server merges them."); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs index 8fc0906..a34584f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs @@ -91,6 +91,15 @@ internal sealed partial class LegacyDashboardRenderer // ── Per-character settings persistence ─────────────────────────────────── private string _charFolder = string.Empty; private string _settingsFilePath = string.Empty; + // The character's profile is in memory (LoadSettings finished; cleared at logout). Until then the + // settings here are the built-in defaults, and they must never reach the engine or be taken back + // from it: after an engine hot reload the engine read them, and the next click in its dashboard + // sent the whole default copy back, which was applied and saved over the profile (2026-11-05, and + // the same way raycasting kept turning off). + private volatile bool _profileLoaded; + + /// The character's profile is loaded: settings may be read and changed from outside. + public bool ProfileLoaded => _profileLoaded; private string _lastSavedJson = string.Empty; private Vector2 _expandedSize = new(430, 452); @@ -505,6 +514,7 @@ internal sealed partial class LegacyDashboardRenderer try { CaptureTransientUiState(); _lastSavedJson = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); } catch { _lastSavedJson = string.Empty; } } + _profileLoaded = true; } /// @@ -515,6 +525,7 @@ internal sealed partial class LegacyDashboardRenderer /// public void ResetCharacterSession() { + _profileLoaded = false; _charFolder = string.Empty; _settingsFilePath = string.Empty; _lastSavedJson = string.Empty; @@ -613,6 +624,7 @@ internal sealed partial class LegacyDashboardRenderer // DXVK change, the launcher's stuck-client kill) left a cut-off file that then loaded // as defaults. string tmp = path + "." + Environment.ProcessId + ".tmp"; + KeepDailyCopy(path); try { File.WriteAllText(tmp, json); @@ -628,6 +640,31 @@ internal sealed partial class LegacyDashboardRenderer /// The last good profile kept by each save (profile path + this). internal const string BackupSuffix = ".bak"; + /// Daily copies kept of each profile (profile path + ".yyyy-MM-dd.bak"). + internal const int DailyCopiesKept = 7; + + /// + /// The first save of a day keeps the profile as it was (Default.json.2026-11-05.bak), the last + /// days kept: .bak alone is the save before, so a reset that was saved + /// twice left nothing to go back to (2026-11-05). Best effort: a copy that fails never stops the save. + /// + internal static void KeepDailyCopy(string path) + { + try + { + if (!File.Exists(path)) return; + string today = path + "." + RynthClock.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + BackupSuffix; + if (File.Exists(today)) return; + File.Copy(path, today); + string dir = Path.GetDirectoryName(path)!, name = Path.GetFileName(path); + var old = Directory.GetFiles(dir, name + ".????-??-??" + BackupSuffix); + Array.Sort(old, StringComparer.Ordinal); + for (int i = 0; i < old.Length - DailyCopiesKept; i++) + try { File.Delete(old[i]); } catch { } + } + catch { } + } + /// Reads and parses a settings profile; false (with the reason) when it's missing or doesn't parse. private static bool TryReadProfile(string path, out LegacyUiSettings? settings, out string json, out string error) { @@ -1234,6 +1271,7 @@ internal sealed partial class LegacyDashboardRenderer TargetFPSFocused = s.TargetFPSFocused, TargetFPSBackground = s.TargetFPSBackground, EnableAutocram = s.EnableAutocram, + AutoSortOn = s.AutoSortOn, PeaceModeWhenIdle = s.PeaceModeWhenIdle, RearmAfterVitals = s.RearmAfterVitals, StartMacroOnLogin = s.StartMacroOnLogin, @@ -1465,6 +1503,13 @@ internal sealed partial class LegacyDashboardRenderer public void ApplySettingsJson(string json) { if (string.IsNullOrWhiteSpace(json)) return; + if (!_profileLoaded) + { + // Nothing from outside lands on the defaults held before the profile loads (they'd be saved + // over it once it does): the engine's copy then can only be the defaults it read. + try { _host.Log("[RynthAi] Settings: a settings change from the engine came before this character's profile loaded; ignored."); } catch { } + return; + } try { // Lay the sent fields over the current settings, so a field the sender leaves diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs index 4a85064..39d3ab4 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs @@ -19,6 +19,11 @@ public sealed class LegacyUiSettings { // ── Runtime-only state — never persisted ──────────────────────────────── [JsonIgnore] public bool IsMacroRunning; + /// + /// RynthSort's auto-sort is on (read from RynthSort every couple of seconds): Auto Cram stands down and + /// its checkboxes are greyed out, as the two fought over the packs (owner, 2026-11-03). Never saved. + /// + [JsonIgnore] public bool AutoSortOn; /// Meta state — set only by meta actions (SetState, CallState, ReturnFromCall, UI, meta load). [JsonIgnore] public string CurrentState = "Default"; /// Bot action state — what the bot is doing right now (Default, Combat, Looting, Navigating, Buffing). @@ -1172,6 +1177,8 @@ public sealed class SettingsBridgePayload public int TargetFPSFocused { get; set; } public int TargetFPSBackground { get; set; } public bool EnableAutocram { get; set; } + /// RynthSort's auto-sort is on: the engine greys out Auto Cram (sent, never read back). + public bool AutoSortOn { get; set; } public bool PeaceModeWhenIdle { get; set; } // Optional: an engine without the row doesn't send it, and that must not turn it off. public bool? RearmAfterVitals { get; set; } @@ -1190,7 +1197,7 @@ public sealed class SettingsBridgePayload public float? OutdoorHuntRadius { get; set; } // Absent from an older engine's payload: must not read as off. public bool YieldToVTank { get; set; } = true; - public bool EnableRaycasting { get; set; } + public bool EnableRaycasting { get; set; } = true; // on unless the player turns it off (2026-11-05) public bool UseArcs { get; set; } public float BowArcVelocity { get; set; } public float CrossbowArcVelocity { get; set; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs index b8589c7..b080161 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs @@ -134,7 +134,9 @@ public sealed class InventoryManager private bool ProcessAutoCram(List inv, int playerId) { - if (!_settings.EnableAutocram && !ManualCram) return false; + // RynthSort's auto-sort on: it owns the packs, and Auto Cram moving items back out of the main pack + // fought it (owner, 2026-11-03). A cram asked for by hand (/ra cram) still runs. + if ((!_settings.EnableAutocram || _settings.AutoSortOn) && !ManualCram) return false; int crammable = 0; foreach (var item in inv) diff --git a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs index 28687ab..71fdcdf 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs @@ -683,7 +683,11 @@ public static unsafe class PluginExports { try { - string json = Runtime.Plugin?.DashboardRenderer?.BuildSettingsJson() ?? "{}"; + // Nothing until the character's profile is loaded (not "{}": the engine read that as a full + // settings copy of its own defaults, and its next save wrote them over the profile, 2026-11-05). + var renderer = Runtime.Plugin?.DashboardRenderer; + if (renderer == null || !renderer.ProfileLoaded) return IntPtr.Zero; + string json = renderer.BuildSettingsJson(); IntPtr newPtr = Marshal.StringToHGlobalAnsi(json); IntPtr oldPtr = Interlocked.Exchange(ref _settingsPtr, newPtr); if (oldPtr != IntPtr.Zero) diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Dashboard.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Dashboard.cs index 0f7a5ca..e0800d1 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Dashboard.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Dashboard.cs @@ -105,10 +105,12 @@ public sealed partial class RynthAiPlugin _dashboard?.RefreshDashboardVitals(); _dashFight = ReadFightTarget(_dashFight); } - if (shown && now >= _nextDashSortMs) + if (now >= _nextDashSortMs) { - _nextDashSortMs = now + 500; + // Twice a second for the dashboard's key; every 2 s otherwise, for Auto Cram (AutoSortOn). + _nextDashSortMs = now + (shown ? 500 : 2000); _dashSort = ReadAutoSort(); + if (_dashboard?.Settings is { } sortSettings) sortSettings.AutoSortOn = _dashSort == 1; } if (now >= _nextDashClassicMs) { diff --git a/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorPlanner.cs b/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorPlanner.cs index 8de5ee6..98c47ca 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorPlanner.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorPlanner.cs @@ -459,9 +459,14 @@ internal static class AutoVendorPlanner if (chosen.Count < 1) { int newStack = unit > 0 ? (int)Math.Floor((p.FreeMainSlots - 2) * (double)Math.Max(1, p.PyrealStackSize) / unit) : 0; + // A partial sold whole frees its own slot for the pyreals, so it may be one slot's worth + // bigger than a split: the stack a split just made took a slot, and judged against the + // split's own margin it no longer fitted, was merged back, and the split came again + // until the 8-try stop left the last stack of peas unsold (2026-11-05). + int sellWholeUpTo = unit > 0 ? (int)Math.Floor((p.FreeMainSlots - 1) * (double)Math.Max(1, p.PyrealStackSize) / unit) : 0; newStack = Math.Min(newStack, stack - 1); if (newStack > 0) - return SplitClean(v, sells, item, newStack, "the pyreals for the whole stack won't fit"); + return SplitClean(v, sells, item, newStack, "the pyreals for the whole stack won't fit", sellWholeUpTo); return VendorPlan.Fatal($"AutoVendor Fatal - No inventory room to sell {item.Name}"); } break; @@ -535,7 +540,10 @@ internal static class AutoVendorPlanner /// fits, else split from it (nothing else partial for the new stack to join); with none, split as /// asked. An unknown max stack size keeps the old plain split. /// - internal static VendorPlan SplitClean(VendorView v, IReadOnlyList sells, SellItem item, int amount, string why) + /// The biggest partial that can be sold whole (its own slot counted free; at + /// least ), else . + internal static VendorPlan SplitClean(VendorView v, IReadOnlyList sells, SellItem item, int amount, string why, + int sellWholeUpTo = -1) { if (item.MaxStack <= 1) return VendorPlan.Split(item, amount, why); @@ -547,7 +555,8 @@ internal static class AutoVendorPlanner // A partial that fits is sold whole first: the stack a split just made, or any leftover. (Merging // it back instead looped split-merge-split three times a second, 2026-10-19.) - SellItem? fits = partials.FirstOrDefault(s => s.StackSize <= amount); + int wholeUpTo = Math.Max(amount, sellWholeUpTo); + SellItem? fits = partials.FirstOrDefault(s => s.StackSize <= wholeUpTo); if (fits != null) return new VendorPlan { Kind = PlanKind.Sell, Sells = new List { fits }, Total = VendorPays(v, fits.IsNote, fits.Value) }; diff --git a/Plugins/RynthCore.Plugin.RynthVision/Overlays/SlopeOverlay.cs b/Plugins/RynthCore.Plugin.RynthVision/Overlays/SlopeOverlay.cs index c85a1d6..3aaefba 100644 --- a/Plugins/RynthCore.Plugin.RynthVision/Overlays/SlopeOverlay.cs +++ b/Plugins/RynthCore.Plugin.RynthVision/Overlays/SlopeOverlay.cs @@ -36,7 +36,7 @@ internal sealed class SlopeOverlay public void Submit(TickContext ctx) { - if (!_settings.ShowUnclimbableSlopes || ctx.Terrain == null || !ctx.OnLandscape) + if (!_settings.ShowUnclimbableSlopes || ctx.Terrain == null || !ctx.OnLandscape || ctx.Indoors) return; if (!_host.HasNav3DTriangle) // requires API v60+ return; diff --git a/Plugins/RynthCore.Plugin.RynthVision/Overlays/TickContext.cs b/Plugins/RynthCore.Plugin.RynthVision/Overlays/TickContext.cs index 102f0ed..96f1e81 100644 --- a/Plugins/RynthCore.Plugin.RynthVision/Overlays/TickContext.cs +++ b/Plugins/RynthCore.Plugin.RynthVision/Overlays/TickContext.cs @@ -23,6 +23,12 @@ internal sealed class TickContext /// public bool OnLandscape; + /// + /// True inside a building or dungeon cell (EnvCell). The terrain under a building runs + /// through its floors, so the slope and water overlays stay off there. + /// + public bool Indoors => (CellId & 0xFFFF) >= 0x100; + /// The terrain around the player, or null while terrain data isn't loaded. public LandblockWindow? Terrain; diff --git a/Plugins/RynthCore.Plugin.RynthVision/Overlays/WaterOverlay.cs b/Plugins/RynthCore.Plugin.RynthVision/Overlays/WaterOverlay.cs index aac0335..762c2e7 100644 --- a/Plugins/RynthCore.Plugin.RynthVision/Overlays/WaterOverlay.cs +++ b/Plugins/RynthCore.Plugin.RynthVision/Overlays/WaterOverlay.cs @@ -61,7 +61,7 @@ internal sealed class WaterOverlay public void Submit(TickContext ctx) { - if (!_settings.ShowImpassableWater || ctx.Terrain == null || !ctx.OnLandscape) + if (!_settings.ShowImpassableWater || ctx.Terrain == null || !ctx.OnLandscape || ctx.Indoors) return; if (!_host.HasNav3DTriangle) // requires API v60+ return; diff --git a/Tools/RynthCore.AutoVendorTests/Program.cs b/Tools/RynthCore.AutoVendorTests/Program.cs index d30624b..5b9501a 100644 --- a/Tools/RynthCore.AutoVendorTests/Program.cs +++ b/Tools/RynthCore.AutoVendorTests/Program.cs @@ -410,6 +410,20 @@ internal static class Program Eq(justSplit2.Kind, PlanKind.Sell, "same with a full stack first"); Eq(justSplit2.Sells.Single().Id, 3u, "the 38"); + // 2026-11-05 (DreamWeave, Pyreal Peas at 50,000 each, two pyreal stacks a pea): the last full stack, + // 80 free slots: split 39 off ((80 - 2) * 25000 / 50000). The new stack takes a slot (79 free): it + // must still be sold whole (its slot frees for the pyreals), never merged back onto the 61. + SellItem PyPea(uint id, int stack) => new() { Id = id, Name = "Pyreal Pea", Value = 50_000 * stack, StackSize = stack, + Class = AcObjectClass.Misc, ItemType = 0x40000000, RuleName = "S: Peas", MaxStack = 100, Wcid = 9003 }; + var lastStack = AutoVendorPlanner.PlanNext(v, none, new List { PyPea(1, 100) }, Pack(0, free: 80)); + Eq(lastStack.Kind, PlanKind.Split, "the last full stack: split"); + Eq(lastStack.SplitAmount, 39, "39 peas fit"); + var afterSplit = AutoVendorPlanner.PlanNext(v, none, new List { PyPea(1, 61), PyPea(2, 39) }, Pack(0, free: 79)); + Eq(afterSplit.Kind, PlanKind.Sell, "after the split: the 39 is sold, not merged back (the loop that left a stack)"); + Eq(afterSplit.Sells.Single().Id, 2u, "the split-off 39"); + var oneTooBig = AutoVendorPlanner.PlanNext(v, none, new List { PyPea(1, 61), PyPea(2, 41) }, Pack(0, free: 79)); + Eq(oneTooBig.Kind, PlanKind.Merge, "a partial more than a slot's worth too big still merges first"); + var onePartialFits = AutoVendorPlanner.PlanNext(v, none, new List { Pea(1, 100), Pea(2, 79) }, Pack(0, free: 88)); Eq(onePartialFits.Kind, PlanKind.Sell, "one partial that fits: sold whole, no split"); Eq(onePartialFits.Sells.Single().Id, 2u, "the partial"); diff --git a/Tools/RynthCore.RynthAiHostTests/Program.cs b/Tools/RynthCore.RynthAiHostTests/Program.cs index f72a038..589dd0f 100644 --- a/Tools/RynthCore.RynthAiHostTests/Program.cs +++ b/Tools/RynthCore.RynthAiHostTests/Program.cs @@ -170,6 +170,7 @@ internal static class Program VTankHotkeyTests.Register(runner); FightSelectedTests.Register(runner); OneTouchHealTests.Register(runner); + ItemHudCountTests.Register(runner); SaveFailureTests.Register(runner); EnvironmentImpactTests.Register(runner); SkCombatAddonTests.Register(runner); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ActionPacingTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ActionPacingTests.cs index 6131c37..e9318c6 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ActionPacingTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ActionPacingTests.cs @@ -1157,6 +1157,7 @@ internal static class ActionPacingTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); var cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/BlankLoadTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/BlankLoadTests.cs index c4857f8..baf126c 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/BlankLoadTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/BlankLoadTests.cs @@ -55,6 +55,7 @@ internal static class BlankLoadTests Directory.CreateDirectory(Metas); Dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(Dash, true); // a stand-in with its profile in memory var navFiles = new List(); Set("_settings", S); Set("_host", FakeHost.Create()); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/BuffTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/BuffTests.cs index d21561c..9489e61 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/BuffTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/BuffTests.cs @@ -634,6 +634,7 @@ internal static class BuffTests Check.True(payload != null && payload.CastBuffsOverItemBuffs == null, "an older engine's payload has no value"); var s = new LegacyUiSettings { CastBuffsOverItemBuffs = false }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); // BuildSettingsJson reads its crafting state @@ -757,6 +758,7 @@ internal static class BuffTests var s = new LegacyUiSettings(); s.SetBuffEnabled("Frost Bane", false); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); @@ -2140,6 +2142,7 @@ internal static class BuffTests Check.True(payload != null && payload.SkipUnusableBuffs == null, "an older engine's payload has no value"); var s = new LegacyUiSettings { SkipUnusableBuffs = false }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs index f4e86a5..104837d 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs @@ -101,6 +101,7 @@ internal static class ChestLootTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ChoresInFightTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ChoresInFightTests.cs index d108770..8c63c63 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ChoresInFightTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ChoresInFightTests.cs @@ -23,6 +23,7 @@ internal static class ChoresInFightTests { r.Add("chores: a fight is a monster in Monster Range or on top of us; never with the macro or combat off", FightSignal); r.Add("chores: AutoCram waits while a monster is on us, and crams once the fight is over", CramWaitsForFight); + r.Add("chores: AutoCram stands down while RynthSort's auto-sort is on (they fought); off again, it crams; /ub autocram by hand still runs", CramOffWithAutoSort); } private static CombatManager.ScannedTarget At(double yards) => @@ -87,4 +88,45 @@ internal static class ChoresInFightTests } finally { TickIsolationTests.Done(); } } + + // Owner, 2026-11-03: "Auto sort and auto cram are fighting each other. When auto sort is on, auto + // cram should be disabled". RynthAi reads RynthSort's auto-sort (LegacyUiSettings.AutoSortOn). + private static void CramOffWithAutoSort() + { + try + { + var bot = new TickIsolationTests.Bot(combat: true, heal: false, arrange: () => + { + FakeHost.Names[Gem] = "Black Opal"; + FakeHost.ItemTypes[Gem] = ItemTypeGem; + FakeHost.Containers[Gem] = Player; + FakeHost.Names[SidePack] = "Backpack"; + FakeHost.ItemTypes[SidePack] = ItemTypeContainer; + FakeHost.Ints[(SidePack, ItemsCapacityKey)] = 24; + FakeHost.Containers[SidePack] = Player; + }); + _ = bot.Cache[unchecked((int)Gem)]; + _ = bot.Cache[unchecked((int)SidePack)]; + bot.S.EnableAutocram = true; + bot.S.AutoSortOn = true; + var inv = new InventoryManager(bot.Host, bot.S, bot.Cache); + bot.Set("_inventoryManager", inv); + for (int i = 0; i < 5; i++) bot.Call("TickCramStack", bot.S); + Check.Eq(FakeHost.Moves.Count, 0, "auto-sort on: Auto Cram moves nothing (the setting itself stays on)"); + Check.True(bot.S.EnableAutocram, "the player's Auto Cram choice is kept"); + + inv.RunManual(cram: true, stack: false); + bot.Call("TickCramStack", bot.S); + Check.True(FakeHost.Moves.Any(m => m.Id == Gem && m.Pack == SidePack), "a cram asked for by hand still runs"); + + FakeHost.Moves.Clear(); + FakeHost.Containers[Gem] = Player; // back in the main pack + bot.S.AutoSortOn = false; + var inv2 = new InventoryManager(bot.Host, bot.S, bot.Cache); + bot.Set("_inventoryManager", inv2); + bot.Call("TickCramStack", bot.S); + Check.True(FakeHost.Moves.Any(m => m.Id == Gem && m.Pack == SidePack), "auto-sort off: Auto Cram crams again"); + } + finally { TickIsolationTests.Done(); } + } } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/CommandReplyTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/CommandReplyTests.cs index 70f99fb..092cb8b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/CommandReplyTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/CommandReplyTests.cs @@ -452,6 +452,7 @@ internal static class CommandReplyTests var host = FakeHost.Create(playerId: Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/CorpseCloseTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/CorpseCloseTests.cs index c0ed1b4..558fd98 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/CorpseCloseTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/CorpseCloseTests.cs @@ -123,6 +123,7 @@ internal static class CorpseCloseTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/DoorTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/DoorTests.cs index f3e0b5b..8387e5e 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/DoorTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/DoorTests.cs @@ -116,6 +116,7 @@ internal static class DoorTests typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(Host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/FightSelectedTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/FightSelectedTests.cs index 58a0737..83bd47b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/FightSelectedTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/FightSelectedTests.cs @@ -364,6 +364,7 @@ internal static class FightSelectedTests // The engine Settings face: sent; a save without the field leaves it alone. var s = new LegacyUiSettings { FightSelectedTarget = true }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", Any)!.SetValue(dash, new LegacyAdvancedSettingsUi(s)); var sent = System.Text.Json.JsonSerializer.Deserialize(dash.BuildSettingsJson(), RynthAiJsonContext.Default.SettingsBridgePayload); @@ -404,6 +405,7 @@ internal static class FightSelectedTests S = t.S; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Set("_objectCache", t.Cache); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/GiveTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/GiveTests.cs index fe4a7d1..d4e35d5 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/GiveTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/GiveTests.cs @@ -90,6 +90,7 @@ internal static class GiveTests var host = FakeHost.Create(playerId: Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/HazardEscapeTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/HazardEscapeTests.cs index e7b888d..d13086b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/HazardEscapeTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/HazardEscapeTests.cs @@ -53,6 +53,7 @@ internal static class HazardEscapeTests var host = FakeHost.Create(Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); typeof(RynthAiPlugin).GetField("_dashboard", Any)!.SetValue(P, dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ItemHudCountTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ItemHudCountTests.cs new file mode 100644 index 0000000..f97d383 --- /dev/null +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ItemHudCountTests.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using RynthCore.Plugin.RynthAi; +using RynthCore.Plugin.RynthAi.Huds; +using RynthCore.RynthAiHostTests.Fakes; +using RynthCore.RynthAiTests.Harness; + +namespace RynthCore.RynthAiHostTests.Tests; + +// The item count HUD and the Mini Remote's item slots (HudController.RebuildPack) count from the +// client's own pack walk. They read the cache's inventory set, kept up from object events, and after +// 10+ hours of macro it showed 1 healing kit of 4 and 4 mana stones of 6 (report +// R-20261103-125252-251c, 2026-11-03); the loot step's Keep # count already walked the pack. +internal static class ItemHudCountTests +{ + private const uint Player = 0x50000D01; + private const uint Pack = 0x80004D10; + private const uint Kit1 = 0x80004D01, Kit2 = 0x80004D02, Kit3 = 0x80004D03, Kit4 = 0x80004D04; + private const uint Stone1 = 0x80004D05, Stone2 = 0x80004D06; + + public static void Register(Runner r) + { + r.Add("item HUD: counts what the pack walk finds, not the cache's event-kept inventory set", CountsThePackWalk); + } + + private static void CountsThePackWalk() + { + FakeHost.Reset(); + FakeHost.ContentsCalls = true; // GetContainerContents: the client's pack walk + FakeHost.Names[Pack] = "Pack"; + FakeHost.ItemTypes[Pack] = 0x200; // Container + FakeHost.Containers[Pack] = Player; + foreach (uint k in new[] { Kit1, Kit2, Kit3, Kit4 }) + { + FakeHost.Names[k] = "Treated Healing Kit"; + FakeHost.Containers[k] = k == Kit4 ? Pack : Player; // one in a side pack + } + foreach (uint s in new[] { Stone1, Stone2 }) + { + FakeHost.Names[s] = "Major Mana Stone"; + FakeHost.Containers[s] = Player; + } + var host = FakeHost.Create(Player); + // The cache's own set heard of one kit and one stone only (the drift). + var cache = FakeHost.MakeCache(host, Player, new[] { Kit1, Stone1 }); + Check.Eq(cache.GetInventory().Count(w => w.Name == "Treated Healing Kit"), 1, "the event-kept set is short (the report's case)"); + + string dir = Path.Combine(Path.GetTempPath(), "rynthai-hudcount-" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(dir); + try + { + var hud = new HudController(host, dir, () => cache, null!, () => null, new HudIconCache(host, () => null), () => 0); + typeof(HudController).GetMethod("RebuildPack", BindingFlags.Instance | BindingFlags.NonPublic)!.Invoke(hud, null); + Check.Eq(hud.Pack.CountOf("Treated Healing Kit"), 4L, "all four kits, the side pack's too"); + Check.Eq(hud.Pack.CountOf("Major Mana Stone"), 2L, "both stones"); + } + finally { try { Directory.Delete(dir, true); } catch { } } + } +} \ No newline at end of file diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ItemToolTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ItemToolTests.cs index 3abca30..2a2c49e 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ItemToolTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ItemToolTests.cs @@ -627,6 +627,7 @@ internal static class ItemToolTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LearnSpellsTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LearnSpellsTests.cs index 79a9420..fb7efd7 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LearnSpellsTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LearnSpellsTests.cs @@ -172,6 +172,7 @@ internal static class LearnSpellsTests S = s; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootAddItemTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootAddItemTests.cs index 5fe06bd..e8d419f 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootAddItemTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootAddItemTests.cs @@ -100,6 +100,7 @@ internal static class LootAddItemTests Host = host; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = FakeHost.MakeCache(host, Player, new[] { Player, Opal, Taper, Coin }.Concat(extra)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootChatLineTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootChatLineTests.cs index 99f4b4c..e4e5cd5 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootChatLineTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootChatLineTests.cs @@ -109,6 +109,7 @@ internal static class LootChatLineTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs index eae4f24..dc346b3 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs @@ -97,6 +97,7 @@ internal static class LootClaimMismatchTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs index 07d0db8..a0c5b8c 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs @@ -196,6 +196,7 @@ internal static class LootCorpseTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs index e8e5f42..193c42f 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs @@ -90,6 +90,7 @@ internal static class LootJumpTests }; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(bot, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s); void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(bot, v); Set("_dashboard", dash); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootLateIdTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootLateIdTests.cs index 2f76e9c..ea06899 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootLateIdTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootLateIdTests.cs @@ -96,6 +96,7 @@ internal static class LootLateIdTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootNothingLineTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootNothingLineTests.cs index 9fdf58b..41df638 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootNothingLineTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootNothingLineTests.cs @@ -104,6 +104,7 @@ internal static class LootNothingLineTests Host = host; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootPacingTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootPacingTests.cs index 4f079b7..fc5871b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootPacingTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootPacingTests.cs @@ -89,6 +89,7 @@ internal static class LootPacingTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootRaresModeTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootRaresModeTests.cs index b9e3c75..f43916e 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootRaresModeTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootRaresModeTests.cs @@ -142,6 +142,7 @@ internal static class LootRaresModeTests S.LootMode = mode; typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); Dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(Dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(Dash, S); Set("_dashboard", Dash); Cache = new WorldObjectCache(host); @@ -350,6 +351,7 @@ internal static class LootRaresModeTests // The engine's Settings face: sent; a save without it leaves it alone. var s = new LegacyUiSettings { LootMode = LootModes.Rares }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", Any)!.SetValue(dash, new LegacyAdvancedSettingsUi(s)); var sent = JsonSerializer.Deserialize(dash.BuildSettingsJson(), RynthAiJsonContext.Default.SettingsBridgePayload); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs index a0f26e7..73672a1 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs @@ -120,6 +120,7 @@ internal static class LootRetryTimingTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootSpeedTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootSpeedTests.cs index dee383c..d75c0b1 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootSpeedTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootSpeedTests.cs @@ -117,6 +117,7 @@ internal static class LootSpeedTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootWandTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootWandTests.cs index e99ba3d..0ab9217 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootWandTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootWandTests.cs @@ -275,6 +275,7 @@ internal static class LootWandTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs index b9f1bed..79550d9 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs @@ -195,6 +195,7 @@ internal static class MetaAuditTests typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var s = new LegacyUiSettings(); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s); Set("_dashboard", dash); Set("_initialized", true); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs index 9d84c02..1db046f 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs @@ -87,6 +87,7 @@ internal static class MetaSampleCompatTests FakeHost.Create(playerId: 0x50000F31); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, new LegacyUiSettings()); Set("_dashboard", dash); Set("_initialized", true); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs index b2939ba..d0e491d 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs @@ -268,6 +268,7 @@ internal static class MiniRemoteMoveTests var s = new LegacyUiSettings(); var dash = (LegacyDashboardRenderer)System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory var flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance; typeof(LegacyDashboardRenderer).GetField("_settings", flags)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", flags)!.SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/NavMapEditTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/NavMapEditTests.cs index 48831bd..156c3d9 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/NavMapEditTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/NavMapEditTests.cs @@ -152,6 +152,7 @@ internal static class NavMapEditTests // RynthPluginGetNavJson reports the map edit version with the route. var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, Settings(P(1, 2), P(3, 4))); typeof(LegacyDashboardRenderer).GetField("_navFiles", Any)!.SetValue(dash, new System.Collections.Generic.List()); // Field initializers don't run on an uninitialized object; the route editor's status line. @@ -174,6 +175,7 @@ internal static class NavMapEditTests var nav = (LegacyNavigationUi)RuntimeHelpers.GetUninitializedObject(typeof(LegacyNavigationUi)); typeof(LegacyNavigationUi).GetField("_settings", Any)!.SetValue(nav, s); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_navigationUi", Any)!.SetValue(dash, nav); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/NavOverlayTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/NavOverlayTests.cs index 8bf62a5..c93c839 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/NavOverlayTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/NavOverlayTests.cs @@ -45,6 +45,7 @@ internal static class NavOverlayTests s.NavOverlay.TrackBreadcrumbs = false; s.NavOverlay.ShowRouteMarkers = true; var dash = (LegacyDashboardRenderer)System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory var flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance; typeof(LegacyDashboardRenderer).GetField("_settings", flags)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", flags)!.SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/NavResumeTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/NavResumeTests.cs index b5b2dfa..ed26982 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/NavResumeTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/NavResumeTests.cs @@ -335,6 +335,7 @@ internal static class NavResumeTests FakeHost.Reset(); At(0, 0); var s = new LegacyUiSettings { IsMacroRunning = true }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory void Set(string f, object v) => typeof(LegacyDashboardRenderer).GetField(f, Any)!.SetValue(dash, v); Set("_settings", s); Set("_host", FakeHost.Create()); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs index 18e3f3e..eb131b9 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs @@ -96,6 +96,7 @@ internal static class OwnCorpseTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); @@ -304,6 +305,7 @@ internal static class OwnCorpseTests Check.True(payload != null && payload.LootOwnCorpse == null && payload.TravelToOwnCorpse == null, "an older engine's payload has no value"); var s = new LegacyUiSettings { LootOwnCorpse = false, TravelToOwnCorpse = true }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolModeTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolModeTests.cs index 63d5992..4314184 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolModeTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolModeTests.cs @@ -42,6 +42,7 @@ internal static class PatrolModeTests FakeHost.Create(Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); typeof(RynthAiPlugin).GetField("_dashboard", Any)!.SetValue(P, dash); } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolPortalTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolPortalTests.cs index fac0614..e799f82 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolPortalTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolPortalTests.cs @@ -430,6 +430,7 @@ internal static class PatrolPortalTests typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(plugin, new object[] { FakeHost.LastApi }); var settings = new LegacyUiSettings(); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, settings); void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(plugin, v); object? Call(string m, params object?[] a) => typeof(RynthAiPlugin).GetMethod(m, Any)!.Invoke(plugin, a); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolSettingsTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolSettingsTests.cs index adc9319..fa3838b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/PatrolSettingsTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/PatrolSettingsTests.cs @@ -176,6 +176,7 @@ internal static class PatrolSettingsTests { var s = new LegacyUiSettings { DunPatrolCoverage = 1, DunPatrolSkipDeadEnds = 6, DunPatrolAvoidFloors = false, DunPatrolWallDistance = 1.25f, DunPatrolLookInSize = 15f, DunPatrolSightYd = 30f }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/PluginFixTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/PluginFixTests.cs index 25ab972..78178e2 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/PluginFixTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/PluginFixTests.cs @@ -72,6 +72,7 @@ internal static class PluginFixTests Host = FakeHost.Create(playerId: Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); Dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(Dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(Dash, new LegacyUiSettings()); typeof(LegacyDashboardRenderer).GetField("_host", Any)!.SetValue(Dash, Host); Cache = new WorldObjectCache(Host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ProfileLoadTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ProfileLoadTests.cs index db141a8..68797cb 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ProfileLoadTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ProfileLoadTests.cs @@ -26,6 +26,8 @@ internal static class ProfileLoadTests public static void Register(Runner r) { r.Add("profile: every saved setting survives loading (CopySettings lists each serialized field)", EverySavedFieldIsCopied); + r.Add("profile: nothing from the engine lands before the profile loads, or after logout (2026-11-05 settings reset)", NoEngineChangeWithoutProfile); + r.Add("profile: the first save of a day keeps a dated copy, the last 7 days kept", DailyCopiesKept); r.Add("profile: Describe Items and the Item Info options survive a save and a reload", ItemInfoSurvivesReload); r.Add("profile: a profile with null item info / nav overlay loads defaults, not null", NullNestedOptionsLoadDefaults); r.Add("profile: a save is atomic (temp file swapped in, no temp left) and keeps the previous profile as .bak", SaveKeepsBackup); @@ -340,4 +342,51 @@ internal static class ProfileLoadTests Check.Eq(File.ReadAllText(Path.Combine(dir, "Third.json")), goodJson, "and put back as the profile"); Check.Eq(Directory.GetFiles(dir, "Third.json.unreadable-*").Length, 1, "the empty file is kept too"); } + + // 2026-11-05: after an engine hot reload the engine read RynthAi's built-in defaults (the profile wasn't + // loaded yet) and the next click in its dashboard sent the whole default copy back, saved over the profile. + private static void NoEngineChangeWithoutProfile() + { + string dir = NewCharDir("guard", out var dash); + var saved = new LegacyUiSettings { StartMacroOnLogin = true, TopOffHP = 77, EnableLooting = true }; + File.WriteAllText(Path.Combine(dir, "Default.json"), Json(saved)); + Check.False(dash.ProfileLoaded, "before LoadSettings: no profile in memory"); + + dash.ApplySettingsJson("{\"StartMacroOnLogin\":false,\"TopOffHP\":50,\"EnableLooting\":false}"); + Check.True(File.Exists(Path.Combine(dir, "Default.json")) && File.ReadAllText(Path.Combine(dir, "Default.json")).Contains("\"TopOffHP\": 77"), + "an engine change before the profile loads doesn't touch the file"); + + dash.LoadSettings("Tester"); + LegacyUiSettings live = SettingsOf(dash); + Check.True(dash.ProfileLoaded, "after LoadSettings: loaded"); + Check.True(live.StartMacroOnLogin && live.TopOffHP == 77 && live.EnableLooting, "the profile's own values, not the early engine change"); + + dash.ApplySettingsJson("{\"TopOffHP\":80}"); + Check.Eq(live.TopOffHP, 80, "loaded: an engine edit lands"); + Check.True(live.StartMacroOnLogin && live.EnableLooting, "and only the field it sent"); + + dash.ResetCharacterSession(); + Check.False(dash.ProfileLoaded, "logout: no profile in memory"); + dash.ApplySettingsJson("{\"TopOffHP\":10}"); + Check.Eq(live.TopOffHP, 80, "an engine change after logout is ignored"); + } + + private static void DailyCopiesKept() + { + string dir = NewCharDir("daily", out var dash); + string path = Path.Combine(dir, "Default.json"); + for (int d = 1; d <= 9; d++) + File.WriteAllText(path + ".2026-10-0" + d + LegacyDashboardRenderer.BackupSuffix, "{}"); + File.WriteAllText(path, Json(new LegacyUiSettings { TopOffHP = 66 })); + dash.LoadSettings("Tester"); + SettingsOf(dash).TopOffHP = 67; + dash.SaveSettings(); + string today = path + "." + DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + LegacyDashboardRenderer.BackupSuffix; + Check.True(File.Exists(today) && File.ReadAllText(today).Contains("\"TopOffHP\": 66"), "today's copy holds the profile from before the save"); + Check.Eq(Directory.GetFiles(dir, "Default.json.????-??-??.bak").Length, LegacyDashboardRenderer.DailyCopiesKept, "seven days kept"); + Check.False(File.Exists(path + ".2026-10-01" + LegacyDashboardRenderer.BackupSuffix), "the oldest went"); + SettingsOf(dash).TopOffHP = 68; + dash.SaveSettings(); + Check.True(File.ReadAllText(today).Contains("\"TopOffHP\": 66"), "a second save the same day leaves today's copy alone"); + } } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/RebuffWhenIdleTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/RebuffWhenIdleTests.cs index d5b49a4..efa2d73 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/RebuffWhenIdleTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/RebuffWhenIdleTests.cs @@ -285,6 +285,7 @@ internal static class RebuffWhenIdleTests // The engine's Settings face: sent; a save without it (an engine that doesn't know it) leaves it alone. var s = new LegacyUiSettings { RebuffIdleMarginMinutes = 5 }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ServerPluginForwardTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ServerPluginForwardTests.cs index 5cb14cf..1c0e778 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ServerPluginForwardTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ServerPluginForwardTests.cs @@ -33,6 +33,7 @@ internal static class ServerPluginForwardTests var p = new RynthAiPlugin(); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(p, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, new LegacyUiSettings()); typeof(RynthAiPlugin).GetField("_dashboard", Any)!.SetValue(p, dash); var client = new ServerHubClient(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ServerPolicyTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ServerPolicyTests.cs index 923b0a4..e778f86 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ServerPolicyTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ServerPolicyTests.cs @@ -56,6 +56,7 @@ internal static class ServerPolicyTests Host = FakeHost.Create(Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); typeof(RynthAiPlugin).GetField("_dashboard", Any)!.SetValue(P, dash); } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/SkCombatAddonTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/SkCombatAddonTests.cs index d3d795b..90435b0 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/SkCombatAddonTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/SkCombatAddonTests.cs @@ -344,6 +344,7 @@ internal static class SkCombatAddonTests private static LegacyDashboardRenderer Dash(LegacyUiSettings s) { var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs index f6715da..eae9795 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs @@ -228,6 +228,7 @@ internal static class TargetingTests // Engine Settings face: the payload carries them; an engine without the fields leaves them alone. s = new LegacyUiSettings { TargetSelection = 2, TargetLock = false }; var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s); typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)! .SetValue(dash, new LegacyAdvancedSettingsUi(s)); // BuildSettingsJson reads its crafting state diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs index 8191e44..ece9009 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs @@ -73,6 +73,7 @@ internal static class TickIsolationTests typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); // As UseAtLoginTests: every empty collection/lock field of the dashboard gets an instance. foreach (var f in typeof(LegacyDashboardRenderer).GetFields(Any)) diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs index 2b28a34..4079eec 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs @@ -49,6 +49,7 @@ internal static class UbCompatTests var host = FakeHost.Create(playerId: Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); var cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/UbMtSafetyTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/UbMtSafetyTests.cs index d331651..1c41b1b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/UbMtSafetyTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/UbMtSafetyTests.cs @@ -59,6 +59,7 @@ internal static class UbMtSafetyTests var host = FakeHost.Create(playerId: Player); typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); var cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/UseAtLoginTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/UseAtLoginTests.cs index 5dddbe5..21f440b 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/UseAtLoginTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/UseAtLoginTests.cs @@ -90,6 +90,7 @@ internal static class UseAtLoginTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); // The full OnTick reaches the dashboard's queues and lists: give every empty // collection/lock field a fresh instance (the constructor builds ImGui panels and diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/UseRefusalTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/UseRefusalTests.cs index bbbae57..1e687dd 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/UseRefusalTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/UseRefusalTests.cs @@ -217,6 +217,7 @@ internal static class UseRefusalTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = new WorldObjectCache(host); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/VTankHotkeyTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/VTankHotkeyTests.cs index 9e87955..63939f6 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/VTankHotkeyTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/VTankHotkeyTests.cs @@ -231,6 +231,7 @@ internal static class VTankHotkeyTests { typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi }); var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer)); + typeof(LegacyDashboardRenderer).GetField("_profileLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(dash, true); // a stand-in with its profile in memory typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S); Set("_dashboard", dash); Cache = cache ?? new WorldObjectCache(host);