| 110 | } |
| 111 | |
| 112 | inline bool is_safe_fall(const df::coord &map_pos) { |
| 113 | df::coord below(map_pos); |
| 114 | for (uint8_t zi = 0; zi < config.fall_threshold; ++zi) { |
| 115 | below.z--; |
| 116 | // falling out of bounds is probably considerably unsafe for a dwarf |
| 117 | if unlikely(!Maps::isValidTilePos(below)) { |
| 118 | return false; |
| 119 | } |
| 120 | // if we require vision, and we can't see below.. we'll need to assume it's safe to get anything done |
| 121 | if (config.require_vision && Maps::getTileDesignation(below)->bits.hidden) { |
| 122 | return true; |
| 123 | } |
| 124 | // finally, if we're not looking at open space (air to fall through) it's safe to fall to |
| 125 | df::tiletype type = *Maps::getTileType(below); |
| 126 | if (!DFHack::isOpenTerrain(type)) { |
| 127 | return true; |
| 128 | } |
| 129 | } |
| 130 | // we exceeded the fall threshold, so it's not a safe fall |
| 131 | return false; |
| 132 | } |
no test coverage detected