<Someone> wrote:

> The new ^V wizmode menu is nice, but it is rather misleading; most of
> the levels it lists are "you can't get there from here". Would it be
> possible either to make it only list levels that can be reached
> directly, or alternatively to allow you to reach the ones you
> ordinarily couldn't (maybe by forcefully changing u.uz.dnum to yoink
> you into the right branch, and even summarily issuing you with an
> Amulet if you ask to teleport to the endgame).[...]; being able to bamf
> quickly to Minetown from DL 1, for example, would be damn useful in > testing stuff.

Allow fairly free roaming of the dungeon via the wizard mode teleport menu.
This commit is contained in:
nethack.allison
2003-11-02 17:59:22 +00:00
parent 5c9c0732cb
commit e3462e093e
4 changed files with 87 additions and 44 deletions

View File

@@ -27,6 +27,14 @@ int n_dgns; /* number of dungeons (used here, */
/* 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 *));
@@ -42,7 +50,7 @@ STATIC_DCL xchar FDECL(pick_level, (boolean *, int));
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
@@ -1515,13 +1523,13 @@ br_string(type)
/* 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];
@@ -1536,14 +1544,16 @@ print_branch(win, dnum, lower_bound, upper_bound, bymenu, menuletter)
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);
}
@@ -1551,9 +1561,11 @@ print_branch(win, dnum, lower_bound, upper_bound, bymenu, menuletter)
}
/* 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];
@@ -1561,13 +1573,14 @@ boolean bymenu;
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++) {
@@ -1600,37 +1613,42 @@ boolean bymenu;
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");
}
@@ -1638,32 +1656,28 @@ boolean bymenu;
}
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 */