used by sel_set_door() and link_doors_rooms() */
| 1039 | |
| 1040 | /* used by sel_set_door() and link_doors_rooms() */ |
| 1041 | staticfn void |
| 1042 | set_door_orientation(int x, int y) |
| 1043 | { |
| 1044 | boolean wleft, wright, wup, wdown; |
| 1045 | |
| 1046 | /* If there's a wall or door on either the left side or right |
| 1047 | * side (or both) of this secret door, make it be horizontal. |
| 1048 | * |
| 1049 | * It is feasible to put SDOOR in a corner, tee, or crosswall |
| 1050 | * position, although once the door is found and opened it won't |
| 1051 | * make a lot sense (diagonal access required). Still, we try to |
| 1052 | * handle that as best as possible. For top or bottom tee, using |
| 1053 | * horizontal is the best we can do. For corner or crosswall, |
| 1054 | * either horizontal or vertical are just as good as each other; |
| 1055 | * we produce horizontal for corners and vertical for crosswalls. |
| 1056 | * For left or right tee, using vertical is best. |
| 1057 | * |
| 1058 | * A secret door with no adjacent walls is also feasible and makes |
| 1059 | * even less sense. It will be displayed as a vertical wall while |
| 1060 | * hidden and become a vertical door when found. Before resorting |
| 1061 | * to that, we check for solid rock which hasn't been wallified |
| 1062 | * yet (cf lower leftside of leader's room in Cav quest). |
| 1063 | */ |
| 1064 | wleft = (isok(x - 1, y) && (IS_WALL(levl[x - 1][y].typ) |
| 1065 | || IS_DOOR(levl[x - 1][y].typ) |
| 1066 | || levl[x - 1][y].typ == SDOOR)); |
| 1067 | wright = (isok(x + 1, y) && (IS_WALL(levl[x + 1][y].typ) |
| 1068 | || IS_DOOR(levl[x + 1][y].typ) |
| 1069 | || levl[x + 1][y].typ == SDOOR)); |
| 1070 | wup = (isok(x, y - 1) && (IS_WALL(levl[x][y - 1].typ) |
| 1071 | || IS_DOOR(levl[x][y - 1].typ) |
| 1072 | || levl[x][y - 1].typ == SDOOR)); |
| 1073 | wdown = (isok(x, y + 1) && (IS_WALL(levl[x][y + 1].typ) |
| 1074 | || IS_DOOR(levl[x][y + 1].typ) |
| 1075 | || levl[x][y + 1].typ == SDOOR)); |
| 1076 | if (!wleft && !wright && !wup && !wdown) { |
| 1077 | /* out of bounds is treated as implicit wall; should be academic |
| 1078 | because we don't expect to have doors so near the level's edge */ |
| 1079 | wleft = (!isok(x - 1, y) || IS_DOORJOIN(levl[x - 1][y].typ)); |
| 1080 | wright = (!isok(x + 1, y) || IS_DOORJOIN(levl[x + 1][y].typ)); |
| 1081 | wup = (!isok(x, y - 1) || IS_DOORJOIN(levl[x][y - 1].typ)); |
| 1082 | wdown = (!isok(x, y + 1) || IS_DOORJOIN(levl[x][y + 1].typ)); |
| 1083 | } |
| 1084 | levl[x][y].horizontal = ((wleft || wright) && !(wup && wdown)) ? 1 : 0; |
| 1085 | } |
| 1086 | |
| 1087 | /* is x,y right next to room droom? */ |
| 1088 | staticfn boolean |
no test coverage detected