wizmode level teleport via menu

If you answer '?' to the level teleport prompt
in debug mode, you get a menu to choose
from, similar to the control-O print_dungeon
display.
This commit is contained in:
nethack.allison
2003-08-17 19:10:52 +00:00
parent 95e4443c11
commit 82e8dd3247
6 changed files with 86 additions and 15 deletions

View File

@@ -157,6 +157,7 @@ unix: better error message for .nethackrc access problems
General New Features General New Features
-------------------- --------------------
debug mode level teleport menu via '?'
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features

View File

@@ -505,7 +505,7 @@ E boolean FDECL(Invocation_lev, (d_level *));
E xchar NDECL(level_difficulty); E xchar NDECL(level_difficulty);
E schar FDECL(lev_by_name, (const char *)); E schar FDECL(lev_by_name, (const char *));
#ifdef WIZARD #ifdef WIZARD
E void NDECL(print_dungeon); E schar FDECL(print_dungeon, (BOOLEAN_P));
#endif #endif
/* ### eat.c ### */ /* ### eat.c ### */

View File

@@ -13,6 +13,7 @@ typedef union any {
struct obj *a_obj; struct obj *a_obj;
int a_int; int a_int;
char a_char; char a_char;
schar a_schar;
/* add types as needed */ /* add types as needed */
} anything; } anything;
#define ANY_P union any /* avoid typedef in prototypes */ #define ANY_P union any /* avoid typedef in prototypes */

View File

@@ -555,7 +555,7 @@ wiz_genesis()
STATIC_PTR int STATIC_PTR int
wiz_where() wiz_where()
{ {
if (wizard) print_dungeon(); if (wizard) (void) print_dungeon(FALSE);
else pline("Unavailable command '^O'."); else pline("Unavailable command '^O'.");
return 0; return 0;
} }

View File

