diff --git a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/TickGuard.cs b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/TickGuard.cs index cae96ca..70fd98f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/TickGuard.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/TickGuard.cs @@ -243,6 +243,7 @@ internal sealed class TickGuard if (!keepsFailing || st.Warned) return; st.Warned = true; string what = $"{ex.GetType().Name}: {ex.Message}"; + if (NeedsNewerCore(ex)) what = $"this RynthAi needs a newer RynthCore core: install the core update in the launcher - {what}"; if (info.Essential) { Say($"[RynthAi] {info.Name} keeps failing ({what}); it is tried every tick, the rest of the bot keeps running. See the log."); @@ -255,6 +256,32 @@ internal sealed class TickGuard } } + /// + /// The failure is a member or type this RynthAi was built against and the loaded RynthCore + /// library lacks (2026-11-23, R-20261123-203520-9756 and three more: RynthAi 2026.11.23.1 on a + /// 2026.11.19.1 core, "looting is off ... MissingMethodException: Method not found: 'Int32 + /// RynthCore.Loot.VTank.VTankLootRule.get_PerDayHours()'"). The update feed ships the plugin as + /// one DLL; the libraries it shares with the other plugins (RynthCore.LootSdk, PluginSdk, + /// PluginCore) come with the core installer in Runtime\PluginShared, so a plugin updated without + /// its core finds an older copy. RynthAi's own types (RynthCore.Plugin.RynthAi.*) never count. + /// + internal static bool NeedsNewerCore(Exception? ex) + { + for (int depth = 0; ex != null && depth < 4; depth++, ex = ex.InnerException) + { + if (ex is not (MissingMemberException or TypeLoadException)) continue; + string m = ex.Message ?? string.Empty; + if (ex is TypeLoadException tle && !string.IsNullOrEmpty(tle.TypeName)) m += " " + tle.TypeName; + int at = 0; + while ((at = m.IndexOf("RynthCore.", at, StringComparison.Ordinal)) >= 0) + { + if (string.CompareOrdinal(m, at, "RynthCore.Plugin.RynthAi", 0, 24) != 0) return true; + at += 10; + } + } + return false; + } + private void Say(string line) { _log(line); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs index ece9009..d4e57e6 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/TickIsolationTests.cs @@ -28,6 +28,7 @@ internal static class TickIsolationTests public static void Register(Runner r) { r.Add("tick isolation: a step before healing that throws every tick (quest tracker) doesn't stop the heal", HealDespiteEarlierFault); + r.Add("tick guard: a member missing from a shared RynthCore library says to install the core update (R-20261123-203520-9756)", GuardSaysNeedsNewerCore); r.Add("tick isolation: chores that throw every tick (mana stones, AutoCram) don't stop combat's heartbeat", CombatDespiteChoreFault); r.Add("tick isolation: a chore failing every tick is switched off with one chat line, retried every 60 s, back on when it works", ChoreTripsAndRecovers); r.Add("tick isolation: healing failing every tick is never switched off; one chat line, and combat still runs", HealingNeverTrips); @@ -267,6 +268,28 @@ internal static class TickIsolationTests return (g, log, chat, () => now += stepMs); } + private static void GuardSaysNeedsNewerCore() + { + var (g, _, chat, advance) = Guard(); + var ex = new MissingMethodException("Method not found: 'Int32 RynthCore.Loot.VTank.VTankLootRule.get_PerDayHours()'."); + for (int i = 0; i < 60; i++) { g.Failed(TickStep.Looting, ex); advance(); } + Check.True(g.IsOff(TickStep.Looting), "looting is off"); + string line = chat.FirstOrDefault(l => l.Contains("looting is off")) ?? ""; + Check.True(line.Contains("this RynthAi needs a newer RynthCore core: install the core update in the launcher"), "the line says what to do: " + line); + Check.True(line.Contains("get_PerDayHours"), "and still names the missing member"); + + Check.True(TickGuard.NeedsNewerCore(new TypeLoadException("Could not load type 'RynthCore.Loot.LootPerDay' from assembly 'RynthCore.LootSdk, Version=1.0.0.0'.")), "a missing type from the loot library"); + Check.True(TickGuard.NeedsNewerCore(new InvalidOperationException("wrapped", new MissingFieldException("Field not found: 'RynthCore.PluginSdk.X.Y'."))), "an inner missing member counts"); + Check.False(TickGuard.NeedsNewerCore(new MissingMethodException("Method not found: 'Void RynthCore.Plugin.RynthAi.Foo.Bar()'.")), "RynthAi's own types never count"); + Check.False(TickGuard.NeedsNewerCore(new InvalidOperationException("RynthCore.Loot broke")), "another kind of failure doesn't"); + Check.False(TickGuard.NeedsNewerCore(new MissingMethodException("Method not found: 'Void MoonSharp.Interpreter.Script.Foo()'.")), "a third-party library doesn't"); + + var (g2, _, chat2, advance2) = Guard(); + var plain = new InvalidOperationException("bad spell data"); + for (int i = 0; i < 60; i++) { g2.Failed(TickStep.Salvage, plain); advance2(); } + Check.False(chat2.Any(l => l.Contains("newer RynthCore")), "an ordinary failure's line is unchanged"); + } + private static void GuardLogThrottle() { var (g, log, chat, advance) = Guard();