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

@ -477,6 +477,13 @@ public sealed class PhysicsDataCache
// #107: retail CEnvCell.seen_outside — consumed by AdjustPosition's
// indoor not-found fallback (acclient :280037).
SeenOutside = envCell.Flags.HasFlag(DatReaderWriter.Enums.EnvCellFlags.SeenOutside),
// AP-71 (Campaign P Slice P4, 2026-07-30): retail CObjCell::
// restriction_obj — a DAT-baked uint32 gated by EnvCellFlags.
// HasRestrictionObj (0x8), confirmed via ACE.DatLoader.FileTypes.
// EnvCell.cs:66-67 and Chorizite.DatReaderWriter's own EnvCell
// field of the same name (reflection-confirmed 2026-07-30). Zero
// for every ordinary (non-house-barrier) cell.
RestrictionObj = envCell.RestrictionObj,
};
_cellStruct[envCellId] = cellPhysics;
@ -654,6 +661,14 @@ public sealed class PhysicsDataCache
VisibleCellIds = new HashSet<uint>(
preparedTopology.VisibleCellIds),
SeenOutside = preparedTopology.SeenOutside,
// AP-71 (Campaign P Slice P4, 2026-07-30): read straight from the
// locally-parsed live envCell, same as SeenOutside historically
// was before the bake pipeline existed — RestrictionObj is NOT
// (and does not need to be) part of the baked FlatEnvCellTopology
// payload; the caller (LandblockPhysicsPublisher.PublishCell)
// already has a real parsed DatReaderWriter.DBObjs.EnvCell in
// hand for Position/EnvironmentId, so this is free.
RestrictionObj = envCell.RestrictionObj,
});
}
@ -1062,4 +1077,19 @@ public sealed class CellPhysics
/// contain it AND this flag is set (retail acclient :280037-280046).
/// </summary>
public bool SeenOutside { get; init; }
/// <summary>
/// AP-71 (Campaign P Slice P4, 2026-07-30): retail <c>CObjCell::
/// restriction_obj</c> — the DAT-baked object IID (gated by
/// <c>EnvCellFlags.HasRestrictionObj</c>) that <c>CObjCell::
/// check_entry_restrictions</c> (0x0052b6d0) resolves and consults
/// before letting a player into this cell. Zero (the default) for
/// every ordinary cell — only house-barrier EnvCells set it. Consumed
/// by <see cref="ObjectInfo.CheckEntryRestrictions"/> via
/// <see cref="Transition.FindEnvCollisions"/>. Resolving the value into
/// a live restriction weenie (for the owner/guest-list
/// <c>CanMoveInto</c> check) is NOT modeled — see the AP-71 register
/// history for the narrower unfed-input row.
/// </summary>
public uint RestrictionObj { get; init; }
}