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:
parent
8b5425498c
commit
bb7b899bfe
17 changed files with 702 additions and 53 deletions
|
|
@ -138,6 +138,9 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
&& MovementSkills.JumpSkill == -1
|
||||
&& MovementSkills.Burden == 0f
|
||||
&& MovementSkills.CurrentStamina == -1
|
||||
&& MovementSkills.OwnPwdBitfield == 0u
|
||||
&& MovementSkills.PlayerKillerStatus == -1
|
||||
&& MovementSkills.LastPkAttackTimestamp is null
|
||||
&& _runSkillBase == -1
|
||||
&& _jumpSkillBase == -1);
|
||||
}
|
||||
|
|
@ -552,19 +555,32 @@ public readonly record struct RuntimeMovementSkillSnapshot(
|
|||
// ratio (0.0 unencumbered) and current stamina (-1 = unknown/don't-gate,
|
||||
// matching RunSkill/JumpSkill's own sentinel convention).
|
||||
float Burden = 0f,
|
||||
int CurrentStamina = -1)
|
||||
int CurrentStamina = -1,
|
||||
// TS-23 (Campaign P Slice P3, 2026-07-30): the local player's own
|
||||
// PublicWeenieDesc._bitfield (0 = never pushed / no PK-relevant bits —
|
||||
// a no-op OR, matching every pre-P3 caller) and the raw
|
||||
// PlayerKillerStatus/LastPkAttackTimestamp pair §12b's PK-timer
|
||||
// jump-cost bump reads (-1 / null = never pushed).
|
||||
uint OwnPwdBitfield = 0u,
|
||||
int PlayerKillerStatus = -1,
|
||||
float? LastPkAttackTimestamp = null)
|
||||
{
|
||||
public bool IsComplete => RunSkill >= 0 && JumpSkill >= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Server-authoritative run/jump/burden/stamina values retained
|
||||
/// Server-authoritative run/jump/burden/stamina/PK-status values retained
|
||||
/// independently of any graphical movement controller. App applies this
|
||||
/// borrowed state whenever its presentation/physics controller exists or is
|
||||
/// rebuilt. Campaign P Slice P1 (2026-07-30) extended this beyond run/jump
|
||||
/// skill to the full stat-coupled-movement input set (burden, current
|
||||
/// stamina) — see the pseudocode doc §9. RunSkill/JumpSkill arrive here
|
||||
/// ALREADY vitae/enchantment-adjusted by
|
||||
/// stamina) — see the pseudocode doc §9. Campaign P Slice P3 (2026-07-30)
|
||||
/// further added the player's own PWD bitfield (PK/PKLite/Impenetrable
|
||||
/// collision-exemption bits) and the PlayerKillerStatus/
|
||||
/// LastPkAttackTimestamp pair (the PK-timer jump-cost bump) — the SAME
|
||||
/// reactive push seam, since both ride the player's own ClientObject
|
||||
/// property-update stream. RunSkill/JumpSkill arrive here ALREADY
|
||||
/// vitae/enchantment-adjusted by
|
||||
/// <see cref="RuntimeCharacterState.RecomputeMovementSkills"/>.
|
||||
/// </summary>
|
||||
public sealed class RuntimeMovementSkillState
|
||||
|
|
@ -573,16 +589,34 @@ public sealed class RuntimeMovementSkillState
|
|||
private int _jumpSkill = -1;
|
||||
private float _burden;
|
||||
private int _currentStamina = -1;
|
||||
private uint _ownPwdBitfield;
|
||||
private int _playerKillerStatus = -1;
|
||||
private float _lastPkAttackTimestamp;
|
||||
private bool _hasLastPkAttackTimestamp;
|
||||
private long _revision;
|
||||
|
||||
public int RunSkill => Volatile.Read(ref _runSkill);
|
||||
public int JumpSkill => Volatile.Read(ref _jumpSkill);
|
||||
public float Burden => Volatile.Read(ref _burden);
|
||||
public int CurrentStamina => Volatile.Read(ref _currentStamina);
|
||||
public uint OwnPwdBitfield => Volatile.Read(ref _ownPwdBitfield);
|
||||
public int PlayerKillerStatus => Volatile.Read(ref _playerKillerStatus);
|
||||
public float? LastPkAttackTimestamp =>
|
||||
Volatile.Read(ref _hasLastPkAttackTimestamp)
|
||||
? Volatile.Read(ref _lastPkAttackTimestamp)
|
||||
: null;
|
||||
public bool IsComplete => _runSkill >= 0 && _jumpSkill >= 0;
|
||||
public long Revision => Interlocked.Read(ref _revision);
|
||||
public RuntimeMovementSkillSnapshot Snapshot =>
|
||||
new(_runSkill, _jumpSkill, Revision, _burden, _currentStamina);
|
||||
new(
|
||||
_runSkill,
|
||||
_jumpSkill,
|
||||
Revision,
|
||||
_burden,
|
||||
_currentStamina,
|
||||
OwnPwdBitfield,
|
||||
PlayerKillerStatus,
|
||||
LastPkAttackTimestamp);
|
||||
|
||||
public void Update(int runSkill, int jumpSkill)
|
||||
{
|
||||
|
|
@ -626,12 +660,62 @@ public sealed class RuntimeMovementSkillState
|
|||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TS-23 (Campaign P Slice P3, 2026-07-30): pushes the local player's own
|
||||
/// raw <c>PublicWeenieDesc._bitfield</c> — the PWD wire bit-space
|
||||
/// <see cref="AcDream.Core.Physics.EntityCollisionFlagsExt.FromPwdBitfield"/>
|
||||
/// decodes. Fires on the SAME <c>ClientObject</c> add/update events
|
||||
/// <see cref="UpdateBurden"/> already reacts to (the player's own
|
||||
/// PublicWeenieBitfield lives on the same row).
|
||||
/// </summary>
|
||||
public void UpdateOwnPwdBitfield(uint bitfield)
|
||||
{
|
||||
if (OwnPwdBitfield == bitfield) return;
|
||||
Volatile.Write(ref _ownPwdBitfield, bitfield);
|
||||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TS-23 §12b: pushes the raw <c>PlayerKillerStatus</c>
|
||||
/// (<c>PropertyInt</c> 0x86) / <c>LastPkAttackTimestamp</c>
|
||||
/// (<c>PropertyFloat</c> 0x91) pair feeding
|
||||
/// <c>CACQualities::JumpStaminaCost</c>'s 20-second PK-timer bump. A
|
||||
/// negative <paramref name="playerKillerStatus"/> restores "never
|
||||
/// pushed" (matches <see cref="UpdateStamina"/>'s own sentinel
|
||||
/// convention); <paramref name="lastPkAttackTimestamp"/> is <c>null</c>
|
||||
/// when the property is absent.
|
||||
/// </summary>
|
||||
public void UpdatePlayerKillerStatus(int playerKillerStatus, float? lastPkAttackTimestamp)
|
||||
{
|
||||
bool changed = false;
|
||||
if (PlayerKillerStatus != playerKillerStatus)
|
||||
{
|
||||
Volatile.Write(ref _playerKillerStatus, playerKillerStatus);
|
||||
changed = true;
|
||||
}
|
||||
bool hasTimestamp = lastPkAttackTimestamp.HasValue;
|
||||
float timestamp = lastPkAttackTimestamp ?? 0f;
|
||||
if (Volatile.Read(ref _hasLastPkAttackTimestamp) != hasTimestamp
|
||||
|| (hasTimestamp && Volatile.Read(ref _lastPkAttackTimestamp) != timestamp))
|
||||
{
|
||||
Volatile.Write(ref _lastPkAttackTimestamp, timestamp);
|
||||
Volatile.Write(ref _hasLastPkAttackTimestamp, hasTimestamp);
|
||||
changed = true;
|
||||
}
|
||||
if (changed)
|
||||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
|
||||
public void ResetSession()
|
||||
{
|
||||
Volatile.Write(ref _runSkill, -1);
|
||||
Volatile.Write(ref _jumpSkill, -1);
|
||||
Volatile.Write(ref _burden, 0f);
|
||||
Volatile.Write(ref _currentStamina, -1);
|
||||
Volatile.Write(ref _ownPwdBitfield, 0u);
|
||||
Volatile.Write(ref _playerKillerStatus, -1);
|
||||
Volatile.Write(ref _lastPkAttackTimestamp, 0f);
|
||||
Volatile.Write(ref _hasLastPkAttackTimestamp, false);
|
||||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue