/* and mklev.c) */
static branch *branches = (branch *) 0; /* dungeon branch list */
+struct lchoice {
+ int idx;
+ schar lev[MAXLINFO];
+ schar playerlev[MAXLINFO];
+ xchar dgn[MAXLINFO];
+ char menuletter;
+};
+
static void FDECL(Fread, (genericptr_t, int, int, dlb *));
STATIC_DCL xchar FDECL(dname_to_dnum, (const char *));
STATIC_DCL int FDECL(find_branch, (const char *, struct proto_dungeon *));
STATIC_DCL boolean FDECL(place_level, (int, struct proto_dungeon *));
#ifdef WIZARD
STATIC_DCL const char *FDECL(br_string, (int));
-STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P, char *));
+STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P, struct lchoice *));
#endif
#ifdef DEBUG
/* Print all child branches between the lower and upper bounds. */
STATIC_OVL void
-print_branch(win, dnum, lower_bound, upper_bound, bymenu, menuletter)
+print_branch(win, dnum, lower_bound, upper_bound, bymenu, lchoices)
winid win;
int dnum;
int lower_bound;
int upper_bound;
boolean bymenu;
- char *menuletter;
+ struct lchoice *lchoices;
{
branch *br;
char buf[BUFSZ];
dungeons[br->end2.dnum].dname,
depth(&br->end1));
if (bymenu) {
- schar lev = depth(&br->end1);
+ lchoices->lev[lchoices->idx] = br->end1.dlevel;
+ lchoices->dgn[lchoices->idx] = br->end1.dnum;
+ lchoices->playerlev[lchoices->idx] = depth(&br->end1);
any.a_void = 0;
- if (lev >= 0) any.a_schar = lev + 1;
- else any.a_schar = lev;
- add_menu(win, NO_GLYPH, &any, *menuletter,
+ any.a_int = lchoices->idx + 1;
+ add_menu(win, NO_GLYPH, &any, lchoices->menuletter,
0, ATR_NONE, buf, MENU_UNSELECTED);
- if (*menuletter == 'z') *menuletter = 'A';
- else *menuletter += 1;
+ if (lchoices->menuletter == 'z') lchoices->menuletter = 'A';
+ else lchoices->menuletter++;
+ lchoices->idx++;
} else
putstr(win, 0, buf);
}
}
/* Print available dungeon information. */
-schar
-print_dungeon(bymenu)
+boolean
+print_dungeon(bymenu, rlev, rdgn)
boolean bymenu;
+schar *rlev;
+xchar *rdgn;
{
int i, last_level, nlev;
char buf[BUFSZ];
s_level *slev;
dungeon *dptr;
branch *br;
-
anything any;
- char mlet;
+ struct lchoice lchoices;
+
winid win = create_nhwindow(NHW_MENU);
if (bymenu) {
start_menu(win);
- mlet = 'a';
+ lchoices.idx = 0;
+ lchoices.menuletter = 'a';
}
for (i = 0, dptr = dungeons; i < n_dgns; i++, dptr++) {
if (slev->dlevel.dnum != i) continue;
/* print any branches before this level */
- print_branch(win, i, last_level, slev->dlevel.dlevel, bymenu, &mlet);
+ print_branch(win, i, last_level, slev->dlevel.dlevel, bymenu, &lchoices);
Sprintf(buf, " %s: %d", slev->proto, depth(&slev->dlevel));
if (Is_stronghold(&slev->dlevel))
Sprintf(eos(buf), " (tune %s)", tune);
if (bymenu) {
- schar lev = depth(&slev->dlevel);
+ /* If other floating branches are added, this will need to change */
+ if (i != knox_level.dnum) {
+ lchoices.lev[lchoices.idx] = slev->dlevel.dlevel;
+ lchoices.dgn[lchoices.idx] = i;
+ } else {
+ lchoices.lev[lchoices.idx] = depth(&slev->dlevel);
+ lchoices.dgn[lchoices.idx] = 0;
+ }
+ lchoices.playerlev[lchoices.idx] = depth(&slev->dlevel);
any.a_void = 0;
- if (lev >= 0) any.a_schar = lev + 1;
- else any.a_schar = lev;
- add_menu(win, NO_GLYPH, &any, mlet, 0, ATR_NONE, buf, MENU_UNSELECTED);
- if (mlet == 'z') mlet = 'A';
- else mlet++;
+ any.a_int = lchoices.idx + 1;
+ add_menu(win, NO_GLYPH, &any, lchoices.menuletter,
+ 0, ATR_NONE, buf, MENU_UNSELECTED);
+ if (lchoices.menuletter == 'z') lchoices.menuletter = 'A';
+ else lchoices.menuletter++;
+ lchoices.idx++;
} else
putstr(win, 0, buf);
last_level = slev->dlevel.dlevel;
}
/* print branches after the last special level */
- print_branch(win, i, last_level, MAXLEVEL, bymenu, &mlet);
+ print_branch(win, i, last_level, MAXLEVEL, bymenu, &lchoices);
}
/* Print out floating branches (if any). */
for (first = TRUE, br = branches; br; br = br->next) {
if (br->end1.dnum == n_dgns) {
if (first) {
- if (bymenu) {
- any.a_void = 0;
- add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
- "Floating branches", MENU_UNSELECTED);
- } else {
+ if (!bymenu) {
putstr(win, 0, "");
putstr(win, 0, "Floating branches");
}
}
Sprintf(buf, " %s to %s",
br_string(br->type), dungeons[br->end2.dnum].dname);
- if (bymenu) {
- schar lev = lev_by_name(dungeons[br->end2.dnum].dname);
- any.a_void = 0;
- if (lev >= 0) any.a_schar = lev + 1;
- else any.a_schar = lev;
- add_menu(win, NO_GLYPH, &any, mlet, 0, ATR_NONE, buf, MENU_UNSELECTED);
- if (mlet == 'z') mlet = 'A';
- else mlet++;
- } else
+ if (!bymenu)
putstr(win, 0, buf);
}
}
if (bymenu) {
int n;
menu_item *selected;
- schar lev = 0;
+ int idx;
end_menu(win, "Level teleport to where:");
n = select_menu(win, PICK_ONE, &selected);
destroy_nhwindow(win);
if (n > 0) {
- lev = selected[0].item.a_schar;
- if (lev > 0) lev--;
+ idx = selected[0].item.a_int - 1;
free((genericptr_t)selected);
+ if (rlev && rdgn) {
+ *rlev = lchoices.lev[idx];
+ *rdgn = lchoices.dgn[idx];
+ return lchoices.playerlev[idx];
+ }
}
- return lev;
+ return 0;
}
/* I hate searching for the invocation pos while debugging. -dean */
d_level newlevel;
const char *escape_by_flying = 0; /* when surviving dest of -N */
char buf[BUFSZ];
+ boolean force_dest = FALSE;
if ((u.uhave.amulet || In_endgame(&u.uz) || In_sokoban(&u.uz))
#ifdef WIZARD
}
#ifdef WIZARD
if (wizard && !strcmp(buf,"?")) {
- newlev = print_dungeon(TRUE);
+ schar destlev = 0;
+ xchar destdnum = 0;
+ if ((newlev = (int)print_dungeon(TRUE, &destlev, &destdnum))) {
+ char buf[BUFSZ];
+ newlevel.dnum = destdnum;
+ newlevel.dlevel = destlev;
+ if (In_endgame(&newlevel) && !In_endgame(&u.uz)) {
+ Sprintf(buf,
+ "Destination is earth level");
+ if (!u.uhave.amulet) {
+ struct obj *obj;
+ obj = mksobj(AMULET_OF_YENDOR,
+ TRUE, FALSE);
+ if (obj) {
+ obj = addinv(obj);
+ Strcat(buf, " with the amulet");
+ }
+ }
+ assign_level(&newlevel, &earth_level);
+ pline("%s.", buf);
+ }
+ force_dest = TRUE;
+ } else return;
} else
#endif
if ((newlev = lev_by_name(buf)) == 0) newlev = atoi(buf);
killer.name[0] = 0; /* still alive, so far... */
- if (newlev < 0) {
+ if (newlev < 0 && !force_dest) {
if (*u.ushops0) {
/* take unpaid inventory items off of shop bills */
in_mklev = TRUE; /* suppress map update */
} else if (u.uz.dnum == medusa_level.dnum &&
newlev >= dungeons[u.uz.dnum].depth_start +
dunlevs_in_dungeon(&u.uz)) {
+#ifdef WIZARD
+ if (!(wizard && force_dest))
+#endif
find_hell(&newlevel);
} else {
/* if invocation did not yet occur, teleporting into
* we must translate newlev to a number relative to the
* current dungeon.
*/
+#ifdef WIZARD
+ if (!(wizard && force_dest))
+#endif
get_level(&newlevel, newlev);
}
schedule_goto(&newlevel, FALSE, FALSE, 0, (char *)0, (char *)0);