Snapshot for release 2026.10.21.3 (internal 24a7b4f)

This commit is contained in:
Tom Bohar 2026-10-21 21:03:48 -04:00
commit 10c58b53b6
47 changed files with 2032 additions and 649 deletions

View file

@ -22,6 +22,7 @@
<ItemGroup>
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Raycasting\BoundingVolume.cs" Link="Linked\BoundingVolume.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Raycasting\BlacklistManager.cs" Link="Linked\BlacklistManager.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\RynthClock.cs" Link="Linked\RynthClock.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Raycasting\DungeonLOS.cs" Link="Linked\DungeonLOS.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Raycasting\GeometryLoader.cs" Link="Linked\GeometryLoader.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Raycasting\LandblockStructs.cs" Link="Linked\LandblockStructs.cs" />

View file

@ -149,6 +149,8 @@ internal static class Program
ServerHubClientLookupTests.Register(runner);
UbMtSafetyTests.Register(runner);
DifficultyTierTests.Register(runner);
TickIsolationTests.Register(runner);
ChoresInFightTests.Register(runner);
return runner.Run("RynthAi host tests", args.Length > 0 ? args[0] : null);
}
}

View file

@ -28,6 +28,100 @@ internal static class CastNoDamageTests
r.Add("no-damage casts: other monsters still get predicted kills; the memory lapses after 10 min", OthersStillPredicted);
r.Add("no-damage casts: the chat after a combat cast is logged, swings at us left out, capped, 4 s", CastChatTrace);
r.Add("no-damage casts (flight 63260): 3 magic casts landing nothing -> one short real sidestep, no cast meanwhile; a hit resets; 30 s apart", ResyncSidestep);
r.Add("no-damage casts (R-20261021 c788): a corpse selected mid-fight stops the target's health; its chat hits still count, it is not blacklisted", SelectionElsewhereChatHitsCount);
}
// ── A corpse selected during the fight (report R-20261021-191720-c788, Conquest) ─────────────
// "RynthAi interprets a corpse selection during combat as a target for attacks, and stops." The
// fight target never changed: the server sends health only for the client's selection, so once
// the player selected a corpse (or themselves) no health came for the monster, and a war spell's
// hit was seen only in chat, which the no-damage judge didn't count. Three casts that all hit
// were "no damage": the live monster was blacklisted, dropped, and combat stopped (the log:
// "3 casts with no damage - blacklisting" at a Curator taking 7,000 a cast).
private const uint Curator = 0x800F26CD, Marionette = 0x80168E96, Corpse = 0x802B29BD;
private const uint CuratorWcid = 40001, MarionetteWcid = 40002;
private const string CuratorHit = "You singe Curator of Torment for 7190 points with Incantation of Flame Bolt.";
private static CombatManager CorpseRig(LegacyUiSettings s)
{
FakeHost.Reset();
FakeHost.WeaponCalls = true; // installs GetCurrentCombatMode
FakeHost.CombatModeValue = CombatMode.Magic;
FakeHost.Names[Player] = "Me";
FakeHost.Positions[Player] = (Lb | 0x0141, 96f, 96f, 0f);
FakeHost.PlayerPose = (Lb | 0x0141, 96f, 96f, 0f);
void Mob(uint id, string name, uint wcid, float north)
{
FakeHost.Names[id] = name;
FakeHost.Positions[id] = (Lb | 0x0141, 96f, 96f + north, 0f);
FakeHost.ItemTypes[id] = 0x10;
FakeHost.Wcids[id] = wcid;
}
Mob(Curator, "Curator of Torment", CuratorWcid, 1.9f);
Mob(Marionette, "Tormented Marionette", MarionetteWcid, 3f);
FakeHost.Names[Corpse] = "Corpse of Qosmos, Guardian of Torment";
FakeHost.Positions[Corpse] = (Lb | 0x0141, 97f, 96f, 0f);
FakeHost.ItemTypes[Corpse] = 0x200; // a container
FakeHost.Bitfields[Corpse] = 0x00002000; // the corpse flag
FakeHost.NotAttackable.Add(Corpse);
s.MonsterRange = 20;
s.EnableRaycasting = false; // no raycast warm-up (it suspends the judge)
s.BlacklistAttempts = 3;
s.BlacklistCastSettleMs = 0; // each cast is judged at the next one
var host = FakeHost.Create();
var cache = FakeHost.MakeCache(host, Player, new[] { Curator, Marionette, Corpse });
var c = new CombatManager(host, s, cache);
c.SetPlayerId(Player);
c.SetDamageStores(null, new MonsterDamageStore());
c.EngageForTest(unchecked((int)Curator));
FakeHost.SelectedItem = Corpse; // the player clicks the corpse: no health for the Curator from here on
return c;
}
/// <summary>Five casts at the Curator, each followed by <paramref name="chat"/> (null: nothing), then one more cast
/// so the fifth is judged too.</summary>
private static void CastFive(CombatManager c, string? chat)
{
for (int i = 0; i < 5; i++)
{
c.RecordOffensiveCast(unchecked((int)Curator)); // judges the cast before it, opens this one's window
if (chat != null) c.HandleChatForDamage(chat, 7);
}
c.RecordOffensiveCast(unchecked((int)Curator));
}
private static void SelectionElsewhereChatHitsCount()
{
var c = CorpseRig(new LegacyUiSettings());
Check.Eq(FakeHost.SelectedItem, Corpse, "the rig: a corpse is selected");
CastFive(c, CuratorHit);
Check.Eq(unchecked((uint)c.activeTargetId), Curator, "five hits seen in chat: the Curator is still the fight target");
Check.False(FakeHost.Chat.Any(l => l.Contains("with no damage", StringComparison.Ordinal)), "no 'casts with no damage' blacklist");
Check.False(FakeHost.Logs.Any(l => l.Contains("[Blacklist] 0x800F26CD", StringComparison.Ordinal)), "the Curator was never blacklisted");
Check.False(FakeHost.Logs.Any(l => l.Contains("one short sidestep", StringComparison.Ordinal)), "no position re-sync sidestep either");
c.ScanNearbyTargets();
Check.True(c.ScannedTargets.Any(t => t.Id == unchecked((int)Curator)), "and it stays in the scan");
Check.False(c.ScannedTargets.Any(t => t.Id == unchecked((int)Corpse)), "the selected corpse is never a candidate");
// A critical hit has its prefix; it counts the same.
c.RecordOffensiveCast(unchecked((int)Curator));
c.HandleChatForDamage("Critical hit! You singe Curator of Torment for 11259 points with Incantation of Flame Bolt.", 7);
c.RecordOffensiveCast(unchecked((int)Curator));
Check.Eq(unchecked((uint)c.activeTargetId), Curator, "a critical hit line counts too");
// The judge still works: casts that land nothing, or hit only another monster, blacklist the target.
c = CorpseRig(new LegacyUiSettings());
CastFive(c, null);
Check.Eq(c.activeTargetId, 0, "no hit line at all: the Curator is blacklisted and dropped, as before");
Check.True(FakeHost.Chat.Any(l => l.Contains("3 casts with no damage", StringComparison.Ordinal)), "and chat says so");
c = CorpseRig(new LegacyUiSettings());
CastFive(c, "You singe Tormented Marionette for 4215 points with Incantation of Flame Bolt.");
Check.Eq(c.activeTargetId, 0, "hits only on another monster are not the Curator's");
c = CorpseRig(new LegacyUiSettings());
CastFive(c, "You singe Curator of Torment for 0 points with Incantation of Flame Bolt.");
Check.Eq(c.activeTargetId, 0, "a 0-point hit is no damage");
}
private sealed class Rig

