Prevent building floor on top of constructed floor (mostly)

develop
DoctorVanGogh 2015-11-02 02:51:52 +01:00
parent 14707e7d81
commit 092979f362
1 changed files with 16 additions and 7 deletions

@ -32,6 +32,7 @@
#include "modules/Constructions.h" #include "modules/Constructions.h"
#include "modules/Buildings.h" #include "modules/Buildings.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/MapCache.h"
#include "TileTypes.h" #include "TileTypes.h"
#include "df/job_item.h" #include "df/job_item.h"
@ -460,19 +461,27 @@ static bool is_valid_building_site(building_site &site, bool orthogonal_check, b
if (material == tiletype_material::CONSTRUCTION) if (material == tiletype_material::CONSTRUCTION)
{ {
// 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 // Can build on top of a wall, but not on a constructed floor
df::coord pos_below = site.pos; df::coord pos_below = site.pos;
pos_below.z--; pos_below.z--;
if (!Maps::isValidTilePos(pos_below)) if (!Maps::isValidTilePos(pos_below))
return false; return false;
auto ttype = Maps::getTileType(pos_below); auto ttype_below = Maps::getTileType(pos_below);
if (!ttype) if (!ttype_below)
return false; return false;
auto shape = tileShape(*ttype); auto shape_below = tileShape(*ttype_below);
auto shapeBasic = tileShapeBasic(shape); auto shapeBasic_below = tileShapeBasic(shape_below);
if (tileShapeBasic(shape) != tiletype_shape_basic::Wall) if (tileShapeBasic(shape_below) != tiletype_shape_basic::Wall)
return false; return false;
} }