fix more your corpse cases
authorcohrs <cohrs>
Wed, 27 Feb 2002 05:15:48 +0000 (05:15 +0000)
committercohrs <cohrs>
Wed, 27 Feb 2002 05:15:48 +0000 (05:15 +0000)
- 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

include/extern.h
src/apply.c
src/mhitm.c
src/mhitu.c
src/objnam.c
src/shk.c
src/steal.c

index e338b5b1a10a14845069dd4f2dd3672df45de2e5..e09f4aeeaf47665d93bcd10b5e24eba158510464 100644 (file)
@@ -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 *));
index 9347a340e972c1cf4d243d41fa890ce164138b20..82ef6428a73ddab22456dd88daee9454d0920aa6 100644 (file)
@@ -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);
index 840702bfbe78e594b8ff6554e64da4490904252d..99cbf42ef982faa78438f9ab2f40cf3e0e0bb3cc 100644 (file)
@@ -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);
 }
 
 /*
index db03bbc911b1709cdda8da2384ae5803ffd7a616..a70add9600b80fda08848e21892e33ebf571daf8 100644 (file)
@@ -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 */
index 88d8f1491ada840e94be1ac16579604e13e82976..c3537988349e947db529df114e47912ae3190078 100644 (file)
@@ -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() */
index b2e5d26ac8ccde60c7558e5ebcc244fa3d7cf2df..4c9b3b75ea5ed79e897a0f0765850eb4cae1ee3e 100644 (file)
--- 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");
index ce2d6a041e3b01a6adfe7148f803a23d99ac95b0..e0cf5212157a1819ab4677436520f3a0230bfa87 100644 (file)
@@ -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) */