@@ -44,7 +44,7 @@ STATIC_DCL xchar FDECL(pick_level, (boolean *, int));
STATIC_DCL boolean FDECL(place_level, (int, struct proto_dungeon *)); STATIC_DCL boolean FDECL(place_level, (int, struct proto_dungeon *));
#ifdef WIZARD #ifdef WIZARD
STATIC_DCL const char *FDECL(br_string, (int)); STATIC_DCL const char *FDECL(br_string, (int));
STATIC_DCL void FDECL(print_branch, (winid, int, int, int)); STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P, char *));
#endif #endif
#ifdef DEBUG #ifdef DEBUG
@@ -1519,7 +1519,6 @@ const char *nam;
return lev; return lev;
} }
#ifdef WIZARD #ifdef WIZARD
/* Convert a branch type to a string usable by print_dungeon(). */ /* Convert a branch type to a string usable by print_dungeon(). */
@@ -1538,14 +1537,17 @@ br_string(type)
/* Print all child branches between the lower and upper bounds. */ /* Print all child branches between the lower and upper bounds. */
STATIC_OVL void STATIC_OVL void
print_branch(win, dnum, lower_bound, upper_bound) print_branch(win, dnum, lower_bound, upper_bound, bymenu, menuletter)
winid win; winid win;
int dnum; int dnum;
int lower_bound; int lower_bound;
int upper_bound; int upper_bound;
boolean bymenu;
char *menuletter;
{ {
branch *br; branch *br;
char buf[BUFSZ]; char buf[BUFSZ];
anything any;
/* This assumes that end1 is the "parent". */ /* This assumes that end1 is the "parent". */
for (br = branches; br; br = br->next) { for (br = branches; br; br = br->next) {
@@ -1555,14 +1557,25 @@ print_branch(win, dnum, lower_bound, upper_bound)
br_string(br->type), br_string(br->type),
dungeons[br->end2.dnum].dname, dungeons[br->end2.dnum].dname,
depth(&br->end1)); depth(&br->end1));
putstr(win, 0, buf); if (bymenu) {
schar lev = 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,
0, ATR_NONE, buf, MENU_UNSELECTED);
if (*menuletter == 'z') *menuletter = 'A';
else *menuletter += 1;
} else
putstr(win, 0, buf);
} }
} }
} }
/* Print available dungeon information. */ /* Print available dungeon information. */
void schar
print_dungeon() print_dungeon(bymenu)
boolean bymenu;
{ {
int i, last_level, nlev; int i, last_level, nlev;
char buf[BUFSZ]; char buf[BUFSZ];
@@ -1570,7 +1583,14 @@ print_dungeon()
s_level *slev; s_level *slev;
dungeon *dptr; dungeon *dptr;
branch *br; branch *br;
anything any;
char mlet;
winid win = create_nhwindow(NHW_MENU); winid win = create_nhwindow(NHW_MENU);
if (bymenu) {
start_menu(win);
mlet = 'a';
}
for (i = 0, dptr = dungeons; i < n_dgns; i++, dptr++) { for (i = 0, dptr = dungeons; i < n_dgns; i++, dptr++) {
nlev = dptr->num_dunlevs; nlev = dptr->num_dunlevs;
@@ -1588,7 +1608,11 @@ print_dungeon()
Sprintf(eos(buf), ", entrance on %d", Sprintf(eos(buf), ", entrance on %d",
dptr->depth_start + dptr->entry_lev - 1); dptr->depth_start + dptr->entry_lev - 1);
} }
putstr(win, 0, buf); if (bymenu) {
any.a_void = 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD, buf, MENU_UNSELECTED);
} else
putstr(win, 0, buf);
/* /*
* Circle through the special levels to find levels that are in * Circle through the special levels to find levels that are in
@@ -1598,32 +1622,71 @@ print_dungeon()
if (slev->dlevel.dnum != i) continue; if (slev->dlevel.dnum != i) continue;
/* print any branches before this level */ /* print any branches before this level */
print_branch(win, i, last_level, slev->dlevel.dlevel); print_branch(win, i, last_level, slev->dlevel.dlevel, bymenu, &mlet);
Sprintf(buf, " %s: %d", slev->proto, depth(&slev->dlevel)); Sprintf(buf, " %s: %d", slev->proto, depth(&slev->dlevel));
if (Is_stronghold(&slev->dlevel)) if (Is_stronghold(&slev->dlevel))
Sprintf(eos(buf), " (tune %s)", tune); Sprintf(eos(buf), " (tune %s)", tune);
putstr(win, 0, buf); if (bymenu) {
schar lev = 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++;
} else
putstr(win, 0, buf);
last_level = slev->dlevel.dlevel; last_level = slev->dlevel.dlevel;
} }
/* print branches after the last special level */ /* print branches after the last special level */
print_branch(win, i, last_level, MAXLEVEL); print_branch(win, i, last_level, MAXLEVEL, bymenu, &mlet);
} }
/* Print out floating branches (if any). */ /* Print out floating branches (if any). */
for (first = TRUE, br = branches; br; br = br->next) { for (first = TRUE, br = branches; br; br = br->next) {
if (br->end1.dnum == n_dgns) { if (br->end1.dnum == n_dgns) {
if (first) { if (first) {
putstr(win, 0, ""); if (bymenu) {
putstr(win, 0, "Floating branches"); any.a_void = 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD,
"Floating branches", MENU_UNSELECTED);
} else {
putstr(win, 0, "");
putstr(win, 0, "Floating branches");
}
first = FALSE; first = FALSE;
} }
Sprintf(buf, " %s to %s", Sprintf(buf, " %s to %s",
br_string(br->type), dungeons[br->end2.dnum].dname); br_string(br->type), dungeons[br->end2.dnum].dname);
putstr(win, 0, buf); 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
putstr(win, 0, buf);
} }
} }
if (bymenu) {
int n;
menu_item *selected;
schar lev = 0;
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--;
free((genericptr_t)selected);
}
return lev;
}
/* I hate searching for the invocation pos while debugging. -dean */ /* I hate searching for the invocation pos while debugging. -dean */
if (Invocation_lev(&u.uz)) { if (Invocation_lev(&u.uz)) {
@@ -1654,6 +1717,7 @@ print_dungeon()
display_nhwindow(win, TRUE); display_nhwindow(win, TRUE);
destroy_nhwindow(win); destroy_nhwindow(win);
return 0;
} }
#endif /* WIZARD */ #endif /* WIZARD */

View File

@@ -606,6 +606,11 @@ level_tele()
pline("Oops..."); pline("Oops...");
goto random_levtport; goto random_levtport;
} }
#ifdef WIZARD
if (wizard && !strcmp(buf,"?")) {
newlev = print_dungeon(TRUE);
} else
#endif
if ((newlev = lev_by_name(buf)) == 0) newlev = atoi(buf); if ((newlev = lev_by_name(buf)) == 0) newlev = atoi(buf);
} while (!newlev && !digit(buf[0]) && } while (!newlev && !digit(buf[0]) &&
(buf[0] != '-' || !digit(buf[1])) && (buf[0] != '-' || !digit(buf[1])) &&