Apply recovered player phases, static camera query and level availability

This commit is contained in:
UnixNight committed 2026-10-25 19:56:44 -04:00
1 parent 117db77c7b
commit 09cf1172bf
33 files changed
+1500 -99

No files matched your search

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="../../src/GamePort/Game/OriginalCameraRay.cs" />
<Compile Include="../../src/GamePort/Game/OriginalBodySupport.cs" />
<Compile Include="../../src/GamePort/Assets/Mesh.cs" />
<Compile Include="../../src/GamePort/Assets/PngImage.cs" />
<Compile Include="../../src/GamePort/Assets/AssetPath.cs" />
</ItemGroup>
</Project>
+151
View File
@@ -0,0 +1,151 @@
using System.Numerics;
using GamePort.Assets;
using GamePort.Game;
var count = 0;
void Check(bool value, string message) { if (!value) throw new Exception(message); }
void Near(float actual, float expected, float tolerance, string message) =>
Check(MathF.Abs(actual - expected) <= tolerance, $"{message}: {actual} != {expected}");
void Test(string name, Action action) { action(); count++; Console.WriteLine($"PASS {name}"); }
void Reject<T>(Action action, string message) where T : Exception
{
try { action(); } catch (T) { return; }
throw new Exception(message);
}
SupportTriangle Horizontal(float y, int shape = 1, int polygon = 0) =>
new(new(-10, y, -10), new(10, y, -10), new(0, y, 10), shape, polygon);
CameraRayPolygon Wall(float y, int shape = 1, int polygon = 0) => new(Horizontal(y, shape, polygon), Vector3.Zero);
CameraRayPolygon Floor(float y, int shape = 1, int polygon = 0) => new(Horizontal(y, shape, polygon), Vector3.UnitY);
var high = new Vector3(0, 100, 0);
var low = Vector3.Zero;
Test("farther FIFO wall hit wins over nearer wall and general-grid floor", () =>
{
var ray = new OriginalCameraRay([Wall(20, 1), Wall(80, 2), Floor(90, 0)]);
var hit = ray.Trace(high, low);
Check(hit?.ShapeId == 1 && hit?.PolygonId == 0, "camera used nearest rather than first source wall");
Near(hit!.Value.Position.Y, 20, .00001f, "first wall point");
Near(hit.Value.Distance, 80, .00001f, "first wall distance");
var nearest = OriginalBodySupport.Trace([Horizontal(20, 1), Horizontal(80, 2), Horizontal(90, 0)], high, low);
Check(nearest?.ShapeId == 0, "support nearest reduction changed while extracting the shared kernel");
var result = ray.Constrain(high, low);
Near(result.Eye.Y, 40, .00001f, "source .25look+.75hit point");
Check(result.Gain == 1.5f && result.Hit == hit, "obstructed gain/identity");
});
Test("registration uses shape and polygon identities rather than render order", () =>
{
var ray = new OriginalCameraRay([Wall(80, 7, 2), Wall(20, 7, 1), Wall(90, 8, 0)]);
Check(ray.Trace(high, low)?.PolygonId == 1, "source polygon registration FIFO changed");
ray = new([Wall(80, 7), Wall(20, 3)]);
Check(ray.Trace(high, low)?.ShapeId == 3, "source shape registration order changed");
});
Test("inclusive cell rectangle scans increasing X and Z even against ray direction", () =>
{
SupportTriangle PlaneX(float x, int id) => new(new(x, -10, -10), new(x, -10, 10), new(x, 10, 0), id);
var rayX = new OriginalCameraRay([new(PlaneX(900, 1), Vector3.Zero), new(PlaneX(100, 2), Vector3.Zero)]);
Check(rayX.Trace(new(1000, 0, 0), Vector3.Zero)?.ShapeId == 2,
"grid rectangle should test farther lower-X cell first");
SupportTriangle PlaneZ(float z, int id) => new(new(-10, -10, z), new(0, 10, z), new(10, -10, z), id);
var rayZ = new OriginalCameraRay([new(PlaneZ(900, 1), Vector3.Zero), new(PlaneZ(100, 2), Vector3.Zero)]);
Check(rayZ.Trace(new(0, 0, 1000), Vector3.Zero)?.ShapeId == 2,
"inner grid rectangle should test farther lower-Z cell first");
});
Test("missed polygons are tested again in each cell and in fallback grid", () =>
{
var triangle = new SupportTriangle(new(-10, 0, 0), new(10, 0, 0), new(0, 0, 600));
var ray = new OriginalCameraRay([new(triangle, Vector3.Zero)]);
Check(ray.Trace(new(0, 10, 1), new(0, 10, 501)) == null, "parallel segment fabricated hit");
Check(ray.LastTriangleTests == 4, "query silently deduplicated source repeated-cell candidates");
});
Test("general grid fallback, stored-normal threshold and source winding", () =>
{
var ray = new OriginalCameraRay([new(Horizontal(50), new(0, .7f, 0))]);
Check(ray.PolygonCount == 1 && ray.WallPolygonCount == 0, "normal.Y equality must be excluded from wall grid");
Check(ray.Trace(high, low).HasValue && ray.LastTriangleTests == 1, "general grid fallback missing");
Check(ray.Trace(low, high) == null, "source backface accepted");
Check(ray.Trace(low, high, true).HasValue, "two-sided source override rejected");
var reverse = Horizontal(50) with { B = Horizontal(50).C, C = Horizontal(50).B };
Check(new OriginalCameraRay([new(reverse, Vector3.UnitY)]).Trace(high, low) == null, "serialized winding was reversed");
});
Test("beginning accepted, endpoint rejected, zero-length and degenerate triangles miss", () =>
{
var ray = new OriginalCameraRay([Floor(0)]);
Check(ray.Trace(new(0, 20, 0), low) == null, "strict segment endpoint accepted");
Check(ray.Trace(low, new(0, -20, 0)).HasValue, "beginning was rejected by an invented skin");
Check(ray.Trace(low, low) == null, "zero segment fabricated hit");
var degenerate = new OriginalCameraRay([new(new(Vector3.Zero, Vector3.Zero, Vector3.Zero), Vector3.Zero)]);
Check(degenerate.Trace(high, low) == null, "degenerate triangle fabricated hit");
Check(ray.Trace(new(0, 20, 0), new(0, .001f, 0)) == null, "triangle beyond segment accepted");
});
Test("NC shapes and checkpoint materials filter registration, null material remains", () =>
{
var ray = new OriginalCameraRay([
new(Horizontal(90, 1), Vector3.Zero, "NCwater"),
new(Horizontal(80, 2), Vector3.Zero, null, "CSTART"),
new(Horizontal(70, 3), Vector3.Zero, null, "cCHECK9"),
new(Horizontal(60, 4), Vector3.Zero, "ordinary", null),
new(Horizontal(50, 5), Vector3.Zero, null, "ccheck0"),
new(Horizontal(40, 6), Vector3.Zero, null, "ccheck10")]);
Check(ray.PolygonCount == 3 && ray.WallPolygonCount == 3, "source registration filters differ");
Check(ray.Trace(high, low)?.ShapeId == 4, "invisible null-material proxy was excluded");
});
Test("source enable flag and unobstructed gain leave desired eye unchanged", () =>
{
var ray = new OriginalCameraRay([Wall(50)]) { Enabled = false };
var result = ray.Constrain(high, low);
Check(result.Eye == low && result.Gain == 1 && result.Hit == null && ray.LastTriangleTests == 0,
"disabled predicate queried geometry or moved eye");
ray.Enabled = true;
result = ray.Constrain(new(100, 100, 100), new(100, 0, 100));
Check(result.Eye == new Vector3(100, 0, 100) && result.Gain == 1 && result.Hit == null, "miss changed eye or gain");
});
Test("stored float cell scale, negative truncation, signed16 domain and out-of-grid misses", () =>
{
Check(BitConverter.SingleToInt32Bits(OriginalCameraRay.CellScale) == 0x3b03126f, "source cell scale changed");
Check(OriginalCameraRay.CellCoordinate(-1) == 129 && OriginalCameraRay.CellCoordinate(0) == 130,
"negative coordinate cell conversion changed");
Check(OriginalCameraRay.CellCoordinate(-65000) == 0 && OriginalCameraRay.CellCoordinate(-65500) == -1,
"source truncation near negative grid edge differs");
Check(OriginalCameraRay.CellCoordinate(1_000_000) == 2130, "out-of-grid conversion incorrectly clamps cells");
var ray = new OriginalCameraRay([Floor(50)]);
Check(ray.Trace(new(1_000_000, 100, 1_000_000), new(1_000_000, 0, 1_000_000)) == null,
"out-of-grid source query fabricated hit");
});
Test("malformed, nonfinite and unsupported scene contracts reject explicitly", () =>
{
Reject<InvalidDataException>(() => new OriginalCameraRay([Wall(20), Wall(80)]), "ambiguous source polygon identity accepted");
Reject<ArgumentOutOfRangeException>(() => new OriginalCameraRay([new(Horizontal(20), new(float.NaN, 0, 0))]), "nonfinite normal accepted");
var ray = new OriginalCameraRay([Wall(50)]);
Reject<ArgumentOutOfRangeException>(() => ray.Trace(new(float.NaN, 0, 0), low), "nonfinite segment accepted");
Reject<ArgumentOutOfRangeException>(() => OriginalCameraRay.CellCoordinate(float.MaxValue), "unknown x87 overflow silently emulated");
var empty = new Mesh([], []);
Reject<NotSupportedException>(() => OriginalCameraRay.FromRouteScene(empty, "LV2A"), "unrecovered game filter silently assumed false");
Reject<InvalidDataException>(() => OriginalCameraRay.FromRouteScene(new Mesh(new MeshVertex[3], [0, 1, 2]), "LV1B"),
"missing polygon source metadata accepted");
});
Test("original route geometry registration counts and retained invisible polygons", () =>
{
var prepared = Path.GetFullPath(args.Length > 0 ? args[0] : "artifacts/extracted");
foreach (var (scene, code, polygons, walls) in new[] {
("level1b", "LV1B", 2851, 2483), ("VR04", "VR04", 508, 420), ("level1", "LEV1", 5231, 3860) })
{
var mesh = Mesh.LoadSceneJson(AssetPath.Resolve(prepared, scene + "/scene.json"));
var ray = OriginalCameraRay.FromRouteScene(mesh, code);
Check(ray.PolygonCount == polygons && ray.WallPolygonCount == walls,
$"{scene} original polygon/wall registration differs: {ray.PolygonCount}/{ray.WallPolygonCount}");
if (scene == "level1b")
Check(mesh.Draws.Sum(d => (long)d.IndexCount) < mesh.Indices.Length, "lab proxy visibility fixture changed");
}
});
Console.WriteLine($"Camera ray checks: {count} groups passed. Source ordering/kernel translation verified; original runtime and x87 boundary equivalence remain unverified.");
+50
View File
@@ -0,0 +1,50 @@
# Static source camera query checks
Run from GamePort:
```sh
source scripts/env.sh
dotnet run --project tests/GamePort.CameraRayTests
dotnet run --project tests/GamePort.SupportTests
```
Optional first argument selects the prepared-scene root (default
`artifacts/extracted`). Original geometry is prepared separately; these tests
do not modify or execute original files.
`OriginalCameraRay.FromRouteScene(mesh, levelCode)` accepts only LV1B, VR04 and
LEV1, whose original game polygon-filter slot134 is475CD0 (false). It retains
source shape/polygon identity and stored normals, excludes NC/checkpoint records,
and rejects included fan-triangulated polygon identities rather than changing the
original first-three-corner rule. All included polygons in these three original
scenes are triangles. Original registration counts are2851/2483 wall (lab),
508/420 (VR04),5231/3860 (outside).
Source anchors and exact file offsets are recorded in
`docs/checkpoint/camera-ray-predicate.md` and checked by
`tests/test_checkpoint_camera_ray.py`. Critical contracts are47C210 wall-first
then general-grid fallback;47C280/47C4B0 inclusive ascending X/Z rectangle and
FIFO first accepted polygon;479800 tail insertion and4798B3 normal.Y<.7;
469A10/469B70 one-sided segment/triangle kernel and strict endpoint rejection.
43B820 applies `.25*look+.75*hit` and returns gain1.5; a miss leaves eye/gain1.
API: `Trace(start,end,twoSided=false)` returns optional SupportHit;
`Constrain(look,desired)` returns CameraRayResult(Eye,Gain,Hit). Enabled is the
per-adapter representation of source global4F69E5. PolygonCount/WallPolygonCount
and LastTriangleTests are modern diagnostics; repeated cells count repeated
triangle tests. OriginalBodySupport.IntersectSegment shares the recovered
individual kernel while its existing Trace retains nearest reduction.
The checks exercise source route counts and deliberately non-nearest results,
cell direction, FIFO identity, repeated candidates, fallback, normal threshold,
winding/sidedness, beginning/end, degenerate segments, filters, proxy retention,
enable flag, look-point weighting, negative/signed16 cells and malformed inputs.
They verify this port implementation and source data, not original running-game
behavior or whole-camera integration.
Limits: grid conversion uses double intermediates in place of x87 extended
precision; exact boundary equivalence and integer overflow remain unrecovered.
Finite values outside supported signed64 conversion throw. Lookup tables retain
the existing support module's modern-trig limitation. Other level-specific
polygon filters, missing shape IDs, nonidentity terrain transforms, camera input
modes and shared viewport/follow update state remain outside this adapter.
@@ -155,6 +155,34 @@ inventory.SetState(0, 3, 0); Throws(() => inventory.SelectGadget(3));
inventory.SetState(0, 3, 1); inventory.SelectGadget(3); Check(inventory.SelectedGadget == 3, "Owned gadget selection");
Console.WriteLine("PASS inventory bounds, ownership, unknown-state preservation and gadget availability");
foreach (var state in new[] { int.MinValue, -1, 0, 1, 2, 3, 4, 5, int.MaxValue })
{
foreach (var tutorial in Enumerable.Range(1, 8).Select(i => "VR0" + i))
{
var availability = new SceneInventory(Enumerable.Repeat(state, 19));
availability.ApplyLevelAvailability(tutorial);
var disabled = state is 1 or 4 ? 4 : state;
Check(Enumerable.Range(0, 8).All(i => availability.State(0, i) == disabled),
"Tutorial PostLoad only disables owned states1/4");
Check(availability.State(0, 8) == state && Enumerable.Range(0, 10).All(i => availability.State(1, i) == state),
"PostLoad availability preserves gadget8 and the independent inventory group");
var carried = OriginalSave.Parse((original with { InventoryStates = availability.Snapshot() }).Encode());
var returned = new SceneInventory(carried.InventoryStates);
returned.ApplyLevelAvailability("LV1B");
Check(Enumerable.Range(0, 8).All(i => returned.State(0, i) == (state is 1 or 4 ? 1 : state)),
"Serialized tutorial state returns to enabled owned gadgets in lab");
}
}
foreach (var normal in new[] { "LV1B", "LEV1", "VR00", "VR09", "vr04" })
{
var availability = new SceneInventory(Enumerable.Repeat(4, 19));
availability.ApplyLevelAvailability(normal);
Check(availability.State(0, 3) == 1 && availability.State(0, 8) == 4,
"Normal/fourcc-boundary PostLoad enables selected owned gadgets only");
}
Check(JetpackBurst.CanStart("VR04", -1, 4, 20), "Tutorial jetpack bypass still works with disabled inventory state4");
Console.WriteLine("PASS source PostLoad gadget availability, tutorial boundaries and lab RETURN round-trip");
// Independently recover the original SCENE setter's two dispatch tables rather
// than testing the port's switch against another manually copied switch.
var exe = File.ReadAllBytes(AssetPath.Resolve(root, "Neutron.exe"));
+80 -9
View File
@@ -8,6 +8,8 @@ var tests = new (string Name, Action Check)[]
{
("60 simulation calls across 60/120/144 Hz presentation", ClockRates),
("clock remainder, stall bound, reset and invalid intervals", ClockBoundaries),
("physics consumes prior motion; fresh versus retained input order", FrameOrdering),
("source camera query origin, hit adjustment, gain and one query per input", CameraQueryConsumer),
("turn-only speed, forward acceleration/cap and release", SpeedLimits),
("backpedal cap and release", Backpedal),
("yaw sign, forward half-turn and left precedence", Turning),
@@ -59,6 +61,69 @@ static void ClockBoundaries()
Throws<ArgumentOutOfRangeException>(() => clock.Advance(elapsed));
}
static void FrameOrdering()
{
var fresh = FlatSimulation();
var origin = fresh.Position;
var forward = new PlayerInput(true, false, false, false, false);
fresh.Step(forward);
NearVector(fresh.Position, origin, .0001f, "input cannot move an already integrated body");
Near(fresh.Speed, 30, 0, "fresh input runs before player callback");
Near(fresh.Velocity.Z, 30, 0, "player produces velocity for the next physics pass");
fresh.Step(forward);
Near(fresh.Position.Z - origin.Z, 30 * FixedStepClock.Step, .0001f, "next physics consumes previous30, not current60");
var retained = FlatSimulation();
retained.InputAfterPlayerUpdate = true;
retained.Step(forward);
Near(retained.Speed, 30, 0, "new level game updates retained player's input later");
Near(retained.Velocity.Z, 0, 0, "retained player callback preceded first destination input");
retained.Step(forward);
NearVector(retained.Position, origin, .0001f, "second retained physics still sees old zero velocity");
Near(retained.Velocity.Z, 30, 0, "retained player now produces prior input speed");
retained.Step(forward);
Near(retained.Position.Z - origin.Z, 30 * FixedStepClock.Step, .0001f, "retained third physics consumes first input");
var jump = FlatSimulation();
jump.Step(new(false, false, false, false, true));
NearVector(jump.Position, origin, .0001f, "queued jump cannot retroactively change physics");
Near(jump.PendingImpulse.Y, 550, 0, "jump impulse remains pending until next body pass");
Check(jump.Grounded && jump.Pose == PlayerPose.Jump, "jump animation request does not change physical support");
jump.Step(default);
Near(jump.PendingImpulse.Y, 0, 0, "next body pass consumes queued impulse exactly once");
Near(jump.Velocity.Y, 550 - 800 * 1.33f * FixedStepClock.Step, .0001f,
"next body pass applies one impulse plus the retained provisional gravity adapter");
Check(!jump.Grounded && jump.Position.Y > origin.Y, "queued jump takes off on following body pass");
jump.Step(default);
Check(jump.Velocity.Y < 550 && jump.Velocity.Y > 500, "later body pass adds acceleration without repeating impulse");
jump.Reset();
NearVector(jump.PendingImpulse, Vector3.Zero, 0, "reset clears pending physical work");
Check(jump.MovementMode == 0, "reset restores stored walking input mode");
}
static void CameraQueryConsumer()
{
var enabled = false;
var queries = 0;
var lastLook = Vector3.Zero;
var lastDesired = Vector3.Zero;
SupportHit? Query(Vector3 look, Vector3 desired)
{
queries++; lastLook = look; lastDesired = desired;
return enabled ? new SupportHit((look + desired) / 2, 7, 9, 0) : null;
}
var simulation = FlatSimulation(cameraRay: Query);
var before = simulation.CameraEye;
var beforeQueries = queries;
enabled = true;
simulation.Step(default);
NearVector(lastLook, simulation.CameraTarget, .0001f, "ray origin is look target rather than actor root");
var adjusted = lastLook + (lastDesired - lastLook) * .375f;
var expected = before + (adjusted - before) * new Vector3(1.6f, 1.2f, 1.6f) * 1.5f * FixedStepClock.Step;
NearVector(simulation.CameraEye, expected, .0001f, "source hit weighting and follow gain feed interpolation");
Check(queries == beforeQueries + 1, "no additional camera obstruction query after interpolation");
}
static void SpeedLimits()
{
var turn = FlatSimulation();
@@ -102,7 +167,8 @@ static void Turning()
Near(left.Yaw, -right.Yaw, .00001f, "opposed keyboard yaw symmetry");
Near(forwardLeft.Yaw, left.Yaw / 2, .00001f, "Up halves target turn offset");
Near(forwardLeft.Speed, 60, 0, "Up plus turn performs both speed increments");
Check(left.Position.X < 0 && right.Position.X > 0, "keyboard side-velocity signs");
Check(left.Velocity.X < 0 && right.Velocity.X > 0, "keyboard side-velocity signs for next physics pass");
Near(left.Position.X, 0, .0001f, "turn input waits for subsequent physics");
var both = FlatSimulation();
var leftOnly = FlatSimulation();
@@ -138,8 +204,8 @@ static void JumpLanding()
var simulation = FlatSimulation();
var floor = simulation.Position.Y;
simulation.Step(new(false, false, false, false, true));
Check(!simulation.Grounded && simulation.Velocity.Y > 500 && simulation.Jumps == 1 && simulation.Pose == PlayerPose.Jump,
"jump takes off with one queued impulse");
Check(simulation.Grounded && simulation.PendingImpulse.Y == 550 && simulation.Jumps == 1 && simulation.Pose == PlayerPose.Jump,
"jump queues once after physics and requests its animation");
var sawFall = false;
var largestHeight = simulation.Position.Y;
for (var i = 0; i < 120; i++)
@@ -164,7 +230,7 @@ static void HeldJump()
for (var i = 0; i < 150; i++) simulation.Step(default);
Check(simulation.Jumps == jumpCount && simulation.Grounded, "release stops held repetition and lands");
simulation.Step(new(false, false, false, false, true));
Check(simulation.Jumps == jumpCount + 1 && !simulation.Grounded, "new grounded press starts another jump");
Check(simulation.Jumps == jumpCount + 1 && simulation.PendingImpulse.Y == 550, "new grounded press queues another jump");
}
static void AirArithmetic()
@@ -196,6 +262,7 @@ static void AirControl()
{
var simulation = FlatSimulation();
simulation.Step(new(false, false, false, false, true));
simulation.Step(default); // Consume the queued takeoff before airborne input.
var origin = simulation.Position;
for (var i = 0; i < 20; i++)
{
@@ -262,10 +329,14 @@ static void LandingTurn()
{
var simulation = FlatSimulation();
simulation.Step(new(true, false, false, false, true));
for (var i = 0; i < 120 && !simulation.Grounded; i++)
var largestAirTurn = 0f;
for (var i = 0; i < 120 && (i == 0 || !simulation.Grounded); i++)
{
simulation.Step(new(true, false, initialLeft, !initialLeft, false));
Check(simulation.Grounded && MathF.Abs(simulation.TurnRate) > 20,
"Landing fixture retains an opposing air turn before outer grounded reset");
largestAirTurn = MathF.Max(largestAirTurn, MathF.Abs(simulation.TurnRate));
}
Check(simulation.Grounded && largestAirTurn > 20 && simulation.TurnRate == 0,
"Physics landing precedes the same-frame player update clearing air turn");
var before = simulation.Yaw;
simulation.Step(new(true, false, !initialLeft, initialLeft, false));
Near(simulation.TurnRate, 0, 0, "grounded released-jump reset clears shared air-turn field");
@@ -376,7 +447,7 @@ static void OriginalLab(string project, string originals)
Near(simulation.Position.Y, .5486332f + SceneCollision.Skin, .03f, "original lab jump returns to floor");
}
static LabSimulation FlatSimulation(float yaw = 0)
static LabSimulation FlatSimulation(float yaw = 0, Func<Vector3, Vector3, SupportHit?>? cameraRay = null)
{
var positions = new[]
{
@@ -386,7 +457,7 @@ static LabSimulation FlatSimulation(float yaw = 0)
var floor = new Mesh(positions.Select(p => new MeshVertex(p, Vector2.Zero, Vector3.One)).ToArray(), [0, 1, 2, 3, 4, 5]);
var standing = new Mesh([new(new(-20, -20, -20), Vector2.Zero, Vector3.One),
new(new(20, 80, 20), Vector2.Zero, Vector3.One)], []);
return new LabSimulation(new SceneCollision(floor), standing, new Vector3(0, 25, 0), yaw);
return new LabSimulation(new SceneCollision(floor), standing, new Vector3(0, 25, 0), yaw, cameraRay);
}
static void SameState(LabSimulation actual, LabSimulation expected, string message)
@@ -136,14 +136,15 @@ void Tick(PlayerInput input)
director.Touch(level.Player.Tag!, simulation.ActorRoot);
interactions.Update(simulation.ActorRoot, simulation.InteractionRadius);
mechanisms.Update(simulation.ActorRoot, simulation.InteractionRadius);
// Test actual aperture clearance when crossing the gate plane, before this
// frame's mechanism movement. The resolver uses this same current transform.
// Test the recovered radius60 root body when crossing the gate plane,
// before mechanism movement. Raw standing mesh height is a provisional
// visual/pivot policy, not the dynamic collider used by the source adapter.
if ((previous.Z - bars.Position.Z) * (simulation.ActorRoot.Z - bars.Position.Z) < 0)
{
var box = visuals.DoorColliders().Single();
var minimumY = DynamicSceneCollision.Corners(box).Min(p => p.Y);
Require(minimumY > simulation.Position.Y + simulation.BodyHeight,
"Replay crossed the bars before the moving doorway cleared the player");
Require(minimumY > simulation.ActorRoot.Y + simulation.InteractionRadius,
"Replay crossed the bars before the moving doorway cleared the recovered body");
crossings++;
}
mechanisms.Step(FixedStepClock.Step);
+49
View File
@@ -0,0 +1,49 @@
"""Retained-character source evidence and state-conversion boundaries."""
from pathlib import Path
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools/binary'))
from checkpoint_character_reset import collect, gadget_postload
class CharacterResetEvidenceTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.report = collect(ROOT.parent / 'Original')
def test_source_identity_reset_and_callback_provenance(self):
self.assertTrue(self.report['known_binary'])
for key in ('sites', 'vtables', 'gadget_calls'):
for item in self.report[key]:
with self.subTest(key=key, item=item):
self.assertTrue(item['matches'])
def test_euler_capture_is_not_body_velocity(self):
sites = {s['name']: s for s in self.report['sites']}
self.assertEqual(sites['euler_getter_y']['actual'], '8b9128020000')
self.assertEqual(sites['player_init_yaw_capture']['actual'], '8b500489961c060000')
tables = {s['name']: s['target'] for s in self.report['vtables']}
self.assertEqual(tables['Jimmy Euler getter'], '0x4723f0')
def test_gadget_postload_disables_owned_only_and_restores_on_return(self):
original = [0, 1, 4, 2, 3, -1, 99, 1, 123]
disabled = gadget_postload(original, True)
self.assertEqual(disabled, [0, 4, 4, 2, 3, -1, 99, 4, 123])
self.assertEqual(gadget_postload(disabled, False), [0, 1, 1, 2, 3, -1, 99, 1, 123])
self.assertEqual(original, [0, 1, 4, 2, 3, -1, 99, 1, 123])
self.assertEqual(gadget_postload(disabled, True), disabled)
with self.assertRaises(ValueError):
gadget_postload([0] * 7, False)
def test_route_properties_do_not_serialize_mode_or_burn_timer(self):
self.assertEqual([x['code'] for x in self.report['route']], ['LV1B', 'VR04', 'LEV1'])
for item in self.report['route']:
self.assertIn('StartPoint', item['player_properties'])
self.assertFalse(any('jump' in p.casefold() or 'mode' in p.casefold()
or 'burn' in p.casefold() for p in item['player_properties']))
if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,39 @@
"""Guard source stored/live lifecycle fields and the old-game deletion path."""
from pathlib import Path
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools/binary'))
from checkpoint_level_game_lifetime import collect
class LevelGameLifetimeTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.report = collect(ROOT.parent / 'Original')
def test_original_instruction_and_vtable_identity(self):
self.assertTrue(self.report['known_binary'])
for item in self.report['sites'] + self.report['vtables']:
with self.subTest(item=item):
self.assertTrue(item['matches'])
def test_route_level_games_share_initialization_contract(self):
slots = {(x['owner'], x['slot']): x['target'] for x in self.report['vtables']}
for owner in ('lab', 'tutorial', 'outside'):
self.assertEqual(slots[owner, '0x28'], '0x44d4e0')
self.assertEqual(slots[owner, '0x8c'], '0x470f30')
self.assertEqual(slots[owner, '0x204'], '0x4719c0')
def test_actual_initializer_precedes_postload_and_teardown_calls_sweep(self):
sites = {x['label']: x for x in self.report['sites']}
self.assertLess(int(sites['loader_init_slot']['va'], 16), int(sites['loader_postload_slot']['va'], 16))
self.assertEqual(sites['base_init_to_common']['target'], '0x470540')
self.assertEqual(sites['teardown_delete_sweep']['target'], '0x473710')
self.assertEqual(sites['lab_destructor_base']['target'], '0x44d390')
self.assertEqual(sites['game_destructor_interface']['target'], '0x4587e0')
if __name__ == '__main__':
unittest.main()
+19
View File
@@ -0,0 +1,19 @@
from pathlib import Path
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools/binary'))
from player_phase_evidence import collect
class PlayerPhaseEvidenceTests(unittest.TestCase):
def test_original_mode_and_frame_boundaries(self):
evidence = collect(ROOT.parent / 'Original')
self.assertEqual(len(evidence['sites']), 9)
self.assertEqual([s['va'] for s in evidence['sites'][-3:]],
['0x47e554', '0x47e582', '0x47e587'])
if __name__ == '__main__':
unittest.main()