From: cohrs Date: Wed, 27 Feb 2002 05:15:48 +0000 (+0000) Subject: fix more your corpse cases X-Git-Tag: MOVE2GIT~3108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fb76648699fd8c2832b9a51d39523d1766deaa1;p=nethack fix more your corpse cases - new cxname() to simplify doing the right thing in increasingly common cases - use for bullwhip snagging - in shopkeeper offer code - in a couple other existing places rather than duplicating CORPSE checks - use singular(...) in "swings" cases, since only one can hit. Singular uses corpse_xname automatically when appropriate --- diff --git a/include/extern.h b/include/extern.h index e338b5b1a..e09f4aeea 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1316,6 +1316,7 @@ E boolean FDECL(the_unique_obj, (struct obj *obj)); E char *FDECL(doname, (struct obj *)); E boolean FDECL(not_fully_identified, (struct obj *)); E char *FDECL(corpse_xname, (struct obj *,BOOLEAN_P)); +E char *FDECL(cxname, (struct obj *)); E const char *FDECL(singular, (struct obj *,char *(*)(OBJ_P))); E char *FDECL(an, (const char *)); E char *FDECL(An, (const char *)); diff --git a/src/apply.c b/src/apply.c index 9347a340e..82ef6428a 100644 --- a/src/apply.c +++ b/src/apply.c @@ -2163,7 +2163,7 @@ struct obj *obj; const char *mon_hand; boolean gotit = proficient && (!Fumbling || !rn2(10)); - Strcpy(onambuf, xname(otmp)); + Strcpy(onambuf, cxname(otmp)); if (gotit) { mon_hand = mbodypart(mtmp, HAND); if (bimanual(otmp)) mon_hand = makeplural(mon_hand); diff --git a/src/mhitm.c b/src/mhitm.c index 840702bfb..99cbf42ef 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1188,7 +1188,7 @@ register struct obj *otemp; Strcpy(buf, mon_nam(mdef)); pline("%s %s %s %s at %s.", Monnam(magr), (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings", - mhis(magr), xname(otemp), buf); + mhis(magr), singular(otemp, xname), buf); } /* diff --git a/src/mhitu.c b/src/mhitu.c index db03bbc91..a70add960 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -111,7 +111,7 @@ register struct obj *otemp; return; pline("%s %s %s %s.", Monnam(mtmp), (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings", - mhis(mtmp), xname(otemp)); + mhis(mtmp), singular(otemp, xname)); } /* return how a poison attack was delivered */ diff --git a/src/objnam.c b/src/objnam.c index 88d8f1491..c35379883 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -824,6 +824,16 @@ boolean ignore_oquan; /* to force singular */ return makeplural(nambuf); } +/* xname, unless it's a corpse, then corpse_xname(obj, FALSE) */ +char * +cxname(obj) +struct obj *obj; +{ + if (obj->otyp == CORPSE) + return corpse_xname(obj, FALSE); + return xname(obj); +} + /* * Used if only one of a collection of objects is named (e.g. in eat.c). */ @@ -1092,10 +1102,7 @@ struct obj *obj; char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */ int space_left = BUFSZ - strlen(s) - sizeof " "; - /* "your corpse" is silly, use corpse_xname for this case */ - return strncat(strcat(s, " "), - (obj->otyp == CORPSE) ? - corpse_xname(obj, FALSE) : xname(obj), space_left); + return strncat(strcat(s, " "), cxname(obj), space_left); } /* capitalized variant of yname() */ diff --git a/src/shk.c b/src/shk.c index b2e5d26ac..4c9b3b75e 100644 --- a/src/shk.c +++ b/src/shk.c @@ -2685,7 +2685,7 @@ move_on: offer, plur(offer), (!ltmp && cltmp && only_partially_your_contents) ? " your items in" : (!ltmp && cltmp) ? " the contents of" : "", - obj->unpaid ? "the" : "your", xname(obj), + obj->unpaid ? "the" : "your", cxname(obj), (obj->quan == 1L && !(!ltmp && cltmp && only_partially_your_contents)) ? "it" : "them"); diff --git a/src/steal.c b/src/steal.c index ce2d6a041..e0cf52121 100644 --- a/src/steal.c +++ b/src/steal.c @@ -310,8 +310,7 @@ gotobj: pline("%s tries to %s your %s but gives up.", Monnam(mtmp), how[rn2(SIZE(how))], (otmp->owornmask & W_ARMOR) ? equipname(otmp) : - (otmp->otyp == CORPSE) ? corpse_xname(otmp, FALSE) : - xname(otmp)); + cxname(otmp)); /* the fewer items you have, the less likely the thief is going to stick around to try again (0) instead of running away (1) */