View file

@ -0,0 +1,90 @@
using System;
using System.Linq;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.Loot;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Structural audit 2026-10-21, finding 3: item chores ignored fights. Missile crafting held combat
// with no danger check (MissileCraftingTests), mana tapping drained loot between swings
// (ManaStoneChoiceTests), and AutoCram/AutoStack moved items between swings: their only gate was
// the busy count, and a swing repeat is not a paced action. They all wait on one signal now,
// RynthAiPlugin.FightIsOn, the one salvage already used.
internal static class ChoresInFightTests
{
private const uint Player = TickIsolationTests.Player;
private const uint Gem = 0x80000F11, SidePack = 0x80000F12, Monster = 0x80000F13;
private const uint ItemTypeGem = 0x800, ItemTypeContainer = 0x200;
private const uint ItemsCapacityKey = 6;
public static void Register(Runner r)
{
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);
}
private static CombatManager.ScannedTarget At(double yards) =>
new() { Id = unchecked((int)Monster), Distance = yards, Name = "Drudge Skulker" };
private static void FightSignal()
{
try
{
var bot = new TickIsolationTests.Bot(combat: true, heal: false);
bot.S.MonsterRange = 20;
var cm = (CombatManager)bot.Get("_combatManager")!;
Check.False(bot.P.FightIsOn(), "no monster: no fight");
cm.SetScannedTargetsForTests(new[] { At(15) });
Check.True(bot.P.FightIsOn(), "a monster inside Monster Range");
cm.SetScannedTargetsForTests(new[] { At(30) });
Check.False(bot.P.FightIsOn(), "only one past it: no fight");
bot.S.MonsterRange = 2;
cm.SetScannedTargetsForTests(new[] { At(4) });
Check.True(bot.P.FightIsOn(), "Monster Range 2, a monster 4 yd away: on top of us all the same");
bot.S.IsMacroRunning = false;
Check.False(bot.P.FightIsOn(), "macro off: the scan's last picture holds nothing");
bot.S.IsMacroRunning = true;
bot.S.EnableCombat = false;
Check.False(bot.P.FightIsOn(), "combat off: no fight");
}
finally { TickIsolationTests.Done(); }
}
private static void CramWaitsForFight()
{
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.MonsterRange = 20;
bot.Set("_inventoryManager", new InventoryManager(bot.Host, bot.S, bot.Cache));
var cm = (CombatManager)bot.Get("_combatManager")!;
cm.SetScannedTargetsForTests(new[] { At(2) });
for (int i = 0; i < 5; i++) bot.Call("TickCramStack", bot.S);
Check.Eq(FakeHost.Moves.Count, 0, "a monster on us: nothing is moved");
cm.SetScannedTargetsForTests(Array.Empty<CombatManager.ScannedTarget>());
bot.Call("TickCramStack", bot.S);
Check.True(FakeHost.Moves.Any(m => m.Id == Gem && m.Pack == SidePack),
"the fight is over: the gem goes into the side pack (moves: " + string.Join(",", FakeHost.Moves.Select(m => $"{m.Id:X8}->{m.Pack:X8}")) + ")");
}
finally { TickIsolationTests.Done(); }
}
}

View file

@ -175,7 +175,7 @@ internal static class LauncherSwapTests
{
const BindingFlags F = BindingFlags.Instance | BindingFlags.NonPublic;
typeof(CombatManager).GetField("_lockedTargetId", F)!.SetValue(C, unchecked((int)target));
typeof(CombatManager).GetField("_targetLockedAt", F)!.SetValue(C, DateTime.Now);
typeof(CombatManager).GetField("_targetLockedAt", F)!.SetValue(C, RynthClock.Now);
typeof(CombatManager).GetField("_lockWasSwitch", F)!.SetValue(C, wasSwitch);
}

View file

