]> granicus.if.org Git - nethack/commitdiff
bear trap vanishes when poly'd hero fails to eat
authornhmall <nhmall@nethack.org>
Wed, 1 Jun 2022 16:31:32 +0000 (12:31 -0400)
committernhmall <nhmall@nethack.org>
Wed, 1 Jun 2022 16:31:32 +0000 (12:31 -0400)
Closes #781

src/eat.c

index 9a1f15531c58dac9d8e2fdd2534730698cd76940..b2e15c76c689deb63dbb69b27e7f79ba2740879f 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -3433,10 +3433,20 @@ floorfood(
             Sprintf(qbuf, "There is a bear trap here (%s); eat it?",
                     u_in_beartrap ? "holding you" : "armed");
             if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
+                struct obj *beartrap;
+
                 deltrap(ttmp);
                 if (u_in_beartrap)
                     reset_utrap(TRUE);
-                return mksobj(BEARTRAP, TRUE, FALSE);
+                beartrap = mksobj(BEARTRAP, TRUE, FALSE);
+                Sprintf(qbuf,"You only manage to %s the bear trap.",
+                        u_in_beartrap ? "free yourself from" : "disarm");
+                if (check_capacity(qbuf) && beartrap) {
+                    obj_extract_self(beartrap);
+                    dropy(beartrap);           /* put it on the floor */
+                    return (struct obj *) 0;
+                }
+                return beartrap;
             } else if (c == 'q') {
                 return (struct obj *) 0;
             }