using System; using Server.Engines.Pathing.Cache; namespace Server.Tests.Pathfinding; /// /// Shared fixtures for the step-cache tests: the walker the parity tests measure against, the /// cell-index arithmetic, and builders for the chunk state several tests inject by hand. /// internal static class PathingTestSupport { /// /// Trammel. Every seed coordinate below is a real location on it, so these tests need the /// client's map files; they skip when those are absent. /// public static Map TestMap => Map.Maps[1]; /// /// A cell in open Britain countryside — flat, walkable in all directions, no statics. The /// default subject when a test needs a chunk to exist and doesn't care what's in it. /// public const int PlainX = 1500; public const int PlainY = 1600; /// Index of world cell (x, y) within its own chunk. public static int CellIndex(int x, int y) => ((y & 15) << 4) | (x & 15); /// A strata offset table with every cell marked single-Z. public static ushort[] NoStrataOffsets() { var offsets = new ushort[StepChunk.CellsPerChunk]; Array.Fill(offsets, StepChunk.NoStrata); return offsets; } /// /// Packs a one-stratum record: a count byte, then the stratum itself. Directions not named in /// stay at 0. Mirrors the layout StepCache.WriteStratum produces. /// public static byte[] OneStratum(sbyte zCenter, byte walkMask = 0, byte wetMask = 0, params sbyte[] walkZs) { var data = new byte[1 + StepChunk.StratumByteLength]; data[0] = 1; // stratum count data[1] = (byte)zCenter; data[2] = walkMask; data[3] = wetMask; // walkZ_N..NW occupy bytes 4..11; swimZ_N..NW follow at 12..19. for (var i = 0; i < walkZs.Length && i < 8; i++) { data[4 + i] = (byte)walkZs[i]; } return data; } /// /// The default static walker. Deriving straight from rather than /// BaseCreature is the point: MovementImpl then sees no creature capabilities (no swim, no fly, /// no door-opening), which is exactly the walker the cache bakes for. /// public sealed class StaticWalker : Mobile { public StaticWalker() { Body = 0xC9; } } }