fix(physics): AP-71 - port check_entry_restrictions at the head of indoor FindEnvCollisions

Campaign P Slice P4 item 1. Ports retail's CObjCell::check_entry_restrictions
(pc:308873-308912, 0x0052b6d0), called FIRST by CEnvCell::find_env_collisions
(pc:309576) before any BSP work, as ObjectInfo.CheckEntryRestrictions wired at
the top of the indoor branch of Transition.FindEnvCollisions.

Resolves the research doc's open question on restriction_obj's source: the
ACE cross-check (references/ACE/Source/ACE.DatLoader/FileTypes/EnvCell.cs:32,
66-67) plus an independent reflection probe of Chorizite.DatReaderWriter
2.1.7's own EnvCell.RestrictionObj field confirm it is a plain DAT-baked
uint32 gated by EnvCellFlags.HasRestrictionObj (0x8) - not a live wire
override. The BN pseudo-C's "count for an array alloc" read at the same
UnPack offset was the mis-attributed field-name collision
feedback_bn_decomp_field_names warned about.

CellPhysics.RestrictionObj is wired from envCell.RestrictionObj in BOTH the
dev/graph-fixture path (CacheCellStruct) and the production/prepared path
(CachePreparedCellStruct) - the latter already receives a live parsed
envCell for Position/EnvironmentId, so no bake-format change was needed.

The mover's own CanBypassMoveRestrictions (BF_ADMIN 0x100000 AND
BF_IMMUNE_CELL_RESTRICTIONS 0x400000, acclient.h:6452-6454) is decoded via
the same PWD-bitfield pipeline TS-23 established for PK/PKLite/Impenetrable
(EntityCollisionFlags -> ToMoverState -> ObjectInfoState moverFlags).

Remaining gap (filed as AP-129, replacing the retired AP-71 row): CanMoveInto
(house owner IID + guest/ban list) is unmodeled, so a genuinely restricted
cell fails CLOSED for everyone, not just intruders - matching retail's own
fallback when the restriction weenie can't be resolved (pc:704-716). Outdoor
CLandCell restriction (LandblockInfo.RestrictionTables, a separate DAT
structure) is explicitly out of scope for this gate.

Conformance: Ap71EntryRestrictionGateTests covers the pure gate logic
(NPC bypass, admin bypass, fail-closed, ordinary-cell no-op), the PWD-bitfield
two-bit AND decode, and three end-to-end Transition.FindEnvCollisions
scenarios proving zero behavior change for ordinary cells.

AcDream.Core.Tests: 4026 passed, 2 skipped, 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-30 10:30:45 +02:00
parent eddad9cb38
commit d6c3f8657a
5 changed files with 380 additions and 2 deletions

View file

@ -49,6 +49,19 @@ public enum EntityCollisionFlags : byte
/// requires this distinction for ethereal targets.
/// </summary>
HasWeenie = 0x20,
/// <summary>
/// AP-71 (Campaign P Slice P4, 2026-07-30): set when BOTH
/// <c>BF_ADMIN (0x100000)</c> and <c>BF_IMMUNE_CELL_RESTRICTIONS
/// (0x400000)</c> are set in <c>pwd._bitfield</c> — the exact two-bit AND
/// retail's <c>ACCWeenieObject::CanBypassMoveRestrictions</c>
/// (0x0058c500) evaluates to let a mover through an access-restricted
/// (house-barrier) cell without an owner/guest-list check. Bit names
/// confirmed at <c>acclient.h:6452-6454</c>
/// (<c>PublicWeenieDesc::BitfieldIndex</c>); <c>BF_ADMIN</c> is
/// independently decoded the same way in
/// <see cref="AcDream.Core.Ui.RadarBlipColors"/>.
/// </summary>
CanBypassMoveRestrictions = 0x40,
}
/// <summary>Helpers to convert raw retail bitfields into <see cref="EntityCollisionFlags"/>.</summary>
@ -72,6 +85,10 @@ public static class EntityCollisionFlagsExt
if ((bitfield & 0x20u) != 0) flags |= EntityCollisionFlags.IsPK;
if ((bitfield & 0x200000u) != 0) flags |= EntityCollisionFlags.IsImpenetrable;
if ((bitfield & 0x2000000u) != 0) flags |= EntityCollisionFlags.IsPKLite;
// AP-71: BF_ADMIN (0x100000) AND BF_IMMUNE_CELL_RESTRICTIONS (0x400000),
// matching CanBypassMoveRestrictions' own AND (not OR) of the two bits.
if ((bitfield & 0x100000u) != 0 && (bitfield & 0x400000u) != 0)
flags |= EntityCollisionFlags.CanBypassMoveRestrictions;
return flags;
}
@ -95,6 +112,10 @@ public static class EntityCollisionFlagsExt
if ((flags & EntityCollisionFlags.IsPK) != 0) state |= ObjectInfoState.IsPK;
if ((flags & EntityCollisionFlags.IsPKLite) != 0) state |= ObjectInfoState.IsPKLite;
if ((flags & EntityCollisionFlags.IsImpenetrable) != 0) state |= ObjectInfoState.IsImpenetrable;
// AP-71 (Campaign P Slice P4): the mover's own house-restriction bypass,
// consumed by ObjectInfo.CheckEntryRestrictions.
if ((flags & EntityCollisionFlags.CanBypassMoveRestrictions) != 0)
state |= ObjectInfoState.CanBypassMoveRestrictions;
return state;
}