]> granicus.if.org Git - nethack/commitdiff
look vs pickup
authornethack.allison <nethack.allison>
Sun, 1 Jun 2003 15:54:41 +0000 (15:54 +0000)
committernethack.allison <nethack.allison>
Sun, 1 Jun 2003 15:54:41 +0000 (15:54 +0000)
I encountered a look vs pickup cockatrice corpse
bug today.

If you looked at a location with ':', you
would instantly get
"Touching the cockatrice corpse is a fatal mistake..."
but if you used "m," you got the full list of
things at the location to choose from.

This patch makes the behaviour consistent
and more informative to the player.
You now get the partial list of things felt
up until the cockatrice corpse is encountered,
and then you get the
"Touching the cockatrice corpse is a fatal mistake..."

Before, the code was never displaying the partially
built list because the feel_cockatrice() call was
happening before the window display call.

include/extern.h
include/hack.h
src/invent.c
src/pickup.c

index 995f99b93dc88c436fe81c83863e7ba2422e0cf8..23a5d4ffef464d0e9541eb2cc65c666bb3fd1ed2 100644 (file)
@@ -797,6 +797,7 @@ E int NDECL(dotypeinv);
 E const char *FDECL(dfeature_at, (int,int,char *));
 E int FDECL(look_here, (int,BOOLEAN_P));
 E int NDECL(dolook);
+E boolean FDECL(will_feel_cockatrice, (struct obj *,BOOLEAN_P));
 E void FDECL(feel_cockatrice, (struct obj *,BOOLEAN_P));
 E void FDECL(stackobj, (struct obj *));
 E int NDECL(doprgold);
index a9e0dc67af37325d93ab4638eadd8ce44306236f..f5277babd062d39ef728dabe88879c2a7acfeb9d 100644 (file)
@@ -150,6 +150,7 @@ NEARDATA extern coord bhitpos;      /* place where throw or zap hits or stops */
 #define USE_INVLET       0x4   /* use object's invlet */
 #define INVORDER_SORT    0x8   /* sort objects by packorder */
 #define SIGNAL_NOMENU    0x10  /* return -1 rather than 0 if none allowed */
+#define FEEL_COCKATRICE   0x20  /* engage cockatrice checks and react */
 
 /* Flags to control query_category() */
 /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
index f7949472553c5882d0b9494bfed4236b899d70dc..2614d68bab6b819fad8c9b3513a004db90e367fd 100644 (file)
@@ -2158,7 +2158,7 @@ boolean picked_some;
        const char *dfeature = (char *)0;
        char fbuf[BUFSZ], fbuf2[BUFSZ];
        winid tmpwin;
-       boolean skip_objects = (obj_cnt >= 5);
+       boolean skip_objects = (obj_cnt >= 5), felt_cockatrice = FALSE;
 
        if (u.uswallow && u.ustuck) {
            struct monst *mtmp = u.ustuck;
@@ -2242,13 +2242,22 @@ boolean picked_some;
                putstr(tmpwin, 0, fbuf);
                putstr(tmpwin, 0, "");
            }
-           putstr(tmpwin, 0, "Things that are here:");
+           putstr(tmpwin, 0, Blind ? "Things that you feel here:" :
+                                     "Things that are here:");
            for ( ; otmp; otmp = otmp->nexthere) {
+               if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) {
+                       char buf[BUFSZ];
+                       felt_cockatrice = TRUE;
+                       Strcpy(buf, doname(otmp));
+                       Strcat(buf, "...");
+                       putstr(tmpwin, 0, buf);
+                       break;
+               }
                putstr(tmpwin, 0, doname(otmp));
-               if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE);
            }
            display_nhwindow(tmpwin, TRUE);
            destroy_nhwindow(tmpwin);
+           if (felt_cockatrice) feel_cockatrice(otmp, FALSE);
            read_engr_at(u.ux, u.uy); /* Eric Backus */
        }
        return(!!Blind);
@@ -2261,6 +2270,17 @@ dolook()
        return look_here(0, FALSE);
 }
 
+boolean
+will_feel_cockatrice(otmp, force_touch)
+struct obj *otmp;
+boolean force_touch;
+{
+       if ((Blind || force_touch) && !uarmg && !Stone_resistance &&
+               (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])))
+                       return TRUE;
+       return FALSE;
+}
+
 void
 feel_cockatrice(otmp, force_touch)
 struct obj *otmp;
@@ -2268,8 +2288,7 @@ boolean force_touch;
 {
        char kbuf[BUFSZ];
 
-       if ((Blind || force_touch) && !uarmg && !Stone_resistance &&
-               (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]))) {
+       if (will_feel_cockatrice(otmp, force_touch)) {
            if(poly_when_stoned(youmonst.data))
                        You("touched the %s corpse with your bare %s.",
                                mons[otmp->corpsenm].mname, makeplural(body_part(HAND)));
index 5664cb11b92795402d13524fe9004678f41442de..407b61ac792af38137341302b7506f149240a8a1 100644 (file)
@@ -465,8 +465,8 @@ int what;           /* should be a long */
                    pick_list[i].count = count;
            } else {
                n = query_objlist("Pick up what?", objchain,
-                           traverse_how|AUTOSELECT_SINGLE|INVORDER_SORT,
-                           &pick_list, PICK_ANY, all_but_uchain);
+                       traverse_how|AUTOSELECT_SINGLE|INVORDER_SORT|FEEL_COCKATRICE,
+                       &pick_list, PICK_ANY, all_but_uchain);
            }
 menu_pickup:
            n_tried = n;
@@ -683,7 +683,13 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */
        pack = flags.inv_order;
        do {
            printed_type_name = FALSE;
-           for (curr = olist; curr; curr = FOLLOW(curr, qflags))
+           for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
+               if ((qflags & FEEL_COCKATRICE) && curr->otyp == CORPSE &&
+                    will_feel_cockatrice(curr, FALSE)) {
+                       destroy_nhwindow(win);  /* stop the menu and revert */
+                       look_here(0, FALSE);
+                       return 0;
+               }
                if ((!(qflags & INVORDER_SORT) || curr->oclass == *pack)
                                                        && (*allow)(curr)) {
 
@@ -701,6 +707,7 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */
                            def_oc_syms[(int)objects[curr->otyp].oc_class],
                            ATR_NONE, doname(curr), MENU_UNSELECTED);
                }
+           }
            pack++;
        } while (qflags & INVORDER_SORT && *pack);