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

Function is_safe_fall

plugins/channel-safely/include/inlines.h:112–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112inline 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}

Callers 1

OnUpdateFunction · 0.85

Calls 4

isValidTilePosFunction · 0.85
getTileDesignationFunction · 0.85
getTileTypeFunction · 0.85
isOpenTerrainFunction · 0.85

Tested by

no test coverage detected