RynthSuite as of 2026-11-29 (internal 3c6745b): release 2026.11.29.1

This commit is contained in:
Tom Bohar 2026-11-29 22:28:29 -05:00
commit 95282c83fa
13 changed files with 916 additions and 36 deletions

View file

@ -52,6 +52,8 @@ internal static class NavEngineTests
r.Add("nav engine (11-28): back from a fight, nothing of the route near in sight: the map's way to the waypoint", InSightNoneFallsBack);
r.Add("nav engine (11-28): a fight during the walk to the route in sight: looked at again from where it ends", InSightInterrupted);
r.Add("nav engine (11-28): Lugian Excavations 0x02E7 on the real dats: the patrol's legs are clear walks, the 18:56 wall stuck isn't, and the route in sight is found from there and from the rooms off the route (if the dats are here)", InSightLugianRealDats);
r.Add("nav engine (11-29): the map's long way back through fight after fight: planned again after each while it gets nearer; three that bring it no nearer end it", LongWalkThroughFights);
r.Add("nav engine (11-29): the nearest waypoint on foot (the patrol's start with nothing in sight): the shortest walk of the nearest few and the old start", NearestOnFootPick);
r.Add("nav engine: Go To Closest Waypoint off keeps the last waypoint (hazard/corpse still rejoin)", ResumeNearestOff);
r.Add("nav engine: a loaded route starts at [0] for Once/Follow, or for any route with the option off", StartsAtFirstPoint);
r.Add("nav engine: nearest waypoint lookup", FindNearest);
@ -94,6 +96,10 @@ internal static class NavEngineTests
r.Add("nav engine: an NPC point (VTank type 7) uses its NPC on arrival, once, waits for the answer, then goes on", NpcPointUsesTheNpc);
r.Add("nav engine: an NPC point waits while the client is busy with the use, 20 s at most", NpcPointWaitsWhileBusy);
r.Add("nav engine: an NPC point whose NPC can't be found says so once and goes on after 15 s", NpcPointNotFound);
r.Add("nav engine (11-29): a Vendor point (VTank type 5) opens its vendor on arrival, once, waits for the window, then goes on", VendorPointOpensTheVendor);
r.Add("nav engine (11-29): a Vendor point whose window never opens says so once and goes on after 20 s", VendorPointNeverOpens);
r.Add("nav engine (11-29): a Vendor point whose vendor can't be found says so once and goes on after 15 s", VendorPointNotFound);
r.Add("nav engine (11-29): a vendor opened by hand away from a Vendor point changes nothing", VendorOpenedElsewhere);
}
// ── Rig ───────────────────────────────────────────────────────────────────
@ -527,6 +533,91 @@ internal static class NavEngineTests
Check.True(nav.S.EnableNavigation, "nav stays on");
}
// ── Vendor points (OpenVendor, type 5) ────────────────────────────────────
private const uint VendorId = 0x7A000003;
private static Nav VendorRoute(bool vendorThere)
{
FakeHost.Reset(); At(0, 0);
FakeHost.WeaponCalls = true; // UseObject
var pose = FakeHost.PlayerPose;
FakeHost.Names[NpcMe] = "Tester";
FakeHost.Positions[NpcMe] = pose;
if (vendorThere)
{
FakeHost.Names[VendorId] = "Renald the Grocer";
FakeHost.Positions[VendorId] = (pose.Cell, pose.X + 2f, pose.Y, pose.Z);
}
var host = FakeHost.Create(NpcMe);
var cache = FakeHost.MakeCache(host, NpcMe, vendorThere ? new[] { VendorId } : Array.Empty<uint>());
var vendor = Pt(0, 0, T.OpenVendor); vendor.TargetName = "Renald the Grocer"; vendor.VendorId = VendorId;
var nav = new Nav(Route(RT.Once, vendor, Pt(20, 0), Pt(40, 0)));
nav.E.SetWorldObjectCache(cache);
nav.E.SetPlayerId(NpcMe);
return nav;
}
private static void VendorPointOpensTheVendor()
{
var nav = VendorRoute(vendorThere: true);
nav.Tick();
Check.Eq(nav.Idx, 0, "arrived at the Vendor point: it doesn't go on yet (it used to walk straight past)");
Check.False(FakeHost.AutoRun, "it stops there");
nav.Run(1.0);
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, $"the vendor is used, once (uses: {string.Join(",", FakeHost.Uses.Select(u => u.ToString("X8")))})");
Check.Eq(LogCount("UseObject vendor 'Renald the Grocer'"), 1, "logged as a vendor use");
nav.Run(10.0);
Check.Eq(nav.Idx, 0, "10 s after the use and no window yet: still waiting for it");
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "and not used again while it waits");
nav.E.NoteVendorOpened(VendorId); // AutoVendor would hold the bot here; the fake doesn't
nav.Run(1.5);
Check.Eq(nav.Idx, 0, "under 2 s after the window opened: still at the vendor");
nav.Run(1.0);
Check.Eq(nav.Idx, 1, "then on to [1]");
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "never used twice");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'")), 0, "nothing said in chat when it worked");
At(19.5, 0); nav.Tick();
Check.Eq(nav.Idx, 2, "the next plain waypoint is walked as before");
}
private static void VendorPointNeverOpens()
{
var nav = VendorRoute(vendorThere: true);
nav.Tick();
nav.Run(1.0);
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "used");
nav.Run(18.0);
Check.Eq(nav.Idx, 0, "18 s after the use, no window: still waiting");
nav.Run(2.5);
Check.Eq(nav.Idx, 1, "past 20 s: goes on without it");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'") && l.Contains("didn't open")), 1, "one chat line says so");
Check.True(nav.S.EnableNavigation, "nav stays on");
}
private static void VendorPointNotFound()
{
var nav = VendorRoute(vendorThere: false);
nav.Tick();
nav.Run(14.0);
Check.Eq(nav.Idx, 0, "14 s looking for the vendor: still there");
Check.Eq(FakeHost.Uses.Count, 0, "nothing used");
nav.Run(1.5);
Check.Eq(nav.Idx, 1, "15 s: goes on without it");
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'") && l.Contains("wasn't found")), 1, "one chat line says so");
Check.True(nav.S.EnableNavigation, "nav stays on");
}
private static void VendorOpenedElsewhere()
{
FakeHost.Reset(); At(0, 0);
var nav = new Nav(Line(RT.Once, 3, 20));
nav.E.NoteVendorOpened(VendorId);
nav.Tick();
Check.Eq(nav.Idx, 1, "a plain route arrives at [0] and goes on as before");
Check.Eq(LogCount("opened for Vendor point"), 0, "the open isn't taken for a Vendor point's");
}
private static void RecallTimeoutNear()
{
var nav = RecallRoute(30);
@ -867,6 +958,84 @@ internal static class NavEngineTests
Check.Eq(nav.Idx, 2, "on to [2]");
}
// ── Long walks through fights, and the start on foot (11-29) ─────────────
// Lugian Excavations again: the patrol laid again mid-dungeon started at [0] 425 yd off, and the map's way there was
// broken into by a fight every 10-30 s. Every re-plan was nearer, but the third ended the walk ("out of re-plans") and
// nav steered straight at [0] through the cave walls until the next fight.
private static void LongWalkThroughFights()
{
FakeHost.Reset(); At(14, 40);
double walk = 530;
var p = new FakePlanner { InSight = _ => false, WalkYd = _ => walk };
var nav = new Nav(Square(), idx: 2, planner: p);
nav.E.KeepWaypointAfterPause = () => true;
nav.Tick();
nav.E.Stop();
At(14, 52);
nav.Run(1.0);
Check.Eq(LogCount("started (back from a pause, [2] is behind a wall"), 1, "the map's way to [2]");
// Five fights on the way, each ending 10 yd from where it began, the walk 40 yd shorter each time.
for (int k = 0; k < 5; k++)
{
nav.E.Stop();
At(14, k % 2 == 0 ? 62 : 52);
walk -= 40;
nav.Run(1.0);
}
Check.Eq(LogCount("re-planned after a pause"), 5, "planned again after each fight");
Check.Eq(LogCount("out of re-plans"), 0, "never out of re-plans while each is nearer");
Check.Eq(LogCount("(no nearer"), 0, "none said to be no nearer");
Check.True(nav.Recovery.Contains("via fake planner"), $"still walking it ({nav.Recovery})");
Check.Eq(LogCount("attempt 2/"), 0, "no second recovery counted against [2]");
Check.Eq(LogCount("FAILED"), 0, "nothing failed");
// Fights that pull it back as far each time: three bring it no nearer, the fourth ends the walk as before.
for (int k = 0; k < 4; k++)
{
nav.E.Stop();
At(14, k % 2 == 0 ? 52 : 62);
nav.Run(1.0);
}
Check.Eq(LogCount("(no nearer: 1/3)") + LogCount("(no nearer: 2/3)") + LogCount("(no nearer: 3/3)"), 3, "three said to be no nearer");
Check.Eq(LogCount("out of re-plans (3 brought it no nearer than 330yd)"), 1, "then out of re-plans, saying why");
Check.False(nav.Recovery.Contains("via fake planner"), $"that walk is over ({nav.Recovery})");
}
private static void NearestOnFootPick()
{
// The lap's [0] across the dungeon; the lap crosses the character's cave later. [7] is nearest but behind a wall,
// [8] has no way there on the map, [9] is a short walk.
var route = Route(RT.Circular,
Pt(425, 0), Pt(300, 0), Pt(200, 0), Pt(120, 0), Pt(80, 0), Pt(60, 0), Pt(40, 0),
Pt(20, 0), Pt(0, 25), Pt(0, 30), Pt(-60, 0), Pt(-140, 0));
var walks = new Dictionary<int, double?> { [0] = 520, [7] = 300, [8] = null, [9] = 35 };
var asked = new List<int>();
double? Walk(NavPoint p)
{
int i = route.Points.IndexOf(p);
asked.Add(i);
if (walks.TryGetValue(i, out var w)) return w;
var (n, e) = NE(p);
return Math.Sqrt(n * n + e * e) * 1.2;
}
int best = NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, Walk, out double yd, candidatesNearest: 6);
Check.Eq(best, 9, "the short walk, not the nearer one behind the wall, the one with no way, or [0]");
Check.True(Math.Abs(yd - 35) < 1e-9, $"its walk ({yd:F1} yd)");
Check.Eq(string.Join(",", asked.OrderBy(i => i)), "0,5,6,7,8,9,10", "the six nearest and the old start asked, no more");
Check.Eq(NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, _ => null, out _, candidatesNearest: 6), -1,
"no walk to any: -1 (the patrol keeps its start)");
walks[0] = 10;
Check.Eq(NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, Walk, out _, candidatesNearest: 6), 0,
"the old start the shortest walk: kept");
// Steps are never picked (a portal or a chat point between).
var steps = Route(RT.Circular, Pt(300, 0), Pt(5, 0, T.Chat), Pt(20, 0));
Check.Eq(NavigationEngine.NearestOnFoot(steps, 0, false, 0, NS0, EW0, p => 1.0, out _), 2, "a tie goes to the nearer; never the chat point");
}
// ── The same on the real map: Lugian Excavations (0x02E7) ───────────────
/// <summary>The dungeon patrol laid 2026-11-28 18:50:47 from cell 02E70285 (71 points; world x, y, z).</summary>