the #close command - try to close a door */
| 954 | |
| 955 | /* the #close command - try to close a door */ |
| 956 | int |
| 957 | doclose(void) |
| 958 | { |
| 959 | coordxy x, y; |
| 960 | struct rm *door; |
| 961 | boolean portcullis; |
| 962 | int res = ECMD_OK; |
| 963 | |
| 964 | if (nohands(gy.youmonst.data)) { |
| 965 | You_cant("close anything -- you have no hands!"); |
| 966 | return ECMD_OK; |
| 967 | } |
| 968 | |
| 969 | if (u.utrap && u.utraptype == TT_PIT) { |
| 970 | You_cant("reach over the edge of the pit."); |
| 971 | return ECMD_OK; |
| 972 | } |
| 973 | |
| 974 | if (!getdir((char *) 0)) |
| 975 | return ECMD_CANCEL; |
| 976 | |
| 977 | x = u.ux + u.dx; |
| 978 | y = u.uy + u.dy; |
| 979 | if (u_at(x, y) && !Passes_walls) { |
| 980 | You("are in the way!"); |
| 981 | return ECMD_TIME; |
| 982 | } |
| 983 | |
| 984 | if (!isok(x, y)) |
| 985 | goto nodoor; |
| 986 | |
| 987 | if (stumble_on_door_mimic(x, y)) |
| 988 | return ECMD_TIME; |
| 989 | |
| 990 | /* when choosing a direction is impaired, use a turn |
| 991 | regardless of whether a door is successfully targeted */ |
| 992 | if (Confusion || Stunned) |
| 993 | res = ECMD_TIME; |
| 994 | |
| 995 | door = &levl[x][y]; |
| 996 | portcullis = (is_drawbridge_wall(x, y) >= 0); |
| 997 | if (Blind) { |
| 998 | int oldglyph = door->glyph; |
| 999 | schar oldlastseentyp = update_mapseen_for(x, y); |
| 1000 | |
| 1001 | feel_location(x, y); |
| 1002 | if (door->glyph != oldglyph |
| 1003 | || svl.lastseentyp[x][y] != oldlastseentyp) |
| 1004 | res = ECMD_TIME; /* learned something */ |
| 1005 | } |
| 1006 | |
| 1007 | if (portcullis || !IS_DOOR(door->typ)) { |
| 1008 | /* is_db_wall: closed portcullis */ |
| 1009 | if (is_db_wall(x, y) || door->typ == DRAWBRIDGE_UP) |
| 1010 | pline_The("drawbridge is already closed."); |
| 1011 | else if (portcullis || door->typ == DRAWBRIDGE_DOWN) |
| 1012 | There("is no obvious way to close the drawbridge."); |
| 1013 | else { |
nothing calls this directly
no test coverage detected