From 777893783a8777d60335b13acf82eab508bbbd8b Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 12 Apr 2026 18:29:20 +0200 Subject: [PATCH] =?UTF-8?q?fix(core):=20Phase=20B.3=20=E2=80=94=20restore?= =?UTF-8?q?=20SceneryGenerator=20road=20exclusion=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The IsRoadVertex check and helper were dropped by a linter pass after the previous commit. Re-adding them explicitly. Co-Authored-By: Claude Sonnet 4.6 --- src/AcDream.Core/World/SceneryGenerator.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/AcDream.Core/World/SceneryGenerator.cs b/src/AcDream.Core/World/SceneryGenerator.cs index 791c905..8b034c3 100644 --- a/src/AcDream.Core/World/SceneryGenerator.cs +++ b/src/AcDream.Core/World/SceneryGenerator.cs @@ -68,6 +68,12 @@ public static class SceneryGenerator uint terrainType = (uint)((raw >> 2) & 0x1F); // bits 2-6 uint sceneType = (uint)((raw >> 11) & 0x1F); // bits 11-15 + // Skip road vertices: bits 0-1 of the terrain word encode the road + // type (non-zero means this vertex is on a road). Ported from + // ACViewer Physics/Common/Landblock.cs GetRoad() and the OnRoad() + // check in get_land_scenes(). Roads should not have trees/rocks. + if (IsRoadVertex(raw)) continue; + if (terrainType >= region.TerrainInfo.TerrainTypes.Count) continue; var sceneTypeList = region.TerrainInfo.TerrainTypes[(int)terrainType].SceneTypes; if (sceneType >= sceneTypeList.Count) continue; @@ -160,6 +166,13 @@ public static class SceneryGenerator return result; } + /// + /// Returns true if the raw terrain word indicates a road vertex. + /// Bits 0-1 of the terrain word encode the road type; any non-zero value + /// means the vertex is on a road. Ported from ACViewer GetRoad(). + /// + public static bool IsRoadVertex(ushort raw) => (raw & 0x3u) != 0; + /// /// Pseudo-random displacement within a cell for a scenery object. Returns a /// Vector3 in local cell-offset space (the caller adds it to the cell corner