From a13d6c03c9e7094c7b4c01c548043f7e27f21bbb Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 21 Jan 2020 15:36:33 -0800 Subject: [PATCH] no more headless eyewear 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 | 3 ++- src/do_wear.c | 26 ++++++++++++++++++++++---- src/polyself.c | 19 +++++++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index c9908ed92..7f067bcf0 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 diff --git a/src/do_wear.c b/src/do_wear.c index 584d9fb7c..663cb6947 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -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.", diff --git a/src/polyself.c b/src/polyself.c index 6c0f5c732..d61a461cb 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -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