fix(physics): TS-23 - plumb real PK/PKLite/Impenetrable mover flags

Campaign P Slice P3 item 3. The wire parse (CreateObject's
PublicWeenieDesc._bitfield), the decode (EntityCollisionFlagsExt.
FromPwdBitfield), the per-GUID storage (ClientObjectTable.
PublicWeenieBitfield), and the exemption logic (CollisionExemption.
ShouldSkip) all already existed and were already correct -- every
mover-flags call site just fed a GUID-prefix IsPlayer heuristic instead
of the real per-entity PK/PKLite/Impenetrable state (retail
OBJECTINFO::init 0x0050cf30 state |= 0x80/0x800/0x1000).

Port:
- EntityCollisionFlagsExt.ToMoverState translates the decoded PWD
  bit-space into the ObjectInfoState bit-space FindObjCollisions
  actually reads -- two different numberings that must not be
  confused. Deliberately does not translate IsPlayer (every call site
  already derives that correctly from its own GUID heuristic per
  #184 Slice 2b).
- EntityCollisionFlagsExt.ResolveMoverPvpState is the one shared
  ClientObjectTable-backed lookup (guid -> ObjectInfoState), replacing
  what would otherwise have been three separate inline copies across
  GameWindow/LivePresentationComposition/RemoteTeleportController.
- Threaded as a new optional moverPvpState parameter through
  RuntimeRemotePhysicsUpdater.Tick/TickHidden and
  RuntimeOrdinaryPhysicsUpdater.TryBegin (default None preserves every
  pre-P3 caller unchanged), and as PlayerMovementController.OwnPvpFlags
  for the local player's own two resolve call sites.
- TS-23 section 12b: PlayerWeenie.JumpStaminaCost's pk parameter now
  reads the real PlayerKillerStatus(0x86)/LastPkAttackTimestamp(0x91)
  pair against retail's 20-second recency window
  (pkStatus in {4, 0x40} && (timestamp + 20.0) >= now), replacing the
  P1 hardcoded false. RuntimeMovementSkillState/Snapshot and
  LiveSessionEventRouter.RecomputePvpStatus push both the PWD bitfield
  and the PlayerKillerStatus pair reactively, riding the SAME
  ClientObject event triggers RecomputeBurden already uses.
- A conformance test caught a genuine precision bug in the first
  PK-timer clock choice: DateTimeOffset.UtcNow's Unix-epoch seconds
  (~1.7 billion) loses ~128 seconds of precision in a 32-bit float,
  silently swallowing the entire 20-second window. Switched to
  Environment.TickCount64 (small, monotonic magnitude) -- also the more
  retail-plausible basis, since LastPkAttackTimestamp is itself a wire
  PropertyFloat and retail's Timer::cur_time is almost certainly a
  process/session-relative counter for the same precision reason, not
  an absolute epoch.

Non-PK invariant (the acceptance criterion): an entity with no
ClientObjectTable row, or a row whose PublicWeenieBitfield is null or
0, resolves to ObjectInfoState.None -- a no-op OR into moverFlags,
bit-identical to every pre-P3 caller's hardcoded value. A dedicated
test drives two real ClientObjectTable rows through
CollisionExemption.ShouldSkip and confirms PK-vs-PK collides while
PK-vs-non-PK and non-PK-vs-non-PK both stay exempt (walk through).

Register: TS-23 retired (both the collision-flags and PK-timer halves);
the stale "M2 combat must land TS-23" phase-gate note removed.

dotnet build + dotnet test (Core.Tests 4008/2 skip, Runtime.Tests
425/0, App.Tests 3968/3 skip, complete solution build) all green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-30 09:52:55 +02:00
parent 8b5425498c
commit bb7b899bfe
17 changed files with 702 additions and 53 deletions

View file

@ -1,3 +1,5 @@
using AcDream.Core.Items;
namespace AcDream.Core.Physics;
/// <summary>
@ -72,4 +74,46 @@ public static class EntityCollisionFlagsExt
if ((bitfield & 0x2000000u) != 0) flags |= EntityCollisionFlags.IsPKLite;
return flags;
}
/// <summary>
/// TS-23 (Campaign P Slice P3, 2026-07-30): translate the decoded
/// per-entity <see cref="EntityCollisionFlags"/> (the PWD-bitfield
/// bit-space) into the <see cref="ObjectInfoState"/> bits
/// <c>CollisionExemption.ShouldSkip</c> and the moverFlags argument to
/// <c>PhysicsEngine.ResolveWithTransition</c> actually consume — a
/// DIFFERENT bit-space (retail <c>OBJECTINFO::init</c> 0x0050cf30
/// `state |= 0x80/0x800/0x1000`, acclient.h:6190-6194) that must not be
/// confused with the PWD wire numbering. <see cref="EntityCollisionFlags.IsPlayer"/>
/// is deliberately NOT translated here — every existing mover-flags call
/// site already derives <see cref="ObjectInfoState.IsPlayer"/> from its
/// own GUID-prefix heuristic (correct per #184 Slice 2b) and this helper
/// only fills the gap that heuristic cannot: PK/PKLite/Impenetrable.
/// </summary>
public static ObjectInfoState ToMoverState(this EntityCollisionFlags flags)
{
var state = ObjectInfoState.None;
if ((flags & EntityCollisionFlags.IsPK) != 0) state |= ObjectInfoState.IsPK;
if ((flags & EntityCollisionFlags.IsPKLite) != 0) state |= ObjectInfoState.IsPKLite;
if ((flags & EntityCollisionFlags.IsImpenetrable) != 0) state |= ObjectInfoState.IsImpenetrable;
return state;
}
/// <summary>
/// TS-23 (Campaign P Slice P3, 2026-07-30): the one shared
/// <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.
/// 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.
/// </summary>
public static ObjectInfoState ResolveMoverPvpState(this ClientObjectTable objects, uint serverGuid)
{
ArgumentNullException.ThrowIfNull(objects);
return objects.Get(serverGuid)?.PublicWeenieBitfield is { } bitfield
? FromPwdBitfield(bitfield).ToMoverState()
: ObjectInfoState.None;
}
}