| 22 | |
| 23 | bool ChannelJobs::has_cavein_conditions(const df::coord &map_pos) { |
| 24 | if likely(Maps::isValidTilePos(map_pos)) { |
| 25 | auto p = map_pos; |
| 26 | auto ttype = *Maps::getTileType(p); |
| 27 | if (!DFHack::isOpenTerrain(ttype)) { |
| 28 | // check shared neighbour for cave-in conditions |
| 29 | df::coord neighbours[4]; |
| 30 | get_connected_neighbours(map_pos, neighbours); |
| 31 | int connectedness = 4; |
| 32 | for (auto n: neighbours) { |
| 33 | if (!Maps::isValidTilePos(n) || active.count(n) || DFHack::isOpenTerrain(*Maps::getTileType(n))) { |
| 34 | connectedness--; |
| 35 | } |
| 36 | } |
| 37 | if (!connectedness) { |
| 38 | // do what? |
| 39 | p.z--; |
| 40 | if (!Maps::isValidTilePos(p)) return false; |
| 41 | ttype = *Maps::getTileType(p); |
| 42 | if (DFHack::isOpenTerrain(ttype) || DFHack::isFloorTerrain(ttype)) { |
| 43 | return true; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | return false; |
| 49 | } |
| 50 |
nothing calls this directly
no test coverage detected