From 092979f3624d9029c14d77688a85746aa1a245ad Mon Sep 17 00:00:00 2001 From: DoctorVanGogh Date: Mon, 2 Nov 2015 02:51:52 +0100 Subject: [PATCH] Prevent building floor on top of constructed floor (mostly) --- plugins/automaterial.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/automaterial.cpp b/plugins/automaterial.cpp index 56b94483b..508831b77 100644 --- a/plugins/automaterial.cpp +++ b/plugins/automaterial.cpp @@ -32,6 +32,7 @@ #include "modules/Constructions.h" #include "modules/Buildings.h" #include "modules/Maps.h" +#include "modules/MapCache.h" #include "TileTypes.h" #include "df/job_item.h" @@ -459,20 +460,28 @@ static bool is_valid_building_site(building_site &site, bool orthogonal_check, b return false; if (material == tiletype_material::CONSTRUCTION) - { - // Can build on top of a wall, but not on a constructed floor + { + // Check this is not a 'constructed floor over X': + // those have something else than open space as *basic* tile types: stonefloor, smoothstonefloor, ... + MapExtras::MapCache mc; + auto btt = mc.baseTiletypeAt(site.pos); + auto bshape = tileShape(btt); + if (bshape != tiletype_shape_basic::Open) + return false; + + // Can build on top of a wall, but not on a constructed floor df::coord pos_below = site.pos; pos_below.z--; if (!Maps::isValidTilePos(pos_below)) return false; - auto ttype = Maps::getTileType(pos_below); - if (!ttype) + auto ttype_below = Maps::getTileType(pos_below); + if (!ttype_below) return false; - auto shape = tileShape(*ttype); - auto shapeBasic = tileShapeBasic(shape); - if (tileShapeBasic(shape) != tiletype_shape_basic::Wall) + auto shape_below = tileShape(*ttype_below); + auto shapeBasic_below = tileShapeBasic(shape_below); + if (tileShapeBasic(shape_below) != tiletype_shape_basic::Wall) return false; }