]> granicus.if.org Git - nethack/commitdiff
fix #U1206 - Quest artifact in WIZKIT file aborts program
authornethack.rankin <nethack.rankin>
Wed, 24 Nov 2004 02:50:32 +0000 (02:50 +0000)
committernethack.rankin <nethack.rankin>
Wed, 24 Nov 2004 02:50:32 +0000 (02:50 +0000)
     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.

doc/fixes34.4
include/decl.h
include/extern.h
src/files.c
src/objnam.c
src/pline.c
src/questpgr.c
src/zap.c

index 1a704ed9dd8967c86ad83bfc63bb7d5a65ad11d2..b08cd61dae27586f9740cd28e42a37bee5873d87 100644 (file)
@@ -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
index c6e4dc0bb78511e368b4e46a61cf173aba7aef0d..580c6662f50fe2d376ece629315509cb6ff85b21 100644 (file)
@@ -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;
index 16015020d57d512f7e9f61ab94575c374fe19326..fb86d4592ac21f37ce262dc3abf333ff7af3f0a3 100644 (file)
@@ -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 *));
index 3c107e1a769de54058a517a33e9fd8b099e1461c..59bfa6ccda5a98082fbee5ddb10a198a366f844e 100644 (file)
@@ -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);
index 1f801cd828fa3f3f5084f7ad21da5eb236c008c5..aacd1dd14ea1ced6db65ad2fcc71a636b5ba8628 100644 (file)
@@ -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;
index 7a5d4920383f9fa112052502e10f7cec80029f79..1f4d903069d95f8930681c91cd363eb2b5fde4f4 100644 (file)
@@ -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;
index b4b80af696cfed558d204c58b726a7471dc302aa..dced6a9e991ec7090361baa06fd7e289c51e16da 100644 (file)
@@ -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;
index 4cac707a365d01e6d66826ed76e32bce5f5b5d4e..c8ce7624fc8ceefecbc8d51b7f5f5cd70180b5ad 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -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, &nothing, TRUE);
+       otmp = readobjnam(buf, &nothing);
        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 == &nothing) {
            /* explicitly wished for "nothing", presumeably attempting