Create stairs up or down at x,y. If force is TRUE, change the terrain to ROOM first */
| 2156 | /* Create stairs up or down at x,y. |
| 2157 | If force is TRUE, change the terrain to ROOM first */ |
| 2158 | void |
| 2159 | mkstairs( |
| 2160 | coordxy x, coordxy y, |
| 2161 | char up, /* [why 'char' when usage is boolean?] */ |
| 2162 | struct mkroom *croom UNUSED, |
| 2163 | boolean force) |
| 2164 | { |
| 2165 | int ltyp; |
| 2166 | d_level dest; |
| 2167 | |
| 2168 | if (!x || !isok(x, y)) { |
| 2169 | impossible("mkstairs: bogus stair attempt at <%d,%d>", x, y); |
| 2170 | return; |
| 2171 | } |
| 2172 | if (force) |
| 2173 | levl[x][y].typ = ROOM; |
| 2174 | ltyp = levl[x][y].typ; /* somexyspace() allows ice */ |
| 2175 | if (ltyp != ROOM && ltyp != CORR && ltyp != ICE) { |
| 2176 | int glyph = back_to_glyph(x, y), |
| 2177 | sidx = glyph_to_cmap(glyph); |
| 2178 | |
| 2179 | impossible("mkstairs: placing stairs %s on %s at <%d,%d>", |
| 2180 | up ? "up" : "down", defsyms[sidx].explanation, x, y); |
| 2181 | } |
| 2182 | |
| 2183 | /* |
| 2184 | * We can't make a regular stair off an end of the dungeon. This |
| 2185 | * attempt can happen when a special level is placed at an end and |
| 2186 | * has an up or down stair specified in its description file. |
| 2187 | */ |
| 2188 | if (dunlev(&u.uz) == (up ? 1 : dunlevs_in_dungeon(&u.uz))) |
| 2189 | return; |
| 2190 | |
| 2191 | dest.dnum = u.uz.dnum; |
| 2192 | dest.dlevel = u.uz.dlevel + (up ? -1 : 1); |
| 2193 | stairway_add(x, y, up ? TRUE : FALSE, FALSE, &dest); |
| 2194 | |
| 2195 | (void) set_levltyp(x, y, STAIRS); |
| 2196 | levl[x][y].ladder = up ? LA_UP : LA_DOWN; |
| 2197 | } |
| 2198 | |
| 2199 | /* is room a good one to generate up or down stairs in? */ |
| 2200 | staticfn boolean |
no test coverage detected