@ -36,6 +36,8 @@ internal static class ManaStoneChoiceTests
r.Add("mana tapping: a drain that never completes keeps the item's place, tries the next stone, then gives up", FailedDrainKeepsPlace);
r.Add("mana tapping: only a stone in the client's pack is used or counted (not one on a corpse, not a stale id)", StoneMustBeInPack);
r.Add("mana tapping: a stone that failed two drains stays parked though it reads empty", FailedStoneStaysParked);
r.Add("mana tapping: in a fight the drain waits (holding no loot, taking no second item); after it, the drain goes", DrainWaitsForFight);
r.Add("mana stones: in a fight, worn gear that runs low is still refilled (armor without mana drops its spells)", RefillInFight);
}
private const uint ChargeA = 0x80400031, ChargeB = 0x80400032, ChargeC = 0x80400033;
@ -355,6 +357,33 @@ internal static class ManaStoneChoiceTests
// 2026-10-15: the pack filled with items looted to tap. A drain that never completed shelved
// its item for 5 minutes and the item stopped counting against the empty stones, so the looter
// took another in its place; and the looter went on opening corpses over the drain.
// Structural audit 2026-10-21, finding 3: a drain is optional work, and each UseObjectOn went out
// between melee swings (only the busy count gated it). It waits for the fight now.
private static void DrainWaitsForFight()
{
using var rig = new Rig(tapping: true, new (uint, int?)[] { (StoneA, null) }, ringToDrain: true, maceMana: 5000);
bool fight = true;
rig.M.FightIsOn = () => fight;
rig.Run(3000);
Check.Eq(rig.OnRing.Count, 0, "a fight is on: no drain");
Check.False(rig.M.HoldsLootForDrain(), "the waiting drain doesn't hold the looter");
Check.Eq(rig.M.FreeEmptyStoneSlots(), 0, "and no second item is looted to tap meanwhile");
Check.Eq(FakeHost.Logs.Count(l => l.Contains("ManaStone: a fight is on")), 1, "one log line for the fight");
fight = false;
rig.Run(1000);
Check.Eq(rig.OnRing.Count, 1, "the fight is over: the ring is drained");
Check.True(rig.M.HoldsLootForDrain(), "and the drain out holds the looter, as before");
}
private static void RefillInFight()
{
using var rig = new Rig(tapping: true, new (uint, int?)[] { (StoneA, 3000) }); // the mace reads 0 of 5000
rig.M.FightIsOn = () => true;
rig.Run(1000);
Check.Eq(rig.OnPlayer.Count, 1, "the charged stone goes on the player in the fight");
Check.Eq(rig.OnPlayer[0], StoneA, "stone A");
}
private static void OneTapItemAtATime()
{
using var rig = new Rig(tapping: true, new (uint, int?)[] { (StoneA, null), (StoneB, null), (StoneC, null) }, maceMana: 5000);

View file

@ -19,6 +19,8 @@ internal static class MissileCraftingTests
{
private const uint Player = 0x50000C01;
private const uint Crossbow = 0x80000601, Bow = 0x80000602, Quarrels = 0x80000603, Arrows = 0x80000604;
private const uint Heads = 0x80000605, Shafts = 0x80000606, Made = 0x80000607;
private const uint StackSizeKey = 12;
private const int MissileSlot = 0x00400000, AmmoSlot = 0x00800000;
public static void Register(Runner r)
@ -27,6 +29,14 @@ internal static class MissileCraftingTests
r.Add("missile crafting: wielded quarrels are not taken for a bow launcher", AmmoNotLauncher);
r.Add("missile crafting: an ammo wield the server ignores backs off after 2 tries", IgnoredWieldBacksOff);
r.Add("missile crafting: a bow in hand with its arrows in the pack still gets them wielded", BowInHandArrowsInPack);
r.Add("missile crafting: in a fight the carried arrows go on at once, better ones are not crafted (no Peace, no combine)", FightWieldsCarried);
r.Add("missile crafting: a craft of better arrows stops when a fight starts, and the carried arrows go on", FightStopsUpgrade);
r.Add("missile crafting: out of arrows in a fight, one combine still goes (nothing else to shoot), then the arrows made go on", FightOutOfAmmoCraftsOnce);
// The engine's real container walk (2026-10-21): the player's own contents list the gear in hand.
r.Add("missile crafting: the walk lists the bow in hand under the player, and Deadly Prismatic Arrows are still made and wielded", WalkBowInHandCrafts);
r.Add("missile crafting: with the engine's tracker, a bow in hand whose client fields read blank is the launcher", WalkTrackerBowInHand);
r.Add("missile crafting: with the engine's tracker, a stowed bow listed first that still reads wielded is not the launcher", WalkTrackerStowedBowNotLauncher);
r.Add("missile crafting: a stowed bow in a side pack that still reads wielded is not the launcher (no tracker)", WalkSidePackBowNotLauncher);
}
/// <summary>Kelpie's state at 13:36: crossbow and quarrels in hand (slot 0), bow and arrows in the main pack.</summary>
@ -76,12 +86,274 @@ internal static class MissileCraftingTests
Check.True(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no Arrow") && l.Contains("'Longbow'")), "the launcher it saw is logged");
}
// ── Fights (structural audit 2026-10-21, finding 3) ──────────────────────
// Crafting holds combat (Peace mode, up to 15 s a step) and had no danger check: the arrows run
// out mid-fight, which is when it starts. In a fight it now does only what the fight needs.
/// <summary>Longbow in hand, nothing in the ammo slot, the Infinite arrows (no recipe: rank 1) in the pack, and bundles for Greater Arrows.</summary>
private static MissileCraftingManager UpgradeRig(Func<bool> fight, bool carriedArrows = true) =>
Rig(crossbowInHand: false, extra: new[] { Heads, Shafts }, arrange: () =>
{
FakeHost.Containers.Remove(Bow);
FakeHost.Names[Bow] = "Longbow";
if (!carriedArrows) { FakeHost.Containers.Remove(Arrows); FakeHost.Names[Arrows] = "Infinite Deadly Prismatic Quarrel"; }
FakeHost.UseOnCalls = true;
FakeHost.CombatModeCalls = true;
FakeHost.CombatModeValue = CombatMode.Missile;
Bundle(Heads, "Bundle of Greater Arrowheads");
Bundle(Shafts, "Bundle of Arrowshafts");
}, fight: fight);
private static void Bundle(uint id, string name)
{
FakeHost.Names[id] = name;
FakeHost.ItemTypes[id] = 0x100;
FakeHost.Containers[id] = Player;
FakeHost.Ints[(id, StackSizeKey)] = 2;
}
private static void FightWieldsCarried()
{
// Out of a fight (the old behaviour): the better arrows are crafted.
var quiet = UpgradeRig(() => false);
Idle(quiet);
Step(quiet);
Check.Eq(quiet.State, MissileCraftingManager.CraftState.Combining, "no fight: Greater Arrows are crafted");
var cm = UpgradeRig(() => true);
Cycle(cm);
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "in a fight: the carried arrows are wielded");
Check.Eq(FakeHost.UsesOn.Count, 0, "no combine");
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "no Peace mode");
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "and crafting let go");
Check.True(FakeHost.Chat.Any(l => l.Contains("In a fight: wielding Infinite Deadly Prismatic Arrow now instead of crafting Greater Arrow")), "chat says why");
}
private static void FightStopsUpgrade()
{
bool fight = false;
var cm = UpgradeRig(() => fight);
Idle(cm);
Step(cm); // evaluating: the craft starts
Step(cm); // the first combine goes out
Check.Eq(FakeHost.UsesOn.Count, 1, "the craft is under way");
Check.Eq(FakeHost.CombatModeRequests.LastOrDefault(), CombatMode.NonCombat, "in Peace mode");
fight = true;
Step(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.EquippingAmmo, "a fight: the craft stops");
Step(cm);
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "the carried arrows go on");
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crafting let go of the bot");
Check.Eq(FakeHost.UsesOn.Count, 1, "no second combine");
Check.True(FakeHost.Chat.Any(l => l.Contains("In a fight: stopped crafting Greater Arrow")), "chat says so");
}
private static void FightOutOfAmmoCraftsOnce()
{
var cm = UpgradeRig(() => true, carriedArrows: false);
Idle(cm);
Step(cm);
Step(cm);
Check.Eq(FakeHost.UsesOn.Count, 1, "no arrows at all: the first combine goes, fight or not");
// The server makes the arrows.
FakeHost.Names[Made] = "Greater Arrow";
FakeHost.ItemTypes[Made] = 0x100;
FakeHost.Containers[Made] = Player;
_ = _cache![unchecked((int)Made)];
cm.HandleChat("You make 2 Greater Arrows.");
Step(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.EquippingAmmo, "arrows to shoot now: the second combine waits");
Step(cm);
Check.Eq(FakeHost.Uses.LastOrDefault(), Made, "the arrows made go on");
Check.Eq(FakeHost.UsesOn.Count, 1, "one combine in the fight");
}
/// <summary>One crafting tick, the phase clock moved past EQUIP_DELAY_MS (inside the 15 s timeout).</summary>
private static void Step(MissileCraftingManager cm)
{
PhaseStart.SetValue(cm, DateTime.Now.AddSeconds(-1));
ForceRescan();
cm.ProcessCrafting();
}
// ── The engine's real container walk ───────────────────────────────────
//
// 2026-10-21, a player: "it doesn't fletch arrows, even when the option is checked" (Deadly
// Prismatic). The engine's GetContainerContents(player) lists what the player wields as well as
// what the main pack holds (UpdateObjectInventoryHooks.ScanByContainerId matches the wielder too),
// so the walk filed the bow in hand under the player. Since 2026-10-19 crafting took any item the
// walk filed under a container as "not in hand", saw no launcher, and never started, with nothing
// in chat or the log. The rig above has no GetContainerContents, so its tests never met the walk.
private const uint SidePack = 0x80000610, WalkHeads = 0x80000611, WalkShafts = 0x80000612, WalkMade = 0x80000613;
private const uint ContainerType = 0x200; // ITEM_TYPE container: the walk opens it
/// <summary>The engine's walk as it is: wielded gear in the player's own contents, with no container.</summary>
private static MissileCraftingManager WalkRig(bool tracker, Action arrange, int fletching = 470)
{
PaceOff();
FakeHost.Reset();
RynthCore.Plugin.RynthAi.EquippedState.Invalidate();
FakeHost.WeaponCalls = true; // UseObject, GetCurrentCombatMode (peace: 1)
FakeHost.SalvageCalls = true; // GetObjectWielderInfo (answers from Wielded)
FakeHost.ContentsCalls = true; // GetContainerContents (Containers, then ContentsExtra)
FakeHost.UseOnCalls = true; // UseObjectOn (the head bundle on the shaft bundle)
FakeHost.EquippedCalls = tracker; // v87 GetWieldedItems (the engine's EquipmentTracker)
FakeHost.Names[Player] = "Archer";
FakeHost.Skills[(Player, 37)] = (fletching, 3); // Fletching, specialized
Item(Crossbow, "Fire Crossbow", MissileSlot);
Item(Bow, "Longbow", MissileSlot);
Item(Quarrels, "Deadly Prismatic Quarrel", AmmoSlot);
Item(Arrows, "Deadly Prismatic Arrow", AmmoSlot);
FakeHost.Names[WalkHeads] = "Bundle of Deadly Prismatic Arrowheads";
FakeHost.Names[WalkShafts] = "Bundle of Arrowshafts";
FakeHost.Ints[(WalkHeads, 12)] = 10; // StackCount
FakeHost.Ints[(WalkShafts, 12)] = 10;
FakeHost.Containers[WalkHeads] = Player;
FakeHost.Containers[WalkShafts] = Player;
arrange();
var host = FakeHost.Create(Player);
_cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows, WalkHeads, WalkShafts, SidePack });
var cm = new MissileCraftingManager(host, new LegacyUiSettings { EnableMissileCrafting = true });
cm.SetObjectCache(_cache);
var skills = new CharacterSkills(host);
skills.SetPlayerId(Player);
cm.SetCharacterSkills(skills);
return cm;
}
/// <summary>In hand as the client shows it: the record names the player, no container, and the
/// walk lists it in the player's contents. The tracker (when on) says so too.</summary>
private static void InHand(uint id, int slot, bool clientSlot = true, bool tracker = false)
{
if (clientSlot) FakeHost.Wielded[id] = unchecked((uint)slot);
FakeHost.Wielders[id] = Player;
if (!FakeHost.ContentsExtra.TryGetValue(Player, out var extra))
FakeHost.ContentsExtra[Player] = extra = new();
extra.Add(id);
if (tracker) FakeHost.Equipped[id] = unchecked((uint)slot);
}
/// <summary>One tick of whatever state crafting is in, its waits already over.</summary>
private static void WalkStep(MissileCraftingManager cm)
{
if (cm.State == MissileCraftingManager.CraftState.Idle) LastAmmoCheck.SetValue(cm, DateTime.MinValue);
else PhaseStart.SetValue(cm, DateTime.Now.AddSeconds(-1)); // past EQUIP_DELAY_MS, well inside the 15 s timeout
ForceRescan();
cm.ProcessCrafting();
}
/// <summary>The player's case: a Longbow wielded at login, the quiver empty, Deadly Prismatic bundles in the pack.</summary>
private static void WalkBowInHandCrafts()
{
var cm = WalkRig(tracker: false, arrange: () =>
{
InHand(Bow, MissileSlot);
FakeHost.Names.Remove(Crossbow); FakeHost.Names.Remove(Quarrels); FakeHost.Names.Remove(Arrows);
});
WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Evaluating, "the empty quiver is seen");
Check.True(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no Arrow") && l.Contains("'Longbow'")), "the bow in hand is the launcher");
WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Combining, "Deadly Prismatic Arrows are made (Fletching 470)");
Check.True(FakeHost.Chat.Any(c => c.Contains("Crafting Deadly Prismatic Arrow x2")), "two combines planned: " + string.Join(" | ", FakeHost.Chat));
WalkStep(cm);
Check.Eq(FakeHost.UsesOn.Count, 1, "one combine sent");
Check.Eq(FakeHost.UsesOn[0], (WalkHeads, WalkShafts), "the head bundle on the shaft bundle");
cm.HandleChat("You make a bundle of deadly prismatic arrows.");
WalkStep(cm);
Check.Eq(FakeHost.UsesOn.Count, 2, "the second combine goes out after the first is confirmed");
cm.HandleChat("You make a bundle of deadly prismatic arrows.");
// The new arrows land in the main pack.
Item(WalkMade, "Deadly Prismatic Arrow", AmmoSlot);
FakeHost.Containers[WalkMade] = Player;
WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.EquippingAmmo, "both combines done: equip");
WalkStep(cm);
Check.Eq(FakeHost.Uses.LastOrDefault(), WalkMade, "UseObject(the new arrows)");
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "done");
}
/// <summary>The bow wielded after login: the client's slot and wielder record read blank; the tracker knows.</summary>
private static void WalkTrackerBowInHand()
{
var cm = WalkRig(tracker: true, arrange: () =>
{
FakeHost.ContentsExtra[Player] = new() { Bow }; // listed, but the record says nothing
FakeHost.Equipped[Bow] = MissileSlot; // the server's WieldObject
FakeHost.Names.Remove(Crossbow); FakeHost.Names.Remove(Quarrels); FakeHost.Names.Remove(Arrows);
});
WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Evaluating, "the tracker's bow is the launcher");
WalkStep(cm);
WalkStep(cm);
Check.Eq(FakeHost.UsesOn.Count, 1, "the combine goes out");
}
/// <summary>
/// Silentkelpie's 2026-10-15 state on the real walk, with the tracker: crossbow and quarrels in
/// hand, the bow and arrows put into the main pack, the bow's record still naming the player and
/// the missile slot, and the bow listed before the crossbow. Only the tracker can tell them apart.
/// </summary>
private static void WalkTrackerStowedBowNotLauncher()
{
var cm = WalkRig(tracker: true, arrange: () =>
{
FakeHost.Containers[Bow] = Player; // in the main pack (listed first) ...
FakeHost.Wielded[Bow] = MissileSlot; // ... with the stale record
FakeHost.Wielders[Bow] = Player;
FakeHost.Containers[Arrows] = Player;
InHand(Crossbow, MissileSlot, clientSlot: false, tracker: true); // wielded after login: slot reads 0
InHand(Quarrels, AmmoSlot, clientSlot: false, tracker: true);
});
for (int i = 0; i < 3; i++) WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crossbow with quarrels on: nothing to do");
Check.Eq(FakeHost.Uses.Count, 0, "no arrow wield at the crossbow");
Check.Eq(FakeHost.UsesOn.Count, 0, "no combine");
Check.False(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no")), "no evaluation logged");
}
/// <summary>
/// Without the tracker: the stowed bow sits in a side pack with its stale record (wielder and
/// missile slot), and the crossbow in hand can't be read (its record is blank, so the walk doesn't
/// list it). The stale bow is the only candidate and must not pass for the launcher.
/// </summary>
private static void WalkSidePackBowNotLauncher()
{
var cm = WalkRig(tracker: false, arrange: () =>
{
FakeHost.Names[SidePack] = "Backpack";
FakeHost.ItemTypes[SidePack] = ContainerType;
FakeHost.Containers[SidePack] = Player;
FakeHost.Containers[Bow] = SidePack;
FakeHost.Wielded[Bow] = MissileSlot; // stale
FakeHost.Wielders[Bow] = Player;
FakeHost.Containers[Arrows] = SidePack;
});
for (int i = 0; i < 3; i++) WalkStep(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "no launcher it can trust: nothing to do");
Check.Eq(FakeHost.Uses.Count, 0, "no arrow wield");
Check.False(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no")), "no evaluation logged");
}
// ── The rig ─────────────────────────────────────────────────────────────
private static WorldObjectCache? _cache;
/// <param name="arrange">Changes to the fake world, made before the host and cache read it.</param>
private static MissileCraftingManager Rig(bool crossbowInHand, Action? arrange = null)
private static MissileCraftingManager Rig(bool crossbowInHand, Action? arrange = null, uint[]? extra = null, Func<bool>? fight = null)
{
PaceOff();
FakeHost.Reset();
@ -111,9 +383,10 @@ internal static class MissileCraftingTests
arrange?.Invoke();
var host = FakeHost.Create(Player);
_cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows });
_cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows }.Concat(extra ?? Array.Empty<uint>()));
var cm = new MissileCraftingManager(host, new LegacyUiSettings { EnableMissileCrafting = true });
cm.SetObjectCache(_cache);
cm.FightIsOn = fight;
return cm;
}
@ -164,10 +437,14 @@ internal static class MissileCraftingTests
}
}
/// <summary>GetDirectInventory re-serves a scan under 1 s old; the test can't wait on the wall clock.</summary>
private static void ForceRescan() =>
/// <summary>GetDirectInventory re-serves a scan under 1 s old; the test can't wait on the wall clock.
/// The tracker read is cached for 100 ms across hosts, so it is dropped too.</summary>
private static void ForceRescan()
{
typeof(WorldObjectCache).GetField("_lastDirectInventoryScan", BindingFlags.Instance | BindingFlags.NonPublic)!
.SetValue(_cache, DateTime.MinValue);
RynthCore.Plugin.RynthAi.EquippedState.Invalidate();
}
private static void PaceOff()
{

View file

@ -242,7 +242,7 @@ internal static class TargetingTests
public readonly CombatManager Combat;
public readonly LegacyUiSettings S;
private readonly WorldObjectCache _cache;
private DateTime _now = DateTime.Now;
private DateTime _now = RynthClock.Now; // the clock RynthAi times with
public Rig(int scheme, bool targetLock, Dictionary<uint, float>? health = null, int monsterRange = 20)
{

View file

@ -0,0 +1,320 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.Shared;
using RynthCore.PluginCore;
using RynthCore.PluginSdk;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Structural audit 2026-10-21, finding 4: OnTick had one try/catch round the whole tick, so a step
// that threw every tick skipped everything after it, healing and combat included ("the bot just
// stood there and died"; one log line every 10 s). Each step now runs under its own guard
// (Diagnostics/TickGuard.cs). These drive the real OnTick with a step made to throw every tick
// (an object left half-built, as a null after a reload would) and check the rest still runs.
internal static class TickIsolationTests
{
internal const uint Player = 0x50000F01;
private const uint STypeLife = 33;
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
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 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);
r.Add("tick guard: one log line per step per 10 s (with the count since), and nothing logged while nothing throws", GuardLogThrottle);
r.Add("tick guard: trips only after 30 failures in a row over 5 s; a success in between starts the count again", GuardTripNeedsAStreak);
}
// ── The rig: the real plugin, logged in, macro on (ChoresInFightTests uses it too) ──
internal sealed class Bot
{
public readonly RynthAiPlugin P = new();
public readonly LegacyUiSettings S;
public readonly PlayerVitalsCache V;
public readonly WorldObjectCache Cache;
public readonly RynthCoreHost Host;
public long Now = 50_000_000;
/// <param name="arrange">The test's own objects and host options, before the host exists.</param>
public Bot(int healthPct = 100, bool combat = false, bool heal = true, Action? arrange = null)
{
PaceOff();
FakeHost.Reset();
FakeHost.WeaponCalls = true;
FakeHost.ServerGates = true;
FakeHost.LastUseDoneCalls = true;
FakeHost.CombatModeValue = CombatMode.Magic;
foreach (var row in SpellTable.Rows) FakeHost.Spellbook.Add((uint)row.Id);
FakeHost.Skills[(Player, STypeLife)] = (400, 2);
FakeHost.Names[Player] = "Isolation Tester";
FakeHost.Vitals = ((uint)healthPct, 100, 100, 100, 100, 100);
arrange?.Invoke();
Host = FakeHost.Create(Player);
RynthLog.Init(Host, Path.Combine(Program.TempRoot, "TickIsolationLogs"));
// No combat manager unless asked: the idle line applies, Heal At = Top Off HP = 60.
S = new LegacyUiSettings
{
IsMacroRunning = true, EnableCombat = combat, EnableLooting = false, EnableNavigation = false,
EnableBuffing = false, HealAt = 60, TopOffHP = 60, EmergencyHealAt = 0, StaminaToHealthAt = 0,
GetManaAt = 0, TopOffMana = 0, RestamAt = 0, TopOffStam = 0, UsePotions = false,
};
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
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))
{
if (f.GetValue(dash) != null || f.FieldType.IsValueType || f.FieldType == typeof(string)) continue;
bool fillable = f.FieldType == typeof(object)
|| (f.FieldType.Namespace?.StartsWith("System.Collections") == true && !f.FieldType.IsInterface && !f.FieldType.IsAbstract);
if (fillable && f.FieldType.GetConstructor(Type.EmptyTypes) != null)
f.SetValue(dash, Activator.CreateInstance(f.FieldType));
}
Set("_dashboard", dash);
Cache = new WorldObjectCache(Host);
Cache.SetPlayerId(Player);
Set("_objectCache", Cache);
Set("_playerId", Player);
Set("_loginComplete", true);
Set("_loginCompletedAt", DateTime.Now.AddSeconds(-10)); // past the inventory settle window
UseAudit.Reset("RynthAi", () => S.IsMacroRunning);
V = new PlayerVitalsCache();
Set("_vitals", V);
if (heal)
{
var skills = new CharacterSkills(Host);
skills.SetPlayerId(Player);
var sm = new SpellManager(Host, S);
sm.InitializeNatively();
sm.SetCharacterSkills(skills);
var b = new BuffManager(Host, S, sm, V);
b.SetCharacterSkills(skills);
b.MarkLiveBuffsReadyForTests();
Set("_buffManager", b);
}
if (combat)
Set("_combatManager", new CombatManager(Host, S, Cache));
P.TickGuards.Clock = () => Now;
}
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
public object? Get(string f) => typeof(RynthAiPlugin).GetField(f, Any)!.GetValue(P);
public object? Call(string m, params object[] a) => typeof(RynthAiPlugin).GetMethod(m, Any)!.Invoke(P, a);
/// <summary>The plugin field's own type, built without its constructor: every call into it throws.</summary>
public object Broken(string field)
{
var type = typeof(RynthAiPlugin).GetField(field, Any)!.FieldType;
object o = RuntimeHelpers.GetUninitializedObject(type);
Set(field, o);
return o;
}
public void Ticks(int n, long msEach = 100)
{
for (int i = 0; i < n; i++)
{
Now += msEach;
P.OnTick();
}
}
public TickGuard G => P.TickGuards;
}
private static void PaceOff()
{
ActionPacer.Enabled = false;
ActionPacer.Reset();
ActionPacer.NowMs = () => Environment.TickCount64;
UseAudit.Reset("?", null);
UseAudit.NowMs = () => Environment.TickCount64;
MoveAudit.Reset();
MoveAudit.NowMs = () => Environment.TickCount64;
}
internal static void Done() => UseAudit.Reset("?", null);
private static int HealSelfCasts()
{
int cat = SpellTable.Named("Heal Self I").First().Category;
return FakeHost.Casts.Count(c => SpellTable.ById(c.SpellId)?.Category == cat);
}
/// <summary>The quest tracker left mid-refresh with no record table: its Tick throws every call.</summary>
private static void BreakQuestTracker(Bot bot)
{
object qt = bot.Broken("_questTracker");
qt.GetType().GetField("_refreshing", Any)!.SetValue(qt, true);
qt.GetType().GetField("_gotFirstQuest", Any)!.SetValue(qt, true);
}
private static string Steps(Bot bot) =>
string.Join(", ", Enum.GetValues<TickStep>().Where(s => bot.G.Failures(s) > 0).Select(s => $"{s}={bot.G.Failures(s)}"));
// ── The tests ────────────────────────────────────────────────────────────
private static void HealDespiteEarlierFault()
{
try
{
var bot = new Bot(healthPct: 40);
BreakQuestTracker(bot);
bot.Ticks(5);
Check.True(bot.G.Failures(TickStep.QuestTracker) >= 5, "the quest tracker threw every tick (" + Steps(bot) + ")");
Check.Eq(HealSelfCasts(), 1, "Heal Self went out anyway (before the guards the whole tick was skipped)");
Check.Eq(bot.G.Failures(TickStep.BuffsAndVitals), 0L, "healing itself ran through");
Check.True(bot.G.Runs(TickStep.Meta) >= 5, "and the tick ran on to its end every time");
Check.False(FakeHost.Logs.Any(l => l.Contains("OnTick exception")), "nothing reached the whole-tick catch");
Check.True(FakeHost.Logs.Any(l => l.Contains("tick step quest tracker error: NullReferenceException")), "the fault is logged by step name");
}
finally { Done(); }
}
private static void CombatDespiteChoreFault()
{
try
{
var bot = new Bot(combat: true, heal: false);
bot.Broken("_manaStoneManager");
bot.Broken("_inventoryManager");
bot.Ticks(10);
Check.True(bot.G.Failures(TickStep.ManaStones) >= 10, "mana stones threw every tick");
Check.True(bot.G.Failures(TickStep.CramStack) >= 10, "AutoCram/AutoStack threw every tick");
Check.Eq(bot.G.Runs(TickStep.Combat), 10L, "combat's heartbeat ran on every tick after them");
Check.Eq(bot.G.Failures(TickStep.Combat), 0L, "and ran through");
Check.True(FakeHost.Logs.Any(l => l.StartsWith("Combat: state enableCombat=True", StringComparison.Ordinal)), "the real heartbeat ran (its state line)");
Check.True(bot.G.Runs(TickStep.Meta) >= 10, "the tick ran to its end");
}
finally { Done(); }
}
private static void ChoreTripsAndRecovers()
{
try
{
var bot = new Bot(combat: true, heal: false);
bot.Broken("_manaStoneManager");
bot.Ticks(29);
Check.False(bot.G.IsOff(TickStep.ManaStones), "29 failures: still on");
bot.Ticks(30); // 59 in a row, 5.9 s
Check.True(bot.G.IsOff(TickStep.ManaStones), "failing every tick for 5 s: switched off");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("mana stones is off")), 1, "one chat line says so");
Check.True(FakeHost.Chat.Any(l => l.Contains("mana stones is off") && l.Contains("NullReferenceException")), "with the error");
long failures = bot.G.Failures(TickStep.ManaStones);
long combatRuns = bot.G.Runs(TickStep.Combat);
bot.Ticks(100); // 10 s
Check.Eq(bot.G.Failures(TickStep.ManaStones), failures, "while off it isn't called");
Check.Eq(bot.G.Runs(TickStep.Combat), combatRuns + 100, "combat runs on every tick");
bot.Ticks(1, msEach: TickGuard.RetryMs); // the retry is due
Check.Eq(bot.G.Failures(TickStep.ManaStones), failures + 1, "tried again after 60 s");
Check.True(bot.G.IsOff(TickStep.ManaStones), "still broken: still off");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("mana stones")), 1, "no second chat line for a failed retry");
bot.Set("_manaStoneManager", null); // a reload rebuilt it (here: none, so the call is a no-op)
bot.Ticks(1, msEach: TickGuard.RetryMs);
Check.False(bot.G.IsOff(TickStep.ManaStones), "the retry ran through: back on");
Check.True(FakeHost.Chat.Any(l => l.Contains("mana stones works again")), "and chat says so");
}
finally { Done(); }
}
private static void HealingNeverTrips()
{
try
{
var bot = new Bot(healthPct: 40, combat: true, heal: false);
bot.Broken("_buffManager");
bot.Ticks(100); // 10 s
Check.Eq(bot.G.Failures(TickStep.BuffsAndVitals), 100L, "healing and buffs failed on every tick");
Check.False(bot.G.IsOff(TickStep.BuffsAndVitals), "and are never switched off");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("healing and buffs keeps failing")), 1, "one chat line says it keeps failing");
Check.Eq(bot.G.Runs(TickStep.Combat), 100L, "combat ran on every tick");
bot.Ticks(50);
Check.Eq(bot.G.Failures(TickStep.BuffsAndVitals), 150L, "still tried every tick");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("healing and buffs")), 1, "and still one chat line");
}
finally { Done(); }
}
// ── TickGuard on its own ────────────────────────────────────────────────
private static (TickGuard G, List<string> Log, List<string> Chat, Func<long> Advance) Guard(long stepMs = 100)
{
FakeHost.Reset();
RynthLog.Init(FakeHost.Create(), Path.Combine(Program.TempRoot, "TickIsolationLogs"));
var log = new List<string>();
var chat = new List<string>();
long now = 1_000_000;
var g = new TickGuard(log.Add, chat.Add) { Clock = () => now };
return (g, log, chat, () => now += stepMs);
}
private static void GuardLogThrottle()
{
var (g, log, chat, advance) = Guard();
var ex = new InvalidOperationException("bad spell data");
for (int i = 0; i < 100; i++) { g.Failed(TickStep.Salvage, ex); advance(); } // one every 100 ms, the last at 9.9 s
int summaries = FakeHost.Logs.Count(l => l.Contains("tick step salvage error: InvalidOperationException: bad spell data"));
Check.Eq(summaries, 1, "100 failures inside 10 s: one summary line");
Check.Eq(log.Count(l => l.Contains("since its last line")), 0, "and no count line yet (the trip at 5 s has its own line)");
g.Failed(TickStep.Salvage, ex); // at 10 s
Check.Eq(FakeHost.Logs.Count(l => l.Contains("tick step salvage error")), 2, "the next one 10 s after the first");
Check.True(log.Any(l => l.Contains("'salvage' failed 100 time(s) since its last line (101 in a row)")), "with the count since the last line: " + string.Join(" | ", log));
int before = FakeHost.Logs.Count;
for (int i = 0; i < 50; i++) { g.Succeeded(TickStep.Combat); advance(); }
Check.Eq(FakeHost.Logs.Count, before, "a step that runs through logs nothing");
Check.Eq(g.Runs(TickStep.Combat), 50L, "but is counted");
Check.False(chat.Any(l => l.Contains("combat")), "and says nothing in chat");
}
private static void GuardTripNeedsAStreak()
{
var (g, _, chat, advance) = Guard(stepMs: 200);
var ex = new NullReferenceException();
// Fails on every other call: never a streak, never off.
for (int i = 0; i < 200; i++)
{
if (i % 2 == 0) g.Failed(TickStep.Pets, ex); else g.Succeeded(TickStep.Pets);
advance();
}
Check.False(g.IsOff(TickStep.Pets), "failing on every other tick: never switched off");
Check.Eq(chat.Count, 0, "no chat");
// One every 100 ms: 30 in a row is not yet 5 s of failing.
var (g2, _, chat2, advance2) = Guard(stepMs: 100);
for (int i = 0; i < 30; i++) { g2.Failed(TickStep.Pets, ex); advance2(); }
Check.False(g2.IsOff(TickStep.Pets), "30 in a row over 2.9 s: not yet");
for (int i = 0; i < 21; i++) { g2.Failed(TickStep.Pets, ex); advance2(); }
Check.True(g2.IsOff(TickStep.Pets), "51 in a row over 5 s: off");
Check.False(g2.MayRun(TickStep.Pets), "and not run");
Check.Eq(chat2.Count, 1, "one chat line");
// An essential step: warned once per streak, never off; a success ends the streak.
for (int i = 0; i < 60; i++) { g2.Failed(TickStep.Combat, ex); advance2(); }
Check.False(g2.IsOff(TickStep.Combat), "combat is never switched off");
Check.True(g2.MayRun(TickStep.Combat), "and always runs");
Check.Eq(chat2.Count(l => l.Contains("combat keeps failing")), 1, "one warning");
g2.Succeeded(TickStep.Combat);
Check.Eq(g2.FailuresInARow(TickStep.Combat), 0, "a success ends the streak");
for (int i = 0; i < 60; i++) { g2.Failed(TickStep.Combat, ex); advance2(); }
Check.Eq(chat2.Count(l => l.Contains("combat keeps failing")), 2, "a new streak warns again");
}
}

