connect smooth walls to doors

develop
myk002 2021-07-20 15:53:03 -07:00
parent 3c8a174a68
commit 92701d6da7
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 15 additions and 5 deletions

@ -7,6 +7,7 @@
#include "TileTypes.h" #include "TileTypes.h"
#include "LuaTools.h" #include "LuaTools.h"
#include "modules/Buildings.h"
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/MapCache.h" #include "modules/MapCache.h"
@ -421,17 +422,26 @@ static bool is_smooth_wall(MapExtras::MapCache &map, const DFCoord &pos) {
&& tileShape(tt) == df::tiletype_shape::WALL; && tileShape(tt) == df::tiletype_shape::WALL;
} }
// adds adjacent smooth walls to the given tdir static bool is_smooth_wall_or_door(MapExtras::MapCache &map,
const DFCoord &pos) {
if (is_smooth_wall(map, pos))
return true;
df::building *bld = Buildings::findAtTile(pos);
return bld && bld->getType() == df::building_type::Door;
}
// adds adjacent smooth walls and doors to the given tdir
static TileDirection get_adjacent_smooth_walls(MapExtras::MapCache &map, static TileDirection get_adjacent_smooth_walls(MapExtras::MapCache &map,
const DFCoord &pos, const DFCoord &pos,
TileDirection tdir) { TileDirection tdir) {
if (is_smooth_wall(map, DFCoord(pos.x, pos.y-1, pos.z))) if (is_smooth_wall_or_door(map, DFCoord(pos.x, pos.y-1, pos.z)))
tdir.north = 1; tdir.north = 1;
if (is_smooth_wall(map, DFCoord(pos.x, pos.y+1, pos.z))) if (is_smooth_wall_or_door(map, DFCoord(pos.x, pos.y+1, pos.z)))
tdir.south = 1; tdir.south = 1;
if (is_smooth_wall(map, DFCoord(pos.x-1, pos.y, pos.z))) if (is_smooth_wall_or_door(map, DFCoord(pos.x-1, pos.y, pos.z)))
tdir.west = 1; tdir.west = 1;
if (is_smooth_wall(map, DFCoord(pos.x+1, pos.y, pos.z))) if (is_smooth_wall_or_door(map, DFCoord(pos.x+1, pos.y, pos.z)))
tdir.east = 1; tdir.east = 1;
return tdir; return tdir;
} }