Flips the last remote classification (SetPosition: teleport-advanced and
cell-less) onto 4b-1's RuntimeRemotePlacementDriveController, runs retail's
teleport_hook before the placement, and deletes the legacy remote-teleport
machinery. Contract: docs/research/2026-08-04-c4-route-4b-3-contract.md.
Retail: MoveOrTeleport @0x00516330's branch @0x00516386 -> teleport_hook
@0x005163EF -> SetFlags(0x1012) @0x00516414 -> SetPosition @0x00516420 ->
return 1 @0x00516438. The hook @0x00514ED0 runs BEFORE the placement and
regardless of its outcome. Retail places this branch unconditionally, at any
distance and any contact state (arg4 is read only @0x0051638E, after the
branch) — which is what retires AP-137's cell-less enqueue-vs-place delta.
D1 — the classifier's cell-less input is now the PRE-merge committed cell.
Retail's predicate is `this_1->cell == 0`, the BODY's own cell at
MoveOrTeleport entry (this_1 is assigned from this @0x00516334). acdream fed
the POST-merge canonical.FullCellId, which RefreshSnapshot ->
RefreshDerivedState -> SetFullCell has already stamped with the accepted wire
cell; a zero wire cell fails validation into RejectedData first. The shipped
remote cell-less predicate was therefore dead code, not merely different from
remotePlacementRequired. Threaded via a builder overload; route 1's overload
is untouched. The graphical !IsSpatiallyVisible arm of
projectionRequiresTeleportHook is deleted — a presentation predicate with no
retail analogue that fired the teleport machinery on a routine hot path.
Deleted: RemoteTeleportController (605), RemoteTeleportPlacement (85),
RemoteShadowPlacementSynchronizer (49), their 1,709 lines of tests, the
remotePlacementRequired predicate, the TeleportHookRequired plumbing, the
legacy pre-operation ConstrainTo fallback, and the player arm's legacy
!IsGrounded fallback. Net -2,030 lines.
Structural fix (two independent Opus reviews, round 1 FAIL/FAIL): three of the
four MAJORs were one defect — OnPosition carried two parallel inline copies of
the routing tail (player-guid, NPC-guid) that had drifted. Extracted
RunRemoteArmTail (3 call sites) and ApplyWireAirborneLeftoverBookkeeping (2),
both branches now share one implementation.
A1 ToConstraintArm mapped AirborneSnap -> AirborneNoOperation, so the NPC
arm armed ConstrainTo ZERO times for an out-of-contact wire-grounded
creature — a regression this slice introduced while closing a
structurally identical hole. Now maps to NearInterpolate; switch made
total with a throwing default proven unreachable.
R1 D2's write-nothing shape existed on the player arm only; NPC packets
fell through and wrote the body. Retail makes no player/NPC distinction.
R2 report_collision_end(this,1) @0x00514F31 was bound to
ShadowObjects.Suspend, a port of a DIFFERENT retail function
(remove_shadows_from_cells) that teleport_hook never calls. Now routes
to RuntimeCollisionReportingState.LeaveWorld, which wraps the private
ForceEnd in an admission-blocking transaction so a DoCollisionEnd
callback cannot recreate the contact table.
R3/A2 A teleported NPC synthesized ServerVelocity from the teleport distance
(~1,000+ m/s) and planned a run cycle from it. Both the install and
RemoteServerControlledVelocityCycle.Apply now gate on !isTeleportRoute.
BISECT HAZARD — A1's fix is correct only BECAUSE R1 landed. AirborneSnap is
reachable wire-airborne on the NPC arm only while D2's shape is missing there.
Reverting R1 alone silently inverts A1 into the opposite divergence: arming
where retail returns 0. Revert both or neither.
Also in the velocity hunk: the NPC block's two !IsPlayerGuid(update.Guid)
guards were dropped when it was wrapped in `if (!isTeleportRoute)`. Safe — all
five exit paths of the enclosing IsPlayerGuid block return, so the predicate is
unconditionally false below it — but it was unremarked by both reviews.
Register: AP-137 REWRITTEN (not deleted) to the surviving acdream-only
divergences — null classification during the login window and Rejected*
through UnroutedCatchUp keep a row. AD-42's RemoteTeleportController citation
retired; AP-136/AP-138 writer lists corrected to the two surviving non-Position
rebucket writers; AP-138 gains the teleport arm as a second producer of the
visible-without-collision residual (retirement path remains #309). AP-135 is
untouched and its two airborne bookkeeping writes are preserved on both arms.
AP-131 does not retire; #276 does not close.
Proof obligation 1: ParkCollisionResidents' overlap throw stays unreachable —
the teleport arm adds packets to the same TryBeginExclusiveAuthoredPlacement
one-operation-per-key machinery the far arm uses, opens no new operation shape,
and every DeferredCell outcome cancels synchronously with
restoreCancelledPark: true. The guarded property remains
HasOldPrefixPlacementDebt's stall, not a throw (4b-1's B2 caveat stands).
Correction to an earlier claim: LiveEntityPresentationController's
_activePlacementOwners was NOT write-never at HEAD —
remotePlacementRequired -> BeginPlacement -> Begin -> BeginAuthoritativePlacement
was a live writer chain. It becomes write-never BECAUSE this slice deletes that
chain, which is why deleting the dead half is behaviour-preserving.
Probe: ACDREAM_PROBE_REMOTE_TELEPORT=1 emits one [remote-teleport] line per
routed arm (guid, cause, hook-ran, placement status). TEMPORARY, strip with the
probe family.
Carried, disclosed not fixed: no dedicated bidirectional collision-partner test
for R2 (the wiring, not LeaveWorld itself, is what lacks coverage); the
stress test's teleport step drives hand-written field assignments rather than
the canonical arm; the per-packet runTeleportHook closure allocation (network
path, not the resolve path Slice I's 0 B discipline governs — file before
route 5 adds a fourth call site). B2: IRuntimeCollisionReportObserver has zero
production implementations, so retail's bidirectional DoCollisionEnd half still
reaches no gameplay consumer — this fix closes the wrong-function binding, not
that nobody listens.
Complete Release suite MEASURED at 11,013 passed / 4 skipped / 0 failed
(baseline 11,027/4/0; net -14 = ~33 deleted test cases against ~19 added).
Neither known flake fired (#302 PortalProjectionTests GC-allocation, #308
NakEmissionTests wall-clock).
STILL OWED: the two-client connected gate, which MUST use an NPC/creature
teleport target. Both round-1 MAJORs lived on the NPC arm and the velocity
cycle early-returns for 0x50xxxxxx guids, so a player target structurally
cannot observe A1, A2, or R3.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
689 lines
28 KiB
C#
689 lines
28 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Physics;
|
|
using AcDream.Core.Net.Messages;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Runtime;
|
|
using AcDream.Runtime.Entities;
|
|
using AcDream.Runtime.Physics;
|
|
using AcDream.Runtime.Session;
|
|
|
|
namespace AcDream.App.Tests.Physics;
|
|
|
|
/// <summary>
|
|
/// C4 route 4b-2: behavioural acceptance for the remote far snap. Every test
|
|
/// calls the PRODUCTION routing entry point
|
|
/// (<see cref="LiveEntityNetworkUpdateController.ApplyRemoteContactRouting"/>)
|
|
/// against a REAL <see cref="RuntimeRemotePlacementDriveController"/>, a real
|
|
/// canonical <see cref="RuntimeEntityRecord"/>/<see cref="PhysicsBody"/> pair,
|
|
/// and REAL
|
|
/// <see cref="RuntimeAuthoritativePositionRouteClassifier"/> output. Nothing
|
|
/// is re-derived in a test body — that is the #292 gap route 2 left and route
|
|
/// 4a's first attempt repeated.
|
|
///
|
|
/// <para>
|
|
/// The load-bearing discriminator is the <c>worldPos</c> argument: it is
|
|
/// deliberately DIFFERENT from the accepted destination merged onto the
|
|
/// canonical snapshot. The deleted legacy far block wrote
|
|
/// <c>Body.Position = worldPos</c>; the canonical placement writes the
|
|
/// snapshot's destination resolved through Runtime's world frame. Any
|
|
/// regression back to the legacy write therefore fails
|
|
/// <see cref="FarSnap_PlacesTheBodyFromTheCanonicalDestination_NotTheCallersWirePose"/>
|
|
/// on the exact position value.
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|
{
|
|
private static readonly Vector3 Destination = new(12f, 14f, 7f);
|
|
|
|
/// <summary>A wire pose the caller passes but the far arm must ignore —
|
|
/// distinct from <see cref="Destination"/> in every component.</summary>
|
|
private static readonly Vector3 DecoyWirePose = new(-70f, -80f, -90f);
|
|
|
|
[Fact]
|
|
public void FarSnap_PlacesTheBodyFromTheCanonicalDestination_NotTheCallersWirePose()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004001u, Destination);
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
DecoyWirePose,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.FarSnapPlacement,
|
|
routing.Arm);
|
|
Assert.Equal(
|
|
RuntimeRemotePlacementExecutionStatus.Committed,
|
|
routing.Placement);
|
|
Assert.Equal(
|
|
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
body.Position);
|
|
Assert.NotEqual(DecoyWirePose, body.Position);
|
|
// The canonical placement — not the App — committed residency.
|
|
Assert.Equal(RemotePlacementDriveFixture.DestinationCell, record.FullCellId);
|
|
|
|
fixture.DrainPlacementFifo();
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retail's far branch stops the interpolation queue BEFORE placing
|
|
/// (@0x005163CB precedes @0x005163D9). A stale near waypoint surviving the
|
|
/// snap would drag the freshly placed body back on the next per-tick
|
|
/// catch-up.
|
|
/// </summary>
|
|
[Fact]
|
|
public void FarSnap_ClearsTheInterpolationQueue()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004002u, Destination);
|
|
remote.Interp.Enqueue(
|
|
new Vector3(40f, 40f, 7f),
|
|
Quaternion.Identity,
|
|
isMovingTo: false,
|
|
currentBodyPosition: body.Position,
|
|
currentBodyOrientation: body.Orientation);
|
|
Assert.True(remote.Interp.IsActive);
|
|
|
|
_ = LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
DecoyWirePose,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.False(remote.Interp.IsActive);
|
|
fixture.DrainPlacementFifo();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <b>The inverted test (C4 route 4b-2 review).</b> This used to assert
|
|
/// <c>Assert.Equal(before, body.Position)</c> and so PINNED the defect
|
|
/// both reviews found: a refused far snap left the body at its stale pose
|
|
/// with the interpolation queue already cleared, i.e. a frozen remote
|
|
/// that the next 5-10 Hz packet reproduces identically.
|
|
///
|
|
/// <para>
|
|
/// Retail never leaves the object behind. When
|
|
/// <c>CPhysicsObj::SetPositionInternal</c> @0x00515BD0 resolves no cell,
|
|
/// it takes @0x00515C1D and still commits the destination —
|
|
/// <c>store_position</c> @0x00515CE2 — before <c>GotoLostCell</c>
|
|
/// @0x00515CF2. So a refusal advances the body to the accepted
|
|
/// destination, resolved through Runtime's world frame (NOT the caller's
|
|
/// wire pose), while retaining no operation and committing no cell.
|
|
/// </para>
|
|
/// </summary>
|
|
[Fact]
|
|
public void FarSnap_RefusedDestination_StillAdvancesTheBodyToTheAcceptedDestination()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
// Deliberately NOT AllowDestination().
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004003u, Destination);
|
|
Vector3 before = body.Position;
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
DecoyWirePose,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.FarSnapPlacement,
|
|
routing.Arm);
|
|
Assert.Equal(
|
|
RuntimeRemotePlacementExecutionStatus.Refused,
|
|
routing.Placement);
|
|
// store_position: the body TRACKED, and from the canonical
|
|
// destination — not the caller's wire pose, and not its stale pose.
|
|
Assert.Equal(
|
|
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
body.Position);
|
|
Assert.NotEqual(before, body.Position);
|
|
Assert.NotEqual(DecoyWirePose, body.Position);
|
|
// …and it is a store_position, NOT a placement: no cell was
|
|
// committed, nothing was retained.
|
|
Assert.Equal(RemotePlacementDriveFixture.SourceCell, record.FullCellId);
|
|
Assert.True(body.InWorld);
|
|
Assert.True(record.ObjectClock.IsActive);
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The same refusal repeated: a remote genuinely beyond the host's
|
|
/// service window keeps TRACKING every packet rather than freezing until
|
|
/// the window opens. This is the reachable production shape the review
|
|
/// named — a remote that is rendered but still streaming, refused while
|
|
/// genuinely beyond 96 m — and it is why the fallback cannot be a
|
|
/// one-shot.
|
|
/// </summary>
|
|
[Fact]
|
|
public void FarSnap_RepeatedRefusals_KeepTrackingEveryPacket()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x7000400Cu, Destination);
|
|
|
|
foreach (Vector3 step in new[]
|
|
{
|
|
new Vector3(20f, 14f, 7f),
|
|
new Vector3(28f, 14f, 7f),
|
|
new Vector3(36f, 14f, 7f),
|
|
})
|
|
{
|
|
record.Snapshot = record.Snapshot with
|
|
{
|
|
Position = new CreateObject.ServerPosition(
|
|
RemotePlacementDriveFixture.DestinationCell,
|
|
step.X,
|
|
step.Y,
|
|
step.Z,
|
|
1f,
|
|
0f,
|
|
0f,
|
|
0f),
|
|
};
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
DecoyWirePose,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
RuntimeRemotePlacementExecutionStatus.Refused,
|
|
routing.Placement);
|
|
Assert.Equal(
|
|
step + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
body.Position);
|
|
}
|
|
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
// ── The null / Rejected* / cell-less policy ────────────────────────────
|
|
|
|
/// <summary>
|
|
/// The login-window trap. <c>ClassifyRemoteAcceptedPosition</c> returns
|
|
/// null for EVERY remote packet until the local movement controller
|
|
/// exists, because there is no <c>player_distance</c> to derive. Deleting
|
|
/// the legacy block without a replacement would freeze every remote for
|
|
/// that whole window. The stated policy routes it through AP-87's
|
|
/// catch-up, whose 4 m guard PLACES a body that has drifted.
|
|
/// </summary>
|
|
[Fact]
|
|
public void NoClassificationAtAll_StillTracksTheServer()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004004u, Destination);
|
|
var target = new Vector3(60f, 10f, 7f); // 50 m from the body.
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
route: null,
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
|
routing.Arm);
|
|
Assert.Equal(target, body.Position);
|
|
// No canonical placement was attempted for an unclassified packet.
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
}
|
|
|
|
/// <summary>
|
|
/// …and the same policy ENQUEUES when the body is already tracking, which
|
|
/// is what proves it is AP-87's catch-up rather than an unconditional
|
|
/// snap bolted on to make the previous test pass.
|
|
///
|
|
/// <para>
|
|
/// R7 review fix: the earlier version asserted only that the body did not
|
|
/// move, which "snap when <c>bodyToTarget > 4 m</c>, else do nothing"
|
|
/// satisfies just as well as an enqueue — it and its sibling both passed
|
|
/// against that regression. The queue assertion below is what actually
|
|
/// distinguishes "enqueued" from "did nothing".
|
|
/// </para>
|
|
/// </summary>
|
|
[Fact]
|
|
public void NoClassificationAtAll_NearAndTicked_EnqueuesInsteadOfSnapping()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004005u, Destination);
|
|
Vector3 before = body.Position;
|
|
var target = before + new Vector3(0.5f, 0f, 0f);
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
route: null,
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
|
routing.Arm);
|
|
Assert.Equal(before, body.Position);
|
|
Assert.True(remote.Interp.IsActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void RejectedData_TakesTheUnroutedCatchUp_NotTheFarSnap()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004006u, Destination);
|
|
var target = new Vector3(60f, 10f, 7f);
|
|
|
|
RuntimeAuthoritativePositionRoute rejected =
|
|
Classify(hasContact: true, playerDistance: float.NaN);
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.RejectedData,
|
|
rejected.Disposition);
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
rejected,
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
|
routing.Arm);
|
|
Assert.Equal(target, body.Position);
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
}
|
|
|
|
/// <summary>
|
|
/// C4 route 4b-3 (D1/D5): retail's cell-less body takes
|
|
/// <c>this_1->cell == 0</c> @0x00516386 — the SAME teleport branch as a
|
|
/// fresh TELEPORT_TS — never the far/near/leftover arms. The hook runs
|
|
/// (before the placement, per D3) and the body ends at the canonical
|
|
/// RESOLVED destination, not at the caller's separately-supplied
|
|
/// <paramref name="target"/> wire pose (the decoy discriminates the same
|
|
/// way the far-snap test above does).
|
|
/// </summary>
|
|
[Fact]
|
|
public void CellLessRemote_TakesTheTeleportArm_RunsTheHookAndPlacesCanonically()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004007u, Destination);
|
|
var target = new Vector3(60f, 10f, 7f);
|
|
|
|
RuntimeAuthoritativePositionRoute cellLess = Classify(
|
|
hasContact: true,
|
|
playerDistance: 200f,
|
|
committedCellId: 0u);
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.SetPosition,
|
|
cellLess.Disposition);
|
|
|
|
int hookCalls = 0;
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
cellLess,
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () =>
|
|
{
|
|
hookCalls++;
|
|
return true;
|
|
});
|
|
|
|
Assert.Equal(1, hookCalls);
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.TeleportPlacement,
|
|
routing.Arm);
|
|
Assert.Equal(
|
|
RuntimeRemotePlacementExecutionStatus.Committed,
|
|
routing.Placement);
|
|
Assert.Equal(
|
|
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
body.Position);
|
|
Assert.NotEqual(target, body.Position);
|
|
Assert.Equal(RemotePlacementDriveFixture.DestinationCell, record.FullCellId);
|
|
|
|
fixture.DrainPlacementFifo();
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The airborne precedence carve-out still outranks the far snap, not
|
|
/// only the near branch: a remote mid-arc whose packet happens to
|
|
/// classify far must keep the pre-existing authoritative hard-snap rather
|
|
/// than open a canonical placement.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AirborneBody_OutranksTheFarSnap()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x70004008u, Destination);
|
|
// AP-140 (retired 2026-08-04): "mid-arc" is retail's CONTACT_TS-clear
|
|
// (`InterpolationManager::adjust_offset` gates on `transient_state & 1`
|
|
// @0x00555D52), not the client `Airborne` walkability flag. Both are
|
|
// set here so the test states free flight in the terms the gate now
|
|
// reads AND the terms it used to.
|
|
remote.Airborne = true;
|
|
remote.Body.TransientState = TransientStateFlags.Active;
|
|
var target = new Vector3(60f, 10f, 7f);
|
|
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true);
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.AirborneSnap,
|
|
routing.Arm);
|
|
Assert.Equal(target, body.Position);
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
}
|
|
|
|
/// <summary>
|
|
/// C4 route 4b-3, test-plan item 6 / contract D5: the teleport/cell-less
|
|
/// classification is decided BEFORE <c>ApplyRemoteContactRouting</c> ever
|
|
/// reads <c>remote.Body.InContact</c> — retail's <c>MoveOrTeleport</c>
|
|
/// tests <c>this_1->cell == 0 || newer_event(TELEPORT_TS)</c>
|
|
/// @0x00516375-@0x00516386 strictly before the wire-contact branch at
|
|
/// @0x0051638E. A mid-arc body's teleport packet must therefore still
|
|
/// place canonically — the OPPOSITE outcome of
|
|
/// <see cref="AirborneBody_OutranksTheFarSnap"/> above, which proves the
|
|
/// far arm defers to airborne precedence while this proves the teleport
|
|
/// arm does not. Fails against a broken ordering that lets the airborne
|
|
/// carve-out claim the packet first: <paramref name="body"/> would then
|
|
/// sit at the raw <c>target</c> wire pose the airborne branch writes,
|
|
/// never resolved through the canonical destination.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AirborneBody_TeleportOutranksAirborneSnap()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x7000400Cu, Destination);
|
|
// Same mid-arc state as AirborneBody_OutranksTheFarSnap: no wire
|
|
// contact, free flight in both the old and new terms of the gate.
|
|
remote.Airborne = true;
|
|
remote.Body.TransientState = TransientStateFlags.Active;
|
|
var target = new Vector3(60f, 10f, 7f);
|
|
|
|
RuntimeAuthoritativePositionRoute cellLess = Classify(
|
|
hasContact: false,
|
|
playerDistance: 200f,
|
|
committedCellId: 0u);
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.SetPosition,
|
|
cellLess.Disposition);
|
|
|
|
int hookCalls = 0;
|
|
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
cellLess,
|
|
target,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () =>
|
|
{
|
|
hookCalls++;
|
|
return true;
|
|
});
|
|
|
|
Assert.Equal(1, hookCalls);
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.TeleportPlacement,
|
|
routing.Arm);
|
|
Assert.Equal(
|
|
RuntimeRemotePlacementExecutionStatus.Committed,
|
|
routing.Placement);
|
|
Assert.Equal(
|
|
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
body.Position);
|
|
Assert.NotEqual(target, body.Position);
|
|
Assert.Equal(RemotePlacementDriveFixture.DestinationCell, record.FullCellId);
|
|
|
|
fixture.DrainPlacementFifo();
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Per-entity independence across the two arms in the same tick: one
|
|
/// remote's committed placement must not touch another's body or leak
|
|
/// into its ledger.
|
|
/// </summary>
|
|
[Fact]
|
|
public void TwoRemotesInTheSameTick_FarAndNear_DoNotContaminateEachOther()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
fixture.PublishDestinationCollision();
|
|
fixture.AllowDestination();
|
|
(RuntimeEntityRecord farRecord, RemoteMotion farRemote,
|
|
PhysicsBody farBody) = fixture.AddRemote(0x70004009u, Destination);
|
|
(RuntimeEntityRecord nearRecord, RemoteMotion nearRemote,
|
|
PhysicsBody nearBody) = fixture.AddRemote(0x7000400Au, Destination);
|
|
Vector3 nearBefore = nearBody.Position;
|
|
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.FarSnapPlacement,
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
farRecord,
|
|
farRemote,
|
|
Classify(hasContact: true, playerDistance: 200f),
|
|
DecoyWirePose,
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true).Arm);
|
|
Assert.Equal(
|
|
LiveEntityNetworkUpdateController.RemoteContactArm
|
|
.SteadyStateInterpolate,
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
nearRecord,
|
|
nearRemote,
|
|
Classify(hasContact: true, playerDistance: 10f),
|
|
nearBefore + new Vector3(0.5f, 0f, 0f),
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true).Arm);
|
|
|
|
Assert.Equal(
|
|
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
|
farBody.Position);
|
|
Assert.Equal(nearBefore, nearBody.Position);
|
|
|
|
fixture.DrainPlacementFifo();
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
Assert.Equal(0, fixture.RemotePlacementLedger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// R10 review fix: <c>AirborneNoOperation</c> used to fall into
|
|
/// <c>default:</c>, whose comment ASSERTED unreachability that nothing
|
|
/// enforced — so a caller that skipped its own airborne-no-op early
|
|
/// return would have silently enqueued a waypoint on a branch where
|
|
/// retail writes nothing at all (@0x0051636D). The explicit case is what
|
|
/// makes the assertion true.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AirborneNoOperationClassification_IsRejectedByTheRoutingSeam()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, PhysicsBody body) =
|
|
fixture.AddRemote(0x7000400Du, Destination);
|
|
Vector3 before = body.Position;
|
|
|
|
RuntimeAuthoritativePositionRoute airborne =
|
|
Classify(hasContact: false, playerDistance: 200f);
|
|
Assert.Equal(
|
|
RuntimeAuthoritativePositionDisposition.NoPositionOperation,
|
|
airborne.Disposition);
|
|
|
|
Assert.Throws<InvalidOperationException>(() =>
|
|
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
|
fixture.Drive,
|
|
record,
|
|
remote,
|
|
airborne,
|
|
new Vector3(60f, 10f, 7f),
|
|
Quaternion.Identity,
|
|
willBeDrTicked: true,
|
|
runTeleportHook: () => true));
|
|
|
|
Assert.Equal(before, body.Position);
|
|
Assert.False(remote.Interp.IsActive);
|
|
Assert.Equal(0, fixture.LiveOperationCount);
|
|
}
|
|
|
|
// ── The NPC arm's post-routing wire-cell adoption ──────────────────────
|
|
|
|
/// <summary>
|
|
/// After a far snap the canonical placement owns the cell. The NPC arm's
|
|
/// wire-cell write sits AFTER its routing (the player arm's sits before),
|
|
/// and <c>RemoteMotion.CellId</c> writes through to the canonical
|
|
/// <c>FullCellId</c> — so an unguarded write would discard the resolved
|
|
/// cell the placement just committed.
|
|
/// </summary>
|
|
[Fact]
|
|
public void WireCellAdoption_IsSuppressedAfterAFarSnapAndRunsForEveryOtherArm()
|
|
{
|
|
using var fixture = new RemotePlacementDriveFixture();
|
|
(RuntimeEntityRecord record, RemoteMotion remote, _) =
|
|
fixture.AddRemote(0x7000400Bu, Destination);
|
|
uint resolved = remote.CellId;
|
|
Assert.Equal(RemotePlacementDriveFixture.SourceCell, resolved);
|
|
|
|
Assert.False(
|
|
LiveEntityNetworkUpdateController.TryAdoptWireCellAfterRouting(
|
|
remote,
|
|
LiveEntityNetworkUpdateController.RemoteContactArm
|
|
.FarSnapPlacement,
|
|
RemotePlacementDriveFixture.DestinationCell));
|
|
Assert.Equal(resolved, remote.CellId);
|
|
Assert.Equal(resolved, record.FullCellId);
|
|
|
|
foreach (LiveEntityNetworkUpdateController.RemoteContactArm arm in
|
|
new[]
|
|
{
|
|
LiveEntityNetworkUpdateController.RemoteContactArm.AirborneSnap,
|
|
LiveEntityNetworkUpdateController.RemoteContactArm
|
|
.SteadyStateInterpolate,
|
|
LiveEntityNetworkUpdateController.RemoteContactArm
|
|
.UnroutedCatchUp,
|
|
})
|
|
{
|
|
remote.CellId = RemotePlacementDriveFixture.SourceCell;
|
|
Assert.True(
|
|
LiveEntityNetworkUpdateController.TryAdoptWireCellAfterRouting(
|
|
remote,
|
|
arm,
|
|
RemotePlacementDriveFixture.DestinationCell));
|
|
Assert.Equal(
|
|
RemotePlacementDriveFixture.DestinationCell, remote.CellId);
|
|
}
|
|
}
|
|
|
|
private static RuntimeAuthoritativePositionRoute Classify(
|
|
bool hasContact,
|
|
float playerDistance,
|
|
uint committedCellId = RemotePlacementDriveFixture.SourceCell) =>
|
|
RuntimeAuthoritativePositionRouteClassifier.ClassifyAcceptedPosition(
|
|
new RuntimeAcceptedPositionRouteRequest(
|
|
new RuntimeAuthoritativePositionAuthority(
|
|
new RuntimeGenerationToken(7),
|
|
new RuntimeEntityKey(0x70000001u, 3),
|
|
PositionAuthorityVersion: 11UL,
|
|
AcceptedPositionSequence: 20,
|
|
PreviousTeleportSequence: 10,
|
|
AcceptedTeleportSequence: 10,
|
|
PositionTimestampDisposition.Apply),
|
|
RuntimePositionEntityKind.Remote,
|
|
RuntimeAcceptedPositionSource.PositionEvent,
|
|
new CreateObject.ServerPosition(
|
|
RemotePlacementDriveFixture.DestinationCell,
|
|
Destination.X,
|
|
Destination.Y,
|
|
Destination.Z,
|
|
1f,
|
|
0f,
|
|
0f,
|
|
0f),
|
|
PlacementFrame: 0u,
|
|
PositionPackVelocity: Vector3.Zero,
|
|
committedCellId,
|
|
hasContact,
|
|
playerDistance,
|
|
UsePositionFromServer: false,
|
|
HasAnimations: false,
|
|
default));
|
|
}
|