View file

@ -174,6 +174,23 @@ internal static class VTankHotkeyTests
Check.True(bot.LastChat.Contains("can't be attacked"), "an NPC: refused (" + bot.LastChat + ")");
Check.Eq(t.Combat.ForcedTargetId, 0, "no lock");
// A corpse selected mid-fight (R-20261021-191720-c788): never a target, and the fight goes on.
const uint Corpse = 0x80000505;
FakeHost.Names[Corpse] = "Corpse of Mob A";
FakeHost.ItemTypes[Corpse] = ItemTypeContainer;
FakeHost.Positions[Corpse] = (Lb | 0x1C, 96f, 97f, 0f);
FakeHost.Bitfields[Corpse] = 0x00002000; // the corpse flag
FakeHost.NotAttackable.Add(Corpse);
t.Cache.OnCreateObject(Corpse);
t.Cache.Tick();
Check.Eq(t.Pick((B, 3)), B, "fighting B");
FakeHost.SelectedItem = Corpse;
bot.P.OnSelectedTargetChange(Corpse, B);
bot.Ra("/ra targetlock");
Check.True(bot.LastChat.Contains("isn't a monster"), "a corpse: refused (" + bot.LastChat + ")");
Check.Eq(t.Combat.ForcedTargetId, 0, "no lock on the corpse");
Check.Eq(t.Pick((B, 3)), B, "the corpse selected: still fighting B");
t.Cache.OnUpdateHealth(A, 0f);
FakeHost.SelectedItem = A;
bot.Ra("/ra targetlock");

