fix #U1206 - Quest artifact in WIZKIT file aborts program
Fix the wizard mode crash From a bug report. Move the WIZKIT
message suppression to a lower level instead of trying to guard against
present and future pline() calls in the wishing code. The way that was
being handling wasn't suitable for dealing with quest feedback.
This also includes a couple of additional wishing synonyms.
This commit is contained in:
@@ -66,6 +66,7 @@ various helmet messages changed to distinguish between "helm" and "hat"
|
||||
helmets don't protect against cockatrice eggs thrown straight up
|
||||
breaking container contents in a shop didn't always charge for them
|
||||
some types of shop theft of a stack of items only charged for a single one
|
||||
wizard mode: WIZKIT wish for own quest artifact triggered crash at startup
|
||||
|
||||
|
||||
Platform- and/or Interface-Specific Fixes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)decl.h 3.4 2001/12/10 */
|
||||
/* SCCS Id: @(#)decl.h 3.4 2004/11/22 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -158,6 +158,9 @@ E NEARDATA struct sinfo {
|
||||
#ifdef PANICLOG
|
||||
int in_paniclog;
|
||||
#endif
|
||||
#ifdef WIZARD
|
||||
int wizkit_wishing;
|
||||
#endif
|
||||
} program_state;
|
||||
|
||||
E boolean restoring;
|
||||
|
||||
@@ -1435,7 +1435,7 @@ E char *FDECL(Ysimple_name2, (struct obj *));
|
||||
E char *FDECL(bare_artifactname, (struct obj *));
|
||||
E char *FDECL(makeplural, (const char *));
|
||||
E char *FDECL(makesingular, (const char *));
|
||||
E struct obj *FDECL(readobjnam, (char *,struct obj *,BOOLEAN_P));
|
||||
E struct obj *FDECL(readobjnam, (char *,struct obj *));
|
||||
E int FDECL(rnd_class, (int,int));
|
||||
E const char *FDECL(cloak_simple_name, (struct obj *));
|
||||
E const char *FDECL(helm_simple_name, (struct obj *));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)files.c 3.4 2003/11/14 */
|
||||
/* SCCS Id: @(#)files.c 3.4 2004/11/22 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2149,6 +2149,7 @@ read_wizkit()
|
||||
|
||||
if (!wizard || !(fp = fopen_wizkit_file())) return;
|
||||
|
||||
program_state.wizkit_wishing = 1;
|
||||
while (fgets(buf, (int)(sizeof buf), fp)) {
|
||||
ep = index(buf, '\n');
|
||||
if (skip) { /* in case previous line was too long */
|
||||
@@ -2158,7 +2159,7 @@ read_wizkit()
|
||||
else *ep = '\0'; /* remove newline */
|
||||
|
||||
if (buf[0]) {
|
||||
otmp = readobjnam(buf, (struct obj *)0, FALSE);
|
||||
otmp = readobjnam(buf, (struct obj *)0);
|
||||
if (otmp) {
|
||||
if (otmp != &zeroobj)
|
||||
otmp = addinv(otmp);
|
||||
@@ -2170,6 +2171,7 @@ read_wizkit()
|
||||
}
|
||||
}
|
||||
}
|
||||
program_state.wizkit_wishing = 0;
|
||||
if (bad_items)
|
||||
wait_synch();
|
||||
(void) fclose(fp);
|
||||
|
||||
32
src/objnam.c
32
src/objnam.c
@@ -1523,6 +1523,7 @@ STATIC_OVL NEARDATA const struct o_range o_ranges[] = {
|
||||
{ "candle", TOOL_CLASS, TALLOW_CANDLE, WAX_CANDLE },
|
||||
{ "horn", TOOL_CLASS, TOOLED_HORN, HORN_OF_PLENTY },
|
||||
{ "shield", ARMOR_CLASS, SMALL_SHIELD, SHIELD_OF_REFLECTION },
|
||||
{ "hat", ARMOR_CLASS, FEDORA, DUNCE_CAP },
|
||||
{ "helm", ARMOR_CLASS, ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY },
|
||||
{ "gloves", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY },
|
||||
{ "gauntlets", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY },
|
||||
@@ -1749,6 +1750,7 @@ struct alt_spellings {
|
||||
{ "lantern", BRASS_LANTERN },
|
||||
{ "mattock", DWARVISH_MATTOCK },
|
||||
{ "amulet of poison resistance", AMULET_VERSUS_POISON },
|
||||
{ "potion of sleep", POT_SLEEPING },
|
||||
{ "stone", ROCK },
|
||||
#ifdef TOURIST
|
||||
{ "camera", EXPENSIVE_CAMERA },
|
||||
@@ -1758,6 +1760,9 @@ struct alt_spellings {
|
||||
{ "can opener", TIN_OPENER },
|
||||
{ "kelp", KELP_FROND },
|
||||
{ "eucalyptus", EUCALYPTUS_LEAF },
|
||||
{ "hook", GRAPPLING_HOOK },
|
||||
{ "grappling iron", GRAPPLING_HOOK },
|
||||
{ "grapnel", GRAPPLING_HOOK },
|
||||
{ "grapple", GRAPPLING_HOOK },
|
||||
{ (const char *)0, 0 },
|
||||
};
|
||||
@@ -1768,13 +1773,11 @@ struct alt_spellings {
|
||||
* if asking explicitly for "nothing" (or "nil") return no_wish;
|
||||
* if not an object return &zeroobj; if an error (no matching object),
|
||||
* return null.
|
||||
* If from_user is false, we're reading from the wizkit, nothing was typed in.
|
||||
*/
|
||||
struct obj *
|
||||
readobjnam(bp, no_wish, from_user)
|
||||
readobjnam(bp, no_wish)
|
||||
register char *bp;
|
||||
struct obj *no_wish;
|
||||
boolean from_user;
|
||||
{
|
||||
register char *p;
|
||||
register int i;
|
||||
@@ -2126,8 +2129,7 @@ boolean from_user;
|
||||
) cnt=5000;
|
||||
if (cnt < 1) cnt=1;
|
||||
#ifndef GOLDOBJ
|
||||
if (from_user)
|
||||
pline("%d gold piece%s.", cnt, plur(cnt));
|
||||
pline("%d gold piece%s.", cnt, plur(cnt));
|
||||
u.ugold += cnt;
|
||||
context.botl=1;
|
||||
return (&zeroobj);
|
||||
@@ -2331,11 +2333,12 @@ srch:
|
||||
}
|
||||
}
|
||||
#ifdef WIZARD
|
||||
/* Let wizards wish for traps --KAA */
|
||||
/* must come after objects check so wizards can still wish for
|
||||
* trap objects like beartraps
|
||||
/* Let wizards wish for traps and furniture.
|
||||
* Must come after objects check so wizards can still wish for
|
||||
* trap objects like beartraps.
|
||||
* Disallow such topology tweaks for WIZKIT startup wishes.
|
||||
*/
|
||||
if (wizard && from_user) {
|
||||
if (wizard && !program_state.wizkit_wishing) {
|
||||
int trap;
|
||||
|
||||
for (trap = NO_TRAP+1; trap < TRAPNUM; trap++) {
|
||||
@@ -2351,7 +2354,8 @@ srch:
|
||||
return(&zeroobj);
|
||||
}
|
||||
}
|
||||
/* or some other dungeon features -dlc */
|
||||
|
||||
/* furniture and terrain */
|
||||
p = eos(bp);
|
||||
if(!BSTRCMP(bp, p-8, "fountain")) {
|
||||
levl[u.ux][u.uy].typ = FOUNTAIN;
|
||||
@@ -2515,11 +2519,13 @@ typfnd:
|
||||
if (oclass == VENOM_CLASS) otmp->spe = 1;
|
||||
#endif
|
||||
|
||||
if (spesgn == 0) spe = otmp->spe;
|
||||
if (spesgn == 0) {
|
||||
spe = otmp->spe;
|
||||
#ifdef WIZARD
|
||||
else if (wizard) /* no alteration to spe */ ;
|
||||
} else if (wizard) {
|
||||
; /* no alteration to spe */
|
||||
#endif
|
||||
else if (oclass == ARMOR_CLASS || oclass == WEAPON_CLASS ||
|
||||
} else if (oclass == ARMOR_CLASS || oclass == WEAPON_CLASS ||
|
||||
is_weptool(otmp) ||
|
||||
(oclass==RING_CLASS && objects[typ].oc_charged)) {
|
||||
if(spe > rnd(5) && spe > otmp->spe) spe = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)pline.c 3.4 2003/11/06 */
|
||||
/* SCCS Id: @(#)pline.c 3.4 2004/11/22 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -49,6 +49,10 @@ pline VA_DECL(const char *, line)
|
||||
/* Do NOT use VA_START and VA_END in here... see above */
|
||||
|
||||
if (!line || !*line) return;
|
||||
#ifdef WIZARD
|
||||
if (program_state.wizkit_wishing) return;
|
||||
#endif
|
||||
|
||||
if (index(line, '%')) {
|
||||
Vsprintf(pbuf,line,VA_ARGS);
|
||||
line = pbuf;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)questpgr.c 3.4 2000/05/05 */
|
||||
/* SCCS Id: @(#)questpgr.c 3.4 2004/11/22 */
|
||||
/* Copyright 1991, M. Stephenson */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -24,6 +24,7 @@ STATIC_DCL void FDECL(convert_arg, (CHAR_P));
|
||||
STATIC_DCL void NDECL(convert_line);
|
||||
STATIC_DCL void FDECL(deliver_by_pline, (struct qtmsg *));
|
||||
STATIC_DCL void FDECL(deliver_by_window, (struct qtmsg *,int));
|
||||
STATIC_DCL boolean FDECL(skip_pager, (BOOLEAN_P));
|
||||
|
||||
static char in_line[80], cvt_buf[64], out_line[128];
|
||||
static struct qtlists qt_list;
|
||||
@@ -386,12 +387,32 @@ int how;
|
||||
destroy_nhwindow(datawin);
|
||||
}
|
||||
|
||||
boolean
|
||||
skip_pager(common)
|
||||
boolean common;
|
||||
{
|
||||
#ifdef WIZARD
|
||||
/* WIZKIT: suppress plot feedback if starting with quest artifact */
|
||||
if (program_state.wizkit_wishing) return TRUE;
|
||||
#endif
|
||||
if (!(common ? qt_list.common : qt_list.chrole)) {
|
||||
panic("%s: no %s quest text data available",
|
||||
common ? "com_pager" : "qt_pager",
|
||||
common ? "common" : "role-specific");
|
||||
/*NOTREACHED*/
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
com_pager(msgnum)
|
||||
int msgnum;
|
||||
{
|
||||
struct qtmsg *qt_msg;
|
||||
|
||||
if (skip_pager(TRUE)) return;
|
||||
|
||||
if (!(qt_msg = msg_in(qt_list.common, msgnum))) {
|
||||
impossible("com_pager: message %d not found.", msgnum);
|
||||
return;
|
||||
@@ -410,6 +431,8 @@ int msgnum;
|
||||
{
|
||||
struct qtmsg *qt_msg;
|
||||
|
||||
if (skip_pager(FALSE)) return;
|
||||
|
||||
if (!(qt_msg = msg_in(qt_list.chrole, msgnum))) {
|
||||
impossible("qt_pager: message %d not found.", msgnum);
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)zap.c 3.4 2004/09/10 */
|
||||
/* SCCS Id: @(#)zap.c 3.4 2004/11/22 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -4232,12 +4232,12 @@ retry:
|
||||
* has been denied. Wishing for "nothing" requires a separate
|
||||
* value to remain distinct.
|
||||
*/
|
||||
otmp = readobjnam(buf, ¬hing, TRUE);
|
||||
otmp = readobjnam(buf, ¬hing);
|
||||
if (!otmp) {
|
||||
pline("Nothing fitting that description exists in the game.");
|
||||
if (++tries < 5) goto retry;
|
||||
pline(thats_enough_tries);
|
||||
otmp = readobjnam((char *)0, (struct obj *)0, TRUE);
|
||||
otmp = readobjnam((char *)0, (struct obj *)0);
|
||||
if (!otmp) return; /* for safety; should never happen */
|
||||
} else if (otmp == ¬hing) {
|
||||
/* explicitly wished for "nothing", presumeably attempting
|
||||
|
||||
Reference in New Issue
Block a user