feat(physics): C4 route 4b-3 — remote teleport + cell-less through the canonical placement
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>
This commit is contained in:
parent
3e002993dd
commit
6dc7ba51ee
53 changed files with 2980 additions and 3372 deletions
|
|
@ -311,9 +311,7 @@ src/
|
|||
RemotePhysicsUpdater.cs -> ordinary/Hidden remote narrow-tick integration
|
||||
LiveEntityOrdinaryPhysicsUpdater.cs -> manager-less body Transition commits
|
||||
RemoteInboundMotionDispatcher.cs -> animation-optional retail UM funnel
|
||||
RemoteTeleportController.cs -> incarnation-scoped loaded/pending placement owner
|
||||
RemoteTeleportHook.cs -> ordered retail teleport teardown seam
|
||||
RemoteTeleportPlacement.cs -> collision-seated SetPosition transition commit
|
||||
RemoteTeleportHook.cs -> ordered retail teleport teardown seam (teleport_hook port; C4 route 4b-3 runs it from LiveEntityNetworkUpdateController's teleport arm dispatch, through RuntimeRemotePlacementDriveController)
|
||||
World/
|
||||
LiveEntityRuntime.cs -> exact-key App projection/lifecycle host
|
||||
LiveEntityProjectionStore.cs -> materialized sidecars by RuntimeEntityKey
|
||||
|
|
@ -466,30 +464,26 @@ What exists and is active:
|
|||
and every routed hook. A delete/local-ID reuse during capture or during an
|
||||
earlier hook can never advance the displaced sequencer or send the old
|
||||
owner's remaining sound, particle, or light hooks to its replacement.
|
||||
- `RemoteTeleportController` owns the placement half of a fresh remote
|
||||
teleport after `RemoteTeleportHook` has torn down movement/target state. It
|
||||
collision-seats loaded destinations through `RemoteTeleportPlacement`; an
|
||||
unloaded destination retains one generation- and PositionSequence-scoped
|
||||
pending placement and resolves the latest accepted frame when that same
|
||||
projection becomes visible. It neither owns GUID identity nor reconstructs
|
||||
an entity. A placement failure after hydration restores the captured source
|
||||
frame/cell/contact rather than leaving a visible collisionless projection;
|
||||
source-resident shadows restore immediately, while an unloaded source
|
||||
delegates one incarnation-scoped restore to
|
||||
`LiveEntityPresentationController`, shared with Hidden/UnHide. A newer
|
||||
placement transfers that marker into an explicit active-placement generation
|
||||
before rebucketing even while Hidden. That generation suppresses every
|
||||
intervening Hidden/UnHide and projection restore until the controller reaches
|
||||
a stable result, then it either restores after collision seating, re-defers
|
||||
its rollback source, or hands a Hidden result back for UnHide. The typed
|
||||
`ILiveEntityRemotePlacementRuntime` seam permits a same-incarnation wrapper
|
||||
rebind only around the canonical body; pending placement adopts that wrapper
|
||||
before hydration and cannot silently lose ownership. Clearing a motion or
|
||||
projectile component retains the incarnation's body/contract identity until
|
||||
logical teardown. The production wrapper exposes an immutable body, while
|
||||
hydration defensively validates arbitrary implementations against the record
|
||||
and rolls the retained body back on mismatch. Runtime binding snapshots the
|
||||
interface Body getter once for validation, assignment, and state mutation.
|
||||
- **C4 route 4b-3 (2026-08-04) deleted `RemoteTeleportController` /
|
||||
`RemoteTeleportPlacement` / `RemoteShadowPlacementSynchronizer` outright** —
|
||||
605 + 85 + 49 lines of App-layer incarnation-scoped placement machinery,
|
||||
replaced by routing the remote teleport/cell-less classification through
|
||||
the SAME canonical `RuntimeRemotePlacementDriveController` the far snap
|
||||
(C4 route 4b-2) already uses (`ApplyAcceptedRemoteTeleport`, sharing
|
||||
`StoresAcceptedDestination`/`StoreAcceptedDestinationPose`). `teleport_hook`
|
||||
(@0x00514ED0) still runs first, via `RemoteTeleportHook` invoked from
|
||||
`LiveEntityNetworkUpdateController`'s teleport-arm dispatch (both the
|
||||
player-guid and NPC-guid branches share one `RunRemoteArmTail` helper for
|
||||
the routing-decision/currency/constraint-arm sequence — see the C4 4b-3
|
||||
fix round, 2026-08-04, for why the two branches were unified there after
|
||||
independently drifting). There is no separate "loaded vs pending
|
||||
destination" placement path anymore: an unresolved destination collision
|
||||
generation retains a preparation-stage retry inside the SAME drive
|
||||
controller that far snap already retries through, not a second incarnation-
|
||||
scoped machine, and `_activePlacementOwners`'s Hidden/UnHide visibility-edge
|
||||
protection is gone with its only writer chain — the synchronous, single-
|
||||
frame teleport commit removes the multi-frame window that protection
|
||||
existed for.
|
||||
`GpuWorldState`
|
||||
rebuckets atomically and commits spatial visibility before draining its
|
||||
transition FIFO; `LiveEntityRuntime` rejects delayed duplicate edges. A
|
||||
|
|
|
|||
|
|
@ -262,9 +262,7 @@ src/AcDream.App/
|
|||
│ ├── DeferredLiveEntityMotionRuntimeBindings.cs # fail-fast construction-order bridge
|
||||
│ ├── LiveEntityShadowPublisher.cs # authoritative exact-owner/residency collision gate
|
||||
│ ├── RemoteInboundMotionDispatcher.cs # shared animated/headless UpdateMotion funnel
|
||||
│ ├── RemoteTeleportController.cs # loaded/pending teleport placement ownership
|
||||
│ ├── RemoteTeleportHook.cs # ordered retail teleport teardown actions
|
||||
│ └── RemoteTeleportPlacement.cs # collision-seated SetPosition transition commit
|
||||
│ └── RemoteTeleportHook.cs # ordered retail teleport teardown actions (teleport_hook port; C4 4b-3 deleted RemoteTeleportController/RemoteTeleportPlacement/RemoteShadowPlacementSynchronizer — the teleport arm now routes through RuntimeRemotePlacementDriveController, the same canonical placement owner the far snap uses)
|
||||
├── World/
|
||||
│ ├── InboundPhysicsStateController.cs # timestamps + accepted spawn snapshots
|
||||
│ ├── LiveEntityRuntime.cs # shipped: logical lifetime + ServerGuid↔entity.Id translation
|
||||
|
|
@ -417,28 +415,19 @@ radar/status targeting, effects, and audio remain closed until reveal. This
|
|||
distinction is part of the Slice E connected gate, not an alternate live-entity
|
||||
lifetime.
|
||||
|
||||
Remote teleport placement is bounded in `Physics/RemoteTeleportController`,
|
||||
not `GameWindow`: it retains at most one pending request per materialized
|
||||
incarnation, scopes it by the live generation and accepted PositionSequence,
|
||||
and asks `RemoteTeleportPlacement` to collision-seat the current body when the
|
||||
destination projection is available. `GameWindow` supplies lifecycle and
|
||||
shadow-sync callbacks only; canonical identity remains in
|
||||
`RuntimeEntityDirectory`, and App placement retains the exact projection key.
|
||||
Failed hydration restores the captured source and delegates an
|
||||
incarnation-scoped shadow restore to `LiveEntityPresentationController` while
|
||||
that source is unloaded, so Hidden/UnHide and teleport never become competing
|
||||
restore owners. A newer placement transfers that restore into an explicit
|
||||
generation-scoped active-placement state before its rebucket visibility edge
|
||||
even while Hidden. All intervening Hidden/UnHide and projection edges defer to
|
||||
that owner until stable success or rollback completes; only then can it restore,
|
||||
re-defer the source, or hand a Hidden result back for UnHide. The
|
||||
`ILiveEntityRemotePlacementRuntime` seam keeps the complete cell/contact
|
||||
handoff available across same-body runtime-wrapper replacement; replacing the
|
||||
canonical body or dropping the placement contract within one incarnation is
|
||||
rejected even after an operational component clear. `RemoteMotion.Body` is
|
||||
constructor-owned; hydration compares pending/current wrappers directly to the
|
||||
record body rather than trusting wrapper-to-wrapper equality. Binding reads an
|
||||
interface Body getter once and reuses that snapshot. `GpuWorldState`
|
||||
**C4 route 4b-3 (2026-08-04) deleted `Physics/RemoteTeleportController` and
|
||||
`RemoteTeleportPlacement` outright** (605 + 85 lines, plus
|
||||
`RemoteShadowPlacementSynchronizer`, 49 lines). Remote teleport placement is
|
||||
no longer a separate App-layer incarnation-scoped machine — it is the SAME
|
||||
canonical `RuntimeRemotePlacementDriveController` route 4b-2's far snap
|
||||
already uses, dispatched via `ApplyAcceptedRemoteTeleport`, which shares
|
||||
`StoresAcceptedDestination`/`StoreAcceptedDestinationPose` unchanged.
|
||||
`teleport_hook` (@0x00514ED0) still runs first — `RemoteTeleportHook`,
|
||||
invoked from `LiveEntityNetworkUpdateController`'s teleport-arm dispatch —
|
||||
and its `report_collision_end(this, 1)` action now routes through
|
||||
`RuntimeCollisionReportingState.LeaveWorld` (the existing, exact port of
|
||||
that retail call) rather than `ShadowObjectRegistry.Suspend`, which ports a
|
||||
DIFFERENT retail function `teleport_hook` never calls. `GpuWorldState`
|
||||
performs remove+place as one spatial rebucket,
|
||||
then commits and serially drains visibility edges; `LiveEntityRuntime` filters
|
||||
delayed duplicates. A rollback inside an observer cannot race the outer
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -105,7 +105,6 @@ internal sealed record LivePresentationResult(
|
|||
EquippedChildRenderController EquippedChildren,
|
||||
EntityEffectController EntityEffects,
|
||||
LiveEntityPresentationController Presentation,
|
||||
RemoteTeleportController RemoteTeleport,
|
||||
WbDrawDispatcher? DrawDispatcher,
|
||||
RetailSelectionScene SelectionScene,
|
||||
WorldSelectionQuery SelectionQuery,
|
||||
|
|
@ -634,26 +633,6 @@ internal sealed class LivePresentationCompositionPhase
|
|||
d.EntityObjects.Objects,
|
||||
liveEntities,
|
||||
d.PhysicsEngine.ShadowObjects));
|
||||
var remoteShadowPlacement = new RemoteShadowPlacementSynchronizer(
|
||||
d.RemotePhysicsUpdater,
|
||||
d.WorldOrigin);
|
||||
var remoteTeleportPresentation =
|
||||
new RemoteTeleportPlacementPresentation(presentationLease.Resource);
|
||||
var remoteTeleportLease = scope.Acquire(
|
||||
"remote teleport",
|
||||
() => new RemoteTeleportController(
|
||||
d.PhysicsEngine,
|
||||
liveEntities,
|
||||
d.MotionBindings.GetSetupCylinder,
|
||||
d.WorldOrigin.CellLocalForSeed,
|
||||
remoteShadowPlacement.Sync,
|
||||
remoteTeleportPresentation.Complete,
|
||||
remoteTeleportPresentation.Begin,
|
||||
getMoverPvpState: guid =>
|
||||
EntityCollisionFlagsExt.ResolveMoverPvpState(
|
||||
d.EntityObjects.Objects,
|
||||
guid)),
|
||||
static value => value.Dispose());
|
||||
bindings.BindProjectionPoseReady(
|
||||
equippedLease.Resource,
|
||||
lightsLease.Resource.OnAttachedPoseReady);
|
||||
|
|
@ -697,7 +676,6 @@ internal sealed class LivePresentationCompositionPhase
|
|||
equippedLease,
|
||||
entityEffects,
|
||||
presentationLease,
|
||||
remoteTeleportLease,
|
||||
selectionInteractionSource,
|
||||
bindings,
|
||||
scope,
|
||||
|
|
@ -747,7 +725,6 @@ internal sealed class LivePresentationCompositionPhase
|
|||
CompositionAcquisitionScope.CompositionAcquisitionLease<EquippedChildRenderController> equippedLease,
|
||||
EntityEffectController entityEffects,
|
||||
CompositionAcquisitionScope.CompositionAcquisitionLease<LiveEntityPresentationController> presentationLease,
|
||||
CompositionAcquisitionScope.CompositionAcquisitionLease<RemoteTeleportController> remoteTeleportLease,
|
||||
DeferredSelectionInteractionSource selectionInteractionSource,
|
||||
LivePresentationRuntimeBindings bindings,
|
||||
CompositionAcquisitionScope scope,
|
||||
|
|
@ -1227,7 +1204,6 @@ internal sealed class LivePresentationCompositionPhase
|
|||
equippedLease.Resource,
|
||||
entityEffects,
|
||||
presentationLease.Resource,
|
||||
remoteTeleportLease.Resource,
|
||||
dispatcherLease.Resource,
|
||||
selectionScene,
|
||||
selectionQuery,
|
||||
|
|
@ -1267,7 +1243,6 @@ internal sealed class LivePresentationCompositionPhase
|
|||
lightsLease.Transfer();
|
||||
equippedLease.Transfer();
|
||||
presentationLease.Transfer();
|
||||
remoteTeleportLease.Transfer();
|
||||
dispatcherLease.Transfer();
|
||||
retainedGameplayLease?.Transfer();
|
||||
paperdollLease?.Transfer();
|
||||
|
|
|
|||
|
|
@ -480,7 +480,6 @@ internal sealed class SessionPlayerCompositionPhase
|
|||
live.LiveEntities,
|
||||
live.Presentation,
|
||||
live.EntityEffects,
|
||||
live.RemoteTeleport,
|
||||
live.SelectionInteractions,
|
||||
d.Actions.Selection,
|
||||
d.AnimatedEntities,
|
||||
|
|
@ -645,7 +644,6 @@ internal sealed class SessionPlayerCompositionPhase
|
|||
live.Lights,
|
||||
live.EquippedChildren,
|
||||
live.ProjectileController,
|
||||
live.RemoteTeleport,
|
||||
d.AnimatedEntities,
|
||||
d.RemoteMovementObservations,
|
||||
d.RemotePhysicsUpdater,
|
||||
|
|
@ -981,7 +979,6 @@ internal sealed class SessionPlayerCompositionPhase
|
|||
liveness,
|
||||
networkUpdates,
|
||||
hydration,
|
||||
live.RemoteTeleport,
|
||||
live.EntityEffects,
|
||||
content.AnimationHookFrames,
|
||||
live.Presentation,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ internal sealed class LiveSessionResetBindings
|
|||
public required Action<RuntimeGenerationToken> RuntimeGeneration { get; init; }
|
||||
public required Action<RuntimeGenerationToken> SessionIdentityPresentation
|
||||
{ get; init; }
|
||||
public required Action RemoteTeleport { get; init; }
|
||||
public required Action NetworkEffects { get; init; }
|
||||
public required Action AnimationHookFrames { get; init; }
|
||||
public required Action LivePresentation { get; init; }
|
||||
|
|
@ -65,7 +64,6 @@ internal static class LiveSessionResetManifest
|
|||
new(
|
||||
"session identity presentation",
|
||||
bindings.SessionIdentityPresentation),
|
||||
new("remote teleport", bindings.RemoteTeleport),
|
||||
// F754/F755 can precede CreateObject, so pending network effects
|
||||
// must clear even when no LiveEntityRecord was constructed.
|
||||
new("network effects", bindings.NetworkEffects),
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ internal sealed record LiveSessionWorldRuntime(
|
|||
LiveEntityLivenessController Liveness,
|
||||
LiveEntityNetworkUpdateController NetworkUpdates,
|
||||
LiveEntityHydrationController Hydration,
|
||||
RemoteTeleportController RemoteTeleport,
|
||||
EntityEffectController EntityEffects,
|
||||
AnimationHookFrameQueue AnimationHookFrames,
|
||||
LiveEntityPresentationController Presentation,
|
||||
|
|
@ -193,7 +192,6 @@ internal sealed class LiveSessionRuntimeFactory
|
|||
RuntimeGeneration = generation =>
|
||||
_domain.Runtime.ResetGeneration(generation, resetHost),
|
||||
SessionIdentityPresentation = ResetIdentityPresentation,
|
||||
RemoteTeleport = _world.RemoteTeleport.Clear,
|
||||
NetworkEffects = _world.EntityEffects.ClearNetworkState,
|
||||
AnimationHookFrames = _world.AnimationHookFrames.Clear,
|
||||
LivePresentation = _world.Presentation.Clear,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,49 +0,0 @@
|
|||
using AcDream.App.World;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Core.World;
|
||||
|
||||
namespace AcDream.App.Physics;
|
||||
|
||||
/// <summary>Synchronizes a resolved remote placement in the current live origin.</summary>
|
||||
internal sealed class RemoteShadowPlacementSynchronizer
|
||||
{
|
||||
private readonly RemotePhysicsUpdater _remotePhysics;
|
||||
private readonly LiveWorldOriginState _origin;
|
||||
|
||||
public RemoteShadowPlacementSynchronizer(
|
||||
RemotePhysicsUpdater remotePhysics,
|
||||
LiveWorldOriginState origin)
|
||||
{
|
||||
_remotePhysics = remotePhysics
|
||||
?? throw new ArgumentNullException(nameof(remotePhysics));
|
||||
_origin = origin ?? throw new ArgumentNullException(nameof(origin));
|
||||
}
|
||||
|
||||
public void Sync(WorldEntity entity, PhysicsBody body, uint cellId) =>
|
||||
_remotePhysics.SyncRemoteShadowToBody(
|
||||
entity.Id,
|
||||
body,
|
||||
_origin.CenterX,
|
||||
_origin.CenterY,
|
||||
cellId);
|
||||
}
|
||||
|
||||
/// <summary>Bridges remote placement ownership to live presentation state.</summary>
|
||||
internal sealed class RemoteTeleportPlacementPresentation
|
||||
{
|
||||
private readonly LiveEntityPresentationController _presentation;
|
||||
|
||||
public RemoteTeleportPlacementPresentation(
|
||||
LiveEntityPresentationController presentation) =>
|
||||
_presentation = presentation
|
||||
?? throw new ArgumentNullException(nameof(presentation));
|
||||
|
||||
public void Complete(uint serverGuid, ushort generation, bool deferShadowRestore) =>
|
||||
_presentation.CompleteAuthoritativePlacement(
|
||||
serverGuid,
|
||||
generation,
|
||||
deferShadowRestore);
|
||||
|
||||
public void Begin(uint serverGuid, ushort generation) =>
|
||||
_presentation.BeginAuthoritativePlacement(serverGuid, generation);
|
||||
}
|
||||
|
|
@ -1,605 +0,0 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.World;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Core.World;
|
||||
using AcDream.Runtime.Entities;
|
||||
|
||||
namespace AcDream.App.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Owns the SetPosition half of retail remote
|
||||
/// <c>CPhysicsObj::MoveOrTeleport</c> (0x00516330). It resolves the
|
||||
/// destination through the placement transition, commits that transition to
|
||||
/// the existing body, and synchronizes the remote movement/contact state.
|
||||
/// Logical identity, target-hook actions, rebucketing callbacks, and render
|
||||
/// presentation remain with their existing owners.
|
||||
/// </summary>
|
||||
internal sealed class RemoteTeleportController : IDisposable
|
||||
{
|
||||
internal delegate ResolveResult PlacementResolver(
|
||||
Vector3 position,
|
||||
uint cellId,
|
||||
float radius,
|
||||
float height,
|
||||
ObjectInfoState moverFlags,
|
||||
uint movingEntityId);
|
||||
|
||||
private readonly PhysicsEngine _physics;
|
||||
private readonly LiveEntityRuntime _liveEntities;
|
||||
private readonly Func<uint, WorldEntity, (float Radius, float Height)> _getSetupCylinder;
|
||||
private readonly Func<Vector3, uint, Vector3> _cellLocalForSeed;
|
||||
private readonly Action<WorldEntity, PhysicsBody, uint> _syncResolvedShadow;
|
||||
private readonly Action<uint, ushort, bool> _completeAuthoritativePlacement;
|
||||
private readonly Action<uint, ushort> _beginAuthoritativePlacement;
|
||||
private readonly PlacementResolver _resolvePlacement;
|
||||
private readonly Func<uint, ObjectInfoState> _getMoverPvpState;
|
||||
private readonly Dictionary<RuntimeEntityKey, PendingPlacement> _pending = new();
|
||||
|
||||
internal RemoteTeleportController(
|
||||
PhysicsEngine physics,
|
||||
LiveEntityRuntime liveEntities,
|
||||
Func<uint, WorldEntity, (float Radius, float Height)> getSetupCylinder,
|
||||
Func<Vector3, uint, Vector3> cellLocalForSeed,
|
||||
Action<WorldEntity, PhysicsBody, uint> syncResolvedShadow,
|
||||
Action<uint, ushort, bool> completeAuthoritativePlacement,
|
||||
Action<uint, ushort> beginAuthoritativePlacement,
|
||||
PlacementResolver? resolvePlacement = null,
|
||||
// TS-23 (Campaign P Slice P3, 2026-07-30): see
|
||||
// RemotePhysicsUpdater's identical parameter.
|
||||
Func<uint, ObjectInfoState>? getMoverPvpState = null)
|
||||
{
|
||||
_physics = physics ?? throw new ArgumentNullException(nameof(physics));
|
||||
_liveEntities = liveEntities ?? throw new ArgumentNullException(nameof(liveEntities));
|
||||
_getSetupCylinder = getSetupCylinder
|
||||
?? throw new ArgumentNullException(nameof(getSetupCylinder));
|
||||
_cellLocalForSeed = cellLocalForSeed
|
||||
?? throw new ArgumentNullException(nameof(cellLocalForSeed));
|
||||
_syncResolvedShadow = syncResolvedShadow
|
||||
?? throw new ArgumentNullException(nameof(syncResolvedShadow));
|
||||
_completeAuthoritativePlacement = completeAuthoritativePlacement
|
||||
?? throw new ArgumentNullException(nameof(completeAuthoritativePlacement));
|
||||
_beginAuthoritativePlacement = beginAuthoritativePlacement
|
||||
?? throw new ArgumentNullException(nameof(beginAuthoritativePlacement));
|
||||
_resolvePlacement = resolvePlacement ?? ResolvePlacement;
|
||||
_getMoverPvpState = getMoverPvpState ?? (static _ => ObjectInfoState.None);
|
||||
_liveEntities.ProjectionVisibilityChanged += OnProjectionVisibilityChanged;
|
||||
}
|
||||
|
||||
internal readonly record struct Result(
|
||||
bool Applied,
|
||||
bool ContactResolved,
|
||||
Vector3 Position,
|
||||
uint CellId,
|
||||
Quaternion Orientation,
|
||||
bool Superseded = false);
|
||||
|
||||
private readonly record struct PendingPlacement(
|
||||
LiveEntityRecord Record,
|
||||
ulong PositionAuthorityVersion,
|
||||
ulong VelocityAuthorityVersion,
|
||||
IRuntimeRemotePlacement Remote,
|
||||
PhysicsBody Body,
|
||||
WorldEntity Entity,
|
||||
Vector3 RequestedWorldPosition,
|
||||
uint RequestedCellId,
|
||||
Quaternion RequestedOrientation,
|
||||
double GameTime,
|
||||
ushort Generation,
|
||||
ushort PositionSequence,
|
||||
bool WasInContact,
|
||||
bool WasOnWalkable,
|
||||
RollbackPlacement Rollback);
|
||||
|
||||
private readonly record struct RollbackPlacement(
|
||||
Vector3 Position,
|
||||
uint CellId,
|
||||
Vector3 CellLocalPosition,
|
||||
Quaternion Orientation,
|
||||
TransientStateFlags TransientState,
|
||||
Plane ContactPlane,
|
||||
bool ContactPlaneValid,
|
||||
uint ContactPlaneCellId,
|
||||
bool ContactPlaneIsWater,
|
||||
double LastUpdateTime,
|
||||
bool Airborne,
|
||||
Vector3 LastServerPosition,
|
||||
double LastServerPositionTime,
|
||||
Vector3 LastShadowSyncPosition,
|
||||
Quaternion LastShadowSyncOrientation);
|
||||
|
||||
/// <summary>
|
||||
/// Applies a placement to whichever exact incarnation is current at this
|
||||
/// call boundary. Packet handlers should use the token-bearing overload;
|
||||
/// this form serves non-wire orchestration and retains the same callback
|
||||
/// revalidation once admitted.
|
||||
/// </summary>
|
||||
internal Result TryApply(
|
||||
IRuntimeRemotePlacement remote,
|
||||
WorldEntity entity,
|
||||
Vector3 requestedWorldPosition,
|
||||
uint requestedCellId,
|
||||
Vector3 requestedCellLocalPosition,
|
||||
Quaternion requestedOrientation,
|
||||
double gameTime,
|
||||
bool destinationProjectionVisible,
|
||||
ushort generation,
|
||||
ushort positionSequence)
|
||||
{
|
||||
if (!_liveEntities.TryGetRecord(entity.ServerGuid, out LiveEntityRecord record))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Remote placement for 0x{entity.ServerGuid:X8} requires a live incarnation.");
|
||||
}
|
||||
|
||||
return TryApply(
|
||||
record,
|
||||
record.PositionAuthorityVersion,
|
||||
record.VelocityAuthorityVersion,
|
||||
remote,
|
||||
entity,
|
||||
requestedWorldPosition,
|
||||
requestedCellId,
|
||||
requestedCellLocalPosition,
|
||||
requestedOrientation,
|
||||
gameTime,
|
||||
destinationProjectionVisible,
|
||||
generation,
|
||||
positionSequence);
|
||||
}
|
||||
|
||||
internal Result TryApply(
|
||||
LiveEntityRecord expectedRecord,
|
||||
ulong expectedPositionAuthorityVersion,
|
||||
ulong expectedVelocityAuthorityVersion,
|
||||
IRuntimeRemotePlacement remote,
|
||||
WorldEntity entity,
|
||||
Vector3 requestedWorldPosition,
|
||||
uint requestedCellId,
|
||||
Vector3 requestedCellLocalPosition,
|
||||
Quaternion requestedOrientation,
|
||||
double gameTime,
|
||||
bool destinationProjectionVisible,
|
||||
ushort generation,
|
||||
ushort positionSequence)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
ArgumentNullException.ThrowIfNull(expectedRecord);
|
||||
if (!_liveEntities.TryGetRecord(entity.ServerGuid, out LiveEntityRecord liveRecord)
|
||||
|| !ReferenceEquals(liveRecord, expectedRecord)
|
||||
|| !_liveEntities.IsCurrentPositionAuthority(
|
||||
expectedRecord,
|
||||
expectedPositionAuthorityVersion)
|
||||
|| liveRecord.Generation != generation
|
||||
|| !ReferenceEquals(liveRecord.WorldEntity, entity)
|
||||
|| !ReferenceEquals(liveRecord.RemoteMotionRuntime, remote)
|
||||
|| liveRecord.PhysicsBody is null
|
||||
|| !ReferenceEquals(liveRecord.PhysicsBody, remote.Body))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Remote placement for 0x{entity.ServerGuid:X8} must use its incarnation's canonical physics body.");
|
||||
}
|
||||
|
||||
bool wasInContact = liveRecord.PhysicsBody.InContact;
|
||||
bool wasOnWalkable = liveRecord.PhysicsBody.OnWalkable;
|
||||
RollbackPlacement rollback = CaptureRollback(remote, liveRecord.PhysicsBody);
|
||||
RuntimeEntityKey key = RequireProjectionKey(liveRecord);
|
||||
if (_pending.TryGetValue(key, out PendingPlacement prior)
|
||||
&& ReferenceEquals(prior.Record, liveRecord))
|
||||
{
|
||||
wasInContact = prior.WasInContact;
|
||||
wasOnWalkable = prior.WasOnWalkable;
|
||||
rollback = prior.Rollback;
|
||||
}
|
||||
|
||||
PendingPlacement request = new(
|
||||
liveRecord,
|
||||
expectedPositionAuthorityVersion,
|
||||
expectedVelocityAuthorityVersion,
|
||||
remote,
|
||||
liveRecord.PhysicsBody,
|
||||
entity,
|
||||
requestedWorldPosition,
|
||||
requestedCellId,
|
||||
requestedOrientation,
|
||||
gameTime,
|
||||
generation,
|
||||
positionSequence,
|
||||
wasInContact,
|
||||
wasOnWalkable,
|
||||
rollback);
|
||||
if (!destinationProjectionVisible)
|
||||
{
|
||||
if (!ParkPending(request, requestedCellLocalPosition))
|
||||
return Superseded(request);
|
||||
return new Result(
|
||||
true,
|
||||
false,
|
||||
requestedWorldPosition,
|
||||
requestedCellId,
|
||||
requestedOrientation);
|
||||
}
|
||||
ResolveResult placement = Resolve(request);
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
if (!placement.Ok)
|
||||
{
|
||||
_pending.Remove(key);
|
||||
if (!RollBackDeferredPlacement(request))
|
||||
return Superseded(request);
|
||||
return new Result(
|
||||
false,
|
||||
false,
|
||||
request.Body.Position,
|
||||
remote.CellId,
|
||||
request.Body.Orientation);
|
||||
}
|
||||
|
||||
_pending.Remove(key);
|
||||
return CommitResolved(request, placement);
|
||||
}
|
||||
|
||||
internal void Forget(LiveEntityRecord record)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
if (record.ProjectionKey is { } key
|
||||
&& _pending.TryGetValue(key, out PendingPlacement pending)
|
||||
&& ReferenceEquals(pending.Record, record))
|
||||
{
|
||||
_pending.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
_pending.Clear();
|
||||
}
|
||||
|
||||
internal bool HasPending(uint serverGuid) =>
|
||||
_liveEntities.TryGetRecord(serverGuid, out LiveEntityRecord record)
|
||||
&& record.ProjectionKey is { } key
|
||||
&& _pending.ContainsKey(key);
|
||||
internal int PendingPlacementCount => _pending.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Transfers any older deferred shadow restoration before the accepted
|
||||
/// destination is rebucketed and can publish a visibility edge.
|
||||
/// </summary>
|
||||
internal void BeginPlacement(uint serverGuid, ushort generation) =>
|
||||
_beginAuthoritativePlacement(serverGuid, generation);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_liveEntities.ProjectionVisibilityChanged -= OnProjectionVisibilityChanged;
|
||||
Clear();
|
||||
}
|
||||
|
||||
private ResolveResult Resolve(PendingPlacement request)
|
||||
{
|
||||
var (radius, height) = _getSetupCylinder(
|
||||
request.Entity.ServerGuid,
|
||||
request.Entity);
|
||||
if (radius < 0.05f)
|
||||
{
|
||||
radius = 0.48f;
|
||||
height = 1.835f;
|
||||
}
|
||||
|
||||
return _resolvePlacement(
|
||||
request.RequestedWorldPosition,
|
||||
request.RequestedCellId,
|
||||
radius,
|
||||
height,
|
||||
// TS-23: moverPvpState is a no-op OR (None) for every non-PK
|
||||
// remote.
|
||||
(IsPlayerGuid(request.Entity.ServerGuid)
|
||||
? ObjectInfoState.IsPlayer | ObjectInfoState.EdgeSlide
|
||||
: ObjectInfoState.EdgeSlide)
|
||||
| _getMoverPvpState(request.Entity.ServerGuid),
|
||||
request.Entity.Id);
|
||||
}
|
||||
|
||||
private ResolveResult ResolvePlacement(
|
||||
Vector3 position,
|
||||
uint cellId,
|
||||
float radius,
|
||||
float height,
|
||||
ObjectInfoState moverFlags,
|
||||
uint movingEntityId) =>
|
||||
_physics.ResolvePlacement(
|
||||
position,
|
||||
cellId,
|
||||
radius,
|
||||
height,
|
||||
stepUpHeight: 0.4f,
|
||||
stepDownHeight: 0.4f,
|
||||
moverFlags: moverFlags,
|
||||
movingEntityId: movingEntityId);
|
||||
|
||||
private Result CommitResolved(PendingPlacement request, ResolveResult placement)
|
||||
{
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
if (!RemoteTeleportPlacement.Apply(
|
||||
request.Remote,
|
||||
request.Body,
|
||||
placement,
|
||||
_cellLocalForSeed(placement.Position, placement.CellId),
|
||||
request.RequestedOrientation,
|
||||
request.GameTime,
|
||||
request.WasInContact,
|
||||
request.WasOnWalkable,
|
||||
() => IsCurrent(request),
|
||||
() => IsVelocityCurrent(request)))
|
||||
{
|
||||
return Superseded(request);
|
||||
}
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
if (request.Remote.CellId != placement.CellId)
|
||||
request.Remote.CellId = placement.CellId;
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
request.Remote.LastServerPosition = placement.Position;
|
||||
request.Remote.LastServerPositionTime = request.GameTime;
|
||||
request.Remote.LastShadowSyncPosition = Vector3.Zero;
|
||||
request.Remote.LastShadowSyncOrientation = Quaternion.Zero;
|
||||
request.Entity.SetPosition(request.Body.Position);
|
||||
request.Entity.ParentCellId = placement.CellId;
|
||||
request.Entity.Rotation = request.Body.Orientation;
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
if (_liveEntities.TryGetRecord(request.Entity.ServerGuid, out LiveEntityRecord record)
|
||||
&& ReferenceEquals(record, request.Record))
|
||||
{
|
||||
bool deferShadowRestore =
|
||||
record.FinalPhysicsState.HasFlag(PhysicsStateFlags.Hidden)
|
||||
|| !record.IsSpatiallyVisible;
|
||||
_completeAuthoritativePlacement(
|
||||
request.Entity.ServerGuid,
|
||||
request.Generation,
|
||||
deferShadowRestore);
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
if (!deferShadowRestore)
|
||||
{
|
||||
request.Remote.LastShadowSyncPosition = request.Body.Position;
|
||||
request.Remote.LastShadowSyncOrientation = request.Body.Orientation;
|
||||
_syncResolvedShadow(request.Entity, request.Body, placement.CellId);
|
||||
if (!IsCurrent(request))
|
||||
return Superseded(request);
|
||||
}
|
||||
}
|
||||
return new Result(
|
||||
true,
|
||||
true,
|
||||
request.Body.Position,
|
||||
placement.CellId,
|
||||
request.Body.Orientation);
|
||||
}
|
||||
|
||||
private bool ParkPending(PendingPlacement request, Vector3 requestedCellLocalPosition)
|
||||
{
|
||||
if (!IsCurrent(request))
|
||||
return false;
|
||||
request.Body.Orientation = request.RequestedOrientation;
|
||||
request.Body.SnapToCell(
|
||||
request.RequestedCellId,
|
||||
request.RequestedWorldPosition,
|
||||
requestedCellLocalPosition);
|
||||
request.Body.LastUpdateTime = request.GameTime;
|
||||
request.Body.ContactPlaneValid = false;
|
||||
request.Body.ContactPlaneCellId = 0u;
|
||||
request.Body.ContactPlaneIsWater = false;
|
||||
PhysicsObjUpdate.ApplySetPositionContact(
|
||||
request.Body,
|
||||
inContact: false,
|
||||
onWalkable: false);
|
||||
request.Remote.Airborne = true;
|
||||
if (request.Remote.CellId != request.RequestedCellId)
|
||||
request.Remote.CellId = request.RequestedCellId;
|
||||
if (!IsCurrent(request))
|
||||
return false;
|
||||
request.Remote.LastServerPosition = request.RequestedWorldPosition;
|
||||
request.Remote.LastServerPositionTime = request.GameTime;
|
||||
request.Remote.LastShadowSyncPosition = Vector3.Zero;
|
||||
request.Remote.LastShadowSyncOrientation = Quaternion.Zero;
|
||||
request.Entity.SetPosition(request.RequestedWorldPosition);
|
||||
request.Entity.ParentCellId = request.RequestedCellId;
|
||||
request.Entity.Rotation = request.RequestedOrientation;
|
||||
if (!IsCurrent(request))
|
||||
return false;
|
||||
_pending[RequireProjectionKey(request.Record)] = request;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnProjectionVisibilityChanged(LiveEntityRecord record, bool visible)
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
RuntimeEntityKey key = RequireProjectionKey(record);
|
||||
if (_pending.TryGetValue(key, out PendingPlacement pending))
|
||||
{
|
||||
if (record.WorldEntity is null
|
||||
|| !ReferenceEquals(record, pending.Record)
|
||||
|| !ReferenceEquals(record.WorldEntity, pending.Entity)
|
||||
|| record.Generation != pending.Generation)
|
||||
{
|
||||
_pending.Remove(key);
|
||||
return;
|
||||
}
|
||||
if (record.RemoteMotionRuntime is not IRuntimeRemotePlacement currentRemote
|
||||
|| record.PhysicsBody is null
|
||||
|| !ReferenceEquals(record.PhysicsBody, pending.Body)
|
||||
|| !ReferenceEquals(currentRemote.Body, record.PhysicsBody))
|
||||
{
|
||||
_pending.Remove(key);
|
||||
if (record.RemoteMotionRuntime is not null
|
||||
&& (record.PhysicsBody is null
|
||||
|| !ReferenceEquals(record.RemoteMotionRuntime.Body, record.PhysicsBody)))
|
||||
{
|
||||
_liveEntities.ClearRemoteMotionRuntime(record.ServerGuid);
|
||||
}
|
||||
RollBackDeferredPlacement(pending);
|
||||
return;
|
||||
}
|
||||
if (!ReferenceEquals(currentRemote, pending.Remote))
|
||||
{
|
||||
pending = pending with { Remote = currentRemote };
|
||||
_pending[key] = pending;
|
||||
}
|
||||
if (!_liveEntities.IsCurrentPositionAuthority(
|
||||
pending.Record,
|
||||
pending.PositionAuthorityVersion)
|
||||
|| record.Snapshot.PositionSequence != pending.PositionSequence)
|
||||
{
|
||||
// A newer accepted UpdatePosition rebucketed the projection
|
||||
// before its TryApply call could replace this request. Keep
|
||||
// the original rollback alive for that synchronous call.
|
||||
return;
|
||||
}
|
||||
|
||||
_pending.Remove(key);
|
||||
ResolveResult placement = Resolve(pending);
|
||||
if (!IsCurrent(pending))
|
||||
return;
|
||||
if (!placement.Ok)
|
||||
RollBackDeferredPlacement(pending);
|
||||
else
|
||||
CommitResolved(pending, placement);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static RollbackPlacement CaptureRollback(
|
||||
IRuntimeRemotePlacement remote,
|
||||
PhysicsBody body)
|
||||
{
|
||||
return new RollbackPlacement(
|
||||
body.Position,
|
||||
body.CellPosition.ObjCellId,
|
||||
body.CellPosition.Frame.Origin,
|
||||
body.Orientation,
|
||||
body.TransientState,
|
||||
body.ContactPlane,
|
||||
body.ContactPlaneValid,
|
||||
body.ContactPlaneCellId,
|
||||
body.ContactPlaneIsWater,
|
||||
body.LastUpdateTime,
|
||||
remote.Airborne,
|
||||
remote.LastServerPosition,
|
||||
remote.LastServerPositionTime,
|
||||
remote.LastShadowSyncPosition,
|
||||
remote.LastShadowSyncOrientation);
|
||||
}
|
||||
|
||||
private bool RollBackDeferredPlacement(PendingPlacement pending)
|
||||
{
|
||||
if (!IsCurrentAuthority(pending))
|
||||
return false;
|
||||
RollbackPlacement rollback = pending.Rollback;
|
||||
PhysicsBody body = pending.Body;
|
||||
body.Orientation = rollback.Orientation;
|
||||
body.SnapToCell(
|
||||
rollback.CellId,
|
||||
rollback.Position,
|
||||
rollback.CellLocalPosition);
|
||||
body.TransientState = rollback.TransientState;
|
||||
body.ContactPlane = rollback.ContactPlane;
|
||||
body.ContactPlaneValid = rollback.ContactPlaneValid;
|
||||
body.ContactPlaneCellId = rollback.ContactPlaneCellId;
|
||||
body.ContactPlaneIsWater = rollback.ContactPlaneIsWater;
|
||||
body.LastUpdateTime = rollback.LastUpdateTime;
|
||||
body.calc_acceleration();
|
||||
pending.Remote.Airborne = rollback.Airborne;
|
||||
pending.Remote.CellId = rollback.CellId;
|
||||
pending.Remote.LastServerPosition = rollback.LastServerPosition;
|
||||
pending.Remote.LastServerPositionTime = rollback.LastServerPositionTime;
|
||||
pending.Remote.LastShadowSyncPosition = rollback.LastShadowSyncPosition;
|
||||
pending.Remote.LastShadowSyncOrientation = rollback.LastShadowSyncOrientation;
|
||||
pending.Entity.SetPosition(rollback.Position);
|
||||
pending.Entity.ParentCellId = rollback.CellId;
|
||||
pending.Entity.Rotation = rollback.Orientation;
|
||||
if (!IsCurrentAuthority(pending))
|
||||
return false;
|
||||
|
||||
if (rollback.CellId == 0)
|
||||
_liveEntities.WithdrawLiveEntityProjectionToCellless(pending.Entity.ServerGuid);
|
||||
else
|
||||
_liveEntities.RebucketLiveEntity(pending.Entity.ServerGuid, rollback.CellId);
|
||||
|
||||
if (!IsCurrentAuthority(pending)
|
||||
|| !_liveEntities.TryGetRecord(
|
||||
pending.Entity.ServerGuid,
|
||||
out LiveEntityRecord restored)
|
||||
|| !ReferenceEquals(restored, pending.Record)
|
||||
|| restored.Generation != pending.Generation)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rollback.CellId == 0)
|
||||
{
|
||||
_completeAuthoritativePlacement(
|
||||
pending.Entity.ServerGuid,
|
||||
pending.Generation,
|
||||
false);
|
||||
return IsCurrentAuthority(pending);
|
||||
}
|
||||
|
||||
bool deferShadowRestore =
|
||||
restored.FinalPhysicsState.HasFlag(PhysicsStateFlags.Hidden)
|
||||
|| !restored.IsSpatiallyVisible;
|
||||
_completeAuthoritativePlacement(
|
||||
pending.Entity.ServerGuid,
|
||||
pending.Generation,
|
||||
deferShadowRestore);
|
||||
if (!IsCurrentAuthority(pending))
|
||||
return false;
|
||||
if (deferShadowRestore)
|
||||
return true;
|
||||
|
||||
pending.Remote.LastShadowSyncPosition = Vector3.Zero;
|
||||
pending.Remote.LastShadowSyncOrientation = Quaternion.Zero;
|
||||
_syncResolvedShadow(pending.Entity, pending.Body, rollback.CellId);
|
||||
return IsCurrentAuthority(pending);
|
||||
}
|
||||
|
||||
private bool IsCurrentAuthority(PendingPlacement request) =>
|
||||
_liveEntities.IsCurrentPositionAuthority(
|
||||
request.Record,
|
||||
request.PositionAuthorityVersion)
|
||||
&& request.Record.Generation == request.Generation
|
||||
&& ReferenceEquals(request.Record.WorldEntity, request.Entity)
|
||||
&& ReferenceEquals(request.Record.PhysicsBody, request.Body);
|
||||
|
||||
private bool IsCurrent(PendingPlacement request) =>
|
||||
IsCurrentAuthority(request)
|
||||
&& ReferenceEquals(request.Record.RemoteMotionRuntime, request.Remote);
|
||||
|
||||
private bool IsVelocityCurrent(PendingPlacement request) =>
|
||||
_liveEntities.IsCurrentVelocityAuthority(
|
||||
request.Record,
|
||||
request.VelocityAuthorityVersion);
|
||||
|
||||
private static Result Superseded(PendingPlacement request) => new(
|
||||
Applied: false,
|
||||
ContactResolved: false,
|
||||
Position: request.Body.Position,
|
||||
CellId: request.Remote.CellId,
|
||||
Orientation: request.Body.Orientation,
|
||||
Superseded: true);
|
||||
|
||||
private static bool IsPlayerGuid(uint guid) =>
|
||||
(guid & 0xFF000000u) == 0x50000000u;
|
||||
|
||||
private static RuntimeEntityKey RequireProjectionKey(
|
||||
LiveEntityRecord record) =>
|
||||
record.ProjectionKey
|
||||
?? throw new InvalidOperationException(
|
||||
$"Live entity 0x{record.ServerGuid:X8}/{record.Generation} " +
|
||||
"has no exact projection key.");
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.World;
|
||||
using AcDream.Core.Physics;
|
||||
|
||||
namespace AcDream.App.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Commits the placement half of retail <c>CPhysicsObj::MoveOrTeleport</c>
|
||||
/// Branch A (<c>0x00516330</c>). The caller runs
|
||||
/// <see cref="RemoteTeleportHook"/> first, then this exact frame/cell snap,
|
||||
/// before considering contact-driven interpolation.
|
||||
/// </summary>
|
||||
internal static class RemoteTeleportPlacement
|
||||
{
|
||||
internal static bool Apply(
|
||||
IRuntimeRemotePlacement remote,
|
||||
PhysicsBody body,
|
||||
ResolveResult placement,
|
||||
Vector3 cellLocalPosition,
|
||||
Quaternion orientation,
|
||||
double gameTime,
|
||||
bool previousContact,
|
||||
bool previousOnWalkable,
|
||||
Func<bool>? isCurrent = null,
|
||||
Func<bool>? isVelocityCurrent = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
ArgumentNullException.ThrowIfNull(body);
|
||||
if (!placement.Ok
|
||||
|| !IsFinite(placement.Position)
|
||||
|| !IsFinite(cellLocalPosition)
|
||||
|| !PositionFrameValidation.IsValid(
|
||||
placement.CellId,
|
||||
cellLocalPosition,
|
||||
orientation)
|
||||
|| !double.IsFinite(gameTime))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(placement),
|
||||
"A remote teleport placement requires an accepted finite frame, clock, and nonzero cell.");
|
||||
}
|
||||
|
||||
body.Orientation = orientation;
|
||||
body.SnapToCell(placement.CellId, placement.Position, cellLocalPosition);
|
||||
body.LastUpdateTime = gameTime;
|
||||
|
||||
body.ContactPlaneValid = placement.InContact;
|
||||
if (placement.InContact)
|
||||
{
|
||||
body.ContactPlane = placement.ContactPlane;
|
||||
body.ContactPlaneCellId = placement.ContactPlaneCellId;
|
||||
body.ContactPlaneIsWater = placement.ContactPlaneIsWater;
|
||||
}
|
||||
else
|
||||
{
|
||||
body.ContactPlaneCellId = 0u;
|
||||
body.ContactPlaneIsWater = false;
|
||||
}
|
||||
|
||||
if (!PhysicsObjUpdate.CommitSetPositionTransition(
|
||||
body,
|
||||
placement.InContact,
|
||||
placement.OnWalkable,
|
||||
placement.CollisionNormalValid,
|
||||
placement.CollisionNormal,
|
||||
previousContact,
|
||||
previousOnWalkable,
|
||||
remote.HitGround,
|
||||
remote.LeaveGround,
|
||||
isCurrent,
|
||||
isVelocityCurrent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (isVelocityCurrent?.Invoke() != false)
|
||||
remote.Airborne = !body.OnWalkable;
|
||||
return isCurrent?.Invoke() ?? true;
|
||||
}
|
||||
|
||||
private static bool IsFinite(Vector3 value) =>
|
||||
float.IsFinite(value.X)
|
||||
&& float.IsFinite(value.Y)
|
||||
&& float.IsFinite(value.Z);
|
||||
|
||||
}
|
||||
|
|
@ -180,7 +180,6 @@ public sealed class GameWindow :
|
|||
_movementTruthDiagnostics;
|
||||
private readonly LocalPlayerOutboundController _localPlayerOutbound;
|
||||
private readonly AcDream.App.Update.UpdateFrameClock _updateFrameClock;
|
||||
private AcDream.App.Physics.RemoteTeleportController? _remoteTeleportController;
|
||||
// Step 7 projectile presentation. The controller owns no identity map;
|
||||
// each runtime component is stored on the canonical LiveEntityRecord.
|
||||
private AcDream.App.Physics.ProjectileController? _projectileController;
|
||||
|
|
@ -1001,7 +1000,6 @@ public sealed class GameWindow :
|
|||
|| _equippedChildRenderer is not null
|
||||
|| _entityEffects is not null
|
||||
|| _liveEntityPresentation is not null
|
||||
|| _remoteTeleportController is not null
|
||||
|| _projectileController is not null
|
||||
|| _liveEntityProjectionWithdrawal is not null
|
||||
|| _liveEntityLights is not null
|
||||
|
|
@ -1039,7 +1037,6 @@ public sealed class GameWindow :
|
|||
_equippedChildRenderer = result.EquippedChildren;
|
||||
_entityEffects = result.EntityEffects;
|
||||
_liveEntityPresentation = result.Presentation;
|
||||
_remoteTeleportController = result.RemoteTeleport;
|
||||
_wbDrawDispatcher = result.DrawDispatcher;
|
||||
_retailSelectionScene = result.SelectionScene;
|
||||
_worldSelectionQuery = result.SelectionQuery;
|
||||
|
|
@ -1638,7 +1635,6 @@ public sealed class GameWindow :
|
|||
_hookRegistrations,
|
||||
_liveEntityLights,
|
||||
_liveEntityPresentation,
|
||||
_remoteTeleportController,
|
||||
_animationHookFrames,
|
||||
_effectPoses,
|
||||
_audioEngine),
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ internal sealed record LiveShutdownRoots(
|
|||
AnimationHookRegistrationSet? HookRegistrations,
|
||||
LiveEntityLightController? LiveLights,
|
||||
LiveEntityPresentationController? LivePresentation,
|
||||
RemoteTeleportController? RemoteTeleport,
|
||||
AnimationHookFrameQueue? AnimationHookFrames,
|
||||
EntityEffectPoseRegistry EffectPoses,
|
||||
OpenAlAudioEngine? Audio);
|
||||
|
|
@ -397,7 +396,6 @@ internal static class GameWindowShutdownManifest
|
|||
[
|
||||
Hard("live lights", () => live.LiveLights?.Dispose()),
|
||||
Hard("live presentation", () => live.LivePresentation?.Dispose()),
|
||||
Hard("remote teleport", () => live.RemoteTeleport?.Dispose()),
|
||||
Hard("effect network state", () =>
|
||||
{
|
||||
live.EntityEffects?.ClearNetworkState();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
private readonly LiveEntityPartArrayEnterWorldPort _partArrayEnterWorld;
|
||||
private readonly HashSet<RuntimeEntityKey> _readyOwners = [];
|
||||
private readonly HashSet<RuntimeEntityKey> _suspendedShadowOwners = [];
|
||||
private readonly HashSet<RuntimeEntityKey> _activePlacementOwners = [];
|
||||
private readonly HashSet<LiveEntityRecord> _drainingRecords = new();
|
||||
private bool _disposed;
|
||||
|
||||
|
|
@ -102,73 +101,12 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
return ApplyPendingTransitions(record);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retains ownership of a collision shadow that another retail transition
|
||||
/// suspended while this incarnation's spatial projection is unavailable.
|
||||
/// Hidden/UnHide and teleport rollback intentionally converge on this one
|
||||
/// generation-scoped restoration marker.
|
||||
/// </summary>
|
||||
public bool DeferShadowRestore(uint serverGuid, ushort generation)
|
||||
=> CompleteAuthoritativePlacement(serverGuid, generation, deferShadowRestore: true);
|
||||
|
||||
/// <summary>
|
||||
/// Completes active placement ownership after its final frame/cell is
|
||||
/// known, either returning a stable deferred restore to presentation or
|
||||
/// clearing the suspension for an immediate controller-owned restore.
|
||||
/// </summary>
|
||||
public bool CompleteAuthoritativePlacement(
|
||||
uint serverGuid,
|
||||
ushort generation,
|
||||
bool deferShadowRestore)
|
||||
{
|
||||
if (!_liveEntities.TryGetRecord(serverGuid, out LiveEntityRecord record)
|
||||
|| record.Generation != generation
|
||||
|| record.WorldEntity is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
RuntimeEntityKey key = RequireProjectionKey(record);
|
||||
_activePlacementOwners.Remove(key);
|
||||
|
||||
if (deferShadowRestore)
|
||||
_suspendedShadowOwners.Add(key);
|
||||
else
|
||||
_suspendedShadowOwners.Remove(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfers a deferred restore to a newer authoritative placement before
|
||||
/// that placement rebuckets and can become visible. The placement hands
|
||||
/// ownership back after it reaches a stable Hidden destination/rollback;
|
||||
/// this prevents an intervening UnHide from restoring an unresolved pose.
|
||||
/// </summary>
|
||||
public bool BeginAuthoritativePlacement(uint serverGuid, ushort generation)
|
||||
{
|
||||
if (!_liveEntities.TryGetRecord(serverGuid, out LiveEntityRecord record)
|
||||
|| record.Generation != generation)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
RuntimeEntityKey key = RequireProjectionKey(record);
|
||||
_activePlacementOwners.Add(key);
|
||||
_suspendedShadowOwners.Remove(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal bool HasDeferredShadowRestore(uint serverGuid) =>
|
||||
TryGetCurrentProjectionKey(serverGuid, out RuntimeEntityKey key)
|
||||
&& _suspendedShadowOwners.Contains(key);
|
||||
|
||||
internal bool HasActivePlacement(uint serverGuid) =>
|
||||
TryGetCurrentProjectionKey(serverGuid, out RuntimeEntityKey key)
|
||||
&& _activePlacementOwners.Contains(key);
|
||||
|
||||
internal int ReadyOwnerCount => _readyOwners.Count;
|
||||
internal int DeferredShadowRestoreCount => _suspendedShadowOwners.Count;
|
||||
internal int ActivePlacementCount => _activePlacementOwners.Count;
|
||||
|
||||
public void Forget(LiveEntityRecord record)
|
||||
{
|
||||
|
|
@ -177,7 +115,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
{
|
||||
_readyOwners.Remove(key);
|
||||
_suspendedShadowOwners.Remove(key);
|
||||
_activePlacementOwners.Remove(key);
|
||||
}
|
||||
_drainingRecords.Remove(record);
|
||||
}
|
||||
|
|
@ -186,7 +123,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
{
|
||||
_readyOwners.Clear();
|
||||
_suspendedShadowOwners.Clear();
|
||||
_activePlacementOwners.Clear();
|
||||
_drainingRecords.Clear();
|
||||
}
|
||||
|
||||
|
|
@ -233,8 +169,7 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
if (!IsCurrent(record, entity))
|
||||
return false;
|
||||
_shadows.Suspend(entity.Id);
|
||||
if (!IsPlacementActive(record))
|
||||
_suspendedShadowOwners.Add(RequireProjectionKey(record));
|
||||
_suspendedShadowOwners.Add(RequireProjectionKey(record));
|
||||
// Retail CPhysicsObj::set_hidden @ 0x00514C60 calls
|
||||
// CPartArray::HandleEnterWorld after hiding the object
|
||||
// from its cell. Despite the name, this is the motion
|
||||
|
|
@ -261,8 +196,7 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
_partArrayEnterWorld.HandleEnterWorld(entity.Id);
|
||||
if (!IsCurrent(record, entity))
|
||||
return false;
|
||||
bool restored = !IsPlacementActive(record)
|
||||
&& RestoreShadow(record, entity);
|
||||
bool restored = RestoreShadow(record, entity);
|
||||
if (!IsCurrent(record, entity))
|
||||
return false;
|
||||
if (restored)
|
||||
|
|
@ -313,8 +247,12 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
// projection edge that suspends its object clock. Keep the retained
|
||||
// registration so a stationary object can be restored immediately on
|
||||
// hydration; it may have no later movement quantum to repair itself.
|
||||
// Projectiles and active authoritative placements own their matching
|
||||
// suspend/restore transaction in their dedicated controllers.
|
||||
// Projectiles own their matching suspend/restore transaction in their
|
||||
// dedicated controller. C4 route 4b-3 deleted the standalone remote-
|
||||
// teleport placement controller (and its `_activePlacementOwners`
|
||||
// suspension gate here) — the canonical Runtime placement owner now
|
||||
// handles that path, and this class no longer defers to a second
|
||||
// authority.
|
||||
if (!visible)
|
||||
{
|
||||
SuspendOrdinaryShadowOutsideProjection(record, entity);
|
||||
|
|
@ -322,7 +260,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
}
|
||||
|
||||
if ((record.FinalPhysicsState & PhysicsStateFlags.Hidden) != 0
|
||||
|| IsPlacementActive(record)
|
||||
|| !TryGetProjectionKey(record, out RuntimeEntityKey key)
|
||||
|| !_readyOwners.Contains(key)
|
||||
|| !_suspendedShadowOwners.Contains(key))
|
||||
|
|
@ -343,7 +280,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
{
|
||||
if (record.IsSpatiallyVisible
|
||||
|| record.ProjectileRuntime is not null
|
||||
|| IsPlacementActive(record)
|
||||
|| !TryGetProjectionKey(record, out RuntimeEntityKey key)
|
||||
|| !_readyOwners.Contains(key)
|
||||
|| !_shadows.Suspend(entity.Id))
|
||||
|
|
@ -362,10 +298,6 @@ public sealed class LiveEntityPresentationController : IDisposable
|
|||
&& ReferenceEquals(current, record)
|
||||
&& ReferenceEquals(current.WorldEntity, entity);
|
||||
|
||||
private bool IsPlacementActive(LiveEntityRecord record) =>
|
||||
TryGetProjectionKey(record, out RuntimeEntityKey key)
|
||||
&& _activePlacementOwners.Contains(key);
|
||||
|
||||
private bool TryGetCurrentProjectionKey(
|
||||
uint serverGuid,
|
||||
out RuntimeEntityKey key)
|
||||
|
|
|
|||
|
|
@ -2143,6 +2143,22 @@ public sealed class LiveEntityRuntime : ILiveEntityRadarSource
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R2 fix round (2026-08-04): the App-layer entry point for retail
|
||||
/// <c>CPhysicsObj::report_collision_end(this, 1)</c> —
|
||||
/// <c>teleport_hook</c>'s sixth action (@0x00514F31 → @0x00514620,
|
||||
/// force-end-all with bidirectional <c>DoCollisionEnd</c> on both this
|
||||
/// object and every collision-table partner). Forwards to
|
||||
/// <see cref="RuntimeCollisionReportingState.LeaveWorld"/>, the exact
|
||||
/// retail leave-world/teleport/Hidden force-end entry point — NOT
|
||||
/// <c>ShadowObjectRegistry.Suspend</c>, which ports a DIFFERENT retail
|
||||
/// function (<c>remove_shadows_from_cells</c>) that <c>teleport_hook</c>
|
||||
/// never calls; that mapping predated this fix and was carried without
|
||||
/// re-derivation.
|
||||
/// </summary>
|
||||
internal void ForceEndCollisionReporting(RuntimeEntityRecord canonical) =>
|
||||
_physics.CollisionReports.LeaveWorld(canonical);
|
||||
|
||||
public bool TryGetRemoteMotionRuntime(
|
||||
uint serverGuid,
|
||||
out IRuntimeRemoteMotion runtime)
|
||||
|
|
@ -2406,29 +2422,16 @@ public sealed class LiveEntityRuntime : ILiveEntityRadarSource
|
|||
System.Numerics.Vector3? currentLocalVelocity,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out WorldSession.EntitySpawn accepted,
|
||||
out AcceptedPhysicsTimestamps timestamps)
|
||||
{
|
||||
bool projectionRequiresTeleportHook =
|
||||
_directory.TryGetActive(
|
||||
update.Guid,
|
||||
out RuntimeEntityRecord canonical)
|
||||
&& (canonical.FullCellId == 0u
|
||||
|| !_projections.TryGet(
|
||||
canonical,
|
||||
out LiveEntityRecord? projection)
|
||||
|| !projection.IsSpatiallyProjected
|
||||
|| !projection.IsSpatiallyVisible);
|
||||
return _entityObjects.TryApplyPosition(
|
||||
out AcceptedPhysicsTimestamps timestamps) =>
|
||||
_entityObjects.TryApplyPosition(
|
||||
update,
|
||||
isLocalPlayer,
|
||||
forcePositionRotation,
|
||||
currentLocalVelocity,
|
||||
projectionRequiresTeleportHook,
|
||||
acknowledgeProjection: null,
|
||||
out disposition,
|
||||
out accepted,
|
||||
out timestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4a: borrows the canonical Runtime classification for one
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ internal sealed class LiveEntityRuntimeTeardownController
|
|||
private readonly LiveEntityRuntime? _runtime;
|
||||
private readonly LiveEntityPresentationController? _presentation;
|
||||
private readonly EntityEffectController? _effects;
|
||||
private readonly RemoteTeleportController? _remoteTeleport;
|
||||
private readonly SelectionInteractionController? _interactions;
|
||||
private readonly SelectionState? _selection;
|
||||
private readonly LiveEntityAnimationRuntimeView<LiveEntityAnimationState>? _animations;
|
||||
|
|
@ -47,7 +46,6 @@ internal sealed class LiveEntityRuntimeTeardownController
|
|||
LiveEntityRuntime runtime,
|
||||
LiveEntityPresentationController presentation,
|
||||
EntityEffectController effects,
|
||||
RemoteTeleportController remoteTeleport,
|
||||
SelectionInteractionController? interactions,
|
||||
SelectionState selection,
|
||||
LiveEntityAnimationRuntimeView<LiveEntityAnimationState> animations,
|
||||
|
|
@ -63,7 +61,6 @@ internal sealed class LiveEntityRuntimeTeardownController
|
|||
_runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
|
||||
_presentation = presentation ?? throw new ArgumentNullException(nameof(presentation));
|
||||
_effects = effects ?? throw new ArgumentNullException(nameof(effects));
|
||||
_remoteTeleport = remoteTeleport ?? throw new ArgumentNullException(nameof(remoteTeleport));
|
||||
_interactions = interactions;
|
||||
_selection = selection ?? throw new ArgumentNullException(nameof(selection));
|
||||
_animations = animations ?? throw new ArgumentNullException(nameof(animations));
|
||||
|
|
@ -110,7 +107,6 @@ internal sealed class LiveEntityRuntimeTeardownController
|
|||
{
|
||||
() => _presentation!.Forget(record),
|
||||
() => _effects!.OnLiveEntityUnregistered(record),
|
||||
() => _remoteTeleport!.Forget(record),
|
||||
() =>
|
||||
{
|
||||
bool replacementExists =
|
||||
|
|
|
|||
|
|
@ -140,8 +140,9 @@ public static class EntityCollisionFlagsExt
|
|||
/// <c>ClientObjectTable</c>-backed mover-flags lookup every physics
|
||||
/// call site (local player world-entry, remote DR sweep + teleport,
|
||||
/// ordinary movers) uses — was inlined three times (App
|
||||
/// <c>GameWindow</c>/<c>LivePresentationComposition</c>/
|
||||
/// <c>RemoteTeleportController</c>) before being consolidated here.
|
||||
/// <c>GameWindow</c>/<c>LivePresentationComposition</c>/the since-deleted
|
||||
/// <c>RemoteTeleportController</c>, C4 route 4b-3) before being
|
||||
/// consolidated here.
|
||||
/// An entity with no row, or a row with no wire bitfield yet, resolves
|
||||
/// to <see cref="ObjectInfoState.None"/> — a no-op OR into moverFlags,
|
||||
/// bit-identical to every pre-P3 caller.
|
||||
|
|
|
|||
|
|
@ -218,6 +218,39 @@ public static class PhysicsDiagnostics
|
|||
public static bool ProbeRemoteLandingEnabled { get; set; } =
|
||||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_REMOTE_LANDING") == "1";
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (2026-08-04) live-execution proof (process rule 5): one
|
||||
/// <c>[remote-teleport]</c> line per routed teleport arm
|
||||
/// (<c>LiveEntityNetworkUpdateController.ApplyRemoteContactRouting</c>'s
|
||||
/// teleport dispatch), so a connected test can confirm the new arm
|
||||
/// actually executed rather than inferring it from a clean-looking
|
||||
/// session (#309's lesson — a session with zero probe lines is a
|
||||
/// not-run). Initial state from <c>ACDREAM_PROBE_REMOTE_TELEPORT=1</c>.
|
||||
/// TEMPORARY — strip with the rest of the probe family once the
|
||||
/// two-client connected teleport gate has landed.
|
||||
/// </summary>
|
||||
public static bool ProbeRemoteTeleportEnabled { get; set; } =
|
||||
Environment.GetEnvironmentVariable("ACDREAM_PROBE_REMOTE_TELEPORT") == "1";
|
||||
|
||||
/// <summary>
|
||||
/// Emit one <c>[remote-teleport]</c> line for one routed teleport arm.
|
||||
/// Self-guards on <see cref="ProbeRemoteTeleportEnabled"/>, so callers
|
||||
/// need not pre-check. <paramref name="cause"/> is <c>"teleport-ts"</c>
|
||||
/// or <c>"cellless"</c> (D1's two classifier predicates); the guid, the
|
||||
/// hook's own currency result, and the placement status are the fields
|
||||
/// the connected gate recipe reads back.
|
||||
/// </summary>
|
||||
public static void LogRemoteTeleport(
|
||||
uint guid,
|
||||
string cause,
|
||||
bool hookRan,
|
||||
string placementStatus)
|
||||
{
|
||||
if (!ProbeRemoteTeleportEnabled) return;
|
||||
Console.WriteLine(System.FormattableString.Invariant(
|
||||
$"[remote-teleport] guid=0x{guid:X8} cause={cause} hookRan={hookRan} placement={placementStatus}"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emit one <c>[remote-landing]</c> line for a remote landing-detection
|
||||
/// edge. Caller MUST guard with
|
||||
|
|
@ -1253,6 +1286,7 @@ public static class PhysicsDiagnostics
|
|||
ProbeSweptEnabled = false;
|
||||
ProbeStepWalkEnabled = false;
|
||||
ProbeTeleportEnabled = false;
|
||||
ProbeRemoteTeleportEnabled = false;
|
||||
ProbeRemoteLandingEnabled = false;
|
||||
ProbeRemoteSlideEnabled = false;
|
||||
ProbeRemoteSlideGuids = new System.Collections.Generic.HashSet<uint>();
|
||||
|
|
|
|||
|
|
@ -755,9 +755,8 @@ public sealed class InboundPhysicsStateController
|
|||
/// immediate-apply path did.
|
||||
///
|
||||
/// A <see cref="PositionTimestampDisposition.Rejected"/> retained
|
||||
/// continuation only ever exists because
|
||||
/// <see cref="AcceptedPhysicsTimestamps.TeleportHookRequired"/>-adjacent
|
||||
/// bookkeeping mutated (see <see cref="PhysicsTimestampGate.TryAcceptPositionEvent"/>:
|
||||
/// continuation only ever exists because timestamp-gate bookkeeping
|
||||
/// mutated (see <see cref="PhysicsTimestampGate.TryAcceptPositionEvent"/>:
|
||||
/// a Rejected outcome always leaves POSITION_TS and TELEPORT_TS net
|
||||
/// unchanged, so the ONLY dimension that can differ is FORCE_POSITION_TS
|
||||
/// from the local-player force-position fallthrough branch) — apply the
|
||||
|
|
@ -1142,8 +1141,7 @@ public sealed class InboundPhysicsStateController
|
|||
gate.TeleportTimestamp,
|
||||
gate.ForcePositionTimestamp,
|
||||
teleportAdvanced,
|
||||
TeleportHookRequired: false,
|
||||
previousTeleport ?? gate.TeleportTimestamp);
|
||||
PreviousTeleport: previousTeleport ?? gate.TeleportTimestamp);
|
||||
|
||||
private static WorldSession.EntitySpawn MergeUntimestampedCreate(
|
||||
WorldSession.EntitySpawn retained,
|
||||
|
|
@ -1375,13 +1373,27 @@ public sealed class InboundPhysicsStateController
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="PreMergeCommittedCellId"/> — C4 route 4b-3 (D1): the
|
||||
/// entity's canonical <c>FullCellId</c> measured by
|
||||
/// <see cref="AcDream.Runtime.Entities.RuntimeEntityObjectLifetime.TryApplyPosition"/>
|
||||
/// BEFORE this packet's merge, for a record that already existed
|
||||
/// (<see langword="null"/> when there was no prior canonical record — never a
|
||||
/// fabricated 0). This is retail's <c>this_1->cell == 0</c> predicate
|
||||
/// (<c>CPhysicsObj::MoveOrTeleport</c> @0x00516330, read at entry, before any
|
||||
/// placement) — "this object has no resolved cell right now" — which is a
|
||||
/// DIFFERENT question from the post-merge <c>canonical.FullCellId</c> the
|
||||
/// classifier's <c>CommittedCellId</c> request field reads from every other
|
||||
/// caller. 0 means the record genuinely had no committed cell (the
|
||||
/// unwield-to-3D shape); it is never invented.
|
||||
/// </summary>
|
||||
public readonly record struct AcceptedPhysicsTimestamps(
|
||||
ushort Instance,
|
||||
ushort ServerControlledMove,
|
||||
ushort Teleport,
|
||||
ushort ForcePosition,
|
||||
bool TeleportAdvanced = false,
|
||||
bool TeleportHookRequired = false,
|
||||
uint? PreMergeCommittedCellId = null,
|
||||
ushort PreviousTeleport = 0);
|
||||
|
||||
public readonly record struct CreateParentUpdate(
|
||||
|
|
|
|||
|
|
@ -622,8 +622,19 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
|
|||
float? playerDistance)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(canonical);
|
||||
if (_generation is not { } generation)
|
||||
if (_generation is not { } generation
|
||||
// C4 route 4b-3 (D1): a remote PositionEvent feeds the
|
||||
// classifier's cell-less predicate the PRE-merge committed cell
|
||||
// — the same value TryApplyPosition measured for THIS packet,
|
||||
// never re-read from the (already merged) canonical record. A
|
||||
// null here means the merge never observed a prior canonical
|
||||
// record for this entity, which "Runtime has no opinion" — the
|
||||
// same policy every other missing-input case in this method
|
||||
// already uses — covers honestly rather than fabricating 0.
|
||||
|| timestamps.PreMergeCommittedCellId is not { } preMergeCommittedCellId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!RuntimeAcceptedPositionRouteRequests.TryBuild(
|
||||
generation(),
|
||||
canonical,
|
||||
|
|
@ -637,6 +648,7 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
|
|||
// Retail's UsePositionFromServer is consumed by the local
|
||||
// player branch only; the Remote branch never reads it.
|
||||
usePositionFromServer: false,
|
||||
preMergeCommittedCellId,
|
||||
out RuntimeAcceptedPositionRouteRequest request))
|
||||
{
|
||||
return null;
|
||||
|
|
@ -1641,7 +1653,6 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
|
|||
bool isLocalPlayer,
|
||||
System.Numerics.Quaternion? forcePositionRotation,
|
||||
System.Numerics.Vector3? currentLocalVelocity,
|
||||
bool projectionRequiresTeleportHook,
|
||||
Action<RuntimeEntityRecord>? acknowledgeProjection,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out WorldSession.EntitySpawn accepted,
|
||||
|
|
@ -1713,7 +1724,6 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
|
|||
update.Guid,
|
||||
out RuntimeEntityRecord beforeCanonical);
|
||||
uint beforeCell = beforeCanonical?.FullCellId ?? 0u;
|
||||
bool wasCellless = hadCanonical && beforeCell == 0u;
|
||||
bool known = Entities.TryApplyPosition(
|
||||
update,
|
||||
isLocalPlayer,
|
||||
|
|
@ -1743,16 +1753,20 @@ public sealed class RuntimeEntityObjectLifetime : IDisposable
|
|||
|
||||
bool acceptedPosition =
|
||||
disposition is not PositionTimestampDisposition.Rejected;
|
||||
if (disposition is PositionTimestampDisposition.Apply)
|
||||
// C4 route 4b-3 (D1): the classifier's remote cell-less predicate
|
||||
// needs the PRE-merge committed cell — the value this method just
|
||||
// measured as `beforeCell`, before `RefreshSnapshot`
|
||||
// below stamps the accepted wire cell onto the canonical record via
|
||||
// `RefreshDerivedState` -> `SetFullCell`. Reading `canonical.FullCellId`
|
||||
// AFTER that merge (as the classifier's default builder overload
|
||||
// does for every other caller) always sees the wire cell, which is
|
||||
// why the predicate as fed to a remote PositionEvent was dead before
|
||||
// this fix. `hadCanonical` is what makes this an honest value rather
|
||||
// than a fabricated 0 — see the field's own doc.
|
||||
timestamps = timestamps with
|
||||
{
|
||||
timestamps = timestamps with
|
||||
{
|
||||
TeleportHookRequired =
|
||||
timestamps.TeleportAdvanced
|
||||
|| wasCellless
|
||||
|| projectionRequiresTeleportHook,
|
||||
};
|
||||
}
|
||||
PreMergeCommittedCellId = hadCanonical ? beforeCell : null,
|
||||
};
|
||||
RuntimePlacementCancellationReceipt cancellation = default;
|
||||
if (acceptedPosition)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,46 @@ internal static class RuntimeAcceptedPositionRouteRequests
|
|||
ushort previousTeleportSequence,
|
||||
ushort acceptedTeleportSequence,
|
||||
float playerDistance,
|
||||
bool usePositionFromServer)
|
||||
bool usePositionFromServer) =>
|
||||
Build(
|
||||
generation,
|
||||
canonical,
|
||||
key,
|
||||
update,
|
||||
entityKind,
|
||||
source,
|
||||
disposition,
|
||||
previousTeleportSequence,
|
||||
acceptedTeleportSequence,
|
||||
playerDistance,
|
||||
usePositionFromServer,
|
||||
// Route 1's own semantics, unchanged (contract invariant 11):
|
||||
// the post-merge FullCellId is exactly what this overload has
|
||||
// always read.
|
||||
committedCellId: canonical.FullCellId);
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (D1): the overload for a caller that holds the PRE-merge
|
||||
/// committed cell explicitly, rather than reading the (already merged)
|
||||
/// canonical record's <c>FullCellId</c>. The only caller today is the
|
||||
/// remote PositionEvent path
|
||||
/// (<see cref="AcDream.Runtime.Entities.RuntimeEntityObjectLifetime.ClassifyRemoteAcceptedPosition"/>);
|
||||
/// every other field still comes from <paramref name="canonical"/> exactly
|
||||
/// as the route-1 overload above reads it.
|
||||
/// </summary>
|
||||
internal static RuntimeAcceptedPositionRouteRequest Build(
|
||||
RuntimeGenerationToken generation,
|
||||
RuntimeEntityRecord canonical,
|
||||
RuntimeEntityKey key,
|
||||
in WorldSession.EntityPositionUpdate update,
|
||||
RuntimePositionEntityKind entityKind,
|
||||
RuntimeAcceptedPositionSource source,
|
||||
PositionTimestampDisposition disposition,
|
||||
ushort previousTeleportSequence,
|
||||
ushort acceptedTeleportSequence,
|
||||
float playerDistance,
|
||||
bool usePositionFromServer,
|
||||
uint? committedCellId)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(canonical);
|
||||
var authority = new RuntimeAuthoritativePositionAuthority(
|
||||
|
|
@ -68,7 +107,7 @@ internal static class RuntimeAcceptedPositionRouteRequests
|
|||
update.Position,
|
||||
update.PlacementId,
|
||||
update.Velocity,
|
||||
canonical.FullCellId,
|
||||
committedCellId,
|
||||
update.IsGrounded,
|
||||
playerDistance,
|
||||
usePositionFromServer,
|
||||
|
|
@ -124,4 +163,53 @@ internal static class RuntimeAcceptedPositionRouteRequests
|
|||
usePositionFromServer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (D1): the overload for a caller that holds the PRE-merge
|
||||
/// committed cell explicitly (see the sibling <c>Build</c> overload's
|
||||
/// doc) instead of letting this method read the already-merged
|
||||
/// <paramref name="canonical"/> record. Refuses (returns
|
||||
/// <see langword="false"/>) exactly like the overload above, PLUS when
|
||||
/// <paramref name="committedCellId"/> itself is <see langword="null"/> —
|
||||
/// an unknown pre-merge cell is "Runtime has no opinion", never a
|
||||
/// fabricated 0.
|
||||
/// </summary>
|
||||
internal static bool TryBuild(
|
||||
RuntimeGenerationToken generation,
|
||||
RuntimeEntityRecord canonical,
|
||||
in WorldSession.EntityPositionUpdate update,
|
||||
RuntimePositionEntityKind entityKind,
|
||||
RuntimeAcceptedPositionSource source,
|
||||
PositionTimestampDisposition disposition,
|
||||
ushort previousTeleportSequence,
|
||||
ushort acceptedTeleportSequence,
|
||||
float? playerDistance,
|
||||
bool usePositionFromServer,
|
||||
uint? committedCellId,
|
||||
out RuntimeAcceptedPositionRouteRequest request)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(canonical);
|
||||
if (canonical.Key is not { } key
|
||||
|| playerDistance is not { } distance
|
||||
|| committedCellId is null)
|
||||
{
|
||||
request = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
request = Build(
|
||||
generation,
|
||||
canonical,
|
||||
key,
|
||||
update,
|
||||
entityKind,
|
||||
source,
|
||||
disposition,
|
||||
previousTeleportSequence,
|
||||
acceptedTeleportSequence,
|
||||
distance,
|
||||
usePositionFromServer,
|
||||
committedCellId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,10 +390,15 @@ internal static class RuntimeAuthoritativePositionRouteClassifier
|
|||
reporting);
|
||||
}
|
||||
|
||||
// Accepted wire position is intentionally distinct from committed
|
||||
// residence. A target frame with a nonzero cell does not make a
|
||||
// cellless canonical body resident; only a later Runtime SetPosition
|
||||
// or simulation commit may change FullCellId.
|
||||
// C4 route 4b-3 (D1): CommittedCellId is the caller's own committed
|
||||
// cell, not derived from the accepted wire frame here — the LOCAL
|
||||
// player's caller reads its own record's FullCellId (unaffected by
|
||||
// this packet), and a remote's caller (D1) supplies the PRE-merge
|
||||
// committed cell measured before the wire frame was merged onto the
|
||||
// canonical record, never the (already merged) post-merge value.
|
||||
// This is retail's `this_1->cell == 0` predicate — "this object has
|
||||
// no resolved cell right now" — read at MoveOrTeleport's entry,
|
||||
// before any placement.
|
||||
bool cellless = !request.CommittedCellId.HasValue
|
||||
|| request.CommittedCellId.Value == 0u;
|
||||
if (request.Authority.TeleportAdvanced || cellless)
|
||||
|
|
|
|||
|
|
@ -21,19 +21,29 @@ internal enum RuntimeRemoteAcceptedPositionArm : byte
|
|||
|
||||
/// <summary>Retail's <c>player_distance >= 96f</c>
|
||||
/// <c>StopInterpolating</c> @0x005163CB + <c>SetPositionSimple</c>
|
||||
/// @0x005163D9. Route 4b-2 — this slice.</summary>
|
||||
/// @0x005163D9. Route 4b-2.</summary>
|
||||
FarSnapPlacement,
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3: retail's teleport/cell-less branch
|
||||
/// (<c>TELEPORT_TS</c> advanced OR the body's cell is 0) —
|
||||
/// <c>teleport_hook</c> @0x005163EF then <c>SetPosition</c>
|
||||
/// @0x00516420, <c>return 1</c> @0x00516438. Decided AHEAD of the
|
||||
/// contact test (D5), so this arm never competes with
|
||||
/// <see cref="AirborneNoOperation"/>/<see cref="NearInterpolate"/>/
|
||||
/// <see cref="FarSnapPlacement"/> for the same packet.
|
||||
/// </summary>
|
||||
TeleportPlacement,
|
||||
|
||||
/// <summary>
|
||||
/// <b>acdream-only.</b> No retail arm corresponds to it, because retail
|
||||
/// cannot reach the states that produce it: a classification of
|
||||
/// <c>RejectedAuthority</c>/<c>RejectedData</c> (retail validates no wire
|
||||
/// frame this way), <see langword="null"/> (retail always has a player, so
|
||||
/// <c>player_distance</c> always exists — acdream returns null for every
|
||||
/// remote packet during the login window before the local movement
|
||||
/// controller exists), or the cell-less <c>SetPosition</c> half that route
|
||||
/// 4b-3 will own. See <see cref="ResolveArm"/>'s remarks for the stated
|
||||
/// policy.
|
||||
/// frame this way), or <see langword="null"/> (retail always has a
|
||||
/// player, so <c>player_distance</c> always exists — acdream returns
|
||||
/// null for every remote packet during the login window before the local
|
||||
/// movement controller exists). See <see cref="ResolveArm"/>'s remarks
|
||||
/// for the stated policy.
|
||||
/// </summary>
|
||||
UnroutedCatchUp,
|
||||
}
|
||||
|
|
@ -80,106 +90,36 @@ internal static class RuntimeRemoteFarSnapPosition
|
|||
&& (route.Value.SetPositionFlags & PhysicsSetPositionFlags.Teleport)
|
||||
!= 0;
|
||||
|
||||
/// <summary>
|
||||
/// The ONE predicate deciding whether retail's single
|
||||
/// <c>SmartBox::HandleReceivedPosition</c> <c>ConstrainTo</c> site
|
||||
/// (@0x00454272, inside <c>if (MoveOrTeleport(...) != 0)</c> @0x00454254)
|
||||
/// is armed AFTER the position operation for this classification, rather
|
||||
/// than by the legacy pre-operation App call.
|
||||
///
|
||||
/// <para>
|
||||
/// Route 4a moved its two dispositions onto the post-operation arm; this
|
||||
/// slice adds the far snap. Every remaining classification still arms
|
||||
/// through the legacy pre-operation call site, unchanged. Both the legacy
|
||||
/// gate and
|
||||
/// <see cref="RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation"/>
|
||||
/// read THIS predicate, so a classification can never be armed twice or
|
||||
/// not at all.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal static bool OwnsAfterOperationConstraint(
|
||||
RuntimeAuthoritativePositionRoute? route) =>
|
||||
RuntimeRemoteSteadyStatePosition.OwnsSteadyState(route)
|
||||
|| OwnsFarSnap(route);
|
||||
|
||||
/// <summary>
|
||||
/// Selects the arm for one already-classified remote accepted Position.
|
||||
/// <b>Does NOT decide the teleport arm</b> — C4 route 4b-3 (D5) routes a
|
||||
/// teleport/cell-less classification (<c>RuntimeRemoteTeleportPosition.
|
||||
/// OwnsTeleportPlacement</c>) AHEAD of this method entirely, from inside
|
||||
/// <c>LiveEntityNetworkUpdateController.ApplyRemoteContactRouting</c>,
|
||||
/// because retail decides that branch before reading the wire contact bit
|
||||
/// this method's callers have already tested. This method is reached only
|
||||
/// for a body already known to be in contact and NOT teleport-classified.
|
||||
///
|
||||
/// <para>
|
||||
/// <b>The <see cref="RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp"/>
|
||||
/// policy, stated.</b> Before this slice, every classification route 4a
|
||||
/// did not own fell into a duplicated App-side near/far block that
|
||||
/// re-derived retail's <c>player_distance >= 96 m</c> test from
|
||||
/// <c>_playerController?.Position ?? Vector3.Zero</c>. That test is
|
||||
/// deleted here rather than preserved, because in every residual case it
|
||||
/// was already meaningless or wrong:
|
||||
/// policy, stated.</b> What remains here after 4b-3's teleport/cell-less
|
||||
/// classification moved out is exactly the two acdream-only divergences
|
||||
/// retail has no state for at all:
|
||||
/// </para>
|
||||
/// <list type="bullet">
|
||||
/// <item><description><see langword="null"/> — the classifier returned no
|
||||
/// route precisely BECAUSE there is no local-player position
|
||||
/// route precisely BECAUSE there is no local-player position yet
|
||||
/// (<c>RuntimeAcceptedPositionRouteRequests.TryBuild</c> refuses to
|
||||
/// fabricate one; <c>GameRuntime</c> states the rule). The legacy block
|
||||
/// then measured the distance from a fabricated <c>Vector3.Zero</c>.
|
||||
/// <b>Review fix — what that actually computed:</b> <c>worldPos</c> is
|
||||
/// streaming-origin-relative
|
||||
/// (<c>LiveEntityNetworkUpdateController.cs</c>: local position plus
|
||||
/// <c>(landblock − _origin.Center) * 192 m</c>), and the streaming origin
|
||||
/// recentres on the local player's landblock, so the fabricated distance
|
||||
/// was the remote's distance from the ORIGIN LANDBLOCK'S CORNER — a
|
||||
/// biased but genuinely correlated proxy for <c>player_distance</c>,
|
||||
/// its error bounded by the player's own offset inside that landblock
|
||||
/// (0-192 m per axis). The earlier claim that it had "no relationship to
|
||||
/// <c>player_distance</c>" was false. It is deleted anyway because a
|
||||
/// silently-biased proxy for retail's exact 96 m threshold is not a
|
||||
/// threshold: the bias is up to ~2.8x the threshold itself, so the arm it
|
||||
/// selects is not the arm retail would select, and there is no honest way
|
||||
/// to correct for it without the player position the classifier already
|
||||
/// declined to fabricate.</description></item>
|
||||
/// <item><description>Cell-less <c>SetPosition</c> — the classifier
|
||||
/// returns at <c>:399-417</c>, BEFORE it ever evaluates the distance.
|
||||
/// Retail's cell-less body takes the <c>this_1->cell == 0</c> branch
|
||||
/// @0x00516386 (<c>SetPosition</c>, flags <c>0x1012</c>), never the far
|
||||
/// branch, so applying a far test to it was a divergence in its own
|
||||
/// right. <b>Review fix — the residual delta, stated:</b> retail's
|
||||
/// cell-less arm is an UNCONDITIONAL placement sitting ahead of the
|
||||
/// contact test — <c>teleport_hook</c> @0x005163EF then <c>SetPosition</c>
|
||||
/// @0x00516420, <c>return 1</c> @0x00516438 — while acdream now routes
|
||||
/// that classification here, where <see cref="ApplyInterpolate"/> ENQUEUES
|
||||
/// whenever <c>!firstUp && willBeDrTicked &&
|
||||
/// bodyToTarget <= 4 m</c>, at any distance. <b>It is deliberately not
|
||||
/// changed to place here.</b> Retail's arm is not a pose write: it is
|
||||
/// <c>teleport_hook</c> @0x00514ED0 — the COMPLETE call list, read from
|
||||
/// the decomp (delta review N6 added the last of these, which the earlier
|
||||
/// enumeration dropped): <c>MovementManager::CancelMoveTo</c> @0x00514EDF,
|
||||
/// <c>PositionManager::UnStick</c> @0x00514EEE,
|
||||
/// <c>PositionManager::StopInterpolating</c> @0x00514EFD,
|
||||
/// <c>PositionManager::UnConstrain</c> @0x00514F0C,
|
||||
/// <c>TargetManager::ClearTarget</c> @0x00514F1B +
|
||||
/// <c>NotifyVoyeurOfEvent(Teleported_TargetStatus)</c> @0x00514F28, and
|
||||
/// <c>CPhysicsObj::report_collision_end(this, 1)</c> @0x00514F31 — followed
|
||||
/// by the canonical flags-<c>0x1012</c>
|
||||
/// <c>SetPosition</c>. Writing only the pose here would leave a live
|
||||
/// moveto, a live stick, a live constraint leash pointing at the old
|
||||
/// cell, and every collision partner still believing it is in contact,
|
||||
/// which is strictly worse than the recorded queue. Porting the
|
||||
/// whole arm is route 4b-3's entire scope; claiming half of it here is
|
||||
/// route 4a's "'not Interpolate' is not 'far'" mistake one level up.
|
||||
/// Recorded as AP-137.</description></item>
|
||||
/// fabricate one; <c>GameRuntime</c> states the rule), or because the
|
||||
/// merge observed no PRIOR canonical record for this entity (D1 — an
|
||||
/// honest "no opinion" rather than a fabricated pre-merge
|
||||
/// cell).</description></item>
|
||||
/// <item><description><c>RejectedAuthority</c>/<c>RejectedData</c> — the
|
||||
/// packet's authority or payload was refused; retail, which validates
|
||||
/// neither, has no state here at all. <b>Review fix — stated plainly:</b>
|
||||
/// this arm therefore APPLIES a payload the classifier just marked
|
||||
/// invalid. <c>ClassifyAcceptedPosition</c> emits <c>RejectedData</c> from
|
||||
/// two sites a remote can reach — an accepted wire position that fails
|
||||
/// <c>ValidPosition</c> (non-finite origin/orientation or a frame
|
||||
/// <c>PositionFrameValidation</c> refuses), and a non-finite or negative
|
||||
/// derived <c>player_distance</c> — and both then take this arm. That is
|
||||
/// not a regression — the deleted legacy block fed the same payload to the
|
||||
/// same snap/enqueue pair — but this slice's stated purpose was an
|
||||
/// EXPLICIT handler, so it is named rather than left implied. Retiring it
|
||||
/// means giving the two rejections their own no-operation arm, which is a
|
||||
/// behaviour change route 4b-3 must decide with the cell-less half, not a
|
||||
/// tidy-up. Recorded as AP-137.</description></item>
|
||||
/// neither, has no state here at all. This arm therefore APPLIES a
|
||||
/// payload the classifier just marked invalid — not a regression (the
|
||||
/// deleted legacy block fed the same payload to the same snap/enqueue
|
||||
/// pair), but named rather than left implied.</description></item>
|
||||
/// </list>
|
||||
/// <para>
|
||||
/// What remains is exactly AP-87 — the shared
|
||||
|
|
@ -188,10 +128,8 @@ internal static class RuntimeRemoteFarSnapPosition
|
|||
/// <c>firstUp || !willBeDrTicked || bodyToTarget > 4 m</c> still PLACES
|
||||
/// an unplaced or badly-lagging body. So a remote keeps tracking the
|
||||
/// server through the login window and through a rejected packet; it is
|
||||
/// never silently frozen, which is what deleting the legacy block without
|
||||
/// a replacement would have done. The single 4 m constant now lives only
|
||||
/// in <c>RuntimeRemoteSteadyStatePosition</c>; the App's two duplicated
|
||||
/// copies are gone.
|
||||
/// never silently frozen. The single 4 m constant lives only in
|
||||
/// <c>RuntimeRemoteSteadyStatePosition</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal static RuntimeRemoteAcceptedPositionArm ResolveArm(
|
||||
|
|
|
|||
|
|
@ -516,10 +516,12 @@ internal sealed class RuntimeRemotePhysicsUpdater
|
|||
// callbacks between the contact prefix and
|
||||
// handle_all_collisions are HitGround/LeaveGround and the
|
||||
// ownership re-check. The packet-driven placement paths are
|
||||
// the ones that need it: `RemoteTeleportPlacement.Apply` is
|
||||
// the only caller that passes the delegate, and
|
||||
// `RuntimeSetPositionState`'s canonical commit makes the same
|
||||
// check inline around its own `HandleAllCollisions`.
|
||||
// the ones that need it: `RuntimeSetPositionState`'s
|
||||
// canonical commit (which now backs every remote packet-
|
||||
// driven placement, teleport included — C4 route 4b-3
|
||||
// deleted the `RemoteTeleportPlacement.Apply` caller this
|
||||
// note used to name) makes the same check inline around its
|
||||
// own `HandleAllCollisions`.
|
||||
//
|
||||
// It is spelled out through its own public sub-steps
|
||||
// (CommitSetPositionContactPrefix / the ground edge /
|
||||
|
|
@ -663,11 +665,14 @@ internal sealed class RuntimeRemotePhysicsUpdater
|
|||
// Bug B (2026-08-04): Airborne is DERIVED from the committed
|
||||
// ON_WALKABLE transient, never latched by a landing test.
|
||||
// This is the project's ONE definition of the flag — every
|
||||
// writer spells `!Body.OnWalkable`, and there are FIVE of
|
||||
// writer spells `!Body.OnWalkable`, and there are FOUR of
|
||||
// them: `SettleSpawnedRemoteContact` (the spawn-settle
|
||||
// tail) and `RemoteTeleportPlacement.Apply` in App,
|
||||
// `RuntimeSetPositionState`'s canonical placement commit,
|
||||
// and this file's two (here and the `TickHidden` resolve).
|
||||
// tail), `RuntimeSetPositionState`'s canonical placement
|
||||
// commit (C4 route 4b-3 retired the fifth writer this
|
||||
// note used to name, `RemoteTeleportPlacement.Apply` in
|
||||
// App — the teleport path's `Airborne` derivation is now
|
||||
// this same canonical commit's), and this file's two
|
||||
// (here and the `TickHidden` resolve).
|
||||
// `PlayerMovementController.IsAirborne` computes the same
|
||||
// predicate for the local player. It stays unchanged here;
|
||||
// only the fact it is derived FROM has moved, from a
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ internal static class RuntimeRemoteSteadyStatePosition
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// D2: retail arms <c>CPhysicsObj::ConstrainTo</c> strictly AFTER
|
||||
/// D2/D4: retail arms <c>CPhysicsObj::ConstrainTo</c> strictly AFTER
|
||||
/// <c>MoveOrTeleport</c> returns nonzero, anchored to the object's own
|
||||
/// CURRENT (i.e. post-move) position — <c>SmartBox::HandleReceivedPosition</c>
|
||||
/// 0x00453FD0 reads <c>&arg2->m_position</c> at 0x00454272, inside
|
||||
|
|
@ -204,38 +204,55 @@ internal static class RuntimeRemoteSteadyStatePosition
|
|||
/// does NOT run on the airborne no-op.
|
||||
///
|
||||
/// <para>
|
||||
/// Route-gated by
|
||||
/// <see cref="RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint"/>
|
||||
/// — route 4a's two dispositions plus (C4 route 4b-2) the far snap. Every
|
||||
/// other classification still arms the leash through the legacy
|
||||
/// pre-operation call site, unchanged, until 4b-3 moves them too. The
|
||||
/// legacy site reads the SAME predicate, so no classification can be
|
||||
/// armed twice or left unarmed.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This deliberately does not consult the outcome of the operation it
|
||||
/// follows. Retail's far branch returns 1 @0x005163E8 unconditionally —
|
||||
/// <c>MoveOrTeleport</c> discards <c>SetPositionSimple</c>'s
|
||||
/// <c>enum SetPositionError</c> return entirely — so
|
||||
/// <c>HandleReceivedPosition</c> arms the leash even when the placement
|
||||
/// FAILED. "Arm only on commit" is the natural misreading and is the same
|
||||
/// shape as the already-recorded unarmed-leash bug.
|
||||
/// C4 route 4b-3 (D4): this is now the ONLY arming site — the legacy
|
||||
/// pre-operation call is deleted, matching retail's single
|
||||
/// @0x00454272. <paramref name="arm"/> is the routing outcome (which arm
|
||||
/// actually claimed the packet), NOT the raw classification, because
|
||||
/// that is the only input that correctly distinguishes a GROUNDED
|
||||
/// <see cref="RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp"/> (arms —
|
||||
/// retail has no state here, but the analogue of "MoveOrTeleport returned
|
||||
/// nonzero" is true) from the wire-airborne leftover shape (D2's
|
||||
/// return-0 replacement, which never reaches this call at all — see the
|
||||
/// caller). The complete partition:
|
||||
/// </para>
|
||||
/// <list type="bullet">
|
||||
/// <item><description><see cref="RuntimeRemoteAcceptedPositionArm.TeleportPlacement"/>
|
||||
/// — arms on EVERY placement outcome (retail discards
|
||||
/// <c>SetPosition</c>'s error and returns 1 unconditionally
|
||||
/// @0x00516438).</description></item>
|
||||
/// <item><description><see cref="RuntimeRemoteAcceptedPositionArm.FarSnapPlacement"/>
|
||||
/// — arms unconditionally, same reason
|
||||
/// (@0x005163E8).</description></item>
|
||||
/// <item><description><see cref="RuntimeRemoteAcceptedPositionArm.NearInterpolate"/>
|
||||
/// — arms; retail's InterpolateTo branch returns 1
|
||||
/// (@0x005163BE).</description></item>
|
||||
/// <item><description><see cref="RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp"/>
|
||||
/// — arms; only reachable here when the body is already known to be in
|
||||
/// contact (the caller's free-flight carve-out already
|
||||
/// returned).</description></item>
|
||||
/// <item><description><see cref="RuntimeRemoteAcceptedPositionArm.AirborneNoOperation"/>
|
||||
/// — never arms; retail's <c>arg4 == 0</c> branch returns 0
|
||||
/// (@0x0051636D). Both production callers already early-return on this
|
||||
/// classification before reaching any arming call, so this case is
|
||||
/// defensive.</description></item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
internal static bool TryArmConstraintAfterOperation(
|
||||
RuntimeAuthoritativePositionRoute? route,
|
||||
RuntimeRemoteAcceptedPositionArm arm,
|
||||
RemoteMotion remote)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
if (route is not { } selected
|
||||
|| !RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
selected)
|
||||
|| !selected.ConstrainAfterRouting
|
||||
|| remote.Host is not { } host)
|
||||
bool arms = arm switch
|
||||
{
|
||||
RuntimeRemoteAcceptedPositionArm.TeleportPlacement => true,
|
||||
RuntimeRemoteAcceptedPositionArm.FarSnapPlacement => true,
|
||||
RuntimeRemoteAcceptedPositionArm.NearInterpolate => true,
|
||||
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp => true,
|
||||
RuntimeRemoteAcceptedPositionArm.AirborneNoOperation => false,
|
||||
_ => false,
|
||||
};
|
||||
if (!arms || remote.Host is not { } host)
|
||||
return false;
|
||||
}
|
||||
|
||||
ArmConstraintAfterOperation(host);
|
||||
return true;
|
||||
|
|
|
|||
47
src/AcDream.Runtime/Physics/RuntimeRemoteTeleportPosition.cs
Normal file
47
src/AcDream.Runtime/Physics/RuntimeRemoteTeleportPosition.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using AcDream.Core.Physics;
|
||||
|
||||
namespace AcDream.Runtime.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (2026-08-04): the remote teleport/cell-less arm selection —
|
||||
/// retail's <c>CPhysicsObj::MoveOrTeleport</c> (0x00516330) branch decided at
|
||||
/// entry, BEFORE the contact test: <c>this_1->cell == 0 || newer_event(TELEPORT_TS)</c>
|
||||
/// @0x00516375-@0x00516386. Sibling to <see cref="RuntimeRemoteFarSnapPosition"/>
|
||||
/// (the >=96 m far snap) and <see cref="RuntimeRemoteSteadyStatePosition"/>
|
||||
/// (airborne no-op / near interpolate); together the three cover every arm a
|
||||
/// remote's accepted Position can take.
|
||||
/// </summary>
|
||||
internal static class RuntimeRemoteTeleportPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// True when route 4b-3 owns this classification: retail's teleport/
|
||||
/// cell-less branch, @0x00516386-@0x00516438.
|
||||
///
|
||||
/// <para>
|
||||
/// The disposition alone is NOT sufficient — the classifier emits
|
||||
/// <c>SetPosition</c> for a remote top-level Create too
|
||||
/// (<c>RuntimeAuthoritativePositionRouteClassifier.ClassifyCreate</c>,
|
||||
/// flags <c>Placement|Slide</c>). The <c>Teleport</c> flag bit is the
|
||||
/// exact discriminator — an accepted remote Position's teleport/cell-less
|
||||
/// branch carries retail's <c>Teleport|Slide|SendPositionEvent</c> =
|
||||
/// <c>0x1012</c>, exactly the flags a Create never sets — the same
|
||||
/// discriminator <see cref="RuntimeRemoteFarSnapPosition.OwnsFarSnap"/>
|
||||
/// uses for its own disposition. This predicate is therefore a strict
|
||||
/// narrowing of
|
||||
/// <see cref="AcDream.Runtime.Session.RuntimeRemotePlacementDriveController.OwnsPlacement"/>
|
||||
/// to its teleport half, exactly as <c>OwnsFarSnap</c> narrows to its far
|
||||
/// half — the two partition <c>OwnsPlacement</c>'s remote scope
|
||||
/// completely and disjointly (a route can never carry both
|
||||
/// <c>SetPosition</c> and <c>SetPositionSimple</c> at once).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal static bool OwnsTeleportPlacement(
|
||||
RuntimeAuthoritativePositionRoute? route) =>
|
||||
route is
|
||||
{
|
||||
Disposition: RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
OperationKind: RuntimeSetPositionOperationKind.RemoteAuthoritative,
|
||||
}
|
||||
&& (route.Value.SetPositionFlags & PhysicsSetPositionFlags.Teleport)
|
||||
!= 0;
|
||||
}
|
||||
|
|
@ -4536,9 +4536,12 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
/// read from that same record field. It is NOT invariant for a RETAINED
|
||||
/// operation: both drives re-submit from their own cadence pump with no
|
||||
/// fresh merge in between (<c>SubmitAndResolve</c> re-reads the record as
|
||||
/// it then stands), and <c>RemoteTeleportController</c>'s rollback is a
|
||||
/// shipped writer that rebuckets <c>FullCellId</c> back to the
|
||||
/// PRE-teleport landblock. <c>RuntimeRemotePlacementDriveController</c>'s
|
||||
/// it then stands). The surviving non-Position rebucket writers (C4
|
||||
/// route 4b-3 deleted the third, <c>RemoteTeleportController</c>'s
|
||||
/// rollback) are the projection materializer
|
||||
/// (<c>DatLiveEntityProjectionMaterializer</c>) and the equipped-child
|
||||
/// renderer (<c>EquippedChildRenderController.TickChild</c>).
|
||||
/// <c>RuntimeRemotePlacementDriveController</c>'s
|
||||
/// <c>CanAttemptDestination</c> doc states this correctly; treat the arm
|
||||
/// as live, not as dead code.
|
||||
/// </para>
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ public sealed class RuntimeLiveEntitySessionController
|
|||
isLocal,
|
||||
forcePositionRotation: localController?.BodyOrientation,
|
||||
currentLocalVelocity: localController?.BodyVelocity,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -783,6 +783,65 @@ internal sealed class RuntimeRemotePlacementDriveController
|
|||
return status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3: retail's teleport/cell-less branch, end to end, for one
|
||||
/// remote whose accepted Position already classified to
|
||||
/// <see cref="RuntimeRemoteTeleportPosition.OwnsTeleportPlacement"/>.
|
||||
///
|
||||
/// <code>
|
||||
/// 00516386 if (newer_event(TELEPORT_TS) || this_1->cell == 0)
|
||||
/// 005163ef CPhysicsObj::teleport_hook(this_1, edx_2);
|
||||
/// 00516414 SetPositionStruct::SetFlags(&var_64, 0x1012);
|
||||
/// 00516420 CPhysicsObj::SetPosition(this_1, &var_64);
|
||||
/// 00516438 return 1;
|
||||
/// </code>
|
||||
///
|
||||
/// <para>
|
||||
/// The teleport hook is the CALLER's responsibility (D3) — it must run
|
||||
/// BEFORE this method, regardless of what the placement then yields,
|
||||
/// exactly like retail's ordering. This method does not clear the
|
||||
/// interpolation queue itself: unlike the far arm, the classifier's
|
||||
/// teleport branch carries <c>StopInterpolating: false</c> on purpose —
|
||||
/// retail's clear for THIS branch lives inside <c>teleport_hook</c>'s
|
||||
/// <c>PositionManager::StopInterpolating</c> @0x00514EFD, not in
|
||||
/// <c>MoveOrTeleport</c> itself.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The <c>store_position</c> fallback (invariant 1) is identical to the
|
||||
/// far arm's: every outcome for which the canonical placement never
|
||||
/// reached the engine
|
||||
/// (<see cref="RuntimeRemotePlacementExecutionStatusExtensions.StoresAcceptedDestination"/>)
|
||||
/// still advances the body to the accepted destination pose. Retail
|
||||
/// discards <c>SetPosition</c>'s error and returns 1 unconditionally
|
||||
/// @0x00516438 — the placement's outcome never changes whether the
|
||||
/// packet "succeeded".
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal RuntimeRemotePlacementExecutionStatus ApplyAcceptedRemoteTeleport(
|
||||
RuntimeEntityRecord record,
|
||||
RemoteMotion remote,
|
||||
in RuntimeAuthoritativePositionRoute route)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
if (!RuntimeRemoteTeleportPosition.OwnsTeleportPlacement(route))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"Only a remote teleport/cell-less classification (SetPosition, "
|
||||
+ "RemoteAuthoritative, Teleport-flagged) may be applied "
|
||||
+ "through the teleport arm; the caller must select the arm "
|
||||
+ "with RuntimeRemoteTeleportPosition.OwnsTeleportPlacement.",
|
||||
nameof(route));
|
||||
}
|
||||
|
||||
RuntimeRemotePlacementExecutionStatus status =
|
||||
TryExecuteAcceptedRemotePosition(record, route);
|
||||
if (status.StoresAcceptedDestination())
|
||||
StoreAcceptedDestinationPose(record);
|
||||
return status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retail <c>CPhysicsObj::store_position</c> @0x00515CE2, reached from
|
||||
/// <c>SetPositionInternal</c>'s no-resolvable-cell branch @0x00515C1D.
|
||||
|
|
@ -1248,10 +1307,13 @@ internal sealed class RuntimeRemotePlacementDriveController
|
|||
/// </list>
|
||||
/// <para>
|
||||
/// <see cref="Advance"/> re-reads this predicate and is subject to the
|
||||
/// same two gaps, plus a third: a non-Position rebucket
|
||||
/// (<c>RemoteTeleportController</c>, the projection materializer, the
|
||||
/// equipped-child renderer) can move <c>record.FullCellId</c> to a THIRD
|
||||
/// landblock between the retained submit and the retry. All three are
|
||||
/// same two gaps, plus a third: a non-Position rebucket (the projection
|
||||
/// materializer <c>DatLiveEntityProjectionMaterializer</c>, the
|
||||
/// equipped-child renderer <c>EquippedChildRenderController.TickChild</c>
|
||||
/// — C4 route 4b-3 deleted the third shipped writer,
|
||||
/// <c>RemoteTeleportController</c>'s rollback) can move
|
||||
/// <c>record.FullCellId</c> to a THIRD landblock between the retained
|
||||
/// submit and the retry. Both remaining writers are
|
||||
/// harmless for the same reason (delta review N3). That reason is the
|
||||
/// paragraph below — NOT, as the round-2 text claimed, that re-reading
|
||||
/// <c>record.CurrentCellId</c> here would "re-derive a private Core
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ public sealed class LiveSessionResetPlanTests
|
|||
},
|
||||
SessionIdentityPresentation = _ =>
|
||||
calls.Add("session identity presentation"),
|
||||
RemoteTeleport = Stage("remote teleport"),
|
||||
NetworkEffects = Stage("network effects"),
|
||||
AnimationHookFrames = Stage("animation hook frames"),
|
||||
LivePresentation = Stage("live presentation"),
|
||||
|
|
@ -306,7 +305,6 @@ public sealed class LiveSessionResetPlanTests
|
|||
"live liveness",
|
||||
"runtime generation",
|
||||
"session identity presentation",
|
||||
"remote teleport",
|
||||
"network effects",
|
||||
"animation hook frames",
|
||||
"live presentation",
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
DecoyWirePose,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.FarSnapPlacement,
|
||||
|
|
@ -105,7 +106,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
DecoyWirePose,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.False(remote.Interp.IsActive);
|
||||
fixture.DrainPlacementFifo();
|
||||
|
|
@ -146,7 +148,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
DecoyWirePose,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.FarSnapPlacement,
|
||||
|
|
@ -214,7 +217,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
DecoyWirePose,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.Refused,
|
||||
|
|
@ -254,7 +258,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
route: null,
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
||||
|
|
@ -294,7 +299,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
route: null,
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
||||
|
|
@ -327,7 +333,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
rejected,
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
||||
|
|
@ -337,13 +344,16 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retail's cell-less body takes <c>this_1->cell == 0</c> @0x00516386
|
||||
/// (<c>SetPosition</c>), never the far branch — and route 4b-3, not this
|
||||
/// slice, owns it. Claiming it here would be exactly route 4a's
|
||||
/// "'not Interpolate' is not 'far'" finding one level up.
|
||||
/// 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_TakesTheUnroutedCatchUp_AndNeverThePlacementOwner()
|
||||
public void CellLessRemote_TakesTheTeleportArm_RunsTheHookAndPlacesCanonically()
|
||||
{
|
||||
using var fixture = new RemotePlacementDriveFixture();
|
||||
fixture.PublishDestinationCollision();
|
||||
|
|
@ -360,6 +370,7 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
cellLess.Disposition);
|
||||
|
||||
int hookCalls = 0;
|
||||
LiveEntityNetworkUpdateController.RemoteContactRouting routing =
|
||||
LiveEntityNetworkUpdateController.ApplyRemoteContactRouting(
|
||||
fixture.Drive,
|
||||
|
|
@ -368,12 +379,27 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
cellLess,
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () =>
|
||||
{
|
||||
hookCalls++;
|
||||
return true;
|
||||
});
|
||||
|
||||
Assert.Equal(1, hookCalls);
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.UnroutedCatchUp,
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.TeleportPlacement,
|
||||
routing.Arm);
|
||||
Assert.Equal(target, body.Position);
|
||||
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);
|
||||
}
|
||||
|
|
@ -409,7 +435,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.AirborneSnap,
|
||||
|
|
@ -418,6 +445,77 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
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
|
||||
|
|
@ -444,7 +542,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 200f),
|
||||
DecoyWirePose,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true).Arm);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true).Arm);
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm
|
||||
.SteadyStateInterpolate,
|
||||
|
|
@ -455,7 +554,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 10f),
|
||||
nearBefore + new Vector3(0.5f, 0f, 0f),
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true).Arm);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true).Arm);
|
||||
|
||||
Assert.Equal(
|
||||
Destination + RemotePlacementDriveFixture.DestinationWorldOffset,
|
||||
|
|
@ -497,7 +597,8 @@ public sealed class LiveEntityNetworkRemoteFarSnapIntegrationTests
|
|||
airborne,
|
||||
new Vector3(60f, 10f, 7f),
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true));
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true));
|
||||
|
||||
Assert.Equal(before, body.Position);
|
||||
Assert.False(remote.Interp.IsActive);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,8 @@ public sealed class LiveEntityNetworkRemoteSteadyStateIntegrationTests
|
|||
route,
|
||||
landing,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.AirborneSnap,
|
||||
|
|
@ -207,7 +208,8 @@ public sealed class LiveEntityNetworkRemoteSteadyStateIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 10f),
|
||||
target,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm
|
||||
|
|
@ -263,7 +265,8 @@ public sealed class LiveEntityNetworkRemoteSteadyStateIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 10f),
|
||||
before + new Vector3(0.5f, 0f, 0f),
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm
|
||||
|
|
@ -302,7 +305,8 @@ public sealed class LiveEntityNetworkRemoteSteadyStateIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 10f),
|
||||
landing,
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm.AirborneSnap,
|
||||
|
|
@ -338,7 +342,8 @@ public sealed class LiveEntityNetworkRemoteSteadyStateIntegrationTests
|
|||
Classify(hasContact: true, playerDistance: 10f),
|
||||
before + new Vector3(0.5f, 0f, 0f),
|
||||
Quaternion.Identity,
|
||||
willBeDrTicked: true);
|
||||
willBeDrTicked: true,
|
||||
runTeleportHook: () => true);
|
||||
|
||||
Assert.Equal(
|
||||
LiveEntityNetworkUpdateController.RemoteContactArm
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,194 +0,0 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Physics;
|
||||
using AcDream.Core.Physics;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.App.Tests.Physics;
|
||||
|
||||
public sealed class RemoteTeleportPlacementTests
|
||||
{
|
||||
[Fact]
|
||||
public void Apply_HardSnapsFullFrameAndPhysicsClock()
|
||||
{
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Orientation = Quaternion.Identity,
|
||||
LastUpdateTime = 2.0,
|
||||
};
|
||||
body.SnapToCell(
|
||||
0x01010001u,
|
||||
new Vector3(3f, 4f, 5f),
|
||||
new Vector3(3f, 4f, 5f));
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body);
|
||||
Quaternion orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, 0.75f);
|
||||
|
||||
RemoteTeleportPlacement.Apply(
|
||||
remote,
|
||||
body,
|
||||
new ResolveResult(
|
||||
new Vector3(210f, 220f, 12f),
|
||||
0x02020123u,
|
||||
IsOnGround: false),
|
||||
new Vector3(18f, 28f, 12f),
|
||||
orientation,
|
||||
17.5,
|
||||
previousContact: body.InContact,
|
||||
previousOnWalkable: body.OnWalkable);
|
||||
|
||||
Assert.Equal(new Vector3(210f, 220f, 12f), body.Position);
|
||||
Assert.Equal(0x02020123u, body.CellPosition.ObjCellId);
|
||||
Assert.Equal(new Vector3(18f, 28f, 12f), body.CellPosition.Frame.Origin);
|
||||
Assert.Equal(orientation, body.Orientation);
|
||||
Assert.Equal(17.5, body.LastUpdateTime);
|
||||
Assert.True(body.InWorld);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Apply_InstallsPlacementDerivedContactAndSynchronizesAirborneState()
|
||||
{
|
||||
var velocity = new Vector3(1f, 2f, 3f);
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Velocity = velocity,
|
||||
TransientState = TransientStateFlags.Active,
|
||||
State = PhysicsStateFlags.Gravity | PhysicsStateFlags.ReportCollisions,
|
||||
};
|
||||
var contactPlane = new Plane(Vector3.UnitZ, 0f);
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body)
|
||||
{
|
||||
Airborne = true,
|
||||
};
|
||||
|
||||
RemoteTeleportPlacement.Apply(
|
||||
remote,
|
||||
body,
|
||||
new ResolveResult(
|
||||
new Vector3(200f, 200f, 50f),
|
||||
0x02020001u,
|
||||
IsOnGround: true,
|
||||
InContact: true,
|
||||
OnWalkable: true,
|
||||
ContactPlane: contactPlane,
|
||||
ContactPlaneCellId: 0x02020001u),
|
||||
new Vector3(8f, 8f, 50f),
|
||||
Quaternion.Identity,
|
||||
9.0,
|
||||
previousContact: false,
|
||||
previousOnWalkable: false);
|
||||
|
||||
Assert.Equal(Vector3.Zero, body.Velocity);
|
||||
Assert.True(body.InContact);
|
||||
Assert.True(body.OnWalkable);
|
||||
Assert.True(body.ContactPlaneValid);
|
||||
Assert.Equal(contactPlane, body.ContactPlane);
|
||||
Assert.False(remote.Airborne);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Apply_PendingHydrationUsesPreservedSourceFlagsBeforeCollisionResponse()
|
||||
{
|
||||
var originalVelocity = new Vector3(-3f, 0f, 0f);
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Velocity = originalVelocity,
|
||||
State = PhysicsStateFlags.Gravity | PhysicsStateFlags.ReportCollisions,
|
||||
};
|
||||
// ParkPending deliberately clears these flags while the destination
|
||||
// landblock is absent. SetPositionInternal must still receive the
|
||||
// grounded source edge captured before parking.
|
||||
body.TransientState &= ~(TransientStateFlags.Contact | TransientStateFlags.OnWalkable);
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body)
|
||||
{
|
||||
Airborne = true,
|
||||
};
|
||||
|
||||
RemoteTeleportPlacement.Apply(
|
||||
remote,
|
||||
body,
|
||||
new ResolveResult(
|
||||
new Vector3(200f, 200f, 50f),
|
||||
0x02020001u,
|
||||
IsOnGround: true,
|
||||
CollisionNormalValid: true,
|
||||
CollisionNormal: Vector3.UnitX,
|
||||
InContact: true,
|
||||
OnWalkable: true,
|
||||
ContactPlane: new Plane(Vector3.UnitZ, 0f),
|
||||
ContactPlaneCellId: 0x02020001u),
|
||||
new Vector3(8f, 8f, 50f),
|
||||
Quaternion.Identity,
|
||||
9.0,
|
||||
previousContact: true,
|
||||
previousOnWalkable: true);
|
||||
|
||||
// Staying on walkable ground suppresses reflection. If the parked
|
||||
// false/false flags were used, the -X velocity would reflect to +X.
|
||||
Assert.Equal(originalVelocity, body.Velocity);
|
||||
Assert.True(body.OnWalkable);
|
||||
Assert.False(remote.Airborne);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Apply_PendingGroundToSteepContact_RestoresSourceWalkabilityForFirstAcceleration()
|
||||
{
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Omega = new Vector3(0f, 0f, 3f),
|
||||
State = PhysicsStateFlags.Gravity | PhysicsStateFlags.ReportCollisions,
|
||||
};
|
||||
// The unloaded-destination parking frame cleared both bits. Retail
|
||||
// restores the captured source OnWalkable bit through the first
|
||||
// calc_acceleration, which clears grounded angular drift, before
|
||||
// set_on_walkable installs the steep destination's false value.
|
||||
body.TransientState &= ~(TransientStateFlags.Contact | TransientStateFlags.OnWalkable);
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body);
|
||||
|
||||
RemoteTeleportPlacement.Apply(
|
||||
remote,
|
||||
body,
|
||||
new ResolveResult(
|
||||
new Vector3(200f, 200f, 50f),
|
||||
0x02020001u,
|
||||
IsOnGround: false,
|
||||
InContact: true,
|
||||
OnWalkable: false,
|
||||
ContactPlane: new Plane(Vector3.Normalize(new Vector3(1f, 0f, 0.2f)), 0f),
|
||||
ContactPlaneCellId: 0x02020001u),
|
||||
new Vector3(8f, 8f, 50f),
|
||||
Quaternion.Identity,
|
||||
9.0,
|
||||
previousContact: true,
|
||||
previousOnWalkable: true);
|
||||
|
||||
Assert.Equal(Vector3.Zero, body.Omega);
|
||||
Assert.True(body.InContact);
|
||||
Assert.False(body.OnWalkable);
|
||||
Assert.True(remote.Airborne);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Apply_RejectsMalformedPlacementWithoutMutatingBody()
|
||||
{
|
||||
var original = new Vector3(7f, 8f, 9f);
|
||||
var body = new PhysicsBody { Position = original };
|
||||
var remote = new AcDream.Runtime.Physics.RemoteMotion(body);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
RemoteTeleportPlacement.Apply(
|
||||
remote,
|
||||
body,
|
||||
new ResolveResult(
|
||||
new Vector3(float.NaN, 0f, 0f),
|
||||
0,
|
||||
IsOnGround: false,
|
||||
Ok: false),
|
||||
Vector3.Zero,
|
||||
Quaternion.Identity,
|
||||
double.NaN,
|
||||
previousContact: false,
|
||||
previousOnWalkable: false));
|
||||
|
||||
Assert.Equal(original, body.Position);
|
||||
Assert.Equal(0u, body.CellPosition.ObjCellId);
|
||||
}
|
||||
}
|
||||
|
|
@ -850,7 +850,6 @@ public sealed class CurrentGameRuntimeAdapterTests
|
|||
LiveLiveness = noop,
|
||||
RuntimeGeneration = _ => { },
|
||||
SessionIdentityPresentation = _ => { },
|
||||
RemoteTeleport = noop,
|
||||
NetworkEffects = noop,
|
||||
AnimationHookFrames = noop,
|
||||
LivePresentation = noop,
|
||||
|
|
|
|||
|
|
@ -263,12 +263,8 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
Assert.Equal(1, fixture.Presentation.DeferredShadowRestoreCount);
|
||||
|
||||
fixture.BeginDeferredTeleport();
|
||||
Assert.Equal(1, fixture.Teleport.PendingPlacementCount);
|
||||
Assert.Equal(1, fixture.Presentation.ActivePlacementCount);
|
||||
|
||||
fixture.LoadDestination();
|
||||
Assert.Equal(0, fixture.Teleport.PendingPlacementCount);
|
||||
Assert.Equal(0, fixture.Presentation.ActivePlacementCount);
|
||||
Assert.Equal(1, fixture.Presentation.DeferredShadowRestoreCount);
|
||||
|
||||
fixture.ApplyVisible();
|
||||
|
|
@ -293,10 +289,8 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
Assert.Equal(0, fixture.ParticleSink.ActiveBindingCount);
|
||||
Assert.Equal(0, fixture.Poses.Count);
|
||||
Assert.Equal(0, fixture.Engine.ShadowObjects.RetainedRegistrationCount);
|
||||
Assert.Equal(0, fixture.Teleport.PendingPlacementCount);
|
||||
Assert.Equal(0, fixture.Presentation.ReadyOwnerCount);
|
||||
Assert.Equal(0, fixture.Presentation.DeferredShadowRestoreCount);
|
||||
Assert.Equal(0, fixture.Presentation.ActivePlacementCount);
|
||||
Assert.Equal(0, fixture.Spatial.PendingLiveEntityCount);
|
||||
Assert.Equal(0, fixture.Spatial.PendingBucketCount);
|
||||
}
|
||||
|
|
@ -590,7 +584,6 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
|
||||
EntityEffectController? effects = null;
|
||||
LiveEntityPresentationController? presentation = null;
|
||||
RemoteTeleportController? teleport = null;
|
||||
Runtime = LiveEntityRuntimeFixture.Create(
|
||||
Spatial,
|
||||
new DelegateLiveEntityResourceLifecycle(
|
||||
|
|
@ -609,7 +602,6 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
{
|
||||
effects?.OnLiveEntityUnregistered(record);
|
||||
presentation?.Forget(record);
|
||||
teleport?.Forget(record);
|
||||
if (record.WorldEntity is { } entity)
|
||||
Engine.ShadowObjects.Deregister(entity.Id);
|
||||
});
|
||||
|
|
@ -669,25 +661,6 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
liveCenter: () => (1, 1));
|
||||
Assert.True(Presentation.OnLiveEntityReady(Guid));
|
||||
|
||||
Teleport = teleport = new RemoteTeleportController(
|
||||
Engine,
|
||||
Runtime,
|
||||
(_, _) => (0.48f, 1.835f),
|
||||
(position, _) => position,
|
||||
(_, _, _) => { },
|
||||
(guid, generation, defer) =>
|
||||
Presentation.CompleteAuthoritativePlacement(guid, generation, defer),
|
||||
(guid, generation) =>
|
||||
Presentation.BeginAuthoritativePlacement(guid, generation),
|
||||
resolvePlacement: (position, cell, _, _, _, _) => new ResolveResult(
|
||||
position,
|
||||
cell,
|
||||
IsOnGround: true,
|
||||
InContact: true,
|
||||
OnWalkable: true,
|
||||
ContactPlane: new Plane(Vector3.UnitZ, 0f),
|
||||
ContactPlaneCellId: cell));
|
||||
|
||||
Runtime.ProjectionVisibilityChanged += OnProjectionVisibilityChanged;
|
||||
_hookQueue = new AnimationHookFrameQueue(Router, Poses);
|
||||
}
|
||||
|
|
@ -703,7 +676,6 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
internal EntityEffectController Effects { get; }
|
||||
internal WorldEntity Entity { get; }
|
||||
internal LiveEntityPresentationController Presentation { get; }
|
||||
internal RemoteTeleportController Teleport { get; }
|
||||
internal List<uint> TypedScripts { get; } = [];
|
||||
internal int RecallHookCount { get; private set; }
|
||||
|
||||
|
|
@ -735,25 +707,27 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
Assert.True(Presentation.OnStateAccepted(Guid));
|
||||
}
|
||||
|
||||
// C4 route 4b-3 deleted the standalone RemoteTeleportController this
|
||||
// step used to drive. The scenario this fixture exists to cover —
|
||||
// Hidden/DeferredShadowRestore correctness across a landblock churn
|
||||
// while an entity is mid-teleport — does not depend on that
|
||||
// controller's own bookkeeping (BeginAuthoritativePlacement/
|
||||
// CompleteAuthoritativePlacement are confirmed dead: their only
|
||||
// production caller was the deleted presentation adapter). This
|
||||
// reproduces the same observable state the canonical teleport arm's
|
||||
// tail produces: the destination cell adopted and the body/entity
|
||||
// moved to the destination pose, still Hidden.
|
||||
internal void BeginDeferredTeleport()
|
||||
{
|
||||
_destinationCell = _currentCell == CellOne ? CellTwo : CellOne;
|
||||
Assert.False(Spatial.IsLoaded((_destinationCell & 0xFFFF0000u) | 0xFFFFu));
|
||||
Teleport.BeginPlacement(Guid, generation: 1);
|
||||
Assert.True(Runtime.RebucketLiveEntity(Guid, _destinationCell));
|
||||
RemoteTeleportController.Result result = Teleport.TryApply(
|
||||
_remote,
|
||||
Entity,
|
||||
new Vector3(Entity.Position.X + 3f, Entity.Position.Y, Entity.Position.Z),
|
||||
_destinationCell,
|
||||
Entity.Position,
|
||||
Quaternion.Identity,
|
||||
gameTime: _stateSequence,
|
||||
destinationProjectionVisible: false,
|
||||
generation: 1,
|
||||
positionSequence: 1);
|
||||
Assert.True(result.Applied);
|
||||
Assert.False(result.ContactResolved);
|
||||
var destination = new Vector3(
|
||||
Entity.Position.X + 3f, Entity.Position.Y, Entity.Position.Z);
|
||||
_remote.Body.Position = destination;
|
||||
_remote.CellId = _destinationCell;
|
||||
Entity.SetPosition(destination);
|
||||
Entity.ParentCellId = _destinationCell;
|
||||
}
|
||||
|
||||
internal void LoadDestination()
|
||||
|
|
@ -797,7 +771,6 @@ public sealed class LiveEntityLifecycleStressTests
|
|||
{
|
||||
Clear();
|
||||
Runtime.ProjectionVisibilityChanged -= OnProjectionVisibilityChanged;
|
||||
Teleport.Dispose();
|
||||
Presentation.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -596,51 +596,12 @@ public sealed class LiveEntityPresentationControllerTests
|
|||
controller.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActivePlacement_IsGenerationScopedAndClearsOnTeardownAndReset()
|
||||
{
|
||||
Fixture fixture = new(PhysicsStateFlags.ReportCollisions);
|
||||
Assert.True(fixture.Controller.OnLiveEntityReady(Fixture.Guid));
|
||||
Assert.True(fixture.Controller.BeginAuthoritativePlacement(Fixture.Guid, 1));
|
||||
Assert.True(fixture.Controller.HasActivePlacement(Fixture.Guid));
|
||||
Assert.True(fixture.Runtime.TryGetRecord(Fixture.Guid, out LiveEntityRecord oldRecord));
|
||||
|
||||
fixture.Controller.Forget(oldRecord);
|
||||
Assert.True(fixture.Runtime.UnregisterLiveEntity(
|
||||
new DeleteObject.Parsed(Fixture.Guid, 1),
|
||||
isLocalPlayer: false));
|
||||
Assert.False(fixture.Controller.HasActivePlacement(Fixture.Guid));
|
||||
|
||||
fixture.Runtime.RegisterLiveEntity(Fixture.Spawn(
|
||||
PhysicsStateFlags.ReportCollisions,
|
||||
instanceSequence: 2));
|
||||
fixture.Runtime.MaterializeLiveEntity(
|
||||
Fixture.Guid,
|
||||
0x01010001u,
|
||||
id => new WorldEntity
|
||||
{
|
||||
Id = id,
|
||||
ServerGuid = Fixture.Guid,
|
||||
SourceGfxObjOrSetupId = 0x02000001u,
|
||||
Position = new Vector3(10f, 10f, 5f),
|
||||
Rotation = Quaternion.Identity,
|
||||
MeshRefs = Array.Empty<MeshRef>(),
|
||||
});
|
||||
Assert.True(fixture.Controller.OnLiveEntityReady(Fixture.Guid));
|
||||
|
||||
Assert.False(fixture.Controller.CompleteAuthoritativePlacement(
|
||||
Fixture.Guid,
|
||||
generation: 1,
|
||||
deferShadowRestore: true));
|
||||
Assert.False(fixture.Controller.HasDeferredShadowRestore(Fixture.Guid));
|
||||
Assert.True(fixture.Controller.BeginAuthoritativePlacement(Fixture.Guid, 2));
|
||||
Assert.True(fixture.Controller.HasActivePlacement(Fixture.Guid));
|
||||
|
||||
fixture.Controller.Clear();
|
||||
|
||||
Assert.False(fixture.Controller.HasActivePlacement(Fixture.Guid));
|
||||
Assert.False(fixture.Controller.HasDeferredShadowRestore(Fixture.Guid));
|
||||
}
|
||||
// C4 route 4b-3: ActivePlacement_IsGenerationScopedAndClearsOnTeardownAndReset
|
||||
// deleted — BeginAuthoritativePlacement/CompleteAuthoritativePlacement/
|
||||
// HasActivePlacement/DeferShadowRestore and the backing
|
||||
// _activePlacementOwners set are dead (their only production caller was
|
||||
// the deleted RemoteTeleportPlacementPresentation); see
|
||||
// docs/research/2026-08-04-c4-route-4b-3-contract.md's deletion inventory.
|
||||
|
||||
private sealed class Fixture
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1785,11 +1785,25 @@ public sealed class LiveEntityRuntimeTests
|
|||
out AcceptedPhysicsTimestamps timestamps));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
Assert.False(timestamps.TeleportAdvanced);
|
||||
Assert.True(timestamps.TeleportHookRequired);
|
||||
// C4 route 4b-3 (D1): the pickup left the record cell-less
|
||||
// (FullCellId == 0, unwield-to-3D), and TryApplyPosition measures
|
||||
// that PRE-merge value — the classifier's remote cell-less predicate
|
||||
// reads this, not the post-merge canonical.FullCellId.
|
||||
Assert.Equal(0u, timestamps.PreMergeCommittedCellId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (D1): before this slice, losing spatial visibility alone
|
||||
/// (no cell-less body, no fresh TELEPORT_TS) flagged
|
||||
/// <c>projectionRequiresTeleportHook</c> — a presentation predicate with
|
||||
/// no retail analogue (the deleted D1 evidence-chain arm). This is the
|
||||
/// regression guard: a record that is still resident at a real cell
|
||||
/// (materialized at 0x01010001u) but has lost spatial projection reports
|
||||
/// its HONEST pre-merge committed cell, not a fabricated cell-less
|
||||
/// signal — visibility is presentation-only now.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void PositionFromPendingProjection_RequiresTeleportHookWithEqualTeleportStamp()
|
||||
public void PositionFromPendingProjection_ReportsTheHonestPreMergeCellNotVisibility()
|
||||
{
|
||||
const uint guid = 0x70000044u;
|
||||
var spatial = new GpuWorldState();
|
||||
|
|
@ -1824,7 +1838,7 @@ public sealed class LiveEntityRuntimeTests
|
|||
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
Assert.False(timestamps.TeleportAdvanced);
|
||||
Assert.True(timestamps.TeleportHookRequired);
|
||||
Assert.Equal(0x01010001u, timestamps.PreMergeCommittedCellId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -122,9 +122,7 @@ public sealed class RuntimeEntityOwnershipTests
|
|||
AssertExactKeyFields(
|
||||
typeof(LiveEntityPresentationController),
|
||||
"_readyOwners",
|
||||
"_suspendedShadowOwners",
|
||||
"_activePlacementOwners");
|
||||
AssertExactKeyFields(typeof(RemoteTeleportController), "_pending");
|
||||
"_suspendedShadowOwners");
|
||||
AssertExactKeyFields(typeof(LiveRenderProjectionJournal), "_byKey");
|
||||
AssertExactKeyFields(
|
||||
typeof(EntityEffectController),
|
||||
|
|
@ -185,7 +183,6 @@ public sealed class RuntimeEntityOwnershipTests
|
|||
[
|
||||
typeof(LiveEntityProjectionStore),
|
||||
typeof(LiveEntityPresentationController),
|
||||
typeof(RemoteTeleportController),
|
||||
typeof(LiveRenderProjectionJournal),
|
||||
typeof(LiveEntityLightController),
|
||||
typeof(EquippedChildRenderController),
|
||||
|
|
|
|||
|
|
@ -911,8 +911,6 @@ public sealed class UpdateFrameOrchestratorTests
|
|||
typeof(LiveSessionLocalPhysicsTimestampPublisher),
|
||||
typeof(AcDream.App.Physics.LiveEntityNetworkUpdateController),
|
||||
typeof(AcDream.App.Rendering.LiveEntityPartArrayLifecycle),
|
||||
typeof(AcDream.App.Physics.RemoteShadowPlacementSynchronizer),
|
||||
typeof(AcDream.App.Physics.RemoteTeleportPlacementPresentation),
|
||||
typeof(AcDream.App.Net.LiveEntitySessionController),
|
||||
];
|
||||
foreach (Type owner in typedProductionOwners)
|
||||
|
|
@ -965,8 +963,11 @@ public sealed class UpdateFrameOrchestratorTests
|
|||
StringComparison.Ordinal);
|
||||
Assert.Contains("d.WorldOrigin.GetCenter", livePresentation,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains("d.WorldOrigin.CellLocalForSeed", livePresentation,
|
||||
StringComparison.Ordinal);
|
||||
// C4 route 4b-3 deleted the sole consumer of
|
||||
// d.WorldOrigin.CellLocalForSeed in this file — the standalone
|
||||
// RemoteTeleportController construction. LiveWorldOriginState.
|
||||
// CellLocalForSeed itself is not deleted (LocalPlayerTeleportController
|
||||
// still uses it).
|
||||
Assert.DoesNotContain("CreateLiveSessionEventRouter", source,
|
||||
StringComparison.Ordinal);
|
||||
Assert.Contains("_world.EntitySession.CreateSink()", sessionRuntime,
|
||||
|
|
|
|||
|
|
@ -508,7 +508,6 @@ public sealed class HeadlessSessionHostTests
|
|||
isLocalPlayer: true,
|
||||
forcePositionRotation: Quaternion.Identity,
|
||||
currentLocalVelocity: controller.BodyVelocity,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -1239,7 +1239,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 15f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, false, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1286,7 +1286,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 1, forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1344,7 +1344,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f, isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1391,7 +1391,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 15f,
|
||||
isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, false, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1432,7 +1432,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f,
|
||||
isGrounded: false);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1468,7 +1468,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1558,7 +1558,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 1, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, false, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.ForcePosition, disposition);
|
||||
|
||||
|
|
@ -1626,7 +1626,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -1727,7 +1727,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -3940,7 +3940,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 1, forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null, out _, out _, out _));
|
||||
update, isLocalPlayer: true, null, null, null, out _, out _, out _));
|
||||
|
||||
RuntimeInitialCreateExecutionStatus status = lifetime.InitialCreateExecution.Execute(
|
||||
canonical, lease.Token, NoContact, out _);
|
||||
|
|
@ -4007,7 +4007,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 1, forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null, out _, out _, out _));
|
||||
update, isLocalPlayer: true, null, null, null, out _, out _, out _));
|
||||
|
||||
RuntimeInitialCreateExecutionStatus status = lifetime.InitialCreateExecution.Execute(
|
||||
canonical, lease.Token, NoContact, out _);
|
||||
|
|
@ -4072,7 +4072,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 1, forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null, out _, out _, out _));
|
||||
update, isLocalPlayer: true, null, null, null, out _, out _, out _));
|
||||
|
||||
RuntimeInitialCreateExecutionStatus status = lifetime.InitialCreateExecution.Execute(
|
||||
canonical, lease.Token, NoContact, out _);
|
||||
|
|
@ -4149,7 +4149,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, positionSequence: 2, teleportSequence: 0, forcePositionSequence: 0, positionX: 25f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: false, null, null, false, null,
|
||||
update, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -4289,7 +4289,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 1,
|
||||
forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -4392,7 +4392,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 1,
|
||||
forcePositionSequence: 0, positionX: 40f);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, true, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -4750,7 +4750,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 0,
|
||||
forcePositionSequence: 0, positionX: 15f, isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, false, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -4806,7 +4806,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
secondGuid, positionSequence: 2, teleportSequence: 0,
|
||||
forcePositionSequence: 0, positionX: 16f, isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
secondUpdate, isLocalPlayer: true, null, null, false, null,
|
||||
secondUpdate, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition secondDisposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, secondDisposition);
|
||||
RuntimeInitialCreateExecutionReceipt secondReceipt = RunToCompletion(
|
||||
|
|
@ -4847,7 +4847,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
guid, positionSequence: 2, teleportSequence: 0,
|
||||
forcePositionSequence: 0, positionX: 15f, isGrounded: true);
|
||||
Assert.True(unbound.TryApplyPosition(
|
||||
update, isLocalPlayer: true, null, null, false, null,
|
||||
update, isLocalPlayer: true, null, null, null,
|
||||
out PositionTimestampDisposition disposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
|
||||
|
|
@ -4896,7 +4896,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
nearGuid, positionSequence: 2, teleportSequence: 0,
|
||||
forcePositionSequence: 0, positionX: 25f, isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
nearUpdate, isLocalPlayer: false, null, null, false, null,
|
||||
nearUpdate, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition nearDisposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, nearDisposition);
|
||||
var farStruct = new RuntimeInitialCreateExecutionInputs(
|
||||
|
|
@ -4936,7 +4936,7 @@ public sealed class RuntimeInitialCreateContinuationExecutorTests
|
|||
farGuid, positionSequence: 2, teleportSequence: 0,
|
||||
forcePositionSequence: 0, positionX: 25f, isGrounded: true);
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
farUpdate, isLocalPlayer: false, null, null, false, null,
|
||||
farUpdate, isLocalPlayer: false, null, null, null,
|
||||
out PositionTimestampDisposition farDisposition, out _, out _));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, farDisposition);
|
||||
|
||||
|
|
|
|||
|
|
@ -532,7 +532,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: _ => callbacks++,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
@ -1126,7 +1125,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
teleportSequence: 0,
|
||||
forcePositionSequence: 0,
|
||||
positionX: 20f,
|
||||
projectionRequiresTeleportHook: false,
|
||||
() => callbacks++);
|
||||
ApplyQueuedPosition(
|
||||
lifetime,
|
||||
|
|
@ -1135,7 +1133,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
teleportSequence: 1,
|
||||
forcePositionSequence: 0,
|
||||
positionX: 30f,
|
||||
projectionRequiresTeleportHook: true,
|
||||
() => callbacks++);
|
||||
ApplyQueuedPosition(
|
||||
lifetime,
|
||||
|
|
@ -1144,7 +1141,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
teleportSequence: 2,
|
||||
forcePositionSequence: 0,
|
||||
positionX: 40f,
|
||||
projectionRequiresTeleportHook: false,
|
||||
() => callbacks++);
|
||||
|
||||
Assert.True(lifetime.TryGetInitialCreateResidence(
|
||||
|
|
@ -1167,10 +1163,15 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
Assert.Equal([(ushort)0, (ushort)1, (ushort)2],
|
||||
retained.Continuations.Select(
|
||||
static item => PositionAction(item).Position!.Value.TeleportSequence));
|
||||
Assert.False(PositionAction(retained.Continuations[0])
|
||||
.AcceptedTimestamps.TeleportHookRequired);
|
||||
Assert.False(PositionAction(retained.Continuations[1])
|
||||
.AcceptedTimestamps.TeleportHookRequired);
|
||||
// C4 route 4b-3 (D1): the deferred initial-residence FIFO
|
||||
// (RuntimeEntities.TryAcceptDeferredPosition) never runs
|
||||
// TryApplyPosition's pre-merge-cell measurement — that is the direct
|
||||
// accepted-Position path's own bookkeeping. A queued continuation's
|
||||
// timestamps therefore carry the honest "not measured here" value.
|
||||
Assert.Null(PositionAction(retained.Continuations[0])
|
||||
.AcceptedTimestamps.PreMergeCommittedCellId);
|
||||
Assert.Null(PositionAction(retained.Continuations[1])
|
||||
.AcceptedTimestamps.PreMergeCommittedCellId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -1199,7 +1200,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
@ -1219,7 +1219,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
teleportSequence: 0,
|
||||
forcePositionSequence: 0,
|
||||
positionX: 25f,
|
||||
projectionRequiresTeleportHook: false,
|
||||
callback: null,
|
||||
isLocalPlayer: false);
|
||||
Assert.True(lifetime.TryGetInitialCreateResidence(
|
||||
|
|
@ -1374,7 +1373,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
teleportSequence: 1,
|
||||
forcePositionSequence: 0,
|
||||
positionX: 55f,
|
||||
projectionRequiresTeleportHook: true,
|
||||
callback: null);
|
||||
Assert.Equal(
|
||||
RuntimeInitialCreateResidenceCompletionStatus.Completed,
|
||||
|
|
@ -1555,7 +1553,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: true,
|
||||
acknowledgeProjection: _ => callbacks++,
|
||||
out _,
|
||||
out _,
|
||||
|
|
@ -2557,7 +2554,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
ushort teleportSequence,
|
||||
ushort forcePositionSequence,
|
||||
float positionX,
|
||||
bool projectionRequiresTeleportHook,
|
||||
Action? callback,
|
||||
bool isLocalPlayer = true)
|
||||
{
|
||||
|
|
@ -2572,7 +2568,6 @@ public sealed class RuntimeInitialCreateResidenceStateTests
|
|||
isLocalPlayer,
|
||||
forcePositionRotation: Quaternion.Identity,
|
||||
currentLocalVelocity: new Vector3(1f, 2f, 3f),
|
||||
projectionRequiresTeleportHook,
|
||||
acknowledgeProjection: callback is null
|
||||
? null
|
||||
: _ => callback(),
|
||||
|
|
|
|||
|
|
@ -478,7 +478,6 @@ public sealed class RuntimeRemoteFirstEntryStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,242 @@
|
|||
using AcDream.Core.Net;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Runtime.Entities;
|
||||
using AcDream.Runtime.Physics;
|
||||
|
||||
namespace AcDream.Runtime.Tests.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-3 (D1): the load-bearing evidence chain for the whole slice —
|
||||
/// <see cref="RuntimeEntityObjectLifetime.TryApplyPosition"/> measures the
|
||||
/// PRE-merge committed cell (<c>beforeCell</c>/<c>wasCellless</c>) before
|
||||
/// <c>RefreshSnapshot</c> stamps the accepted wire cell onto the canonical
|
||||
/// record, and <see cref="RuntimeEntityObjectLifetime.ClassifyRemoteAcceptedPosition"/>
|
||||
/// must read THAT value, not the post-merge <c>canonical.FullCellId</c> every
|
||||
/// other classifier caller reads. Reverting the fix (feeding the classifier
|
||||
/// <c>canonical.FullCellId</c> after the merge instead of the pre-merge value)
|
||||
/// must fail <see cref="CompanionTest_NonzeroPreMergeCellWithNoTeleportAdvance_DoesNotClassifySetPosition"/>
|
||||
/// — that is the ONE test that discriminates the fix from the shipped dead
|
||||
/// predicate, because both predicates agree whenever the pre-merge cell truly
|
||||
/// was zero.
|
||||
/// </summary>
|
||||
public sealed class RuntimeRemoteTeleportClassificationTests
|
||||
{
|
||||
private const uint Cell = 0x0101FFFFu;
|
||||
private const uint OtherCell = 0x0102FFFFu;
|
||||
|
||||
[Fact]
|
||||
public void CellLessRecord_ClassifiesSetPosition_EvenWithoutATeleportAdvance()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime();
|
||||
lifetime.BindEventContext(static () => new RuntimeGenerationToken(1), static () => 1UL);
|
||||
const uint guid = 0x70005001u;
|
||||
RuntimeEntityRecord canonical =
|
||||
lifetime.RegisterEntity(Spawn(guid, Cell, instance: 1)).Canonical!;
|
||||
Assert.Equal(Cell, canonical.FullCellId);
|
||||
|
||||
// The unwield-to-3D shape (AP-137's citation): a canonical withdrawal
|
||||
// zeroes the committed cell without any wire packet.
|
||||
lifetime.Entities.SetFullCell(canonical, 0u, 0u);
|
||||
Assert.Equal(0u, canonical.FullCellId);
|
||||
|
||||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, OtherCell, positionSequence: 2, teleportSequence: 0);
|
||||
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update,
|
||||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
out AcceptedPhysicsTimestamps timestamps));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
// The measured pre-merge value is the honest 0 — not a fabrication,
|
||||
// and not re-read after the merge (which would already show OtherCell).
|
||||
Assert.Equal(0u, timestamps.PreMergeCommittedCellId);
|
||||
Assert.False(timestamps.TeleportAdvanced);
|
||||
|
||||
Assert.True(lifetime.Entities.TryGetActive(guid, out RuntimeEntityRecord after));
|
||||
RuntimeAuthoritativePositionRoute? route = lifetime.ClassifyRemoteAcceptedPosition(
|
||||
after, update, disposition, timestamps, playerDistance: 10f);
|
||||
|
||||
Assert.NotNull(route);
|
||||
Assert.Equal(
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
route!.Value.Disposition);
|
||||
Assert.True(
|
||||
(route.Value.SetPositionFlags & PhysicsSetPositionFlags.Teleport) != 0);
|
||||
Assert.True(RuntimeRemoteTeleportPosition.OwnsTeleportPlacement(route));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The discriminator (contract's test plan item 4, companion half): the
|
||||
/// SAME shape but WITHOUT the cell-less reset and WITHOUT a TELEPORT_TS
|
||||
/// advance must NOT classify <c>SetPosition</c>. Under the shipped dead
|
||||
/// predicate (reading <c>canonical.FullCellId</c> AFTER the merge) this
|
||||
/// would ALSO pass, because the merge always stamps a nonzero wire cell —
|
||||
/// the predicate was unreachable, not merely conservative. This test only
|
||||
/// distinguishes the fix once <see cref="CellLessRecord_ClassifiesSetPosition_EvenWithoutATeleportAdvance"/>
|
||||
/// establishes the positive case is reachable at all.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void CompanionTest_NonzeroPreMergeCellWithNoTeleportAdvance_DoesNotClassifySetPosition()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime();
|
||||
lifetime.BindEventContext(static () => new RuntimeGenerationToken(1), static () => 1UL);
|
||||
const uint guid = 0x70005002u;
|
||||
RuntimeEntityRecord canonical =
|
||||
lifetime.RegisterEntity(Spawn(guid, Cell, instance: 1)).Canonical!;
|
||||
Assert.Equal(Cell, canonical.FullCellId);
|
||||
// Deliberately NO SetFullCell(0, 0) — the record stays resident.
|
||||
|
||||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, OtherCell, positionSequence: 2, teleportSequence: 0);
|
||||
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update,
|
||||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
out AcceptedPhysicsTimestamps timestamps));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
// Honest pre-merge value: still resident at the ORIGINAL cell, not
|
||||
// the just-merged wire cell (which would be OtherCell) and not 0.
|
||||
Assert.Equal(Cell, timestamps.PreMergeCommittedCellId);
|
||||
Assert.False(timestamps.TeleportAdvanced);
|
||||
|
||||
Assert.True(lifetime.Entities.TryGetActive(guid, out RuntimeEntityRecord after));
|
||||
RuntimeAuthoritativePositionRoute? route = lifetime.ClassifyRemoteAcceptedPosition(
|
||||
after, update, disposition, timestamps, playerDistance: 10f);
|
||||
|
||||
Assert.NotNull(route);
|
||||
Assert.NotEqual(
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
route!.Value.Disposition);
|
||||
Assert.False(RuntimeRemoteTeleportPosition.OwnsTeleportPlacement(route));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A fresh TELEPORT_TS still classifies <c>SetPosition</c> even when the
|
||||
/// pre-merge cell was resident — the OTHER half of retail's predicate
|
||||
/// (<c>newer_event(TELEPORT_TS) || this_1->cell == 0</c>), unaffected by
|
||||
/// D1's plumbing change.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void FreshTeleportTimestamp_ClassifiesSetPosition_WithAResidentPreMergeCell()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime();
|
||||
lifetime.BindEventContext(static () => new RuntimeGenerationToken(1), static () => 1UL);
|
||||
const uint guid = 0x70005003u;
|
||||
RuntimeEntityRecord canonical =
|
||||
lifetime.RegisterEntity(Spawn(guid, Cell, instance: 1)).Canonical!;
|
||||
Assert.Equal(Cell, canonical.FullCellId);
|
||||
|
||||
WorldSession.EntityPositionUpdate update = PositionUpdate(
|
||||
guid, OtherCell, positionSequence: 2, teleportSequence: 5);
|
||||
|
||||
Assert.True(lifetime.TryApplyPosition(
|
||||
update,
|
||||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
out AcceptedPhysicsTimestamps timestamps));
|
||||
Assert.Equal(PositionTimestampDisposition.Apply, disposition);
|
||||
Assert.Equal(Cell, timestamps.PreMergeCommittedCellId);
|
||||
Assert.True(timestamps.TeleportAdvanced);
|
||||
|
||||
Assert.True(lifetime.Entities.TryGetActive(guid, out RuntimeEntityRecord after));
|
||||
RuntimeAuthoritativePositionRoute? route = lifetime.ClassifyRemoteAcceptedPosition(
|
||||
after, update, disposition, timestamps, playerDistance: 10f);
|
||||
|
||||
Assert.NotNull(route);
|
||||
Assert.Equal(
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
route!.Value.Disposition);
|
||||
Assert.True(RuntimeRemoteTeleportPosition.OwnsTeleportPlacement(route));
|
||||
}
|
||||
|
||||
private static WorldSession.EntityPositionUpdate PositionUpdate(
|
||||
uint guid,
|
||||
uint cellId,
|
||||
ushort positionSequence,
|
||||
ushort teleportSequence) =>
|
||||
new(
|
||||
guid,
|
||||
new CreateObject.ServerPosition(
|
||||
cellId, 12f, 14f, 7f, 1f, 0f, 0f, 0f),
|
||||
Velocity: null,
|
||||
PlacementId: null,
|
||||
IsGrounded: true,
|
||||
InstanceSequence: 1,
|
||||
PositionSequence: positionSequence,
|
||||
TeleportSequence: teleportSequence,
|
||||
ForcePositionSequence: 0);
|
||||
|
||||
private static WorldSession.EntitySpawn Spawn(
|
||||
uint guid,
|
||||
uint cellId,
|
||||
ushort instance)
|
||||
{
|
||||
var position = new CreateObject.ServerPosition(
|
||||
cellId, 10f, 20f, 5f, 1f, 0f, 0f, 0f);
|
||||
var timestamps = new PhysicsTimestamps(
|
||||
Position: 1,
|
||||
Movement: 1,
|
||||
State: 1,
|
||||
Vector: 1,
|
||||
Teleport: 0,
|
||||
ServerControlledMove: 1,
|
||||
ForcePosition: 0,
|
||||
ObjDesc: 1,
|
||||
Instance: instance);
|
||||
var physics = new PhysicsSpawnData(
|
||||
RawState: 0x408u,
|
||||
Position: position,
|
||||
Movement: null,
|
||||
AnimationFrame: null,
|
||||
SetupTableId: 0x02000001u,
|
||||
MotionTableId: 0x09000001u,
|
||||
SoundTableId: null,
|
||||
PhysicsScriptTableId: null,
|
||||
Parent: null,
|
||||
Children: null,
|
||||
Scale: null,
|
||||
Friction: null,
|
||||
Elasticity: null,
|
||||
Translucency: null,
|
||||
Velocity: null,
|
||||
Acceleration: null,
|
||||
AngularVelocity: null,
|
||||
DefaultScriptType: null,
|
||||
DefaultScriptIntensity: null,
|
||||
Timestamps: timestamps);
|
||||
return new WorldSession.EntitySpawn(
|
||||
guid,
|
||||
position,
|
||||
0x02000001u,
|
||||
Array.Empty<CreateObject.AnimPartChange>(),
|
||||
Array.Empty<CreateObject.TextureChange>(),
|
||||
Array.Empty<CreateObject.SubPaletteSwap>(),
|
||||
null,
|
||||
null,
|
||||
"remote-teleport-classification",
|
||||
null,
|
||||
null,
|
||||
0x09000001u,
|
||||
PhysicsState: 0x408u,
|
||||
InstanceSequence: instance,
|
||||
MovementSequence: 1,
|
||||
ServerControlSequence: 1,
|
||||
PositionSequence: 1,
|
||||
Physics: physics);
|
||||
}
|
||||
}
|
||||
|
|
@ -241,7 +241,6 @@ public sealed class RuntimeLocalPlayerFirstEntryStateTests
|
|||
isLocalPlayer: true,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: true,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -1139,7 +1139,6 @@ public sealed class RuntimeLocalPlayerPhysicsPublicationStateTests
|
|||
isLocalPlayer: true,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out _,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -207,13 +207,11 @@ public sealed class RuntimeRemoteFarSnapPositionTests
|
|||
RuntimeRemoteFarSnapPosition.ResolveArm(
|
||||
Classify(hasContact: true, playerDistance: 200f)));
|
||||
|
||||
// The acdream-only leftovers, all four shapes. This is the stated
|
||||
// policy: they are NOT far. Reading "not Interpolate" as "far" is
|
||||
// route 4a's own review finding, one level up.
|
||||
Assert.Equal(
|
||||
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp,
|
||||
RuntimeRemoteFarSnapPosition.ResolveArm(
|
||||
Classify(hasContact: true, playerDistance: 10f, committedCellId: 0u)));
|
||||
// The acdream-only leftovers left in THIS arm after C4 route 4b-3
|
||||
// moved the cell-less/fresh-teleport shapes onto the teleport arm
|
||||
// (RuntimeRemoteTeleportPosition.OwnsTeleportPlacement — see that
|
||||
// class's own tests). What remains: no classification at all, and
|
||||
// the two rejections.
|
||||
Assert.Equal(
|
||||
RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp,
|
||||
RuntimeRemoteFarSnapPosition.ResolveArm(
|
||||
|
|
@ -230,31 +228,6 @@ public sealed class RuntimeRemoteFarSnapPositionTests
|
|||
RuntimeRemoteFarSnapPosition.ResolveArm(null));
|
||||
}
|
||||
|
||||
// ── The single ConstrainTo site's gate ──────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void OwnsAfterOperationConstraint_CoversTheThreeArmsThatRunAnOperation()
|
||||
{
|
||||
// Retail arms @0x00454272 for every nonzero MoveOrTeleport return.
|
||||
// The airborne no-op returns 0 @0x0051636D, so it is excluded — and
|
||||
// that exclusion is route 4a's, carried forward unchanged.
|
||||
Assert.True(RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
Classify(hasContact: true, playerDistance: 10f)));
|
||||
Assert.True(RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
Classify(hasContact: true, playerDistance: 200f)));
|
||||
Assert.True(RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
Classify(hasContact: false, playerDistance: 10f)));
|
||||
|
||||
// The leftovers still arm through the App's legacy pre-operation
|
||||
// site; claiming them here would double-arm them.
|
||||
Assert.False(RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
Classify(hasContact: true, playerDistance: 10f, committedCellId: 0u)));
|
||||
Assert.False(RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(
|
||||
Classify(hasContact: true, playerDistance: float.NaN)));
|
||||
Assert.False(
|
||||
RuntimeRemoteFarSnapPosition.OwnsAfterOperationConstraint(null));
|
||||
}
|
||||
|
||||
private static RuntimeAuthoritativePositionAuthority Authority(
|
||||
PositionTimestampDisposition disposition,
|
||||
ushort previousTeleport,
|
||||
|
|
|
|||
|
|
@ -291,83 +291,45 @@ public sealed class RuntimeRemoteSteadyStatePositionTests
|
|||
Assert.Equal(0f, constraint.ConstraintPosOffset, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryArmConstraintAfterOperation_ArmsForTheNearInterpolateBranch()
|
||||
{
|
||||
(RemoteMotion remote, EntityPhysicsHost host) = MakeRemoteWithHost(
|
||||
new Vector3(1f, 2f, 3f));
|
||||
|
||||
Assert.True(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
Classify(hasContact: true, playerDistance: 10f),
|
||||
remote));
|
||||
Assert.True(host.PositionManager.Constraint?.IsConstrained);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryArmConstraintAfterOperation_SkipsTheAirborneNoOperation()
|
||||
{
|
||||
// MoveOrTeleport returns 0 for arg4 == 0, so HandleReceivedPosition's
|
||||
// `if (MoveOrTeleport(...) != 0)` never reaches ConstrainTo.
|
||||
(RemoteMotion remote, EntityPhysicsHost host) = MakeRemoteWithHost(
|
||||
new Vector3(1f, 2f, 3f));
|
||||
|
||||
Assert.False(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
Classify(hasContact: false, playerDistance: 10f),
|
||||
remote));
|
||||
Assert.Null(host.PositionManager.Constraint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C4 route 4b-2: the far branch moved onto the post-operation arm with
|
||||
/// route 4a's two. Retail's `MoveOrTeleport` returns 1 @0x005163E8 there,
|
||||
/// so `HandleReceivedPosition`'s single `ConstrainTo` @0x00454272 runs —
|
||||
/// and the App's legacy PRE-operation call site now reads the same
|
||||
/// predicate and skips it, so it is armed exactly once.
|
||||
/// C4 route 4b-3 (D4): the complete arm-count partition, proof obligation
|
||||
/// 3 — one assertion per row of the contract's partition table, on the
|
||||
/// OBSERVABLE (whether <c>ConstrainTo</c> actually armed), not the code
|
||||
/// shape. <see cref="RuntimeRemoteAcceptedPositionArm.TeleportPlacement"/>
|
||||
/// and <see cref="RuntimeRemoteAcceptedPositionArm.FarSnapPlacement"/>
|
||||
/// arm unconditionally (retail discards the placement error and returns
|
||||
/// 1 either way, @0x00516438/@0x005163E8);
|
||||
/// <see cref="RuntimeRemoteAcceptedPositionArm.UnroutedCatchUp"/> arms
|
||||
/// too — it is only ever reached here when the caller's free-flight
|
||||
/// carve-out has already confirmed the body is in contact; only
|
||||
/// <see cref="RuntimeRemoteAcceptedPositionArm.AirborneNoOperation"/>
|
||||
/// does not (retail's <c>arg4 == 0</c> branch returns 0 @0x0051636D).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TryArmConstraintAfterOperation_ArmsForTheFarSnapBranch()
|
||||
[Theory]
|
||||
[InlineData("TeleportPlacement", true)]
|
||||
[InlineData("FarSnapPlacement", true)]
|
||||
[InlineData("NearInterpolate", true)]
|
||||
[InlineData("UnroutedCatchUp", true)]
|
||||
[InlineData("AirborneNoOperation", false)]
|
||||
public void TryArmConstraintAfterOperation_MatchesTheCompletePartition(
|
||||
string armName,
|
||||
bool expectedArmed)
|
||||
{
|
||||
// RuntimeRemoteAcceptedPositionArm is internal; xUnit's [InlineData]
|
||||
// requires public-visible argument types, so the arm travels as its
|
||||
// name and is parsed back here.
|
||||
var arm = (RuntimeRemoteAcceptedPositionArm)Enum.Parse(
|
||||
typeof(RuntimeRemoteAcceptedPositionArm), armName);
|
||||
(RemoteMotion remote, EntityPhysicsHost host) = MakeRemoteWithHost(
|
||||
new Vector3(1f, 2f, 3f));
|
||||
|
||||
RuntimeAuthoritativePositionRoute far =
|
||||
Classify(hasContact: true, playerDistance: 200f);
|
||||
bool armed = RuntimeRemoteSteadyStatePosition
|
||||
.TryArmConstraintAfterOperation(arm, remote);
|
||||
|
||||
Assert.Equal(expectedArmed, armed);
|
||||
Assert.Equal(
|
||||
RuntimeAuthoritativePositionDisposition.SetPositionSimple,
|
||||
far.Disposition);
|
||||
|
||||
Assert.True(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
far,
|
||||
remote));
|
||||
Assert.True(host.PositionManager.Constraint?.IsConstrained);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryArmConstraintAfterOperation_SkipsClassificationsNoArmOwns()
|
||||
{
|
||||
// The cell-less half, the two rejections, and "no classification at
|
||||
// all" still arm their leash through the untouched legacy
|
||||
// PRE-operation call site, not through here. Arming here too would
|
||||
// double-arm them.
|
||||
(RemoteMotion remote, EntityPhysicsHost host) = MakeRemoteWithHost(
|
||||
new Vector3(1f, 2f, 3f));
|
||||
|
||||
Assert.False(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
Classify(hasContact: true, playerDistance: 10f, committedCellId: 0u),
|
||||
remote));
|
||||
Assert.False(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
Classify(
|
||||
hasContact: true,
|
||||
playerDistance: 10f,
|
||||
disposition: PositionTimestampDisposition.Rejected),
|
||||
remote));
|
||||
Assert.False(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
Classify(hasContact: true, playerDistance: float.NaN),
|
||||
remote));
|
||||
Assert.False(RuntimeRemoteSteadyStatePosition.TryArmConstraintAfterOperation(
|
||||
null,
|
||||
remote));
|
||||
Assert.Null(host.PositionManager.Constraint);
|
||||
expectedArmed,
|
||||
host.PositionManager.Constraint?.IsConstrained == true);
|
||||
}
|
||||
|
||||
private static RuntimeAuthoritativePositionRoute Classify(
|
||||
|
|
|
|||
|
|
@ -1772,7 +1772,6 @@ public sealed class RuntimeSetPositionStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out _,
|
||||
out _,
|
||||
|
|
@ -3194,7 +3193,6 @@ public sealed class RuntimeSetPositionStateTests
|
|||
isLocalPlayer: false,
|
||||
forcePositionRotation: null,
|
||||
currentLocalVelocity: null,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out _,
|
||||
out _,
|
||||
|
|
|
|||
|
|
@ -1237,7 +1237,6 @@ public sealed class RuntimeAcceptedPositionDriveControllerTests
|
|||
isLocalPlayer: true,
|
||||
forcePositionRotation: controller.BodyOrientation,
|
||||
currentLocalVelocity: controller.BodyVelocity,
|
||||
projectionRequiresTeleportHook: false,
|
||||
acknowledgeProjection: null,
|
||||
out PositionTimestampDisposition disposition,
|
||||
out _,
|
||||
|
|
@ -1306,7 +1305,6 @@ public sealed class RuntimeAcceptedPositionDriveControllerTests
|
|||
Teleport: teleport,
|
||||
ForcePosition: 1,
|
||||
TeleportAdvanced: false,
|
||||
TeleportHookRequired: false,
|
||||
PreviousTeleport: teleport);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1935,6 +1935,327 @@ public sealed class RuntimeRemotePlacementDriveControllerTests
|
|||
}
|
||||
}
|
||||
|
||||
// ── C4 route 4b-3: the teleport/cell-less arm ───────────────────────────
|
||||
// TryExecuteAcceptedRemotePosition/SubmitAndResolve's own mechanics
|
||||
// (commit/park/reject dispatch, currency, ledger convergence) are already
|
||||
// exhaustively proven above for SetPosition-disposition routes — several
|
||||
// far-snap tests already construct SetPosition routes because
|
||||
// TryExecuteAcceptedRemotePosition is disposition-agnostic. What is new
|
||||
// here is ApplyAcceptedRemoteTeleport's OWN behaviour: the route guard,
|
||||
// the store_position fallback wired for the teleport disposition
|
||||
// specifically, and (D3) that it does NOT clear the interpolation queue
|
||||
// itself — unlike the far arm, retail's clear for this branch lives
|
||||
// inside teleport_hook, not in MoveOrTeleport.
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors <see cref="Committed_WhenDestinationIsWithinServiceWindowAndCollisionGenerationCommitted"/>
|
||||
/// through the teleport arm specifically.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_Committed_PlacesFromCanonicalDestination()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003040u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
var window = new FakeServiceWindow();
|
||||
window.Allow(DestinationLandblock);
|
||||
RuntimeRemotePlacementDriveController drive = CreateDrive(lifetime, window);
|
||||
|
||||
var destination = new Vector3(12f, 14f, SpawnHeight);
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
destination);
|
||||
|
||||
RuntimeRemotePlacementExecutionStatus status =
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, route);
|
||||
|
||||
Assert.Equal(RuntimeRemotePlacementExecutionStatus.Committed, status);
|
||||
Assert.Equal(destination + new Vector3(192f, 0f, 0f), body.Position);
|
||||
DrainPlacementFifo(lifetime);
|
||||
Assert.Equal(
|
||||
0, lifetime.Physics.CaptureOwnership().SetPositionOperationCount);
|
||||
AssertConverged(lifetime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invariant 1: a teleport whose destination the service window declines
|
||||
/// still advances the body to the accepted destination — retail's
|
||||
/// no-transition <c>store_position</c> branch, identical to the far arm's
|
||||
/// own fallback.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_RefusedByServiceWindow_StillStoresTheDestinationPose()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
// The world frame must still be published (store_position resolves
|
||||
// through it); the service window is what refuses — mirrors
|
||||
// FarSnap_ClearsTheInterpolationQueue_IndependentlyOfThePlacementOutcome's
|
||||
// setup, which is the far arm's own Refused-fallback test.
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003041u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
Vector3 positionBefore = body.Position;
|
||||
// Deliberately does not Allow(DestinationLandblock) — the service
|
||||
// window refuses.
|
||||
var window = new FakeServiceWindow();
|
||||
RuntimeRemotePlacementDriveController drive = CreateDrive(lifetime, window);
|
||||
|
||||
var destination = new Vector3(12f, 14f, SpawnHeight);
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
destination);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.Refused,
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, route));
|
||||
|
||||
Assert.NotEqual(positionBefore, body.Position);
|
||||
Assert.True(body.InWorld);
|
||||
AssertConverged(lifetime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The non-storing half of retail's partition, through the teleport arm:
|
||||
/// the engine's own sweep refused the destination
|
||||
/// (<c>RejectedByPlacement</c>), so the body must be left exactly where
|
||||
/// it was — mirrors
|
||||
/// <see cref="FarSnap_EngineRefusedTheDestination_LeavesTheBodyWhereItWas"/>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_EngineRefusedTheDestination_LeavesTheBodyWhereItWas()
|
||||
{
|
||||
PhysicsEngine engine = FlatEngine();
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(engine);
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003042u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
Vector3 positionBefore = body.Position;
|
||||
var window = new FakeServiceWindow();
|
||||
window.Allow(DestinationLandblock);
|
||||
RuntimeRemotePlacementDriveController drive = CreateDrive(lifetime, window);
|
||||
|
||||
engine.TransitionCellCollisionTestHook =
|
||||
static (_, _, _, _) => TransitionState.Collided;
|
||||
|
||||
var destination = new Vector3(12f, 14f, SpawnHeight);
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
destination);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.RejectedByPlacement,
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, route));
|
||||
|
||||
Assert.Equal(positionBefore, body.Position);
|
||||
Assert.NotEqual(destination + new Vector3(192f, 0f, 0f), body.Position);
|
||||
AssertConverged(lifetime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// D3: unlike the far arm, <c>ApplyAcceptedRemoteTeleport</c> must NOT
|
||||
/// clear the interpolation queue itself — the classifier's teleport
|
||||
/// branch carries <c>StopInterpolating: false</c> on purpose, because
|
||||
/// retail's clear for this branch lives inside <c>teleport_hook</c>'s
|
||||
/// <c>PositionManager::StopInterpolating</c> @0x00514EFD, which the
|
||||
/// CALLER (<c>ApplyRemoteContactRouting</c>) runs before this method. If
|
||||
/// this method also cleared the queue, the two would race on which side
|
||||
/// "owns" the retail action.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_DoesNotClearTheInterpolationQueueItself()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003043u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
remote.Interp.Enqueue(
|
||||
new Vector3(40f, 40f, SpawnHeight),
|
||||
Quaternion.Identity,
|
||||
isMovingTo: false,
|
||||
currentBodyPosition: body.Position,
|
||||
currentBodyOrientation: body.Orientation);
|
||||
Assert.True(remote.Interp.IsActive);
|
||||
var window = new FakeServiceWindow();
|
||||
window.Allow(DestinationLandblock);
|
||||
RuntimeRemotePlacementDriveController drive = CreateDrive(lifetime, window);
|
||||
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
new Vector3(12f, 14f, SpawnHeight));
|
||||
Assert.False(route.StopInterpolating);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.Committed,
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, route));
|
||||
|
||||
Assert.True(remote.Interp.IsActive);
|
||||
DrainPlacementFifo(lifetime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The teleport arm must never be handed a route it does not own — the
|
||||
/// caller selects with
|
||||
/// <c>RuntimeRemoteTeleportPosition.OwnsTeleportPlacement</c>. Mirrors
|
||||
/// <see cref="FarSnap_ThrowsForARouteThisArmDoesNotOwn"/>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_ThrowsForARouteThisArmDoesNotOwn()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003044u);
|
||||
AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
RuntimeRemotePlacementDriveController drive =
|
||||
CreateDrive(lifetime, new FakeServiceWindow());
|
||||
|
||||
foreach (RuntimeAuthoritativePositionDisposition disposition in
|
||||
new[]
|
||||
{
|
||||
RuntimeAuthoritativePositionDisposition.SetPositionSimple,
|
||||
RuntimeAuthoritativePositionDisposition.Interpolate,
|
||||
RuntimeAuthoritativePositionDisposition.NoPositionOperation,
|
||||
RuntimeAuthoritativePositionDisposition.RejectedData,
|
||||
})
|
||||
{
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record, disposition, DestinationCell);
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => drive.ApplyAcceptedRemoteTeleport(record, remote, route));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test-plan item 7 / contract D3's currency rule, "now for the teleport
|
||||
/// arm" — the R5 shape
|
||||
/// <see cref="FarSnap_SupersededIncarnation_DoesNotStoreThroughTheStaleRecord"/>
|
||||
/// already pins for <c>ApplyAcceptedRemoteFarSnap</c>. Retail's
|
||||
/// <c>store_position</c> fallback is the SAME method
|
||||
/// (<c>StoreAcceptedDestinationPose</c>) both arms call through, but that
|
||||
/// sharing is exactly why it needs its own pin: a future edit could special-
|
||||
/// case one arm's call site without the other, and only a same-shaped test
|
||||
/// for each caller catches that. Reaches the stale-record state the same
|
||||
/// deterministic way — dropping the record from the active directory while
|
||||
/// its body/key/snapshot stay exactly as the packet left them, so the
|
||||
/// currency guard (not a null check) is what's under test.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_SupersededIncarnation_DoesNotStoreThroughTheStaleRecord()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(lifetime, 0x70003045u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
Vector3 positionBefore = body.Position;
|
||||
// Deliberately does not Allow(DestinationLandblock) — the service
|
||||
// window refuses, landing on the SAME store_position fallback the far
|
||||
// arm's currency test exercises.
|
||||
RuntimeRemotePlacementDriveController drive =
|
||||
CreateDrive(lifetime, new FakeServiceWindow());
|
||||
|
||||
var destination = new Vector3(12f, 14f, SpawnHeight);
|
||||
RuntimeAuthoritativePositionRoute route = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
destination);
|
||||
|
||||
Assert.True(lifetime.Entities.RemoveActive(record));
|
||||
Assert.False(lifetime.Entities.IsCurrent(record));
|
||||
Assert.NotNull(record.PhysicsBody);
|
||||
Assert.NotNull(record.Key);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.Refused,
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, route));
|
||||
|
||||
Assert.Equal(positionBefore, body.Position);
|
||||
Assert.NotEqual(destination + new Vector3(192f, 0f, 0f), body.Position);
|
||||
AssertConverged(lifetime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test-plan item 8 / proof obligation 2: teardown, session reset, and
|
||||
/// generation change all converge <c>RemotePlacementDrivePendingCount</c>
|
||||
/// to zero — driven through <see cref="ApplyAcceptedRemoteTeleport"/>
|
||||
/// itself, not assumed transitively from
|
||||
/// <see cref="LedgerConverges_AfterDetachRouteClearsTrackedEntries"/>
|
||||
/// (which seeds its retained entry through the lower shared
|
||||
/// <c>TryExecuteAcceptedRemotePosition</c> entry point, bypassing the
|
||||
/// teleport arm's own route-ownership check entirely). <c>DetachRoute</c>
|
||||
/// is the one production convergence hook this controller exposes —
|
||||
/// <c>GameRuntime</c>'s teardown, session reset, and generation-change
|
||||
/// paths all funnel through it, exactly as they do for the far arm's own
|
||||
/// already-covered case; there is no separate per-cause API to test
|
||||
/// independently at this layer.
|
||||
///
|
||||
/// <para>
|
||||
/// Retains via the SAME "retryable preparation" shape
|
||||
/// <see cref="FarSnap_RetryablePreparation_StoresThePoseAndStillRetainsTheRetry"/>
|
||||
/// uses (an unresolved Setup collision reports <c>Contention</c> and
|
||||
/// parks an entry in <c>_pending</c> for the cadence pump) — so the
|
||||
/// convergence this test proves is genuinely draining a LIVE retained
|
||||
/// teleport retry, not an already-empty ledger.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Teleport_LedgerConverges_AfterDetachRouteClearsARetainedRetry()
|
||||
{
|
||||
using var lifetime = new RuntimeEntityObjectLifetime(FlatEngine());
|
||||
CommitLandblockCollision(lifetime, DestinationLandblock);
|
||||
RuntimeEntityRecord record = CreateRemoteRecord(
|
||||
lifetime, 0x70003046u, setupTableId: 0x02000001u);
|
||||
PhysicsBody body = AttachBody(lifetime, record, SourceCell);
|
||||
RemoteMotion remote = lifetime.Physics.GetOrCreateRemoteMotion(record);
|
||||
Vector3 positionBefore = body.Position;
|
||||
var window = new FakeServiceWindow();
|
||||
window.Allow(DestinationLandblock);
|
||||
RuntimeRemotePlacementDriveController drive = CreateDrive(lifetime, window);
|
||||
var route = new object();
|
||||
drive.AttachRoute(route);
|
||||
|
||||
var destination = new Vector3(12f, 14f, SpawnHeight);
|
||||
RuntimeAuthoritativePositionRoute teleportRoute = MakeRoute(
|
||||
record,
|
||||
RuntimeAuthoritativePositionDisposition.SetPosition,
|
||||
DestinationCell,
|
||||
destination,
|
||||
stopInterpolating: true);
|
||||
|
||||
Assert.Equal(
|
||||
RuntimeRemotePlacementExecutionStatus.Contention,
|
||||
drive.ApplyAcceptedRemoteTeleport(record, remote, teleportRoute));
|
||||
// The retained retry is live (not assumed) — a second call through
|
||||
// the arm proves it, mirroring the far arm's own
|
||||
// FarSnap_RetryablePreparation test's shape.
|
||||
Assert.Equal(1, drive.PendingCount);
|
||||
Assert.Equal(
|
||||
1, lifetime.CaptureOwnership().RemotePlacementDrivePendingCount);
|
||||
Assert.Equal(
|
||||
destination + new Vector3(192f, 0f, 0f), body.Position);
|
||||
Assert.NotEqual(positionBefore, body.Position);
|
||||
|
||||
drive.DetachRoute(route);
|
||||
|
||||
Assert.Equal(0, drive.PendingCount);
|
||||
Assert.Equal(
|
||||
0, lifetime.CaptureOwnership().RemotePlacementDrivePendingCount);
|
||||
AssertConverged(lifetime);
|
||||
}
|
||||
|
||||
// ── Fixture ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue