unhide properly when digging at visible edges

develop
myk002 2021-06-28 13:04:58 -07:00
parent 0b703d9818
commit a6c62a025f
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 22 additions and 1 deletions

@ -726,11 +726,32 @@ static void flood_unhide(color_ostream &out, const DFCoord &pos) {
Lua::SafeCall(out, L, 1, 0); Lua::SafeCall(out, L, 1, 0);
} }
static bool needs_unhide(const DFCoord &pos) {
return !Maps::ensureTileBlock(pos)
|| Maps::getTileDesignation(pos)->bits.hidden;
}
static bool needs_flood_unhide(const DFCoord &pos) {
return needs_unhide(pos)
|| needs_unhide(DFCoord(pos.x-1, pos.y-1, pos.z))
|| needs_unhide(DFCoord(pos.x, pos.y-1, pos.z))
|| needs_unhide(DFCoord(pos.x+1, pos.y-1, pos.z))
|| needs_unhide(DFCoord(pos.x-1, pos.y, pos.z))
|| needs_unhide(DFCoord(pos.x+1, pos.y, pos.z))
|| needs_unhide(DFCoord(pos.x-1, pos.y+1, pos.z))
|| needs_unhide(DFCoord(pos.x, pos.y+1, pos.z))
|| needs_unhide(DFCoord(pos.x+1, pos.y+1, pos.z));
}
static void post_process_dug_tiles(color_ostream &out, static void post_process_dug_tiles(color_ostream &out,
const std::vector<DFCoord> &dug_coords) { const std::vector<DFCoord> &dug_coords) {
for (DFCoord pos : dug_coords) { for (DFCoord pos : dug_coords) {
if (Maps::getTileDesignation(pos)->bits.hidden) if (needs_flood_unhide(pos)) {
// set current tile to hidden to allow flood_unhide to work on tiles
// that were already visible but that reveal hidden tiles when dug.
Maps::getTileDesignation(pos)->bits.hidden = true;
flood_unhide(out, pos); flood_unhide(out, pos);
}
df::tile_occupancy &to = *Maps::getTileOccupancy(pos); df::tile_occupancy &to = *Maps::getTileOccupancy(pos);
if (to.bits.unit || to.bits.item) { if (to.bits.unit || to.bits.item) {