]> granicus.if.org Git - nethack/commitdiff
fix #H9479 - worn dented pot can't be taken off
authorPatR <rankin@nethack.org>
Sun, 1 Dec 2019 04:19:10 +0000 (20:19 -0800)
committerPatR <rankin@nethack.org>
Sun, 1 Dec 2019 04:19:10 +0000 (20:19 -0800)
Taking off no-delay helmets, gloves, and boots were unintentionally
taking off suit instead and stayed worn themselves.  As far as I
saw, only helmet types "fedora" and "dented pot" were applicable;
all gloves and boots have a small multi-turn delay.  This was an
unintended side-effect of the first "slippery gloves" commit so
happened about three weeks ago.

doc/fixes36.3
src/do_wear.c

index 8fa4afc0af1ab927644c82aacda06e7354845f9e..375c2497c1d9a0b108e53db2819a8f3b76cbbd41 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.192 $ $NHDT-Date: 1574882658 2019/11/27 19:24:18 $
+$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.197 $ $NHDT-Date: 1575173931 2019/12/01 04:18:51 $
 
 This fixes36.3 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -320,6 +320,8 @@ update window port spec to include a color-availability table that the window
        function in src/windows.c which uses a few data checks only and
        elminates multiple string function calls for each map cell update
        that were being done in some cases previously
+taking off a fedora or dented pot (no-delay helmets) left the helmet stuck
+       and took off hero's suit
 unix: fix double DLB definition in linux hints file
 windows: fix --showpaths output for the data file which relies on being
        constructed programmatically to incorporate the version suffix
index 15959738d03e7999a254c13111f5fd495375b11d..afbb98faefa1607f375db22cc697936d55f7d4ab 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 do_wear.c       $NHDT-Date: 1574638390 2019/11/24 23:33:10 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.114 $ */
+/* NetHack 3.6 do_wear.c       $NHDT-Date: 1575173934 2019/12/01 04:18:54 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.115 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1577,28 +1577,46 @@ int
 armoroff(otmp)
 struct obj *otmp;
 {
-    register int delay = -objects[otmp->otyp].oc_delay;
+    static char offdelaybuf[60];
+    int delay = -objects[otmp->otyp].oc_delay;
+    const char *what = 0;
 
     if (cursed(otmp))
         return 0;
+    /* this used to make assumptions about which types of armor had
+       delays and which didn't; now both are handled for all types */
     if (delay) {
         nomul(delay);
         multi_reason = "disrobing";
         if (is_helmet(otmp)) {
             /* ick... */
-            nomovemsg = !strcmp(helm_simple_name(otmp), "hat")
-                            ? "You finish taking off your hat."
-                            : "You finish taking off your helmet.";
+            what = helm_simple_name(otmp);
             afternmv = Helmet_off;
         } else if (is_gloves(otmp)) {
-            nomovemsg = "You finish taking off your gloves.";
+            what = gloves_simple_name(otmp);
             afternmv = Gloves_off;
         } else if (is_boots(otmp)) {
-            nomovemsg = "You finish taking off your boots.";
+            what = c_boots;
             afternmv = Boots_off;
-        } else {
-            nomovemsg = "You finish taking off your suit.";
+        } else if (is_suit(otmp)) {
+            what = suit_simple_name(otmp);
             afternmv = Armor_off;
+        } else if (is_cloak(otmp)) {
+            what = cloak_simple_name(otmp);
+            afternmv = Cloak_off;
+        } else if (is_shield(otmp)) {
+            what = c_shield;
+            afternmv = Shield_off;
+        } else if (is_shirt(otmp)) {
+            what = c_shirt;
+            afternmv = Shirt_off;
+        } else {
+            impossible("Taking off unknown armor (%d: %d), delay %d",
+                       otmp->otyp, objects[otmp->otyp].oc_armcat, delay);
+        }
+        if (what) {
+            Sprintf(offdelaybuf, "You finish taking off your %s.", what);
+            nomovemsg = offdelaybuf;
         }
     } else {
         /* Be warned!  We want off_msg after removing the item to
@@ -1622,8 +1640,19 @@ struct obj *otmp;
             (void) Cloak_off();
         else if (is_shield(otmp))
             (void) Shield_off();
-        else
+        else if (is_helmet(otmp))
+            (void) Helmet_off();
+        else if (is_gloves(otmp))
+            (void) Gloves_off();
+        else if (is_boots(otmp))
+            (void) Boots_off();
+        else if (is_shirt(otmp))
+            (void) Shirt_off();
+        else if (is_suit(otmp))
             (void) Armor_off();
+        else
+            impossible("Taking off unknown armor (%d: %d), no delay",
+                       otmp->otyp, objects[otmp->otyp].oc_armcat);
         off_msg(otmp);
     }
     context.takeoff.mask = context.takeoff.what = 0L;