Accept custom level annotations at the level teleport prompt

via UnNetHack, original implementation by aaxelb
This commit is contained in:
Pasi Kallinen
2016-10-18 23:19:12 +03:00
parent 1506572ea0
commit bf1c81c0b4
2 changed files with 44 additions and 19 deletions

View File

@@ -62,6 +62,7 @@ STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P,
STATIC_DCL mapseen *FDECL(load_mapseen, (int)); STATIC_DCL mapseen *FDECL(load_mapseen, (int));
STATIC_DCL void FDECL(save_mapseen, (int, mapseen *)); STATIC_DCL void FDECL(save_mapseen, (int, mapseen *));
STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *)); STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *));
STATIC_DCL mapseen *FDECL(find_mapseen_by_str, (const char *));
STATIC_DCL void FDECL(print_mapseen, (winid, mapseen *, int, int, BOOLEAN_P)); STATIC_DCL void FDECL(print_mapseen, (winid, mapseen *, int, int, BOOLEAN_P));
STATIC_DCL boolean FDECL(interest_mapseen, (mapseen *)); STATIC_DCL boolean FDECL(interest_mapseen, (mapseen *));
STATIC_DCL void FDECL(traverse_mapseenchn, (BOOLEAN_P, winid, STATIC_DCL void FDECL(traverse_mapseenchn, (BOOLEAN_P, winid,
@@ -1642,6 +1643,13 @@ const char *nam;
const char *p; const char *p;
int idx, idxtoo; int idx, idxtoo;
char buf[BUFSZ]; char buf[BUFSZ];
mapseen *mseen;
/* look at the player's custom level annotations first */
if ((mseen = find_mapseen_by_str(nam)) != 0) {
dlev = mseen->lev;
} else {
/* no matching annotation, check whether they used a name we know */
/* allow strings like "the oracle level" to find "oracle" */ /* allow strings like "the oracle level" to find "oracle" */
if (!strncmpi(nam, "the ", 4)) if (!strncmpi(nam, "the ", 4))
@@ -1659,8 +1667,11 @@ const char *nam;
nam = "valley"; nam = "valley";
} }
if ((slev = find_level(nam)) != 0) { if ((slev = find_level(nam)) != 0)
dlev = slev->dlevel; dlev = slev->dlevel;
}
if (mseen || slev) {
idx = ledger_no(&dlev); idx = ledger_no(&dlev);
if ((dlev.dnum == u.uz.dnum if ((dlev.dnum == u.uz.dnum
/* within same branch, or else main dungeon <-> gehennom */ /* within same branch, or else main dungeon <-> gehennom */
@@ -1672,7 +1683,7 @@ const char *nam;
wizard wizard
|| (level_info[idx].flags & (FORGOTTEN | VISITED)) || (level_info[idx].flags & (FORGOTTEN | VISITED))
== VISITED)) { == VISITED)) {
lev = depth(&slev->dlevel); lev = depth(&dlev);
} }
} else { /* not a specific level; try branch names */ } else { /* not a specific level; try branch names */
idx = find_branch(nam, (struct proto_dungeon *) 0); idx = find_branch(nam, (struct proto_dungeon *) 0);
@@ -2055,6 +2066,20 @@ d_level *lev;
return mptr; return mptr;
} }
STATIC_OVL mapseen *
find_mapseen_by_str(s)
const char *s;
{
mapseen *mptr;
for (mptr = mapseenchn; mptr; mptr = mptr->next)
if (mptr->custom && !strcmpi(s, mptr->custom))
break;
return mptr;
}
void void
forget_mapseen(ledger_num) forget_mapseen(ledger_num)
int ledger_num; int ledger_num;

View File

@@ -609,9 +609,9 @@ level_tele()
do { do {
if (++trycnt == 2) { if (++trycnt == 2) {
if (wizard) if (wizard)
Strcat(qbuf, " [type a number or ? for a menu]"); Strcat(qbuf, " [type a number, name, or ? for a menu]");
else else
Strcat(qbuf, " [type a number]"); Strcat(qbuf, " [type a number or name]");
} }
getlin(qbuf, buf); getlin(qbuf, buf);
if (!strcmp(buf, "\033")) { /* cancelled */ if (!strcmp(buf, "\033")) { /* cancelled */