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,