From 91fd9de3f62da7954cffe10f5b3e57b89a058d82 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 8 May 2026 09:20:53 +0200 Subject: [PATCH] phase(N.1): document LandBlock length-81 invariant on adapter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses code-review feedback on commit 26cf2b8. The dropped ArgumentException length guards were correct to drop because DatReaderWriter.LandBlock self-initializes Terrain[] and Height[] to length 81 in its constructor — but that invariant was not documented anywhere visible to future readers. Adds an XML doc block explaining the guarantee so callers constructing synthetic LandBlocks know what to expect. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/AcDream.Core/World/WbSceneryAdapter.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/AcDream.Core/World/WbSceneryAdapter.cs b/src/AcDream.Core/World/WbSceneryAdapter.cs index ca73809..1a90149 100644 --- a/src/AcDream.Core/World/WbSceneryAdapter.cs +++ b/src/AcDream.Core/World/WbSceneryAdapter.cs @@ -25,6 +25,16 @@ internal static class WbSceneryAdapter /// TerrainInfo.Scenery (bits 11-15) → /// LandBlock.Height[i] /// + /// + /// No runtime length guards are needed here because + /// DatReaderWriter.DBObjs.LandBlock's default constructor + /// self-initializes both Terrain and Height to fixed-length + /// arrays of exactly 81 elements (9×9 vertices per landblock). Any caller + /// that constructs a synthetic with partial arrays + /// will receive an at the first + /// mis-sized index, which is the correct fast-fail behaviour for a + /// contract violation of this kind. + /// public static TerrainEntry[] BuildTerrainEntries(LandBlock block) { ArgumentNullException.ThrowIfNull(block);