From c68ffb460713af427432e18cc9b2358dfaefead5 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Fri, 25 Jan 2008 03:25:38 +0000 Subject: [PATCH] 'T' failure feedback; suit_simple_name() (trunk only) The post-3.4.3 ring removal bug also applied to suit when wearing a cloak and shirt when wearing a suit or cloak or both, although it would never give "you have nothing else to take off" because the covering item was always present as a likely candidate. The ring fix also fixed armor. When testing that fix, I saw "you can't take that off" for trying to take off a suit while wearing a cloak. That isn't new or a bug, but it seemed awfully terse so I've changed it to give "you can't take that off without taking off your cloak first". (Likewise, "cloak", "suit", or "cloak and suit" as appropriate when trying to take off a shirt.) This adds new routine `suit_simple_name()', comparable to 3.4.3's cloak_simple_name() and post-3.4.3 helm_simple_name(). No doubt there are other places besides "without taking off your X first" that could make use of it but I haven't attempted to track them down. The "you are already wearing _some armor_" one doesn't quite fit. It would need to adjust "some" to "a"/"an" at times ("some mail" or "some dragon scales" vs "a suit" or "a jacket"). --- include/extern.h | 1 + src/do_wear.c | 18 ++++++++++++++++-- src/objnam.c | 22 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/extern.h b/include/extern.h index eceb0ff3c..8ad793291 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1570,6 +1570,7 @@ E char *FDECL(makeplural, (const char *)); E char *FDECL(makesingular, (const char *)); E struct obj *FDECL(readobjnam, (char *,struct obj *)); E int FDECL(rnd_class, (int,int)); +E const char *FDECL(suit_simple_name, (struct obj *)); E const char *FDECL(cloak_simple_name, (struct obj *)); E const char *FDECL(helm_simple_name, (struct obj *)); E const char *FDECL(mimic_obj_name, (struct monst *)); diff --git a/src/do_wear.c b/src/do_wear.c index 27050679e..f79aba25f 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1118,7 +1118,20 @@ dotakeoff() || ((otmp == uarmu) && (uarmc || uarm)) #endif ) { - You_cant("take that off."); + char why[BUFSZ], what[BUFSZ]; + + why[0] = what[0] = '\0'; + if (otmp != uskin) { + if (uarmc) Strcat(what, cloak_simple_name(uarmc)); +#ifdef TOURIST + if ((otmp == uarmu) && uarm) { + if (uarmc) Strcat(what, " and "); + Strcat(what, suit_simple_name(uarm)); + } +#endif + Sprintf(why, " without taking off your %s first", what); + } + You_cant("take that off%s.", why); return 0; } @@ -1406,7 +1419,8 @@ boolean noisy; *mask = W_ARMC; } else if (is_suit(otmp)) { if (uarmc) { - if (noisy) You("cannot wear armor over a %s.", cloak_simple_name(uarmc)); + if (noisy) You("cannot wear armor over a %s.", + cloak_simple_name(uarmc)); err++; } else if (uarm) { if (noisy) already_wearing("some armor"); diff --git a/src/objnam.c b/src/objnam.c index 7d8d727e7..44e24608b 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)objnam.c 3.5 2007/04/30 */ +/* SCCS Id: @(#)objnam.c 3.5 2008/01/23 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3226,6 +3226,26 @@ int i; return (const char *)0; } +const char * +suit_simple_name(suit) +struct obj *suit; +{ + const char *suitnm, *esuitp; + + if (Is_dragon_mail(suit)) + return "dragon mail"; /* dragon scale mail */ + else if (Is_dragon_scales(suit)) + return "dragon scales"; + suitnm = OBJ_NAME(objects[suit->otyp]); + esuitp = eos((char *)suitnm); + if (strlen(suitnm) > 5 && !strcmp(esuitp - 5, " mail")) + return "mail"; /* most suits fall into this category */ + else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket")) + return "jacket"; /* leather jacket */ + /* suit is lame but armor is ambiguous and body armor is absurd */ + return "suit"; +} + const char * cloak_simple_name(cloak) struct obj *cloak;