From f2663b7e4bff65bc7d22e134f680b8d0826edc45 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 2 Jun 2026 09:44:14 +0200 Subject: [PATCH] =?UTF-8?q?fix(core):=20UCG=20Stage=201=20=E2=80=94=20fina?= =?UTF-8?q?l-review=20polish=20(VisibleCells=20null-guard,=20Neighbor=20do?= =?UTF-8?q?c)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.Core/World/Cells/CellGraph.cs | 5 +++++ src/AcDream.Core/World/Cells/EnvCell.cs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/AcDream.Core/World/Cells/CellGraph.cs b/src/AcDream.Core/World/Cells/CellGraph.cs index 80ee9ac..8f19e59 100644 --- a/src/AcDream.Core/World/Cells/CellGraph.cs +++ b/src/AcDream.Core/World/Cells/CellGraph.cs @@ -49,5 +49,10 @@ public sealed class CellGraph return LandCell.Synthesize(id, t.Terrain, t.Origin, idx / 8, idx % 8); } + /// + /// Resolve the cell on the far side of a portal — retail CCellPortal::GetOtherCell = + /// GetVisible(other_cell_id). documents the traversal source and is + /// reserved for the OtherCellPtr neighbor cache (Stage 3); the lookup keys only on the portal. + /// public ObjCell? Neighbor(ObjCell cell, in CellPortal portal) => GetVisible(portal.OtherCellId); } diff --git a/src/AcDream.Core/World/Cells/EnvCell.cs b/src/AcDream.Core/World/Cells/EnvCell.cs index 10a0407..cb24f03 100644 --- a/src/AcDream.Core/World/Cells/EnvCell.cs +++ b/src/AcDream.Core/World/Cells/EnvCell.cs @@ -66,8 +66,9 @@ public sealed class EnvCell : ObjCell } uint lbPrefix = id & 0xFFFF0000u; - var stab = new List(datCell.VisibleCells.Count); - foreach (var low in datCell.VisibleCells) stab.Add(lbPrefix | low); + var stab = new List(); + if (datCell.VisibleCells is not null) // match BuildLoadedCell:5701 null guard + foreach (var low in datCell.VisibleCells) stab.Add(lbPrefix | low); bool seenOutside = datCell.Flags.HasFlag(EnvCellFlags.SeenOutside); return new EnvCell(id, worldTransform, inverse, min, max, portals, stab,