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

Function find_branch

src/dungeon.c:310–337  ·  view source on GitHub ↗

Find the branch that links the named dungeon. */

Source from the content-addressed store, hash-verified

308
309/* Find the branch that links the named dungeon. */
310staticfn int
311find_branch(
312 const char *s, /* dungeon name */
313 struct proto_dungeon *pd)
314{
315 int i;
316
317 if (pd) {
318 for (i = 0; i < pd->n_brs; i++)
319 if (!strcmp(pd->tmpbranch[i].name, s))
320 break;
321 if (i == pd->n_brs)
322 panic("find_branch: can't find %s", s);
323 } else {
324 /* support for level tport by name */
325 branch *br;
326 const char *dnam;
327
328 for (br = svb.branches; br; br = br->next) {
329 dnam = svd.dungeons[br->end2.dnum].dname;
330 if (!strcmpi(dnam, s)
331 || (!strncmpi(dnam, "The ", 4) && !strcmpi(dnam + 4, s)))
332 break;
333 }
334 i = br ? ((ledger_no(&br->end1) << 8) | ledger_no(&br->end2)) : -1;
335 }
336 return i;
337}
338
339DISABLE_WARNING_UNREACHABLE_CODE
340

Callers 4

parent_dnumFunction · 0.85
parent_dlevelFunction · 0.85
add_branchFunction · 0.85
lev_by_nameFunction · 0.85

Calls 3

ledger_noFunction · 0.85
strncmpiFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected