diff --git a/AGENTS.md b/AGENTS.md index b843a4e..ad3b91e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -76,6 +76,15 @@ timing and retained helper cleanup/order; consult current verification receipts. The populated correction passes348 Python+2 HUD, all managed projects and36 GPU checks, plus native Linux Carl/VR04 SDL replays and Windows x64 cross-publish. All539 originals and924ad2f packages are unchanged; no new Windows execution. +Normal continuation: docs/checkpoint/actor-normal-contacts.md adds30 complete +original/C# snapshots,13 interfaces/182 bindings and5 scalar getter fields. +OriginalNormalContacts is standalone; Jimmy ordinary374 bypasses reflection. +Soldier174 and Jimmy204 endpoints are recorded, not fully executed policies. +Next derived response and retained helper cleanup/activation/order; do not wire +new actors or cache pre-callback radius/flags. Use reviewed relocation operands. +352 Python and targeted body/pair/reclip checks pass, with Linux/Windows builds; +539 originals and924ad2f packages stay unchanged. Latest integrated SDL/GPU +evidence is bf876e9; no new live profile or native Windows verification is claimed. 2026-11-06 continuation: the earlier292 original component cases plus50 derived- caller cases and body/visual-sync audit supply no extra reset. Startup diagnostics diff --git a/docs/architecture.md b/docs/architecture.md index f7a2559..3ab9b60 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -12,6 +12,12 @@ separate. Dynamic pair/reclip composition remains a test fixture until real actor callbacks and retained physical order are recovered. See checkpoint/dynamic-reclip.md; no generic live box solver is implied. +`OriginalNormalContacts` exposes inherited370/374/378 through an actor-owned +accessor interface, keeping full-vector/XYZ setters, fresh Y, damping and heading +impulse distinct. It is not a universal Jimmy callback: Jimmy's ordinary374 +override bypasses reflection. Real class bindings and late scalar ownership are +documented in checkpoint/actor-normal-contacts.md; live profile wiring is retained. + `Scooter` is a separate registered C3DJEEP in VR05/LEV1, owning body, wheels, steering/impact/jump clocks and camera state. Selection summons at the companion; strict contact transfers raw control. PlayerSceneBinding runs body, player/input, diff --git a/docs/checkpoint/actor-normal-contacts.md b/docs/checkpoint/actor-normal-contacts.md new file mode 100644 index 0000000..213a7be --- /dev/null +++ b/docs/checkpoint/actor-normal-contacts.md @@ -0,0 +1,210 @@ +# Original normal callbacks and late scalar reads + +2026-11-07. Continues [populated reclip](dynamic-reclip.md). Thirty complete +emitted original/C# fixture snapshots now match exact float32 values and event +order. `OriginalNormalContacts` implements the bounded inherited ceiling/wall/ +reflection callbacks as a standalone component. Live actor admission and the +current body/profile wiring are unchanged. + +## Evidence, layout and class coverage + +Canonical Neutron.exe SHA-256: +`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`. +Retained complete REA instruction Evidence: +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`. +`tools/binary/actor_contact.py` guards17 complete bodies,139 relocation operands, +13 actual VR04 interfaces/182 method bindings and5 scalar getters. Source hashes, +table/file offsets and pointer displacements are local in +`artifacts/actor-contact/native/source.json`. Text offsets below equal VA−400000; +the helper uses actual PE mapping. + +| Callback VA / file offset | Owner / complete span | +|---|---| +|42A660 /2A660|Jimmy374, through42A714.| +|43AA40 /3AA40|Player material policy, through43AFE3.| +|472690 /72690|Inherited370 positive-Y response, through47274A.| +|458890 /58890|Inherited374 reflection gate, through4588CD.| +|472750 /72750|Inherited378 reflection/heading impulse, guarded through472970.| +|409590 /9590|Soldier374 override, through4095EE.| + +Prior REA pseudocode is reused for472690 +(`ev_122849f87121b02fefe6a3a443f75c7f02fee30c59c816b617d30e1f98fc2cff`), +458890 (`ev_2e4ec83ea68f06777162a80ab45793cff068e973dc248556d4a408932d24c85a`) +and43AA40 (`ev_4f2a6aa666451db831efd46f5c587573e22d8072315626b8bc2f844f9c6f0cae`). +The new REA/Ghidra requests for409590 and4098C0 both report unrecognized +procedures. Their complete failures, export and closed-session snapshot are +retained under `artifacts/actor-contact/rea/`; no successful pseudocode is +attributed to them. Existing REA instructions, canonical bytes and new copied-code +execution support the bounded caller findings instead. Earlier unrecognized +42A660/472750 requests were not repeated. + +Jimmy game table4A373C selects374→42A660; soldier4C19C4 selects409590; +Rocketship4B25AC selects43E8D0 and its separate370→43EB70. The other10 serialized +VR04 interfaces use374→458890. All13 bind378→472750. Tables and complete-object +displacements are recorded separately: some interfaces are+C8 rather than+C0. +Class bindings do not establish active physical membership or constructor defaults. + +The sampled offsets are class-specific beyond the shared base. Soldier608 is an +integer state; Jimmy608 is its controller speed float. Player704 movement mode +is separate from physical collision mode178. The composition fixes178 to0; +the direct `jimmy_mode2` fixture changes704, not box-vs-box collision mode. +Snapshot labels do not define a universal actor structure or shared mode enum. + +All13 share these pure live-field getters: + +| Slot → function VA / file offset | Interface-relative field / use | +|---|---| +|1D0→4718F0 /718F0|byte13C, per-body geometry permission.| +|1D8→471910 /71910|byte13D, inherited wall-reflection gate.| +|1E0→471930 /71930|byte137, box response inhibition.| +|248→471AD0 /71AD0|float150, wall damping.| +|260→471B30 /71B30|float15C, live radius.| + +These are source field/read facts. The native fixtures supply explicit accessor +stubs so they can log reads and inject changes; they do not execute these getters +on constructor-created actors. Scene global4F69E5 is a different owner from1D0. +The constructor/property/Init lifetimes of these fields are not established by a +vtable binding alone. + +## Recovered policies and state transitions + +**Jimmy:**42A660 forwards to43AA40 on ordinary selections, including−1 and +jetpack3.43AA65 explicitly accepts a null polygon, using material sentinel−1. +Neither ordinary/null contact nor rejected elapsed<=3 material contact reaches +generic reflection378. Test modes0/1/2 and raw-control NULL preserve velocity, +acceleration, angular state and root; no control query occurs in this handler. +VR04 has no special material IDs, as previously established in +[material contacts](collision-contact-callbacks.md). Actual lab/outside hazard, +FENCE and LADDER success remain separate gates. + +The additional gadget7/active branch zeros globals4F82BC/C0, tests their prior +two-component magnitude **strictly greater than60**, then invokes complete204 +and sets interface1D65.36/48 is equality and issues no204;36/49 does. Our204 is a +record-only endpoint, not the actual429C10 cleanup. This does not change live +grappler behavior or recover every cleanup effect. + +**Inherited ceiling370:**472690 reads velocity, clears strictly positive Y +through2C0, then independently reads acceleration and clears its positive Y +through274. Negative channels survive independently. There is no generic +position, movement-mode, jump or control reset. The adapter distinguishes full +Vec4 writes from the wall callback's XYZ setter. + +**Inherited wall374/378:**458890 first reads1D8; false returns before velocity +normalization.472750 snapshots horizontal velocity, stores its quick magnitude, +normalizes with the retained quotient and reflects using the supplied normal. +It reads velocity again for live Y, then248 damping, then publishes XYZ through +2C4. Damping is not clamped:1.25 reverses the damped horizontal result. + +After publication, the source calls copied OMT `angles` twice: old normalized +horizontal direction, then normalized reflected horizontal direction **before +damping**. It wraps oldHeading−newHeading once at strict±180 and adds angular Y: + +``` +heading delta degrees × old horizontal quick magnitude × float32(0.001) +``` + +The factor is4D5FD8; angles import48D108 is +`?angles@OMedia3DVector@@QAEXAAF0@Z`. The source's raw yaw uses the14-bit circle, +e.g.9870 and14706 for the oblique fixture. `OriginalHeading.Angles` is a signed +consumer view; masking yaw with16383 recovers that raw circle. Its behavior is +unchanged; its comment now makes the distinction explicit. + +Axis velocity(0,7,−40), normal+Z, damping.25 gives velocity(0,7,30) and angular +Y9.20000076 from initial2. Oblique(30,7,−40) gives velocityX22.5000019 and +angularY−3.31300402. Angular response remains independent of damping. A synthetic +second velocity getter returningY99 proves that the second read owns the +published Y; it is an accessor-order test, not observed spontaneous actor mutation. + +**Soldier:**409590 calls generic458890 first. It then checks interface608==10 +and, independently of reflection being enabled, calls complete174 with force500 +and the supplied normal. Complete table4C1E64+174 targets4098C0. That callee +begins by advancing RNG through509A40 twice, then reaches target/action-dependent +branches. Its complete policy is not executed here. The fixture records174 and +optionally changes scalar fields to test the enclosing caller, not to claim +that the real soldier naturally performs those changes. + +## Dynamic composition and late ownership + +Three cases invoke complete original47A5E0 with real Jimmy/generic/soldier normal +callbacks. Four more use the soldier's record-only174 endpoint to change one +dependency after its dynamic callback: + +| Injected change | Original/C# result | +|---|---| +|Box inhibition=true|Contact remains true; root staysZ15, radius reads[10], no static pass or314.| +|Radius10→20|Reclip reads[10,20,20], rootZ55 against wallZ35; cached10 would give45.| +|Scene geometry=false|Static primitive is skipped but retained polygon still gives a second normal callback; rootZ20.| +|Sphere42C=true|Static force flag is visible to reclip; rootZ45, radius reads[10,10,10].| + +Static callbacks can therefore run the full generic/soldier chain again. In +these fixtures, the second reflection gives velocityZ−22.5 and angularY3.80000067. +The final local root still publishes after callbacks. There is no added implicit +context reset or root-changed guard. + +The C# dynamic composition remains test-only. Its static getters are fixed +between primitive passes; the fixture records repeated identical radius reads +before the sole terminal callback. This is not a reusable live getter/reentrant +dispatcher, linked-list mutation policy or proof of real actor registry ordering. + +## Probe correction and implementation boundary + +The initial numeric relocation scan selected bytes4095BE..C1 (`8B C4 68 00`) +spanning `mov eax,esp` and `push500`, misreading them as pointer68C48B. It also +selected other cross-instruction sequences. This corrupted the **private probe +image**, causing a derived-dispatch fault. Those partial runs are invalid source +behavior evidence and are retained as diagnostic failures only. Originals were +never patched. The corrected generator uses37 individually reviewed callback +operands within complete REA instructions:139 total rather than152. A regression +explicitly rejects4095BE and guards the original seven bytes. The final30-case +capture exits0 with all source/probe hashes verified. + +`OriginalNormalContacts` and `IOriginalNormalBody` preserve the recovered getter/ +setter order, XYZ/full-vector distinction, reflection and angular tail. The +standalone component is not substituted into the live Baseball, Jimmy or NPC +profiles. Zero horizontal normalization remains an explicit unsupported source +arithmetic boundary; the component throws rather than silently admitting a new +policy. A disabled reflection gate returns before that boundary. General x87, +arbitrary normals and zero/degenerate cases are not certified by these fixtures. + +`tests/GamePort.ActorContactTests` keeps30 fixed snapshots and can compare the +generated native observations with `--native`; `--dump` plus the Python helper's +`--managed` produces complete exact-float32 differences. Snapshots include roots, +velocity/acceleration/angular XYZW, two modes, marker/tether, derived endpoint +calls/arguments, flags, radius samples, raw angle arguments/results, context +counters/limits and the full emitted accessor event order. Jimmy no-effect paths +and the two derived endpoints are bounded fixture logic, not complete new Player, +grappler or soldier implementations. + +## Next chunk + +Recover the soldier174 policy and helper cleanup/activation/physical order across +LOAD/RETURN; retain special Jimmy material and gadget gates. The next response +adapter must preserve post-callback1E0, live radius/42C and per-node scene-geometry +ownership, and may admit only explicitly supported actor states. Keep lab/outside +capsule and current VR04 static body while those dependencies remain. Final tests, +build identities and runtime limits are recorded in progress.md/compatibility.md +and `artifacts/actor-contact/validation.json`. + +Reproduce after preparing and fully copying the disposable Wine prefix: + +```sh +python3 tools/binary/actor_contact.py ../Original --output artifacts/actor-contact/native +i686-w64-mingw32-gcc -O0 -Wall -Wextra -Wno-unused-function -o artifacts/actor-contact/native/probe.exe artifacts/actor-contact/native/actor_contact_probe.c +python3 tools/recon/reference_capture.py --asset-probe --probe-executable artifacts/actor-contact/native/probe.exe --probe-success ACTOR_CONTACT_COMPLETE --seconds 45 --output artifacts/actor-contact/probe +python3 tools/binary/actor_contact.py ../Original --output artifacts/actor-contact/native --capture artifacts/actor-contact/probe +source scripts/env.sh +dotnet run --project tests/GamePort.ActorContactTests -- --native artifacts/actor-contact/native/observations.json +``` + +Normal response is separate from pair enter/stay/leave notifications and their +game/task effects; those real consumers remain an admission gate too. In +particular, an inhibited position response does not cancel pair membership. + +Verification:352 Python checks,30 native/fixed managed snapshots,5 sphere groups, +11 static groups,20 ordinary-body groups,100 complete body-ownership comparisons +plus6 bounded state cases,28 pair cases,17 prior context cases and14 populated +reclip/12 kernel steps pass. Linux Debug builds with zero warnings/errors; +Windows x64 self-contained cross-publish succeeds. All539 originals and both +924ad2f packaged DLLs/BUILD-INFO remain unchanged. No new SDL/Vulkan or Windows +execution is claimed; the latest integrated render/native SDL evidence belongs +to bf876e9. This unused component does not change live profile wiring. diff --git a/docs/checkpoint/coverage.md b/docs/checkpoint/coverage.md index cf0118b..3ea1c1c 100644 --- a/docs/checkpoint/coverage.md +++ b/docs/checkpoint/coverage.md @@ -1,5 +1,13 @@ # Core architecture coverage map +2026-11-07 normal callbacks: [actor contacts](actor-normal-contacts.md) adds30 +full emitted original/C# snapshots (S/P/M),13 interface/182 method bindings and5 +pure scalar getter fields. Inherited ceiling/reflection/angular response is a +standalone component; Jimmy's ordinary374 override stays separate. Late scalar +reads are tested with explicit injected endpoint changes. Soldier174/Jimmy204 +full policies, retained helper order and live scene binding remain open. No new +port-render/original-game/native Windows runtime coverage is claimed. + 2026-11-07 populated follow-up: [dynamic reclip](dynamic-reclip.md) adds14 full original/C# comparisons and12 kernel-step matches (S/P/M). Real synthetic static walls/ceiling now exercise shared nearest, retries,370/374 order and primitive diff --git a/docs/checkpoint/next-work-plan.md b/docs/checkpoint/next-work-plan.md index c69eb14..9538c0d 100644 --- a/docs/checkpoint/next-work-plan.md +++ b/docs/checkpoint/next-work-plan.md @@ -49,6 +49,13 @@ rounding divergences without admitting new actors. Next prioritize real Jimmy/ VR04 callback mutations and live getter timing, then constructor-only helper cleanup/order across LOAD/RETURN; integrate the bounded response only afterward. +Actor continuation: [normal contacts](actor-normal-contacts.md) now compares30 +complete snapshots and implements inherited ceiling/reflection/heading impulse +outside live wiring. Jimmy ordinary374 is separate; soldier mode10's174 policy +and helper lifetime remain unresolved. Post-callback radius/inhibition/geometry/ +42C reads are explicit contracts, not constructor snapshots. Next close derived +response and retained helper activation/order before a supported response adapter. + ## Objective Establish the original ownership and timing of player state across gameplay, diff --git a/docs/compatibility.md b/docs/compatibility.md index 1bc0906..ae919fd 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,5 +1,19 @@ # Compatibility and validation +2026-11-07 normal-callback checkpoint:30 complete emitted original/C# fixture +snapshots match exact float32 values, raw angle arguments/results and getter +order. The inherited ceiling/reflection/angular component remains outside live +profile wiring. Jimmy no-effect paths and Soldier174/Jimmy204 record-only +endpoints are explicitly bounded; no full derived policy is implied.352 Python +checks and targeted sphere/static/body/ownership/pair/context/reclip checks pass. +Linux Debug build has zero warnings/errors; Windows x64 self-contained cross- +publish succeeds.539 originals and both924ad2f packaged DLLs/BUILD-INFO are +unchanged. No new graphics/native SDL, whole-original or Windows execution is +claimed; integrated runtime evidence remains bf876e9. Invalid partial captures +from the corrected relocation scan are excluded. See +[normal callbacks](checkpoint/actor-normal-contacts.md) and local +artifacts/actor-contact/validation.json for source/capture/build identities. + 2026-11-07 populated-reclip correction:14 complete original/C# observations and12 kernel steps match exact float32 values after source-store arithmetic corrections. Initial node-visit, edge-projection and ray-hit failures are retained. No epsilon diff --git a/docs/decisions.md b/docs/decisions.md index d26af71..34b07b6 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -422,3 +422,13 @@ assets and generated packages stay excluded. Count static node visits before the geometry gate, separately from actual primitive tests. Real actor callbacks/lifetime still gate live integration. See checkpoint/dynamic-reclip.md. +59. **Bind normal response by real class and preserve late scalar reads.** + Jimmy ordinary/null/jetpack374 does not enter inherited reflection378. + The inherited handler samples live Y again, preserves unclamped damping and + has a separate angular-heading tail. Implement that as an isolated component, + confirmed by30 complete original/C# snapshots. Soldier mode10 additionally + invokes complete174 with500; its RNG/action policy remains outside this + boundary. Sample inhibition/radius/42C/scene geometry at their source points, + not once before callbacks. Explicitly reviewed relocation operands replace + the probe's rejected cross-instruction numeric scan. No new live actor is + admitted from these finite fixtures. See checkpoint/actor-normal-contacts.md. diff --git a/docs/progress.md b/docs/progress.md index 7cc649c..30a9586 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -7,6 +7,33 @@ Next-work plan: [recover interactions, then implement verified changes](checkpoi It defines the Carl source/differential gate, the bounded implementation step, movement/contact/animation recovery and the end-to-end platform checkpoint. +## Real normal callback continuation + +[Normal callbacks](checkpoint/actor-normal-contacts.md) adds30 complete original/ +C# fixture comparisons,13 class interfaces/182 bindings and5 pure scalar getter +fields. Jimmy's ordinary/null/jetpack374 does not invoke generic reflection; +the inherited callback has a live gate, fresh Y read, unclamped damping and an +angular-heading tail. Soldier mode10 adds a separate complete174/force500 call. +Its full RNG/action-dependent policy remains open;174 and Jimmy204 are recorded +endpoints, not executed derived policies. The two new REA procedure requests were +unrecognized; retained original REA instructions and byte guards support the work. + +The standalone OriginalNormalContacts component and bounded fixture match30 emitted states, +angle arguments/results and accessor order exactly as float32. Four bounded +injections confirm post-callback inhibition, radius10→20 reclip toZ55, retained +callback with geometry disabled and fresh42C. Live body/profile wiring remains +unchanged. Partial captures from an erroneous cross-instruction relocation scan +are excluded;37 reviewed operands fix it, with a regression guarding4095BE. + +Next recover derived soldier response and helper cleanup/activation/physical +order across LOAD/RETURN, then bind a response adapter only to supported actor +states. Class-specific608/704 state must remain distinct from collision mode178. +Normal callbacks do not replace real enter/stay/leave/game-task effects; those +consumers remain a separate gate.352 Python checks and targeted sphere/static/ +body/ownership/pair/context/reclip regressions pass. Linux Debug build and Windows +x64 cross-publish succeed;539 originals and924ad2f packages are unchanged. No new +graphics/SDL or Windows runtime run; prior integrated evidence remains bf876e9. + ## Populated reclip and source rounding [Populated dynamic reclip](checkpoint/dynamic-reclip.md) extends the copied diff --git a/docs/reverse-engineering.md b/docs/reverse-engineering.md index eddcedf..9bb7102 100644 --- a/docs/reverse-engineering.md +++ b/docs/reverse-engineering.md @@ -5,6 +5,11 @@ offsets, virtual addresses, API symbols or observed behavior. Decompiled output evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL probes and modern runtime checks are recorded separately. +- [Actor normal contacts](checkpoint/actor-normal-contacts.md):30 complete + original/C# emitted snapshots,13 interfaces/182 bindings and5 scalar getters. + Jimmy override versus inherited ceiling/reflection/angular behavior and late + dynamic reclip reads are verified in bounded fixtures. Soldier174/Jimmy204 are + record-only endpoints; full policies/helper lifetime still gate live wiring. - [Populated dynamic reclip](checkpoint/dynamic-reclip.md):14 full observations and12 captured kernel steps. Original instruction stores explain delayed edge projection, ray normalization and hit-coordinate rounding. Shared kernels now diff --git a/docs/tasks.md b/docs/tasks.md index 772e5e5..9280eac 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -94,6 +94,13 @@ Execution order and acceptance criteria: [next work plan](checkpoint/next-work-p float stores; separate pre-gate node visits from primitive tests. See checkpoint/dynamic-reclip.md. Sequential same-actor queries do not establish real physical ordering, callback mutation contracts or helper lifetime. +- [x] Compare30 original normal-callback/composition snapshots and implement the + bounded inherited ceiling/reflection/angular component. Guard13 actual class + interfaces/182 bindings and5 scalar getter fields; preserve post-callback live + reads. See checkpoint/actor-normal-contacts.md. No new live actor admission. +- [ ] Close soldier complete174 RNG/target/action effects and helper cleanup/ + activation/order across LOAD/RETURN before binding the shared response adapter. + Real enter/stay/leave game/task consumers remain separate from normal response. - [x] Expand original lifecycle coverage:96 Carl contact,8 composed input/ controller/skip-prefix,48 task/objective and140 base/STOP cases; recover complete diff --git a/scripts/test.sh b/scripts/test.sh index ed07037..eebc84a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -21,6 +21,7 @@ dotnet run --project tests/GamePort.BodyOwnershipTests dotnet run --project tests/GamePort.PairLifecycleTests dotnet run --project tests/GamePort.DynamicContextTests dotnet run --project tests/GamePort.DynamicReclipTests +dotnet run --project tests/GamePort.ActorContactTests dotnet run --project tests/GamePort.GadgetTests dotnet run --project tests/GamePort.InvisibleTests dotnet run --project tests/GamePort.BubbleMotionTests diff --git a/src/GamePort/Game/OriginalHeading.cs b/src/GamePort/Game/OriginalHeading.cs index d0f8b71..4888b96 100644 --- a/src/GamePort/Game/OriginalHeading.cs +++ b/src/GamePort/Game/OriginalHeading.cs @@ -30,7 +30,10 @@ public static class OriginalHeading return (-angle) & 0x3fff; } - /// Copied OMT2 vector::angles pitch/yaw, in signed14-bit circle units. + /// + /// Signed circle representation used by movement consumers of OMT2 angles. + /// Mask yaw with16383 when matching the DLL's raw14-bit circle output. + /// public static (int Pitch,int Yaw) Angles(Vector3 vector) { var heading=HeadingUnits(vector); diff --git a/src/GamePort/Game/OriginalNormalContacts.cs b/src/GamePort/Game/OriginalNormalContacts.cs new file mode 100644 index 0000000..e1c1b6c --- /dev/null +++ b/src/GamePort/Game/OriginalNormalContacts.cs @@ -0,0 +1,84 @@ +using System.Numerics; + +namespace GamePort.Game; + +/// Actor-owned accessors used by the base370/374/378 callbacks. +public interface IOriginalNormalBody +{ + Vector4 ReadVelocity(); + void WriteVelocity(Vector4 value); + void WriteVelocityXYZ(Vector3 value); + Vector4 ReadAcceleration(); + void WriteAcceleration(Vector4 value); + bool ReflectWalls { get; } + float WallDamping { get; } + void AddAngularVelocity(Vector3 delta); +} + +/// +/// Bounded472690/458890/472750 callbacks, with live accessor order and original +/// heading impulse. Not a Jimmy override or live scene-admission policy. +/// +public static class OriginalNormalContacts +{ + public static void Ceiling(IOriginalNormalBody body) + { + ArgumentNullException.ThrowIfNull(body); + var velocity = body.ReadVelocity(); + if (velocity.Y > 0) body.WriteVelocity(velocity with {Y = 0}); + var acceleration = body.ReadAcceleration(); + if (acceleration.Y > 0) body.WriteAcceleration(acceleration with {Y = 0}); + } + + public static void GenericWall(IOriginalNormalBody body, Vector3 normal, + Func? headingUnits = null) + { + ArgumentNullException.ThrowIfNull(body); + if (!body.ReflectWalls) return; + Reflect(body,normal,headingUnits); + } + + public static void Reflect(IOriginalNormalBody body, Vector3 normal, + Func? headingUnits = null) + { + ArgumentNullException.ThrowIfNull(body); + Finite(normal); + var velocity = body.ReadVelocity(); + var horizontal = new Vector3(velocity.X,0,velocity.Z); + var magnitude = OriginalBodySupport.QuickMagnitude(horizontal); + if (magnitude <= 0) throw new NotSupportedException("Original zero-horizontal normalization is outside the finite contact contract"); + var direction = Normalize(horizontal,velocity.W); + var dot = -((double)direction.Z*normal.Z + (double)direction.X*normal.X + (double)direction.Y*normal.Y); + var reflected = new Vector3((float)(direction.X + 2*dot*normal.X), + (float)(direction.Y + 2*dot*normal.Y),(float)(direction.Z + 2*dot*normal.Z)); + var x = reflected.X*magnitude; + //472834 samples live Y again, after computing the horizontal reflection. + var y = body.ReadVelocity().Y; + var z = reflected.Z*magnitude; + var damping = body.WallDamping; + if (!float.IsFinite(damping)) throw new ArgumentOutOfRangeException(nameof(body)); + body.WriteVelocityXYZ(new((float)(x-(double)damping*x),y,(float)(z-(double)damping*z))); + + headingUnits ??= static vector => OriginalHeading.Angles(new(vector.X,vector.Y,vector.Z)).Yaw & 16383; + var oldHeading = headingUnits(direction)*0.02197265625f; + var outgoing = Normalize(new(x,0,z),0); + var newHeading = headingUnits(outgoing)*0.02197265625f; + double delta = oldHeading-newHeading; + if (delta > 180) delta -= 360; + else if (delta < -180) delta += 360; + body.AddAngularVelocity(new(0,(float)(delta*magnitude*0.001f),0)); + } + + private static Vector4 Normalize(Vector3 vector,float w) + { + var length = OriginalBodySupport.QuickMagnitudeIntermediate(vector); + if (length <= 0) throw new NotSupportedException("Original zero reflected normalization is outside the finite contact contract"); + var reciprocal = 1/length; + return new((float)(vector.X*reciprocal),(float)(vector.Y*reciprocal),(float)(vector.Z*reciprocal),w); + } + private static void Finite(Vector3 vector) + { + if (!float.IsFinite(vector.X) || !float.IsFinite(vector.Y) || !float.IsFinite(vector.Z)) + throw new ArgumentOutOfRangeException(nameof(vector)); + } +} diff --git a/tests/GamePort.ActorContactTests/GamePort.ActorContactTests.csproj b/tests/GamePort.ActorContactTests/GamePort.ActorContactTests.csproj new file mode 100644 index 0000000..6469a8e --- /dev/null +++ b/tests/GamePort.ActorContactTests/GamePort.ActorContactTests.csproj @@ -0,0 +1,13 @@ + + + Exenet10.0 + enableenable + false + + + + + + + + diff --git a/tests/GamePort.ActorContactTests/Program.cs b/tests/GamePort.ActorContactTests/Program.cs new file mode 100644 index 0000000..beb9e1c --- /dev/null +++ b/tests/GamePort.ActorContactTests/Program.cs @@ -0,0 +1,219 @@ +using System.Numerics; +using System.Text.Json; +using GamePort.Game; + +// Original normal callback component over synthetic state/accessors. Derived +// Soldier174 and Jimmy204 are recorded endpoints, not full policy emulation. +var fixture = new Fixture(); +var rows = new List(); +void Direct(string name,bool ceiling = false) => rows.Add(fixture.Direct(name,ceiling)); +void Dynamic(string name) => rows.Add(fixture.Dynamic(name)); +fixture.Reset(0); Direct("jimmy_null"); +fixture.Reset(0); fixture.Selection = 3; Direct("jimmy_jetpack"); +fixture.Reset(0); Direct("jimmy_ordinary_polygon"); +fixture.Reset(0); fixture.Elapsed = 3; Direct("jimmy_elapsed_gate"); +fixture.Reset(0); fixture.MovementMode = 1; Direct("jimmy_mode1"); +fixture.Reset(0); fixture.MovementMode = 2; Direct("jimmy_mode2"); +fixture.Reset(0); Direct("jimmy_uncontrolled"); +fixture.Reset(0); fixture.Selection = 7; Direct("jimmy_gadget7_inactive"); +fixture.Reset(0); fixture.Selection = 7; fixture.Grappling = true; Direct("jimmy_gadget7_equal"); +fixture.Reset(0); fixture.Selection = 7; fixture.Grappling = true; fixture.Tether.Y = 49; Direct("jimmy_gadget7_large"); +fixture.Reset(0); Direct("ceiling_positive",true); +fixture.Reset(0); fixture.Velocity.Y = -7; fixture.Acceleration.Y = -13; Direct("ceiling_negative",true); +fixture.Reset(0); fixture.Acceleration.Y = -13; Direct("ceiling_velocity_only",true); +fixture.Reset(0); fixture.Velocity.Y = -7; Direct("ceiling_acceleration_only",true); +fixture.Reset(1); fixture.Reflection = false; Direct("generic_disabled"); +fixture.Reset(1); Direct("generic_axis"); +fixture.Reset(1); fixture.Damping = 0; Direct("generic_no_damping"); +fixture.Reset(1); fixture.Damping = 1.25f; Direct("generic_excess_damping"); +fixture.Reset(1); fixture.Velocity.X = 30; Direct("generic_oblique"); +fixture.Reset(1); fixture.FreshY = true; Direct("generic_fresh_y"); +fixture.Reset(2); Direct("soldier_mode0"); +fixture.Reset(2); fixture.ActorMode = 10; Direct("soldier_mode10"); +fixture.Reset(2); fixture.ActorMode = 10; fixture.Reflection = false; Direct("soldier_mode10_disabled"); +fixture.Reset(0); Dynamic("dynamic_jimmy"); +fixture.Reset(1); Dynamic("dynamic_generic"); +fixture.Reset(2); fixture.ActorMode = 10; Dynamic("dynamic_soldier"); +fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 1; Dynamic("late_inhibition"); +fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 2; fixture.Wall(); Dynamic("late_radius"); +fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 3; fixture.Wall(true); Dynamic("late_geometry"); +fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 4; fixture.Wall(); Dynamic("late_force"); + +if(args is ["--dump"]) +{ + Console.WriteLine(JsonSerializer.Serialize(new {cases = rows})); + return; +} +var native = args is ["--native", _]; +if(args.Length != 0 && !native) throw new ArgumentException("Use --native or --dump"); +using var expected = JsonDocument.Parse(File.ReadAllText(native ? args[1] : Path.Combine(AppContext.BaseDirectory,"expected.json"))); +var cases = expected.RootElement.GetProperty("cases").EnumerateArray().ToArray(); +if(cases.Length != rows.Count) throw new Exception("Case count differs"); +for(var i = 0; i < rows.Count; i++) Compare(cases[i],rows[i],cases[i].GetProperty("name").GetString()!); +fixture.Reset(1); fixture.Velocity = Vector4.Zero; fixture.Reflection = false; +OriginalNormalContacts.GenericWall(fixture,Vector3.UnitZ); +fixture.Reflection = true; +try +{ + OriginalNormalContacts.GenericWall(fixture,Vector3.UnitZ); + throw new Exception("Undefined original zero-horizontal path was silently admitted"); +} +catch(NotSupportedException) { } +Console.WriteLine($"PASS {rows.Count} original actor-contact snapshots, live getter order and bounded derived endpoints; exact float32."); + +static void Compare(JsonElement expected,JsonElement actual,string path) +{ + if(expected.ValueKind != actual.ValueKind) throw new Exception($"{path}: kind differs"); + if(expected.ValueKind == JsonValueKind.Object) + { + if(expected.EnumerateObject().Count() != actual.EnumerateObject().Count()) throw new Exception($"{path}: field count differs"); + foreach(var p in expected.EnumerateObject()) Compare(p.Value,actual.GetProperty(p.Name),path+"."+p.Name); + } + else if(expected.ValueKind == JsonValueKind.Array) + { + if(expected.GetArrayLength() != actual.GetArrayLength()) throw new Exception($"{path}: array length differs"); + for(var i = 0; i < expected.GetArrayLength(); i++) Compare(expected[i],actual[i],$"{path}[{i}]"); + } + else if(expected.ValueKind == JsonValueKind.Number) + { + if(expected.GetSingle() != actual.GetSingle()) throw new Exception($"{path}: {actual} != original {expected}"); + } + else if(!JsonElement.DeepEquals(expected,actual)) throw new Exception($"{path}: {actual} != original {expected}"); +} + +sealed class Fixture : IOriginalNormalBody +{ + public Vector4 Root,Velocity,Acceleration,Angular; + public Vector2 Tether; + public int Selection,MovementMode,ActorMode,Mutation; + public bool Grappling,Reflection,FreshY,Inhibited,ForceStatic,Geometry; + public float Elapsed,Damping,Radius; + private int profile,knocks,cleanups,marker,velocityGets; + private float knockForce; + private Vector4 knockNormal; + private StaticCollisionContext context = null!; + private readonly List events = []; + private readonly List radii = []; + private readonly List angles = []; + private CameraRayPolygon? wall; + + public void Reset(int kind) + { + profile = kind; Root = new(0,0,15,1); Velocity = new(0,7,-40,0); + Acceleration = new(11,13,17,0); Angular = new(1,2,3,0); + Tether = new(36,48); Selection = -1; MovementMode = ActorMode = Mutation = 0; + Grappling = FreshY = Inhibited = ForceStatic = false; Reflection = Geometry = true; + Elapsed = 4; Damping = .25f; Radius = 10; + knocks = cleanups = marker = velocityGets = 0; knockForce = 0; knockNormal = default; + events.Clear(); radii.Clear(); angles.Clear(); wall = null; + context = new(88,77){Nearest = new(77,88,new(111,222,333))}; + } + public void Wall(bool seedLast = false) + { + wall = new(new(new(-100,-100,35),new(-100,100,35),new(100,100,35)),Vector3.UnitZ); + if(seedLast) context.LastPolygon = wall; + } + public Vector4 ReadVelocity() + { + events.Add("Gv"); velocityGets++; + if(FreshY && velocityGets == 2) Velocity.Y = 99; + return Velocity; + } + public void WriteVelocity(Vector4 value) { events.Add("Sv4"); Velocity = value; } + public void WriteVelocityXYZ(Vector3 value) { events.Add("Sv3"); Velocity = new(value,Velocity.W); } + public Vector4 ReadAcceleration() { events.Add("Ga"); return Acceleration; } + public void WriteAcceleration(Vector4 value) { events.Add("Sa4"); Acceleration = value; } + public bool ReflectWalls { get { events.Add("Gate"); return Reflection; } } + public float WallDamping { get { events.Add("F"); return Damping; } } + public void AddAngularVelocity(Vector3 value) { events.Add("Aw"); Angular += new Vector4(value,0); } + private int Heading(Vector4 vector) + { + var result = OriginalHeading.Angles(new(vector.X,vector.Y,vector.Z)); + var pitch = result.Pitch & 16383; var yaw = result.Yaw & 16383; + angles.Add(new {vector = Values(vector),pitch,yaw}); events.Add("Angles"); + return yaw; + } + private void Knock(Vector3 normal) + { + events.Add("K174"); knocks++; knockForce = 500; knockNormal = new(normal,0); + if(Mutation == 1) Inhibited = true; + if(Mutation == 2) Radius = 20; + if(Mutation == 3) Geometry = false; + if(Mutation == 4) ForceStatic = true; + } + private void WallContact(Vector3 normal) + { + if(profile == 0) + { + // Only tested null/ordinary/elapsed-rejected Player material paths. + // Complete204 is recorded, not the actual grappler cleanup policy. + if(Selection == 7 && Grappling) + { + var length = Math.Sqrt((double)Tether.X*Tether.X+(double)Tether.Y*Tether.Y); + Tether = default; + if(length > 60) { events.Add("C204"); cleanups++; marker = 1; } + } + } + else + { + OriginalNormalContacts.GenericWall(this,normal,Heading); + if(profile == 2 && ActorMode == 10) Knock(normal); + } + } + public JsonElement Direct(string name,bool ceiling) + { + if(ceiling) OriginalNormalContacts.Ceiling(this); else WallContact(Vector3.UnitZ); + return Snapshot(name,-1); + } + private float ReadRadius() { events.Add("Radius"); radii.Add(Radius); return Radius; } + public JsonElement Dynamic(string name) + { + var previous = new Vector3(0,0,50); + var candidate = new Vector3(Root.X,Root.Y,Root.Z); + var radius = ReadRadius(); + context.Nearest = context.Nearest with {FaceDistance = -1,EdgeDistance = radius}; + var box = new DynamicBoxCollider(1,Vector3.Zero,new(-50,-50,-10),new(50,50,10),Matrix4x4.Identity,40); + foreach(var triangle in DynamicSceneCollision.Triangles(box)) + { + var cross = Vector3.Cross(triangle.B-triangle.A,triangle.C-triangle.A); + var normal = cross/OriginalBodySupport.QuickMagnitude(cross); + var response = OriginalSphereResponse.Resolve(new(triangle.A,triangle.C,triangle.B),normal, + previous,candidate,radius,context.Nearest); + if(response.Contact == SphereContact.None) continue; + candidate = response.Position; context.Nearest = response.State; + WallContact(normal); + } + var contact = context.Nearest.FaceDistance != -1 || context.Nearest.EdgeDistance < radius; + if(contact) + { + events.Add("Inhibit"); + if(!Inhibited) + { + var world = new OriginalStaticCollision(wall is {} polygon ? [polygon] : []); + var initialPasses = context.Passes; + var clipped = world.Move(previous,candidate-previous,ReadRadius(),context,edges:false, + lowerEdges:ForceStatic,geometryEnabled:Geometry); + // Fixed primitive getters: recursive source calls read the same + // radius before their sole terminal callback. No actor callback + // occurs between these bounded passes in this composition. + for(var pass = 1; pass < context.Passes-initialPasses; pass++) ReadRadius(); + if(clipped.CallbackPolygon is {} last) + { + if(last.StoredNormal.Y <= -.7f) OriginalNormalContacts.Ceiling(this); + else WallContact(last.StoredNormal); + } + events.Add("Root"); Root = new(clipped.Position,1); + } + } + return Snapshot(name,contact ? 1 : 0); + } + private JsonElement Snapshot(string name,int contact) => JsonSerializer.SerializeToElement(new { + name,contact,root = Values(Root),velocity = Values(Velocity),acceleration = Values(Acceleration), + angular = Values(Angular),movementMode = MovementMode,actorMode = ActorMode,marker, + tether = new[]{Tether.X,Tether.Y},knocks,force = knockForce,knockNormal = Values(knockNormal),cleanups, + radius = Radius,forceStatic = ForceStatic ? 1 : 0,geometry = Geometry ? 1 : 0,inhibited = Inhibited ? 1 : 0, + radii,angles,passes = context.Passes,visits = context.NodeVisits,face = context.Nearest.FaceDistance, + edge = context.Nearest.EdgeDistance,events = string.Join(',',events) + }); + private static float[] Values(Vector4 v) => [v.X,v.Y,v.Z,v.W]; +} diff --git a/tests/GamePort.ActorContactTests/expected.json b/tests/GamePort.ActorContactTests/expected.json new file mode 100644 index 0000000..b8e46b5 --- /dev/null +++ b/tests/GamePort.ActorContactTests/expected.json @@ -0,0 +1,34 @@ +{ + "cases": [ + {"name":"jimmy_null","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_jetpack","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_ordinary_polygon","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_elapsed_gate","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_mode1","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":1,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_mode2","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":2,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_uncontrolled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_gadget7_inactive","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_gadget7_equal","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[0,0],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""}, + {"name":"jimmy_gadget7_large","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":1,"tether":[0,0],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":1,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"C204"}, + {"name":"ceiling_positive","contact":-1,"root":[0,0,15,1],"velocity":[0,0,-40,0],"acceleration":[11,0,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Sv4,Ga,Sa4"}, + {"name":"ceiling_negative","contact":-1,"root":[0,0,15,1],"velocity":[0,-7,-40,0],"acceleration":[11,-13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Ga"}, + {"name":"ceiling_velocity_only","contact":-1,"root":[0,0,15,1],"velocity":[0,0,-40,0],"acceleration":[11,-13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Sv4,Ga"}, + {"name":"ceiling_acceleration_only","contact":-1,"root":[0,0,15,1],"velocity":[0,-7,-40,0],"acceleration":[11,0,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Ga,Sa4"}, + {"name":"generic_disabled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate"}, + {"name":"generic_axis","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"generic_no_damping","contact":-1,"root":[0,0,15,1],"velocity":[0,7,40,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"generic_excess_damping","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-10,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"generic_oblique","contact":-1,"root":[0,0,15,1],"velocity":[22.5000019,7,30,0],"acceleration":[11,13,17,0],"angular":[1,-3.31300402,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0.599998295,0,-0.799997687,0],"pitch":0,"yaw":9870},{"vector":[0.599998295,0,0.799997687,0],"pitch":0,"yaw":14706}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"generic_fresh_y","contact":-1,"root":[0,0,15,1],"velocity":[0,99,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"soldier_mode0","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"}, + {"name":"soldier_mode10","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174"}, + {"name":"soldier_mode10_disabled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,K174"}, + {"name":"dynamic_jimmy","contact":1,"root":[0,0,20,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Inhibit,Radius,Root"}, + {"name":"dynamic_generic","contact":1,"root":[0,0,20,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,Inhibit,Radius,Root"}, + {"name":"dynamic_soldier","contact":1,"root":[0,0,20,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Root"}, + {"name":"late_inhibition","contact":1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":1,"radii":[10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit"}, + {"name":"late_radius","contact":1,"root":[0,0,55,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":20,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,20,20],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":2,"visits":4,"face":15,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"}, + {"name":"late_geometry","contact":1,"root":[0,0,20,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":0,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":1,"visits":2,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"}, + {"name":"late_force","contact":1,"root":[0,0,45,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":1,"geometry":1,"inhibited":0,"radii":[10,10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":2,"visits":4,"face":15,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"} + ] +} diff --git a/tests/test_actor_contact.py b/tests/test_actor_contact.py new file mode 100644 index 0000000..b63b858 --- /dev/null +++ b/tests/test_actor_contact.py @@ -0,0 +1,56 @@ +from pathlib import Path +import json +import sys +import tempfile +import unittest + +ROOT=Path(__file__).resolve().parents[1] +sys.path.insert(0,str(ROOT/'tools/binary')) +from actor_contact import CALLBACK_OPERANDS,CASES,collect,generate +from checkpoint_script_state import find_case,read_va +from pe_inspect import PE + + +class ActorContactTests(unittest.TestCase): + def test_complete_bodies_and_reviewed_relocations(self): + source=collect(ROOT.parent/'Original') + self.assertEqual(len(source['bodies']),17) + self.assertEqual(len(source['probe_operands']),139) + self.assertEqual(len(CALLBACK_OPERANDS),37) + addresses=[p['va'] for p in source['probe_operands']] + self.assertEqual(len(addresses),len(set(addresses))) + self.assertNotIn(0x4095be,addresses) + pe=PE(find_case(ROOT.parent/'Original','Neutron.exe')) + self.assertEqual(read_va(pe,0x4095be,7).hex(),'8bc4680000fa43') + + def test_real_class_overrides_and_pure_scalar_getters(self): + source=collect(ROOT.parent/'Original') + classes={c['kind']:c for c in source['normal_bindings']} + self.assertEqual(len(classes),13) + self.assertTrue(all(len(c['methods'])==14 for c in classes.values())) + self.assertEqual(classes['3JIM']['methods']['0x374'],'0x42a660') + self.assertEqual(classes['3SOL']['methods']['0x374'],'0x409590') + self.assertEqual(classes['3ROC']['methods']['0x374'],'0x43e8d0') + self.assertEqual(classes['3TRO']['methods']['0x374'],'0x458890') + self.assertEqual([g['field'] for g in source['scalar_getters']],['0x13c','0x13d','0x137','0x150','0x15c']) + + def test_generation_rejects_original_and_symlink_outputs(self): + original=ROOT.parent/'Original' + with self.assertRaisesRegex(ValueError,'Separate output'): + generate(original,original/'forbidden-generated-probe') + with tempfile.TemporaryDirectory() as temporary: + output=Path(temporary) + (output/'probe.exe').symlink_to(find_case(original,'Neutron.exe')) + with self.assertRaisesRegex(ValueError,'symlinks'):generate(original,output) + + def test_saved_reference_covers_all_bounded_profiles_and_late_reads(self): + cases=json.loads((ROOT/'tests/GamePort.ActorContactTests/expected.json').read_text())['cases'] + self.assertEqual(tuple(c['name'] for c in cases),CASES) + by_name={c['name']:c for c in cases} + self.assertEqual(by_name['late_radius']['radii'],[10,20,20]) + self.assertEqual(by_name['late_radius']['root'],[0,0,55,1]) + self.assertEqual(by_name['late_inhibition']['radii'],[10]) + self.assertEqual(by_name['soldier_mode10_disabled']['force'],500) + + +if __name__=='__main__':unittest.main() diff --git a/tools/binary/actor_contact.py b/tools/binary/actor_contact.py new file mode 100644 index 0000000..b8c573d --- /dev/null +++ b/tools/binary/actor_contact.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +"""Guard and execute original normal callbacks on bounded synthetic actors.""" +import argparse +import hashlib +import json +from pathlib import Path +import struct +from dynamic_context import collect as dynamic_collect +from collision_response import header +from checkpoint_script_state import find_case,read_va +from pe_inspect import PE +from physical_registration import CLASSES +from dynamic_reclip import differences + +CALLBACKS=(('jimmy_wall',0x42a660,0x42a714),('player_wall',0x43aa40,0x43afe3), + ('base_ceiling',0x472690,0x47274a),('base_wall',0x458890,0x4588cd), + ('reflection',0x472750,0x472970),('soldier_wall',0x409590,0x4095ee)) +# Complete operands reviewed within individual instructions in retained REA +# ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904. +# A numeric scan across instruction boundaries incorrectly selected4095BE. +CALLBACK_OPERANDS=( + (0x42a663,0x4f0588),(0x42a678,0x4f8210),(0x42a69d,0x4f82bc), + (0x42a6a3,0x4f82c0),(0x42a6b1,0x4f82bc),(0x42a6bb,0x4f82c0), + (0x42a6cd,0x49d5b4),(0x43aa52,0x48e5a0),(0x43ab58,0x48d400), + (0x43abd2,0x4f0668),(0x43ac25,0x48d108),(0x43ac3c,0x48e5b4), + (0x43acb9,0x4f0668),(0x43ad05,0x4afd40),(0x43ad9d,0x48e5ec), + (0x43adbd,0x48d400),(0x43ae4c,0x48e5ec),(0x43ae6c,0x48d400), + (0x43af16,0x48d108),(0x43af30,0x48e5b4),(0x43afd1,0x4f0670), + (0x4726ac,0x48d914),(0x472703,0x48d914),(0x47278f,0x48d104), + (0x47279d,0x48d104),(0x4727a3,0x48d924),(0x472882,0x48d108), + (0x4728b1,0x48e5b4),(0x4728bb,0x48d104),(0x4728c1,0x48d924), + (0x472900,0x48e5b4),(0x47290a,0x48d914),(0x472917,0x48e5b0), + (0x472924,0x48e5c4),(0x47292c,0x48e5c0),(0x472939,0x48e5c4), + (0x47294a,0x4d5fd8)) +GETTERS=((0x1d0,0x4718f0,'8a813c010000c3',0x13c), + (0x1d8,0x471910,'8a813d010000c3',0x13d), + (0x1e0,0x471930,'8a8137010000c3',0x137), + (0x248,0x471ad0,'d98150010000c3',0x150), + (0x260,0x471b30,'d9815c010000c3',0x15c)) +SLOTS=(0x370,0x374,0x378,0x1d0,0x1d8,0x1e0,0x248,0x260,0x270,0x274,0x2b8,0x2bc,0x2c0,0x2c4) +CASES=('jimmy_null','jimmy_jetpack','jimmy_ordinary_polygon','jimmy_elapsed_gate', + 'jimmy_mode1','jimmy_mode2','jimmy_uncontrolled','jimmy_gadget7_inactive', + 'jimmy_gadget7_equal','jimmy_gadget7_large','ceiling_positive','ceiling_negative', + 'ceiling_velocity_only','ceiling_acceleration_only','generic_disabled','generic_axis', + 'generic_no_damping','generic_excess_damping','generic_oblique','generic_fresh_y', + 'soldier_mode0','soldier_mode10','soldier_mode10_disabled','dynamic_jimmy', + 'dynamic_generic','dynamic_soldier','late_inhibition','late_radius','late_geometry','late_force') + + +def collect(original): + report=dynamic_collect(original);pe=PE(find_case(Path(original),'Neutron.exe')) + for name,start,end in CALLBACKS: + code=read_va(pe,start,end-start) + report['bodies'].append(dict(name=name,va=hex(start),file_offset=hex(pe.offset(start-pe.base)), + length=end-start,sha256=hashlib.sha256(code).hexdigest())) + for va,target in CALLBACK_OPERANDS: + if read_va(pe,va,4)!=struct.pack('0&&event_length+(unsigned)n