Introduces the two value types (Frame, Position) that represent retail's cell-relative position pair (acclient.h:30647/30658). Types are unused by consumers yet — zero behavior change. Also ports LandDefs::get_block_offset (pc:69189, @0x0043e630): world-meter offset between two named landblock ids, the ONLY cross-cell translation primitive in retail physics. Conformance tests: same-landblock→Zero, south-neighbour→(0,-192,0) (the exact #145 cascade cell), east-neighbour→(+192,0,0), diagonal→(+192,+192,0). 4/4 pass; full Core suite 1522 passed / 0 failed. DatFrame alias added to 4 files that had using DatReaderWriter.Types + using AcDream.Core.Physics in scope simultaneously. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Numerics;
|
|
using AcDream.Core.Physics;
|
|
using Xunit;
|
|
|
|
namespace AcDream.Core.Tests.Physics;
|
|
|
|
public class LandDefsBlockOffsetTests
|
|
{
|
|
// get_block_offset(src, dst) returns the world-meter offset from src's
|
|
// landblock origin to dst's landblock origin. block_byte<<3 = lcoord, *24 m/cell
|
|
// → nets to (Δlandblock)·192 m. Same landblock → Zero. Decomp @0x0043e630.
|
|
|
|
[Fact]
|
|
public void SameLandblock_ReturnsZero()
|
|
{
|
|
// both 0xC95B
|
|
Assert.Equal(Vector3.Zero, LandDefs.GetBlockOffset(0xC95B0001u, 0xC95B0008u));
|
|
}
|
|
|
|
[Fact]
|
|
public void SouthNeighbour_IsMinus192Y()
|
|
{
|
|
// 0xC95B (lbY=0x5B) → 0xC95A (lbY=0x5A): one landblock south = (0,-192,0).
|
|
// This is the exact #145 case: correct origin for 0xC95A relative to 0xC95B.
|
|
Assert.Equal(new Vector3(0f, -192f, 0f), LandDefs.GetBlockOffset(0xC95B0001u, 0xC95A0001u));
|
|
}
|
|
|
|
[Fact]
|
|
public void EastNeighbour_IsPlus192X()
|
|
{
|
|
// 0xC95B (lbX=0xC9) → 0xCA5B (lbX=0xCA): one landblock east = (+192,0,0).
|
|
Assert.Equal(new Vector3(192f, 0f, 0f), LandDefs.GetBlockOffset(0xC95B0001u, 0xCA5B0001u));
|
|
}
|
|
|
|
[Fact]
|
|
public void DiagonalNeighbour_CombinesBothAxes()
|
|
{
|
|
// 0xC95B → 0xCA5C: lbX +1 (+192), lbY +1 (+192).
|
|
Assert.Equal(new Vector3(192f, 192f, 0f), LandDefs.GetBlockOffset(0xC95B0001u, 0xCA5C0001u));
|
|
}
|
|
}
|