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

Function parent_dlevel

src/dungeon.c:414–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414staticfn xint16
415parent_dlevel(const char *s, struct proto_dungeon *pd)
416{
417 int i, j, num, base, dnum = parent_dnum(s, pd);
418 branch *curr;
419
420 i = find_branch(s, pd);
421 num = level_range(dnum, pd->tmpbranch[i].lev.base,
422 pd->tmpbranch[i].lev.rand, pd->tmpbranch[i].chain, pd,
423 &base);
424
425 /* KMH -- Try our best to find a level without an existing branch */
426 i = j = rn2(num);
427 do {
428 if (++i >= num)
429 i = 0;
430 for (curr = svb.branches; curr; curr = curr->next)
431 if ((curr->end1.dnum == dnum && curr->end1.dlevel == base + i)
432 || (curr->end2.dnum == dnum && curr->end2.dlevel == base + i))
433 break;
434 } while (curr && i != j);
435 return (base + i);
436}
437
438/* Convert from the temporary branch type to the dungeon branch type. */
439staticfn int

Callers 1

add_branchFunction · 0.85

Calls 4

parent_dnumFunction · 0.85
find_branchFunction · 0.85
level_rangeFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected