feat(pathfinding): .swb format v8 compact index (#3b) (#2471)
## Summary Phase #3b (final roadmap item), stacked on #2470. Compacts the index trailer from 20 to 8 bytes/chunk. Trammel: 19.2 MB → 17.9 MB. Roadmap total: 565 MB → 17.9 MB (−96.8%). ## Details - Trailer stores `{ u32 packedKey = (ChunkX << 16) | ChunkY, u32 recordLength }` per chunk, in record write order; the file offset is dropped and reconstructed by cumulative recordLength from HeaderSize. - No record reordering, no varint; fixed-stride, TryReadChunk unchanged. - Also simplifies the accumulated `.swb` code comments across the stack. - Format v8; v7 files rejected and re-baked once. ## Tests v8 multi-chunk round-trip (cumulative offset reconstruction) + the v6/v7 suite; full pathfinding suite green; Release build clean.
This commit is contained in:
parent
c265bcbb5e
commit
c7aaf33de9
16 changed files with 960 additions and 868 deletions
|
|
@ -1,35 +1,29 @@
|
|||
namespace Server.PathAlgorithms
|
||||
namespace Server.PathAlgorithms;
|
||||
|
||||
public abstract class PathAlgorithm
|
||||
{
|
||||
public abstract class PathAlgorithm
|
||||
private static readonly Direction[] _calcDirections =
|
||||
{
|
||||
private static readonly Direction[] _calcDirections =
|
||||
{
|
||||
Direction.Up,
|
||||
Direction.North,
|
||||
Direction.Right,
|
||||
Direction.West,
|
||||
Direction.North,
|
||||
Direction.East,
|
||||
Direction.Left,
|
||||
Direction.South,
|
||||
Direction.Down
|
||||
};
|
||||
Direction.Up,
|
||||
Direction.North,
|
||||
Direction.Right,
|
||||
Direction.West,
|
||||
Direction.North,
|
||||
Direction.East,
|
||||
Direction.Left,
|
||||
Direction.South,
|
||||
Direction.Down
|
||||
};
|
||||
|
||||
public abstract bool CheckCondition(Mobile m, Map map, Point3D start, Point3D goal);
|
||||
public abstract Direction[] Find(Mobile m, Map map, Point3D start, Point3D goal);
|
||||
public abstract bool CheckCondition(Mobile m, Map map, Point3D start, Point3D goal);
|
||||
public abstract Direction[] Find(Mobile m, Map map, Point3D start, Point3D goal);
|
||||
|
||||
public static Direction GetDirection(int xSource, int ySource, int xDest, int yDest)
|
||||
{
|
||||
var x = xDest + 1 - xSource;
|
||||
var y = yDest + 1 - ySource;
|
||||
var v = y * 3 + x;
|
||||
public static Direction GetDirection(int xSource, int ySource, int xDest, int yDest)
|
||||
{
|
||||
var x = xDest + 1 - xSource;
|
||||
var y = yDest + 1 - ySource;
|
||||
var v = y * 3 + x;
|
||||
|
||||
if (v is < 0 or >= 9)
|
||||
{
|
||||
return Direction.North;
|
||||
}
|
||||
|
||||
return _calcDirections[v];
|
||||
}
|
||||
return v is < 0 or >= 9 ? Direction.North : _calcDirections[v];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue