]> granicus.if.org Git - nethack/commitdiff
no more headless eyewear
authorPatR <rankin@nethack.org>
Tue, 21 Jan 2020 23:36:33 +0000 (15:36 -0800)
committerPatR <rankin@nethack.org>
Tue, 21 Jan 2020 23:36:33 +0000 (15:36 -0800)
Noticed while working on something else:  hero kept wearing a towel
after polymorphing into a form without any head.  And when not already
wearing one, could put on a blindfold/towel/lenses while in a headless
form.

doc/fixes37.0
src/do_wear.c
src/polyself.c

index c9908ed92708718ba2cc12c69a0e80a796311e81..7f067bcf0fae5a962684faa1129c74f247013ad2 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.69 $ $NHDT-Date: 1579261284 2020/01/17 11:41:24 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ $NHDT-Date: 1579649788 2020/01/21 23:36:28 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -46,6 +46,7 @@ when poly'd into a giant and moving onto a boulder's spot, message given was
        confused about whether autopickup would occur so could be misleading
 random role selection wasn't honoring unwanted alignment(s) properly
 if at the edge of the map window, trying to move farther fails but used a turn
+hero can no longer wear blindfold/towel/lenses when poly'd into headless form
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 584d9fb7c314cb33771042c25c9e0a57e9c54825..663cb6947a2cc338e62016fb8acad86c727ad60c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 do_wear.c       $NHDT-Date: 1575768410 2019/12/08 01:26:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.126 $ */
+/* NetHack 3.6 do_wear.c       $NHDT-Date: 1579649788 2020/01/21 23:36:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.127 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1159,15 +1159,19 @@ void
 Blindf_off(otmp)
 struct obj *otmp;
 {
-    boolean was_blind = Blind, changed = FALSE;
+    boolean was_blind = Blind, changed = FALSE,
+            nooffmsg = !otmp;
 
+    if (!otmp)
+        otmp = ublindf;
     if (!otmp) {
-        impossible("Blindf_off without otmp");
+        impossible("Blindf_off without eyewear?");
         return;
     }
     g.context.takeoff.mask &= ~W_TOOL;
     setworn((struct obj *) 0, otmp->owornmask);
-    off_msg(otmp);
+    if (!nooffmsg)
+        off_msg(otmp);
 
     if (Blind) {
         if (was_blind) {
@@ -1895,6 +1899,15 @@ struct obj *obj;
             return 1;
         }
     } else {
+        /*
+         * FIXME:
+         *  except for the rings/nolimbs case, this allows you to put on
+         *  accessories without having any hands to manipulate them, and
+         *  to put them on when poly'd into a tiny or huge form where
+         *  they shouldn't fit.  [If the latter situation changes, make
+         *  comparable change to break_armor(polyself.c).]
+         */
+
         /* accessory */
         if (ring) {
             char answer, qbuf[QBUFSZ];
@@ -1965,6 +1978,11 @@ struct obj *obj;
                 return 0;
             }
         } else if (eyewear) {
+            if (!has_head(g.youmonst.data)) {
+                You("have no head to wear %s on.", ansimpleoname(obj));
+                return 0;
+            }
+
             if (ublindf) {
                 if (ublindf->otyp == TOWEL)
                     Your("%s is already covered by a towel.",
index 6c0f5c7320f75584ebc127ec9707bf110880f4e5..d61a461cb258ccbd6b3bdd1372a1709a470e06cd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 polyself.c      $NHDT-Date: 1573290419 2019/11/09 09:06:59 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.135 $ */
+/* NetHack 3.6 polyself.c      $NHDT-Date: 1579649789 2020/01/21 23:36:29 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.148 $ */
 /*      Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -934,7 +934,7 @@ break_armor()
             useup(uarmu);
         }
     } else if (sliparm(g.youmonst.data)) {
-        if (((otmp = uarm) != 0) && (racial_exception(&g.youmonst, otmp) < 1)) {
+        if ((otmp = uarm) != 0 && racial_exception(&g.youmonst, otmp) < 1) {
             if (donning(otmp))
                 cancel_don();
             Your("armor falls around you!");
@@ -1016,6 +1016,21 @@ break_armor()
             dropp(otmp);
         }
     }
+    /* not armor, but eyewear shouldn't stay worn without a head to wear
+       it/them on (should also come off if head is too tiny or too huge,
+       but putting accessories on doesn't reject those cases [yet?]);
+       amulet stays worn */
+    if ((otmp = ublindf) != 0 && !has_head(g.youmonst.data)) {
+        int l;
+        const char *eyewear = simpleonames(otmp); /* blindfold|towel|lenses */
+
+        if (!strncmp(eyewear, "pair of ", l = 8)) /* lenses */
+            eyewear += l;
+        Your("%s %s off!", eyewear, vtense(eyewear, "fall"));
+        (void) Blindf_off((struct obj *) 0); /* Null: skip usual off mesg */
+        dropp(otmp);
+    }
+    /* rings stay worn even when no hands */
 }
 
 static void