MCPcopy Index your code
hub / github.com/NetHack/NetHack / dig_check

Function dig_check

src/dig.c:206–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204#define BY_OBJECT ((struct monst *) 0)
205
206enum digcheck_result
207dig_check(struct monst *madeby, coordxy x, coordxy y)
208{
209 struct trap *ttmp = t_at(x, y);
210
211 if (On_stairs(x, y)) {
212 stairway *stway = stairway_at(x, y);
213 if (stway->isladder) {
214 return DIGCHECK_FAIL_ONLADDER;
215 } else {
216 return DIGCHECK_FAIL_ONSTAIRS;
217 }
218 } else if (IS_THRONE(levl[x][y].typ) && madeby != BY_OBJECT) {
219 return DIGCHECK_FAIL_THRONE;
220 } else if (IS_ALTAR(levl[x][y].typ)
221 && (madeby != BY_OBJECT
222 || (altarmask_at(x, y) & AM_SANCTUM) != 0)) {
223 return DIGCHECK_FAIL_ALTAR;
224 } else if (Is_airlevel(&u.uz)) {
225 return DIGCHECK_FAIL_AIRLEVEL;
226 } else if (Is_waterlevel(&u.uz)) {
227 return DIGCHECK_FAIL_WATERLEVEL;
228 } else if ((IS_OBSTRUCTED(levl[x][y].typ) && levl[x][y].typ != SDOOR
229 && (levl[x][y].wall_info & W_NONDIGGABLE) != 0)) {
230 return DIGCHECK_FAIL_TOOHARD;
231 } else if (ttmp && undestroyable_trap(ttmp->ttyp)) {
232 return DIGCHECK_FAIL_UNDESTROYABLETRAP;
233 } else if (!Can_dig_down(&u.uz) && !levl[x][y].candig) {
234 if (ttmp) {
235 if (!is_hole(ttmp->ttyp) && !is_pit(ttmp->ttyp))
236 return DIGCHECK_PASSED_DESTROY_TRAP;
237 else
238 return DIGCHECK_FAIL_CANTDIG;
239 } else {
240 return DIGCHECK_PASSED_PITONLY;
241 }
242 } else if (sobj_at(BOULDER, x, y)) {
243 return DIGCHECK_FAIL_BOULDER;
244 } else if (madeby == BY_OBJECT
245 /* the block against existing traps is mainly to
246 prevent broken wands from turning holes into pits */
247 && (ttmp || is_pool_or_lava(x, y))) {
248 /* digging by player handles pools separately */
249 return DIGCHECK_FAIL_OBJ_POOL_OR_TRAP;
250 }
251 return DIGCHECK_PASSED;
252}
253
254void
255digcheck_fail_message(enum digcheck_result digresult, struct monst *madeby,

Callers 3

digFunction · 0.85
digholeFunction · 0.85
do_break_wandFunction · 0.85

Calls 7

t_atFunction · 0.85
On_stairsFunction · 0.85
stairway_atFunction · 0.85
altarmask_atFunction · 0.85
Can_dig_downFunction · 0.85
sobj_atFunction · 0.85
is_pool_or_lavaFunction · 0.85

Tested by

no test coverage detected