Recover retained route state and complete PostLoad availability tails
This commit is contained in:
1 parent
1dddfefc68
commit
9ad5a8ef6b
36 files changed
+1559
-32
No files matched your search
@@ -9,6 +9,7 @@
|
||||
<Compile Include="../../src/GamePort/Game/TaskActivation.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/TaskStates.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/LabSimulation.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/PlayerLevelState.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/AirSteering.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/JetpackBurst.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/SceneCollision.cs"/>
|
||||
|
||||
@@ -162,15 +162,17 @@ foreach (var state in new[] { int.MinValue, -1, 0, 1, 2, 3, 4, 5, int.MaxValue }
|
||||
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");
|
||||
var practiceItem = tutorial[3] - '1';
|
||||
Check(Enumerable.Range(0, 8).All(i => availability.State(0, i)
|
||||
== (i == practiceItem && state is 1 or 4 ? 1 : disabled)),
|
||||
"Complete tutorial PostLoad re-enables its practice gadget after the common disable pass");
|
||||
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");
|
||||
Check(Enumerable.Range(0, 8).All(i => returned.State(0, i) == (state is 1 or 4 ? i is 1 or 7 ? 4 : 1 : state)),
|
||||
"Serialized tutorial state returns to lab-specific owned gadget availability");
|
||||
}
|
||||
}
|
||||
foreach (var normal in new[] { "LV1B", "LEV1", "VR00", "VR09", "vr04" })
|
||||
@@ -181,7 +183,7 @@ foreach (var normal in new[] { "LV1B", "LEV1", "VR00", "VR09", "vr04" })
|
||||
"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");
|
||||
Console.WriteLine("PASS complete route/tutorial PostLoad availability tails, unknown states 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.
|
||||
|
||||
@@ -9,6 +9,7 @@ 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),
|
||||
("ordinary route load retains scalars independently of body/jump reset", RetainedLevelState),
|
||||
("source camera query origin, hit adjustment, gain and one query per input", CameraQueryConsumer),
|
||||
("debug noclip bypasses walls/gravity/camera and exits without queued motion", Noclip),
|
||||
("turn-only speed, forward acceleration/cap and release", SpeedLimits),
|
||||
@@ -102,6 +103,38 @@ static void FrameOrdering()
|
||||
Check(jump.MovementMode == 0, "reset restores stored walking input mode");
|
||||
}
|
||||
|
||||
static void RetainedLevelState()
|
||||
{
|
||||
var state = new PlayerLevelState("LV1B", 3, 1, .625f, 6.125f);
|
||||
foreach (var destination in new[] { "VR04", "LV1B", "LEV1" })
|
||||
{
|
||||
var next = FlatSimulation(); next.LevelCode = destination; next.InputAfterPlayerUpdate = true;
|
||||
Check(next.ApplyRetainedLevelState(state), "Proven route accepts supported retained scalars");
|
||||
Check(next.MovementMode == 1 && next.JumpState == 0 && next.JumpHoldSeconds == .625f
|
||||
&& next.JetpackRemaining == 6.125f, "Jump reset does not imply mode/hold/fire reset");
|
||||
Check(next.Speed == 0 && next.TurnRate == 0 && next.Velocity == Vector3.Zero
|
||||
&& next.PendingImpulse == Vector3.Zero && !next.JetpackEffectVisible, "Body and effect presentation remain independently initialized");
|
||||
next.RestoreReturnRoot(next.ActorRoot + Vector3.UnitY * 500);
|
||||
next.Step(default);
|
||||
Check(!next.Grounded && next.MovementMode == 1 && next.JumpState == 0,
|
||||
"Airborne first destination tick keeps retained input mode after jump state reset");
|
||||
Near(next.JetpackRemaining, 6.125f - FixedStepClock.Step, .00001f, "Fire timer advances in its own next-tick phase");
|
||||
var carried = next.CaptureLevelState(-1)!;
|
||||
Check(carried.SourceLevel == destination && carried.HoldSeconds == .625f, "Ordinary boundary captures current scalars");
|
||||
next.Reset();
|
||||
Check(next.MovementMode == 0 && next.JumpHoldSeconds == 0 && next.JetpackRemaining == 0, "Explicit modern reset clears transient carry state");
|
||||
}
|
||||
var grounded = FlatSimulation(); grounded.ApplyRetainedLevelState(state); grounded.Step(default);
|
||||
Check(grounded.MovementMode == 0 && grounded.JetpackRemaining < 0,
|
||||
"First grounded released controller/fire ticks clear mode and timer independently of loader");
|
||||
var unsupported = FlatSimulation();
|
||||
Check(!unsupported.ApplyRetainedLevelState(state with { SourceLevel = "LEV6" })
|
||||
&& !unsupported.ApplyRetainedLevelState(state with { SelectedGadget = 0 }), "Unproven class cleanup/level states do not acquire carry policy");
|
||||
unsupported.SetNoclip(true); Check(unsupported.CaptureLevelState(-1) == null, "Modern noclip does not leak flight into retained gameplay state");
|
||||
Throws<ArgumentOutOfRangeException>(() => grounded.ApplyRetainedLevelState(state with { HoldSeconds = float.NaN }));
|
||||
Throws<ArgumentOutOfRangeException>(() => grounded.ApplyRetainedLevelState(state with { EffectRemaining = float.PositiveInfinity }));
|
||||
}
|
||||
|
||||
static void CameraQueryConsumer()
|
||||
{
|
||||
var enabled = false;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<Compile Include="../../src/GamePort/Game/TaskStates.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/TaskActivation.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/LabSimulation.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/PlayerLevelState.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/AirSteering.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/JetpackBurst.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/SceneCollision.cs"/>
|
||||
|
||||
@@ -27,7 +27,7 @@ class CharacterResetEvidenceTests(unittest.TestCase):
|
||||
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):
|
||||
def test_common_availability_prefix_without_level_specific_tails(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])
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Retained companion local reset provenance; static evidence, not runtime fidelity."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from retained_companion import collect, level_policy, HIDDEN_CODES
|
||||
|
||||
|
||||
class RetainedCompanionTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.report = collect(ROOT.parent / 'Original')
|
||||
|
||||
def test_hash_instruction_and_virtual_callback_provenance(self):
|
||||
self.assertTrue(self.report['known_binary'])
|
||||
for key in ('sites', 'vtables'):
|
||||
for site in self.report[key]:
|
||||
with self.subTest(key=key, site=site):
|
||||
self.assertTrue(site['matches'])
|
||||
if key == 'sites':
|
||||
self.assertEqual(int(site['file_offset'], 16), int(site['va'], 16) - 0x400000)
|
||||
|
||||
def test_route_has_no_companion_property_reload(self):
|
||||
self.assertEqual([r['code'] for r in self.report['route']], ['LV1B', 'VR04', 'LEV1'])
|
||||
for route in self.report['route']:
|
||||
self.assertEqual(route['dog_records'], [])
|
||||
self.assertEqual(route['shadow_records'], [])
|
||||
self.assertEqual(route['policy'], dict(hidden=False, range=1500, collision_enabled=True,
|
||||
radius=130, submode=0, flag928=0))
|
||||
|
||||
def test_reused_companion_callback_resets_rotation_not_velocity(self):
|
||||
targets = {s['name']: s['target'] for s in self.report['vtables']}
|
||||
self.assertEqual(targets['Goddard authored Euler setter'], '0x4716d0')
|
||||
self.assertEqual(targets['Goddard logical Euler xyz setter'], '0x472420')
|
||||
self.assertEqual(targets['Goddard rotation sync'], '0x4624f0')
|
||||
sites = {s['name']: s['actual'] for s in self.report['sites']}
|
||||
self.assertEqual(sites['rotation_set_authored_x'], '8986fc000000')
|
||||
self.assertEqual(sites['rotation_set_logical'], 'ff9030030000')
|
||||
|
||||
def test_level_policy_hidden_branches_leave_radius_submode_unassigned(self):
|
||||
for code in HIDDEN_CODES:
|
||||
self.assertEqual(level_policy(code), dict(hidden=True, range=1500, collision_enabled=False,
|
||||
radius=None, submode=None, flag928=1))
|
||||
for code in ('LEV5', 'LEV8', 'LV1B', 'LV1E', 'LV4B', 'LV6B', 'VR04'):
|
||||
self.assertFalse(level_policy(code)['hidden'])
|
||||
self.assertEqual(level_policy('VR06')['range'], 3500)
|
||||
with self.assertRaises(ValueError):
|
||||
level_policy('VR004')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Guard body-vector owners and their initialization/physics consumers."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from retained_player_body import collect
|
||||
|
||||
|
||||
class RetainedBodyTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.report = collect(ROOT.parent / 'Original')
|
||||
|
||||
def test_authored_body_vectors_reapplied_in_init(self):
|
||||
targets = {x['name']: x['target'] for x in self.report['tables']}
|
||||
self.assertEqual(targets['live velocity'], '0x471f70')
|
||||
self.assertEqual(targets['physics velocity'], '0x471f10')
|
||||
self.assertEqual(targets['live impulse'], '0x471cc0')
|
||||
self.assertEqual(targets['physics impulse'], '0x471c60')
|
||||
|
||||
def test_preparation_has_its_own_velocity_reset_boundary(self):
|
||||
sites = {x['name']: x['bytes'] for x in self.report['sites']}
|
||||
self.assertEqual(sites['prepare_velocity_xyz'], '6a006a006a008bceff90c4020000')
|
||||
self.assertEqual(sites['prepare_speed_clear'], 'c7860806000000000000')
|
||||
self.assertEqual(sites['postload_prepare'], 'ff9010040000')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Guard RETURN/ordinary departure distinctions against the original EXE."""
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from retained_return_cleanup import collect, JetpackCleanupProjection, project_jetpack_cleanup
|
||||
|
||||
|
||||
class RetainedReturnCleanupTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.report = collect(ROOT.parent / 'Original')
|
||||
|
||||
def test_original_identity_instruction_targets_and_dispatch(self):
|
||||
self.assertTrue(self.report['known_binary'])
|
||||
for key in ('sites', 'vtables', 'cleanup_table', 'select_table', 'tutorial_tail', 'tutorial_table'):
|
||||
for site in self.report[key]:
|
||||
with self.subTest(key=key, site=site):
|
||||
self.assertTrue(site['matches'])
|
||||
|
||||
def test_jetpack_dispatch_is_common_epilogue_not_other_gadget_mode_reset(self):
|
||||
targets = [s['target'] for s in self.report['cleanup_table']]
|
||||
self.assertEqual(targets[3], '0x42882f')
|
||||
self.assertNotEqual(targets[3], targets[0])
|
||||
self.assertNotEqual(targets[3], targets[1])
|
||||
sites = {s['name']: s for s in self.report['sites']}
|
||||
self.assertEqual(sites['cleanup_case0_mode_zero']['actual'], '66899ec4070000')
|
||||
self.assertEqual(sites['cleanup_case1_mode_one']['actual'], '6689aec4070000')
|
||||
|
||||
def test_cleanup_prelude_is_menu_and_return_flags_precede_stage(self):
|
||||
self.assertEqual(self.report['menu_identity'], 'C2DInGameMenu')
|
||||
tables = {t['name']: t['target'] for t in self.report['vtables']}
|
||||
self.assertEqual(tables['Menu select'], '0x405fb0')
|
||||
self.assertEqual(tables['Menu close'], '0x406590')
|
||||
sites = {s['name']: int(s['va'], 16) for s in self.report['sites']}
|
||||
self.assertLess(sites['return_cleanup'], sites['return_flag'])
|
||||
self.assertLess(sites['return_flag'], sites['return_preserve_departure'])
|
||||
self.assertLess(sites['return_preserve_departure'], sites['return_stage'])
|
||||
self.assertLess(sites['stage_request'], sites['stage_sound_callback'])
|
||||
|
||||
def test_postload_tail_is_part_of_the_route_contract(self):
|
||||
sites = {s['name']: s for s in self.report['sites']}
|
||||
# The earlier generic-enable/VR-disable prefix is not the final state.
|
||||
self.assertEqual(sites['route_lab_disable1']['actual'][:12], '6a016a016a00')
|
||||
self.assertEqual(sites['route_lab_disable7']['actual'][:12], '6a016a076a00')
|
||||
self.assertEqual(sites['route_vr04_enable3']['actual'][:12], '6a006a036a00')
|
||||
self.assertEqual([t['target'] for t in self.report['select_table']], ['0x428de0']*2)
|
||||
self.assertEqual(self.report['final_action'], 'STOP')
|
||||
self.assertEqual([x['item'] for x in self.report['tutorial_tail']], list(range(8)))
|
||||
self.assertTrue(all(not x['disabled'] and x['target'] == '0x403870' for x in self.report['tutorial_tail']))
|
||||
|
||||
def test_bounded_jetpack_projection_does_not_invent_blanket_reset(self):
|
||||
# Deliberately nondefault sentinels expose accidental conflation of
|
||||
# selected gadget, movement mode, jump state, hold and owned effect timer.
|
||||
state = JetpackCleanupProjection(3, 1, 3, .625, 6.5)
|
||||
self.assertEqual(project_jetpack_cleanup(state), replace(state, selected=-1))
|
||||
self.assertEqual(state.selected, 3)
|
||||
no_selection = replace(state, selected=-1)
|
||||
self.assertEqual(project_jetpack_cleanup(no_selection), no_selection)
|
||||
for other in (0, 1, 2, 4, 5, 6, 7, 99):
|
||||
with self.assertRaises(ValueError):
|
||||
project_jetpack_cleanup(replace(state, selected=other))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Immutable original streamer/descriptor evidence; no original code execution."""
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location('retained_streamer', ROOT / 'tools/binary/retained_streamer.py')
|
||||
streamer = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(streamer)
|
||||
|
||||
|
||||
class RetainedStreamerTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.evidence = streamer.collect(ROOT.parent / 'Original')
|
||||
|
||||
def test_import_export_and_receiver_dispatch(self):
|
||||
r = self.evidence
|
||||
self.assertTrue(r['known_binary'])
|
||||
self.assertTrue(r['import_export_matches'])
|
||||
self.assertEqual(r['extraction_export']['va'], '0x10073e00')
|
||||
self.assertTrue(all(s['matches'] for s in r['sites']), r['sites'])
|
||||
self.assertEqual(len(r['sites']), 20)
|
||||
self.assertEqual(len(r['vtables']), 6)
|
||||
self.assertTrue(all(t['matches'] for t in r['vtables']))
|
||||
self.assertEqual({t['target'] for t in r['vtables'] if t['slot'] == '0x4'}, {'0x473b30'})
|
||||
|
||||
def test_entire_reader_lookup_bodies_and_direct_field_destinations(self):
|
||||
r = self.evidence
|
||||
self.assertEqual(len(r['functions']), 2)
|
||||
self.assertTrue(all(f['matches'] for f in r['functions']))
|
||||
self.assertEqual(len(r['descriptors']), 20)
|
||||
self.assertTrue(all(d['matches'] for d in r['descriptors']), r['descriptors'])
|
||||
fields = {d['name']: int(d['interface_offset'], 16) for d in r['descriptors']}
|
||||
self.assertEqual([fields[n] for n in ('PositionX', 'PositionY', 'PositionZ')], [0xEC, 0xF0, 0xF4])
|
||||
self.assertEqual([fields[n] for n in ('RotationX', 'RotationY', 'RotationZ')], [0xFC, 0x100, 0x104])
|
||||
self.assertEqual(fields['StartPoint'], 0x664)
|
||||
self.assertTrue(set(fields.values()).isdisjoint({0x704, 0x728, 0x1A4, 0x274, 0x288}),
|
||||
'Mode/jump/live body vectors are not these GAM descriptor destinations')
|
||||
|
||||
def test_route_properties_are_exact_registered_subset_without_runtime_fields(self):
|
||||
r = self.evidence
|
||||
self.assertEqual([s['code'] for s in r['route']], ['LV1B', 'VR04', 'LEV1'])
|
||||
self.assertTrue(all(s['exact_descriptor_set'] for s in r['route']))
|
||||
names = sorted(d['name'] for d in r['descriptors'])
|
||||
for scene in r['route']:
|
||||
self.assertEqual(scene['player_properties'], names)
|
||||
self.assertEqual(len(scene['player_properties']), 20)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user