DramaticShapeVoxelMod archival mirror · read-only
d229622b095ba27c9bfea4e546e1647111c5839a

conditional pins must not mark the shared class shape authored

DramaticShape · 2026-07-27 · parent 326c595336

conditional pins must not mark the shared class shape authored

A `when_above` match returned shapes.classes[class] after setting
.authored on it -- but those canonical shapes are SHARED, and
shapes.classes.wall is the very object rule 4 hands every unauthored
solid tile. Marking it authored made all of them return early from
TileShape.at, skipping the cell rules, so walkable floors stopped
flattening: the gate houses came out as a checkerboard of raised blocks
with the room's floor standing 16px.

Conditional pins now resolve to their own authored shape per class,
built alongside the canonical ones and kept apart from them.

Changed files

lib/TileShape.lua | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

Diff

diff --git a/lib/TileShape.lua b/lib/TileShape.lua
index 1e11c59..a1fddcb 100644
--- a/lib/TileShape.lua
+++ b/lib/TileShape.lua
@@ -297,6 +297,17 @@ function TileShape.forMap(map)
   for class in pairs(FALLBACK_HEIGHTS) do
     shapes.classes[class] = shapeFor(class, heights)
   end
+  -- a conditional pin's own AUTHORED shape per class it can resolve to,
+  -- kept apart from the shared canonical ones above (see TileShape.at)
+  if shapes.cond then
+    shapes.condShape = {}
+    for _, rules in pairs(shapes.cond) do
+      for _, rule in ipairs(rules) do
+        shapes.condShape[rule.class] = shapes.condShape[rule.class]
+          or shapeFor(rule.class, heights, true)
+      end
+    end
+  end
   for t = 0, count - 1 do
     local class = authored[t]
     if class then
@@ -334,8 +345,13 @@ function TileShape.at(map, shapes, tile, tx, ty)
     local above = map:tileAt(tx, ty - 1)
     for _, rule in ipairs(rules) do
       if above and rule.above[above] then
-        shapes.classes[rule.class].authored = true
-        return shapes.classes[rule.class]
+        -- shapes.condShape, NOT shapes.classes: the canonical class
+        -- shapes are SHARED, and `wall` in particular is the very object
+        -- rule 4 hands every unauthored solid tile. Marking that one
+        -- authored (which the first cut did) made every one of them skip
+        -- the cell rules below, so walkable floors stopped flattening and
+        -- whole rooms rose into a checkerboard of blocks.
+        return shapes.condShape[rule.class]
       end
     end
   end