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

Function init_dungeon_set_depth

src/dungeon.c:959–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957}
958
959staticfn void
960init_dungeon_set_depth(struct proto_dungeon *pd, int dngidx)
961{
962 branch *br;
963 schar from_depth;
964 boolean from_up;
965
966 br = add_branch(dngidx, svd.dungeons[dngidx].entry_lev, pd);
967
968 /* Get the depth of the connecting end. */
969 if (br->end1.dnum == dngidx) {
970 from_depth = depth(&br->end2);
971 from_up = !br->end1_up;
972 } else {
973 from_depth = depth(&br->end1);
974 from_up = br->end1_up;
975 }
976
977 /*
978 * Calculate the depth of the top of the dungeon via
979 * its branch. First, the depth of the entry point:
980 *
981 * depth of branch from "parent" dungeon
982 * + -1 or 1 depending on an up or down stair or
983 * 0 if portal
984 *
985 * Followed by the depth of the top of the dungeon:
986 *
987 * - (entry depth - 1)
988 *
989 * We'll say that portals stay on the same depth.
990 */
991 svd.dungeons[dngidx].depth_start =
992 from_depth + (br->type == BR_PORTAL ? 0 : (from_up ? -1 : 1))
993 - (svd.dungeons[dngidx].entry_lev - 1);
994}
995
996staticfn boolean
997init_dungeon_dungeons(

Callers 1

init_dungeon_dungeonsFunction · 0.85

Calls 2

add_branchFunction · 0.85
depthFunction · 0.85

Tested by

no test coverage detected