Fix for construction over existing construction & on top of walls

Fix to allow constructions on top of (natural) down stairs
develop
DoctorVanGogh 2015-11-06 19:00:43 +01:00
parent d692458038
commit e9be1aa657
3 changed files with 16 additions and 24 deletions

@ -59,6 +59,7 @@ DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount(); DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out); DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out);
DFHACK_EXPORT df::construction * getConstruction (const int32_t index); DFHACK_EXPORT df::construction * getConstruction (const int32_t index);
DFHACK_EXPORT df::construction * findAtTile(df::coord pos);
DFHACK_EXPORT bool designateNew(df::coord pos, df::construction_type type, DFHACK_EXPORT bool designateNew(df::coord pos, df::construction_type type,
df::item_type item = df::item_type::NONE, int mat_index = -1); df::item_type item = df::item_type::NONE, int mat_index = -1);

@ -68,6 +68,15 @@ df::construction * Constructions::getConstruction(const int32_t index)
return world->constructions[index]; return world->constructions[index];
} }
df::construction * Constructions::findAtTile(df::coord pos)
{
for (auto it = begin (world->constructions); it != end (world->constructions); ++it) {
if ((*it)->pos == pos)
return *it;
}
return NULL;
}
bool Constructions::copyConstruction(const int32_t index, t_construction &out) bool Constructions::copyConstruction(const int32_t index, t_construction &out)
{ {
if (uint32_t(index) >= getCount()) if (uint32_t(index) >= getCount())

@ -456,32 +456,14 @@ static bool is_valid_building_site(building_site &site, bool orthogonal_check, b
} }
else else
{ {
if (shape_basic != tiletype_shape_basic::Floor) if (shape != tiletype_shape::STAIR_DOWN && shape_basic != tiletype_shape_basic::Floor)
return false; return false;
if (material == tiletype_material::CONSTRUCTION) // Can build on top of a wall, but not on other construction
auto construction = Constructions::findAtTile(site.pos);
if (construction)
{ {
// Check this is not a 'constructed floor over X': if (construction->flags.bits.top_of_wall==0)
// 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_below = Maps::getTileType(pos_below);
if (!ttype_below)
return false;
auto shape_below = tileShape(*ttype_below);
auto shapeBasic_below = tileShapeBasic(shape_below);
if (tileShapeBasic(shape_below) != tiletype_shape_basic::Wall)
return false; return false;
} }