| 5143 | } |
| 5144 | |
| 5145 | staticfn boolean |
| 5146 | generate_way_out_method( |
| 5147 | coordxy nx, coordxy ny, |
| 5148 | struct selectionvar *ov) |
| 5149 | { |
| 5150 | static const int escapeitems[] = { |
| 5151 | PICK_AXE, DWARVISH_MATTOCK, WAN_DIGGING, |
| 5152 | WAN_TELEPORTATION, SCR_TELEPORTATION, RIN_TELEPORTATION |
| 5153 | }; |
| 5154 | struct selectionvar *ov2 = selection_new(), *ov3; |
| 5155 | coordxy x, y; |
| 5156 | boolean res = TRUE; |
| 5157 | |
| 5158 | selection_floodfill(ov2, nx, ny, TRUE); |
| 5159 | ov3 = selection_clone(ov2); |
| 5160 | |
| 5161 | /* try to make a secret door */ |
| 5162 | while (selection_rndcoord(ov3, &x, &y, TRUE)) { |
| 5163 | if (isok(x + 1, y) && !selection_getpoint(x + 1, y, ov) |
| 5164 | && IS_WALL(levl[x + 1][y].typ) |
| 5165 | && isok(x + 2, y) && selection_getpoint(x + 2, y, ov) |
| 5166 | && ACCESSIBLE(levl[x + 2][y].typ)) { |
| 5167 | levl[x + 1][y].typ = SDOOR; |
| 5168 | goto gotitdone; |
| 5169 | } |
| 5170 | if (isok(x - 1, y) && !selection_getpoint(x - 1, y, ov) |
| 5171 | && IS_WALL(levl[x - 1][y].typ) |
| 5172 | && isok(x - 2, y) && selection_getpoint(x - 2, y, ov) |
| 5173 | && ACCESSIBLE(levl[x - 2][y].typ)) { |
| 5174 | levl[x - 1][y].typ = SDOOR; |
| 5175 | goto gotitdone; |
| 5176 | } |
| 5177 | if (isok(x, y + 1) && !selection_getpoint(x, y + 1, ov) |
| 5178 | && IS_WALL(levl[x][y + 1].typ) |
| 5179 | && isok(x, y + 2) && selection_getpoint(x, y + 2, ov) |
| 5180 | && ACCESSIBLE(levl[x][y + 2].typ)) { |
| 5181 | levl[x][y + 1].typ = SDOOR; |
| 5182 | goto gotitdone; |
| 5183 | } |
| 5184 | if (isok(x, y - 1) && !selection_getpoint(x, y - 1, ov) |
| 5185 | && IS_WALL(levl[x][y - 1].typ) |
| 5186 | && isok(x, y - 2) && selection_getpoint(x, y - 2, ov) |
| 5187 | && ACCESSIBLE(levl[x][y - 2].typ)) { |
| 5188 | levl[x][y - 1].typ = SDOOR; |
| 5189 | goto gotitdone; |
| 5190 | } |
| 5191 | } |
| 5192 | |
| 5193 | /* try to make a hole or a trapdoor */ |
| 5194 | if (Can_fall_thru(&u.uz)) { |
| 5195 | selection_free(ov3, TRUE); |
| 5196 | ov3 = selection_clone(ov2); |
| 5197 | while (selection_rndcoord(ov3, &x, &y, TRUE)) { |
| 5198 | if (maketrap(x, y, rn2(2) ? HOLE : TRAPDOOR)) |
| 5199 | goto gotitdone; |
| 5200 | } |
| 5201 | } |
| 5202 |
no test coverage detected