Merge remote-tracking branch 'DoctorVanGogh/automats-floorfix' into develop

develop
lethosor 2015-11-06 19:54:06 -05:00
commit d1cd5df314
3 changed files with 17 additions and 16 deletions

@ -59,6 +59,7 @@ DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out);
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,
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];
}
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)
{
if (uint32_t(index) >= getCount())

@ -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"
@ -455,27 +456,17 @@ static bool is_valid_building_site(building_site &site, bool orthogonal_check, b
}
else
{
if (shape_basic != tiletype_shape_basic::Floor)
if (shape != tiletype_shape::STAIR_DOWN && shape_basic != tiletype_shape_basic::Floor)
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)
{
// 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)
return false;
auto shape = tileShape(*ttype);
auto shapeBasic = tileShapeBasic(shape);
if (tileShapeBasic(shape) != tiletype_shape_basic::Wall)
if (construction->flags.bits.top_of_wall==0)
return false;
}
if (material == tiletype_material::FIRE ||
material == tiletype_material::POOL ||
material == tiletype_material::BROOK ||