MCPcopy Create free account
hub / github.com/NetHack/NetHack / generate_stairs

Function generate_stairs

src/mklev.c:2249–2282  ·  view source on GitHub ↗

construct stairs up and down within the same branch, up and down in different rooms if possible */

Source from the content-addressed store, hash-verified

2247/* construct stairs up and down within the same branch,
2248 up and down in different rooms if possible */
2249staticfn void
2250generate_stairs(void)
2251{
2252 /* generate_stairs_find_room() returns Null if nroom == 0, but that
2253 should never happen for a rooms+corridors style level */
2254 static const char
2255 gen_stairs_panic[] = "generate_stairs: failed to find a room! (%d)";
2256 struct mkroom *croom;
2257 coord pos;
2258
2259 if (!Is_botlevel(&u.uz)) {
2260 if ((croom = generate_stairs_find_room()) == NULL)
2261 panic(gen_stairs_panic, svn.nroom);
2262
2263 if (!somexyspace(croom, &pos)) {
2264 pos.x = somex(croom);
2265 pos.y = somey(croom);
2266 }
2267 mkstairs(pos.x, pos.y, 0, croom, FALSE); /* down */
2268 }
2269
2270 if (u.uz.dlevel != 1) {
2271 /* if there is only 1 room and we found it above, this will find
2272 it again */
2273 if ((croom = generate_stairs_find_room()) == NULL)
2274 panic(gen_stairs_panic, svn.nroom);
2275
2276 if (!somexyspace(croom, &pos)) {
2277 pos.x = somex(croom);
2278 pos.y = somey(croom);
2279 }
2280 mkstairs(pos.x, pos.y, 1, croom, FALSE); /* up */
2281 }
2282}
2283
2284staticfn void
2285mkfount(struct mkroom *croom)

Callers 1

makelevelFunction · 0.85

Calls 7

Is_botlevelFunction · 0.85
somexyspaceFunction · 0.85
somexFunction · 0.85
someyFunction · 0.85
mkstairsFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected