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

Function fixup_level_locations

src/dungeon.c:1121–1182  ·  view source on GitHub ↗

fix up the special level names and locations for quick access */

Source from the content-addressed store, hash-verified

1119
1120/* fix up the special level names and locations for quick access */
1121staticfn void
1122fixup_level_locations(void)
1123{
1124 int i;
1125 s_level *x;
1126 struct level_map *lev_map;
1127
1128 /*
1129 * Find most of the special levels and dungeons so we can access their
1130 * locations quickly.
1131 */
1132 for (lev_map = level_map; lev_map->lev_name[0]; lev_map++) {
1133 x = find_level(lev_map->lev_name);
1134 if (x) {
1135 assign_level(lev_map->lev_spec, &x->dlevel);
1136 if (!strncmp(lev_map->lev_name, "x-", 2)) {
1137 /* This is where the name substitution on the
1138 * levels of the quest dungeon occur.
1139 */
1140 Sprintf(x->proto, "%s%s", gu.urole.filecode,
1141 &lev_map->lev_name[1]);
1142 } else if (lev_map->lev_spec == &knox_level) {
1143 branch *br;
1144 /*
1145 * Kludge to allow floating Knox entrance. We
1146 * specify a floating entrance by the fact that its
1147 * entrance (end1) has a bogus dnum, namely n_dgns.
1148 */
1149 for (br = svb.branches; br; br = br->next)
1150 if (on_level(&br->end2, &knox_level))
1151 break;
1152
1153 if (br) {
1154 br->end1.dnum = svn.n_dgns;
1155 /* adjust the branch's position on the list */
1156 insert_branch(br, TRUE);
1157 }
1158 }
1159 }
1160 }
1161 /*
1162 * I hate hardwiring these names. :-(
1163 */
1164 quest_dnum = dname_to_dnum("The Quest");
1165 sokoban_dnum = dname_to_dnum("Sokoban");
1166 mines_dnum = dname_to_dnum("The Gnomish Mines");
1167 tower_dnum = dname_to_dnum("Vlad's Tower");
1168 tutorial_dnum = dname_to_dnum("The Tutorial");
1169
1170 /* one special fixup for dummy surface level */
1171 if ((x = find_level("dummy")) != 0) {
1172 i = x->dlevel.dnum;
1173 /* the code above puts earth one level above dungeon level #1,
1174 making the dummy level overlay level 1; but the whole reason
1175 for having the dummy level is to make earth have depth -1
1176 instead of 0, so adjust the start point to shift endgame up */
1177 if (dunlevs_in_dungeon(&x->dlevel) > 1 - svd.dungeons[i].depth_start)
1178 svd.dungeons[i].depth_start -= 1;

Callers 1

init_dungeonsFunction · 0.85

Calls 6

find_levelFunction · 0.85
assign_levelFunction · 0.85
on_levelFunction · 0.85
insert_branchFunction · 0.85
dname_to_dnumFunction · 0.85
dunlevs_in_dungeonFunction · 0.85

Tested by

no test coverage detected