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

Function test_move

src/hack.c:990–1255  ·  view source on GitHub ↗

return TRUE if (ux+dx,uy+dy) is an OK place to move; mode is one of DO_MOVE, TEST_MOVE, TEST_TRAV, or TEST_TRAP */

Source from the content-addressed store, hash-verified

988/* return TRUE if (ux+dx,uy+dy) is an OK place to move;
989 mode is one of DO_MOVE, TEST_MOVE, TEST_TRAV, or TEST_TRAP */
990boolean
991test_move(
992 coordxy ux, coordxy uy,
993 coordxy dx, coordxy dy, /* these are -1|0|+1, not coordinates */
994 int mode)
995{
996 coordxy x = ux + dx;
997 coordxy y = uy + dy;
998 struct rm *tmpr;
999 struct rm *ust;
1000
1001 svc.context.door_opened = FALSE;
1002
1003 if (!isok(x, y))
1004 return FALSE;
1005
1006 tmpr = &levl[x][y];
1007
1008 /*
1009 * Check for physical obstacles. First, the place we are going.
1010 */
1011 if (IS_OBSTRUCTED(tmpr->typ) || tmpr->typ == IRONBARS) {
1012 if (Blind && mode == DO_MOVE)
1013 feel_location(x, y);
1014 if (Passes_walls && may_passwall(x, y)) {
1015 ; /* do nothing */
1016 } else if (Underwater) {
1017 /* note: if water_friction() changes direction due to
1018 turbulence, new target destination will always be water,
1019 so we won't get here, hence don't need to worry about
1020 "there" being somewhere the player isn't sure of */
1021 if (mode == DO_MOVE)
1022 There("is an obstacle there.");
1023 return FALSE;
1024 } else if (tmpr->typ == IRONBARS) {
1025 if (mode == DO_MOVE
1026 && (dmgtype(gy.youmonst.data, AD_RUST)
1027 || dmgtype(gy.youmonst.data, AD_CORR)
1028 || metallivorous(gy.youmonst.data))
1029 && still_chewing(x, y)) {
1030 return FALSE;
1031 }
1032 if (!(Passes_walls || passes_bars(gy.youmonst.data))) {
1033 if (mode == DO_MOVE && flags.mention_walls)
1034 You("cannot pass through the bars.");
1035 return FALSE;
1036 }
1037 } else if (tunnels(gy.youmonst.data)
1038 && !needspick(gy.youmonst.data)) {
1039 /* Eat the rock. */
1040 if (mode == DO_MOVE && still_chewing(x, y))
1041 return FALSE;
1042 } else if (flags.autodig && !svc.context.run && !svc.context.nopick
1043 && uwep && is_pick(uwep)) {
1044 /* MRKR: Automatic digging when wielding the appropriate tool */
1045 if (mode == DO_MOVE)
1046 (void) use_pick_axe2(uwep);
1047 return FALSE;

Callers 10

mhitm_knockbackFunction · 0.85
mount_steedFunction · 0.85
landing_spotFunction · 0.85
findtravelpathFunction · 0.85
avoid_trap_andor_regionFunction · 0.85
domove_coreFunction · 0.85
move_into_trapFunction · 0.85
bhitFunction · 0.85
there_cmd_menuFunction · 0.85
domouseactionFunction · 0.85

Calls 15

isokFunction · 0.85
feel_locationFunction · 0.85
may_passwallFunction · 0.85
ThereFunction · 0.85
dmgtypeFunction · 0.85
still_chewingFunction · 0.85
passes_barsFunction · 0.85
YouFunction · 0.85
use_pick_axe2Function · 0.85
is_db_wallFunction · 0.85
pline_TheFunction · 0.85
back_to_glyphFunction · 0.85

Tested by

no test coverage detected