MCPcopy Create free account
hub / github.com/DFHack/dfhack / smooth_tile

Function smooth_tile

plugins/dig-now.cpp:647–685  ·  view source on GitHub ↗

assumes that if the game let you designate a tile for smoothing, it must be valid to do so.

Source from the content-addressed store, hash-verified

645// assumes that if the game let you designate a tile for smoothing, it must be
646// valid to do so.
647static bool smooth_tile(color_ostream &out, MapExtras::MapCache &map,
648 const DFCoord &pos) {
649 df::tiletype tt = map.tiletypeAt(pos);
650
651 df::tiletype_shape shape = tileShape(tt);
652 df::tiletype_variant variant = tileVariant(tt);
653 df::tiletype_special special = df::tiletype_special::SMOOTH;
654
655 TileDirection tdir;
656 if (is_smooth_wall(map, pos)) {
657 // engraving is filtered out at a higher level, so this is a
658 // fortification designation
659 shape = tiletype_shape::FORTIFICATION;
660 variant = df::tiletype_variant::NONE;
661 special = df::tiletype_special::NONE;
662 }
663 else if (shape == df::tiletype_shape::WALL) {
664 if (adjust_smooth_wall_dir(map, DFCoord(pos.x, pos.y-1, pos.z),
665 TileDirection(0, 1, 0, 0)))
666 tdir.north = 1;
667 if (adjust_smooth_wall_dir(map, DFCoord(pos.x, pos.y+1, pos.z),
668 TileDirection(1, 0, 0, 0)))
669 tdir.south = 1;
670 if (adjust_smooth_wall_dir(map, DFCoord(pos.x-1, pos.y, pos.z),
671 TileDirection(0, 0, 0, 1)))
672 tdir.west = 1;
673 if (adjust_smooth_wall_dir(map, DFCoord(pos.x+1, pos.y, pos.z),
674 TileDirection(0, 0, 1, 0)))
675 tdir.east = 1;
676 tdir = ensure_valid_tdir(tdir);
677 }
678
679 tt = findTileType(shape, tileMaterial(tt), variant, special, tdir);
680 if (tt == df::tiletype::Void)
681 return false;
682
683 map.setTiletypeAt(pos, tt);
684 return true;
685}
686
687// assumes that if the game let you designate a tile for track carving, it must
688// be valid to do so.

Callers 1

do_digFunction · 0.85

Calls 10

tileShapeFunction · 0.85
tileVariantFunction · 0.85
adjust_smooth_wall_dirFunction · 0.85
TileDirectionFunction · 0.85
ensure_valid_tdirFunction · 0.85
findTileTypeFunction · 0.85
tileMaterialFunction · 0.85
tiletypeAtMethod · 0.80
setTiletypeAtMethod · 0.80
is_smooth_wallFunction · 0.70

Tested by

no test coverage detected