View file

@ -28,6 +28,7 @@
<ItemGroup>
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\**\*.cs" Exclude="..\..\Plugins\RynthCore.Plugin.RynthOracle\obj\**;..\..\Plugins\RynthCore.Plugin.RynthOracle\bin\**" Link="RynthOracle\%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\FellowshipTracker.cs" Link="RynthOracle\Shared\FellowshipTracker.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\RynthClock.cs" Link="RynthOracle\Shared\RynthClock.cs" />
<Compile Include="..\..\Plugins\Shared\RynthAiHubApi.cs" Link="RynthOracle\Shared\RynthAiHubApi.cs" />
<Compile Include="..\..\Plugins\Shared\RynthAiSessionClient.cs" Link="RynthOracle\Shared\RynthAiSessionClient.cs" />
<!-- RynthCore's server list and the owner plugin's profile (as in the plugin's csproj). -->

View file

@ -48,12 +48,43 @@ internal static class Program
SharedCodeNamesNoServer(root);
NoServerCommands(root);
NoServerOnlyLinks(root);
RynthAiTimesWithItsClock(root);
Console.WriteLine();
Console.WriteLine($"{_checks - _failed}/{_checks} checks passed.");
Console.WriteLine(_failed == 0 ? "ALL BOUNDARY CHECKS PASSED." : $"{_failed} FAILED.");
return _failed == 0 ? 0 : 1;
}
/// <summary>
/// RynthAi times intervals with RynthClock, never DateTime.Now: the wall clock jumps an hour when
/// daylight saving ends, and every "now - last &lt; interval" check stalled for that hour (no target
/// scans or attacks; structural audit 2026-10-21). DateTime.Now stays only where the time of day is
/// shown: RynthLog's timestamps and file names, a backup file's name, a meta's getdatetimelocal.
/// </summary>
private static void RynthAiTimesWithItsClock(string root)
{
string dir = Path.Combine(root, "Plugins", "RynthCore.Plugin.RynthAi");
var found = new List<string>();
int files = 0;
foreach (string file in Directory.EnumerateFiles(dir, "*.cs", SearchOption.AllDirectories).Where(NotBuildOutput))
{
files++;
string rel = Rel(root, file);
if (rel.EndsWith("/Diagnostics/RynthLog.cs", StringComparison.Ordinal) || rel.EndsWith("/RynthClock.cs", StringComparison.Ordinal)) continue; // the log and the clock's own anchor
string[] lines = File.ReadAllLines(file);
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i].Trim();
if (!line.Contains("DateTime.Now", StringComparison.Ordinal) || line.StartsWith("//", StringComparison.Ordinal)) continue;
if (line.Contains("\"getdatetimelocal\"", StringComparison.Ordinal) || line.Contains("\".unreadable-\"", StringComparison.Ordinal)) continue;
found.Add($"{rel}:{i + 1}");
}
}
Check(files > 100, $"RynthAi's sources were found ({files})");
Check(found.Count == 0, "RynthAi times with RynthClock.Now, not DateTime.Now" +
(found.Count > 0 ? ": " + string.Join(", ", found.Take(10)) : ""));
}
/// <summary>No project here is a server plugin: they are RynthServers' (2026-10-21).</summary>
private static void NoServerPlugins(string root)
{