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

Function add_branch

src/dungeon.c:513–536  ·  view source on GitHub ↗

Add a dungeon branch to the branch list. */

Source from the content-addressed store, hash-verified

511
512/* Add a dungeon branch to the branch list. */
513staticfn branch *
514add_branch(
515 int dgn, int child_entry_level,
516 struct proto_dungeon *pd)
517{
518 static int branch_id = 0;
519 int branch_num;
520 branch *new_branch;
521
522 branch_num = find_branch(svd.dungeons[dgn].dname, pd);
523 new_branch = (branch *) alloc(sizeof(branch));
524 (void) memset((genericptr_t) new_branch, 0, sizeof(branch));
525 new_branch->next = (branch *) 0;
526 new_branch->id = branch_id++;
527 new_branch->type = correct_branch_type(&pd->tmpbranch[branch_num]);
528 new_branch->end1.dnum = parent_dnum(svd.dungeons[dgn].dname, pd);
529 new_branch->end1.dlevel = parent_dlevel(svd.dungeons[dgn].dname, pd);
530 new_branch->end2.dnum = dgn;
531 new_branch->end2.dlevel = child_entry_level;
532 new_branch->end1_up = pd->tmpbranch[branch_num].up ? TRUE : FALSE;
533
534 insert_branch(new_branch, FALSE);
535 return new_branch;
536}
537
538/*
539 * Add new level to special level chain. Insert it in level order with the

Callers 1

init_dungeon_set_depthFunction · 0.85

Calls 6

find_branchFunction · 0.85
correct_branch_typeFunction · 0.85
parent_dnumFunction · 0.85
parent_dlevelFunction · 0.85
insert_branchFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected