MCPcopy Index your code
hub / github.com/NetHack/NetHack / makelevel

Function makelevel

src/mklev.c:1250–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1248
1249
1250staticfn void
1251makelevel(void)
1252{
1253 struct mkroom *croom;
1254 branch *branchp;
1255 stairway *prevstairs;
1256 int room_threshold;
1257 s_level *slev;
1258 int i;
1259
1260 if (wiz1_level.dlevel == 0) {
1261 impossible("makelevel() called when dungeon not yet initialized.");
1262 init_dungeons();
1263 }
1264 oinit(); /* assign level dependent obj probabilities */
1265 clear_level_structures();
1266
1267 slev = Is_special(&u.uz);
1268 /* check for special levels */
1269 if (slev && !Is_rogue_level(&u.uz)) {
1270 makemaz(slev->proto);
1271 } else if (svd.dungeons[u.uz.dnum].proto[0]) {
1272 makemaz("");
1273 } else if (svd.dungeons[u.uz.dnum].fill_lvl[0]) {
1274 makemaz(svd.dungeons[u.uz.dnum].fill_lvl);
1275 } else if (In_quest(&u.uz)) {
1276 char fillname[9];
1277 s_level *loc_lev;
1278
1279 Sprintf(fillname, "%s-loca", gu.urole.filecode);
1280 loc_lev = find_level(fillname);
1281
1282 Sprintf(fillname, "%s-fil", gu.urole.filecode);
1283 Strcat(fillname,
1284 (u.uz.dlevel < loc_lev->dlevel.dlevel) ? "a" : "b");
1285 makemaz(fillname);
1286 } else if (In_hell(&u.uz)
1287 || (rn2(5) && u.uz.dnum == medusa_level.dnum
1288 && depth(&u.uz) > depth(&medusa_level))) {
1289 makemaz("");
1290 } else {
1291 /* otherwise, fall through - it's a "regular" level. */
1292 int u_depth = depth(&u.uz);
1293
1294 if (Is_rogue_level(&u.uz)) {
1295 makeroguerooms();
1296 makerogueghost();
1297 } else {
1298 makerooms();
1299 }
1300 assert(svn.nroom > 0);
1301 sort_rooms();
1302
1303 generate_stairs(); /* up and down stairs */
1304
1305 branchp = Is_branchlev(&u.uz); /* possible dungeon branch */
1306 room_threshold = branchp ? 4 : 3; /* minimum number of rooms needed
1307 to allow a random special room */

Callers 1

mklevFunction · 0.85

Calls 15

init_dungeonsFunction · 0.85
oinitFunction · 0.85
clear_level_structuresFunction · 0.85
Is_specialFunction · 0.85
makemazFunction · 0.85
In_questFunction · 0.85
find_levelFunction · 0.85
In_hellFunction · 0.85
rn2Function · 0.85
depthFunction · 0.85
makerogueroomsFunction · 0.85
makerogueghostFunction · 0.85

Tested by

no test coverage detected