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 */
| 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 */ |
| 990 | boolean |
| 991 | test_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; |
no test coverage detected