]> granicus.if.org Git - nethack/commitdiff
fix #H348 - "you trip over it" after non-"it" message (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 10 Jun 2007 03:01:31 +0000 (03:01 +0000)
committernethack.rankin <nethack.rankin>
Sun, 10 Jun 2007 03:01:31 +0000 (03:01 +0000)
     Reported to us by <email deleted>:
  'You are beginning to feel hungry.  You trip over it.'
and also recently in the newsgroup by "<Someone>":
  There is ice here.  *You see here an electric eel corpse.*
  Bib hits the electric eel.  Bib misses the electric eel.
  Bib misses the electric eel.  The electric eel misses Bib.
  The electric eel misses Bib.  *You trip over it.*

     slip_or_trip() was oversimplifying things by assuming that if there
is one object at the hero's location, a message about what that object is
has just been given.  Any timeout message which precedes Fumbling (lots
of candiates besides hunger) could intervene, as could monster activity
between the hero's move and timeout handling.  Aside from the reported
cases, that code hadn't been updated to account for the new pile_limit
option which could be set to 1 and force a popup display instead of the
usual "you see <an item> here".  This fix adds a flag that can be used
to track the most recent message.  It is cleared by pline for every
message, so pline's caller sets it _after_ the message of interest has
been displayed.

doc/fixes35.0
include/flag.h
src/cmd.c
src/invent.c
src/pline.c
src/timeout.c

index 7004ad92a24ca1f3154166932f86b98042b18ea4..d582c805d7f5991ac10d3f6670e7f15c9371c388 100644 (file)
@@ -246,6 +246,8 @@ applying an unpaid stack of potions of oil forced hero to buy all of them
        instead of just the one which got split off and lit
 sometimes when hero is forced to buy an unpaid shop item its price changed
 monster could attack with a polearm even after attempt to wield that failed
+sometimes got "you trip over it" after intervening messages following the
+       once which described "it"
 
 
 Platform- and/or Interface-Specific Fixes
index c4acdad4e992a8fd6cbfbe1dc150adfd5e2dab83..02ad13ab97421836336436330e8996230792103e 100644 (file)
@@ -159,6 +159,7 @@ struct instance_flags {
         * a structure of their own elsewhere some day.
         */
        int      in_lava_effects;       /* hack for Boots_off() */
+       int      last_msg;              /* indicator of last message player saw */
        int      purge_monsters;        /* # of dead monsters still on fmon list */
        int      override_ID;   /* true to force full identification of objects */
        int      suppress_price; /* controls doname() for unpaid objects */
@@ -320,6 +321,10 @@ extern NEARDATA struct sysflag sysflags;
 #endif
 extern NEARDATA struct instance_flags iflags;
 
+/* last_msg values */
+#define PLNMSG_UNKNOWN         0       /* arbitrary */
+#define PLNMSG_ONE_ITEM_HERE   1       /* "you see <single item> here" */
+
 /* runmode options */
 #define RUN_TPORT      0       /* don't update display until movement stops */
 #define RUN_LEAP       1       /* update display every 7 steps */
index 295acdbc74e877018c5b0cba0a8be534906f39c6..82045b8f5cacf07dee4138ba93f5660446b370bd 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -3044,6 +3044,8 @@ char def;
 {
        char qbuf[QBUFSZ];
 
+       iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
+
        /* maximum acceptable length is QBUFSZ-1 */
        if (strlen(query) < QBUFSZ)
                return (*windowprocs.win_yn_function)(query, resp, def);
index 2eb120f26b6f36504cc06fd771fd2b46a0cb4c7a..c2a579cb410319bb40290b8e275c46e72bc8278c 100644 (file)
@@ -2450,6 +2450,7 @@ boolean picked_some;
            if (otmp->oinvis && !See_invisible) verb = "feel";
 #endif
            You("%s here %s.", verb, doname(otmp));
+           iflags.last_msg = PLNMSG_ONE_ITEM_HERE;
            if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE);
        } else {
            char buf[BUFSZ];
index df8920ae2819195d76f83c71cf93c65db42a5a0d..a4e3e0b6b1eb2a7408484842f202ac458530b1fb 100644 (file)
@@ -73,6 +73,7 @@ pline VA_DECL(const char *, line)
        }
        if (!iflags.window_inited) {
            raw_print(line);
+           iflags.last_msg = PLNMSG_UNKNOWN;
            return;
        }
 #ifndef MAC
@@ -86,6 +87,8 @@ pline VA_DECL(const char *, line)
        if (vision_full_recalc) vision_recalc(0);
        if (u.ux) flush_screen(1);              /* %% */
        putstr(WIN_MESSAGE, 0, line);
+       /* this gets cleared after every pline message */
+       iflags.last_msg = PLNMSG_UNKNOWN;
 }
 
 /*VARARGS1*/
index b0f7793bcf511dbd3e669e7a2653183d04770b7c..0d71b516ee3df245e54fc4ee0baf345e8fcec699 100644 (file)
@@ -656,7 +656,7 @@ STATIC_OVL void
 slip_or_trip()
 {
        struct obj *otmp = vobj_at(u.ux, u.uy);
-       const char *what, *pronoun;
+       const char *what;
        char buf[BUFSZ];
        boolean on_foot = TRUE;
 #ifdef STEED
@@ -673,8 +673,8 @@ slip_or_trip()
                name; if not, look for rocks to trip over; trip over
                anonymous "something" if there aren't any rocks.
             */
-           pronoun = otmp->quan == 1L ? "it" : Hallucination ? "they" : "them";
-           what = !otmp->nexthere ? pronoun :
+           what = (iflags.last_msg == PLNMSG_ONE_ITEM_HERE) ?
+               ((otmp->quan == 1L) ? "it" : Hallucination ? "they" : "them") :
                  (otmp->dknown || !Blind) ? doname(otmp) :
                  ((otmp = sobj_at(ROCK, u.ux, u.uy)) == 0 ? something :
                  (otmp->quan == 1L ? "a rock" : "some rocks"));