]> granicus.if.org Git - nethack/commitdiff
verb agreement
authorcohrs <cohrs>
Sat, 9 Feb 2002 00:24:49 +0000 (00:24 +0000)
committercohrs <cohrs>
Sat, 9 Feb 2002 00:24:49 +0000 (00:24 +0000)
add and use new APIs, Tobjnam, otense and vtense, is_plural
to determine tense/form of verbs and a few pronouns as well

17 files changed:
src/do_wear.c
src/dog.c
src/dokick.c
src/dothrow.c
src/eat.c
src/end.c
src/engrave.c
src/explode.c
src/hack.c
src/mhitu.c
src/mthrowu.c
src/muse.c
src/music.c
src/objnam.c
src/pickup.c
src/potion.c
src/pray.c

index eabd0a9613a6db4c56bac2836b3ee6fb14b8cc5c..f71d278a462908ba3201e5437c6b17dc6d90267d 100644 (file)
@@ -226,7 +226,7 @@ Cloak_on()
                }
                break;
        case OILSKIN_CLOAK:
-               pline("%s fits very tightly.",The(xname(uarmc)));
+               pline("%s very tightly.", Tobjnam(uarmc, "fit"));
                break;
        /* Alchemy smock gives poison _and_ acid resistance */
        case ALCHEMY_SMOCK:
@@ -317,9 +317,11 @@ Helmet_on()
                /*FALLTHRU*/
        case DUNCE_CAP:
                if (!uarmh->cursed) {
-                   pline("%s %s%s for a moment.", The(xname(uarmh)),
-                         Blind ? "vibrates" : "glows ",
-                         Blind ? (const char *)"" : hcolor(Black));
+                   if (Blind)
+                       pline("%s for a moment.", Tobjnam(uarmh, "vibrate"));
+                   else
+                       pline("%s %s for a moment.",
+                             Tobjnam(uarmh, "glow"), hcolor(Black));
                    curse(uarmh);
                }
                flags.botl = 1;         /* reveal new alignment or INT & WIS */
@@ -435,9 +437,9 @@ Gloves_off()
                touch_petrifies(&mons[uwep->corpsenm])) {
        char kbuf[BUFSZ];
 
-       You("wield the %s corpse in your bare %s.",
-           mons[uwep->corpsenm].mname, makeplural(body_part(HAND)));
-       Sprintf(kbuf, "%s corpse", an(mons[uwep->corpsenm].mname));
+       You("wield the %s in your bare %s.",
+           corpse_xname(uwep, TRUE), makeplural(body_part(HAND)));
+       Strcpy(kbuf, an(corpse_xname(uwep, TRUE)));
        instapetrify(kbuf);
        uwepgone();  /* life-saved still doesn't allow touching cockatrice */
     }
@@ -447,10 +449,10 @@ Gloves_off()
        touch_petrifies(&mons[uswapwep->corpsenm])) {
        char kbuf[BUFSZ];
 
-       You("wield the %s corpse in your bare %s.",
-           mons[uswapwep->corpsenm].mname, body_part(HAND));
+       You("wield the %s in your bare %s.",
+           corpse_xname(uswapwep, TRUE), body_part(HAND));
 
-       Sprintf(kbuf, "%s corpse", an(mons[uswapwep->corpsenm].mname));
+       Strcpy(kbuf, an(corpse_xname(uswapwep, TRUE)));
        instapetrify(kbuf);
        uswapwepgone(); /* lifesaved still doesn't allow touching cockatrice */
     }
index fde74e25d7dc78732c1211789876fa9922f6b889..ea0133ca5968dfcca8f20e6c981d6fb9584a5680 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -721,7 +721,7 @@ register struct obj *obj;
                          Monnam(mtmp), the(xname(obj)),
                          !big_corpse ? "." : ", or vice versa!");
                } else if (cansee(mtmp->mx,mtmp->my))
-                   pline("%s stops.", The(xname(obj)));
+                   pline("%s.", Tobjnam(obj, "stop"));
                /* dog_eat expects a floor object */
                place_object(obj, mtmp->mx, mtmp->my);
                (void) dog_eat(mtmp, obj, mtmp->mx, mtmp->my, FALSE);
index 427c451704af4f74e9f3455931774dbf6d8f1f0c..14ac369b2e73c585c1f71f54e0091eae2a8c21e6 100644 (file)
@@ -370,16 +370,16 @@ xchar x, y;
 
        if(kickobj->otyp == CORPSE && touch_petrifies(&mons[kickobj->corpsenm])
                        && !Stone_resistance && !uarmf) {
-               char kbuf[BUFSZ];
+           char kbuf[BUFSZ];
 
-               You("kick the %s corpse with your bare %s.",
-                               mons[kickobj->corpsenm].mname, makeplural(body_part(FOOT)));
+           You("kick the %s with your bare %s.",
+               corpse_xname(kickobj, TRUE), makeplural(body_part(FOOT)));
            if (!(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) {
                You("turn to stone...");
                killer_format = KILLED_BY;
                /* KMH -- otmp should be kickobj */
-               Sprintf(kbuf, "kicking a %s corpse without boots",
-                       mons[kickobj->corpsenm].mname);
+               Sprintf(kbuf, "kicking %s without boots",
+                       an(corpse_xname(kickobj, TRUE)));
                killer = kbuf;
                done(STONING);
            }
@@ -451,7 +451,8 @@ xchar x, y;
                }
                if(costly && loss) {
                    if(!insider) {
-                       You("caused %ld %s worth of damage!", loss, currency(loss));
+                       You("caused %ld %s worth of damage!",
+                           loss, currency(loss));
                        make_angry_shk(shkp, x, y);
                    } else {
                        You("owe %s %ld %s for objects destroyed.",
@@ -486,15 +487,15 @@ xchar x, y;
                                 || IS_ROCK(levl[u.ux][u.uy].typ)
                                 || closed_door(u.ux, u.uy)) {
                        if (Blind) pline("It doesn't come loose.");
-                       else pline("%s do%sn't come loose.",
+                       else pline("%s %sn't come loose.",
                                The(distant_name(kickobj, xname)),
-                               (kickobj->quan == 1L) ? "es" : "");
+                               otense(kickobj, "do"));
                        return(!rn2(3) || martial());
                }
                if (Blind) pline("It comes loose.");
-               else pline("%s come%s loose.",
+               else pline("%s %s loose.",
                           The(distant_name(kickobj, xname)),
-                          (kickobj->quan == 1L) ? "s" : "");
+                          otense(kickobj, "come"));
                obj_extract_self(kickobj);
                newsym(x, y);
                if (costly && (!costly_spot(u.ux, u.uy)
@@ -522,9 +523,8 @@ xchar x, y;
        if (kickobj->quan > 1L && !isgold) kickobj = splitobj(kickobj, 1L);
 
        if (slide && !Blind)
-           pline("Whee!  %s slide%s across the %s.", Doname2(kickobj),
-               kickobj->quan > 1L ? "" : "s",
-               surface(x,y));
+           pline("Whee!  %s %s across the %s.", Doname2(kickobj),
+                 otense(kickobj, "slide"), surface(x,y));
 
        obj_extract_self(kickobj);
        (void) snuff_candle(kickobj);
@@ -861,10 +861,10 @@ dokick()
                    if (!rn2(2) && !(maploc->looted & TREE_LOOTED) &&
                          (treefruit = rnd_treefruit_at(x, y))) {
                        treefruit->quan = (long)(8 - rnl(8));
-                       if (treefruit->quan > 1L)
-                               pline("Some %s fall from the tree!", xname(treefruit));
+                       if (is_plural(treefruit))
+                           pline("Some %s fall from the tree!", xname(treefruit));
                        else
-                               pline("%s falls from the tree!", An(xname(treefruit)));
+                           pline("%s falls from the tree!", An(xname(treefruit)));
                        scatter(x,y,2,MAY_HIT,treefruit);
                        exercise(A_DEX, TRUE);
                        exercise(A_WIS, TRUE);  /* discovered a new food source! */
@@ -1385,19 +1385,18 @@ long num;
                 xname(otmp));
 
        if(num) { /* means: other objects are impacted */
-           Sprintf(eos(obuf), " hit%s %s object%s",
-                     otmp->quan == 1L ? "s" : "",
-                     num == 1L ? "another" : "other",
-                     num > 1L ? "s" : "");
+           Sprintf(eos(obuf), " %s %s object%s",
+                   otense(otmp, "hit"),
+                   num == 1L ? "another" : "other",
+                   num > 1L ? "s" : "");
            if(nodrop)
                Sprintf(eos(obuf), ".");
            else
-               Sprintf(eos(obuf), " and fall%s %s.",
-                       otmp->quan == 1L ? "s" : "", gate_str);
+               Sprintf(eos(obuf), " and %s %s.",
+                       otense(otmp, "fall"), gate_str);
            pline("%s", obuf);
        } else if(!nodrop)
-           pline("%s fall%s %s.", obuf,
-                 otmp->quan == 1L ? "s" : "", gate_str);
+           pline("%s %s %s.", obuf, otense(otmp, "fall"), gate_str);
 }
 
 /* migration destination for objects which fall down to next level */
index 89dd598cbf03e4844c176555fe87b4601cfd2b01..d3a45aa14d46282c371c170392096800b319b4ca 100644 (file)
@@ -827,13 +827,13 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
        if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) {
            boolean slipok = TRUE;
            if (ammo_and_launcher(obj, uwep))
-               pline("%s misfires!", The(xname(obj)));
+               pline("%s!", Tobjnam(obj, "misfire"));
            else {
                /* only slip if it's greased or meant to be thrown */
                if (obj->greased || throwing_weapon(obj))
                    /* BUG: this message is grammatically incorrect if obj has
                       a plural name; greased gloves or boots for instance. */
-                   pline("%s slips as you throw it!", The(xname(obj)));
+                   pline("%s as you throw it!", Tobjnam(obj, "slip"));
                else slipok = FALSE;
            }
            if (slipok) {
@@ -864,8 +864,8 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
        } else if(u.dz) {
            if (u.dz < 0 && Role_if(PM_VALKYRIE) &&
                    obj->oartifact == ART_MJOLLNIR && !impaired) {
-               pline("%s hits the %s and returns to your hand!",
-                     The(xname(obj)), ceiling(u.ux,u.uy));
+               pline("%s the %s and returns to your hand!",
+                     Tobjnam(obj, "hit"), ceiling(u.ux,u.uy));
                obj = addinv(obj);
                (void) encumber_msg();
                setuwep(obj);
@@ -975,7 +975,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
                    sho_obj_return_to_u(obj);       /* display its flight */
 
                    if (!impaired && rn2(100)) {
-                       pline("%s returns to your hand!", The(xname(obj)));
+                       pline("%s to your hand!", Tobjnam(obj, "return"));
                        obj = addinv(obj);
                        (void) encumber_msg();
                        setuwep(obj);
@@ -985,11 +985,11 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
                    } else {
                        int dmg = rnd(4);
                        if (Blind)
-                           pline("%s hits your %s!",
-                                 The(xname(obj)), body_part(ARM));
+                           pline("%s your %s!",
+                                 Tobjnam(obj, "hit"), body_part(ARM));
                        else
-                           pline("%s flies back toward you, hitting your %s!",
-                                 The(xname(obj)), body_part(ARM));
+                           pline("%s back toward you, hitting your %s!",
+                                 Tobjnam(obj, "fly"), body_part(ARM));
                        (void) artifact_hit((struct monst *) 0, &youmonst,
                                            obj, &dmg, 0);
                        losehp(dmg, xname(obj), KILLED_BY);
@@ -1319,8 +1319,8 @@ register struct obj   *obj;
                        }
                }
            }
-           pline("%s vanishes into %s %s.",
-               The(xname(obj)), s_suffix(mon_nam(mon)),
+           pline("%s into %s %s.",
+               Tobjnam(obj, "vanish"), s_suffix(mon_nam(mon)),
                is_animal(u.ustuck->data) ? "entrails" : "currents");
        } else {
            tmiss(obj, mon);
index 369c1e47dd981a5413030c91e2ae1c1e51f1fa38..471016fc85476fff94a232c3d4775f71893282d3 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1654,7 +1654,7 @@ struct obj *otmp;
           ability to detect food that is unfit for consumption
           or dangerous and avoid it. */
 
-       char buf[BUFSZ], foodname[BUFSZ];
+       char buf[BUFSZ], foodsmell[BUFSZ];
        char *eat_it_anyway = "Eat it anyway?";
        boolean cadaver = (otmp->otyp == CORPSE);
        boolean stoneorslime = FALSE;
@@ -1666,7 +1666,7 @@ struct obj *otmp;
        mnum = 0;
 #endif
 
-       Strcpy(foodname, The(xname(otmp)));
+       Strcpy(foodsmell, Tobjnam(otmp, "smell"));
        if (cadaver || otmp->otyp == EGG || otmp->otyp == TIN) {
                mnum = otmp->corpsenm;
                /* These checks must match those in eatcorpse() */
@@ -1697,48 +1697,48 @@ struct obj *otmp;
 
        if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && !Sick_resistance) {
                /* Tainted meat */
-               Sprintf(buf, "%s smells like it could be tainted! %s",
-                    foodname, eat_it_anyway);
+               Sprintf(buf, "%s like it could be tainted! %s",
+                    foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (stoneorslime) {
-               Sprintf(buf, "%s smells like it could be something very dangerous! %s",
-                    foodname, eat_it_anyway);
+               Sprintf(buf, "%s like it could be something very dangerous! %s",
+                    foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (otmp->orotten || (cadaver && rotted > 3L)) {
                /* Rotten */
-               Sprintf(buf, "%s smells like it could be rotten! %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s like it could be rotten! %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (cadaver && poisonous(&mons[mnum]) && !Poison_resistance) {
                /* poisonous */
-               Sprintf(buf, "%s smells like it might be poisonous! %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s like it might be poisonous! %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (cadaver && !vegetarian(&mons[mnum]) &&
            !u.uconduct.unvegetarian && Role_if(PM_MONK)) {
-               Sprintf(buf, "%s smells unhealthy. %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s unhealthy. %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (cadaver && acidic(&mons[mnum]) && !Acid_resistance) {
-               Sprintf(buf, "%s smells rather acidic. %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s rather acidic. %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (Upolyd &&
            (u.umonnum == PM_RUST_MONSTER && is_metallic(otmp) && otmp->oerodeproof)) {
-               Sprintf(buf, "%s smells disgusting to you right now. %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s disgusting to you right now. %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
@@ -1751,24 +1751,24 @@ struct obj *otmp;
            ((material == LEATHER || material == BONE ||
              material == DRAGON_HIDE || material == WAX) ||
             (cadaver && !vegan(&mons[mnum])))) {
-               Sprintf(buf, "%s smells foul and unfamiliar to you. %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s foul and unfamiliar to you. %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
        if (!u.uconduct.unvegetarian &&
            ((material == LEATHER || material == BONE || material == DRAGON_HIDE) ||
             (cadaver && !vegetarian(&mons[mnum])))) {
-               Sprintf(buf, "%s smells unfamiliar to you. %s",
-                       foodname, eat_it_anyway);
+               Sprintf(buf, "%s unfamiliar to you. %s",
+                       foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
 
        if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && Sick_resistance) {
                /* Tainted meat with Sick_resistance */
-               Sprintf(buf, "%s smells like it could be tainted! %s",
-                    foodname, eat_it_anyway);
+               Sprintf(buf, "%s like it could be tainted! %s",
+                    foodsmell, eat_it_anyway);
                if (yn_function(buf,ynchars,'n')=='n') return 1;
                else return 2;
        }
@@ -2254,10 +2254,11 @@ boolean incr;
                                  "You still have the munchies." :
       "The munchies are interfering with your motor capabilities.");
                        else if (incr &&
-                               (Role_if(PM_WIZARD) || Race_if(PM_ELF) || Role_if(PM_VALKYRIE)))
+                               (Role_if(PM_WIZARD) || Race_if(PM_ELF) ||
+                                Role_if(PM_VALKYRIE)))
                            pline("%s needs food, badly!",
-                                       (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ?
-                                       urole.name.m : "Elf");
+                                 (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ?
+                                 urole.name.m : "Elf");
                        else
                            You((!incr) ? "feel weak now." :
                                  (u.uhunger < 45) ? "feel weak." :
@@ -2348,7 +2349,7 @@ floorfood(verb,corpsecheck)       /* get food from floor or pack */
                    feeding ? (otmp->oclass != GOLD_CLASS && is_edible(otmp)) :
                                                otmp->oclass==FOOD_CLASS) {
                        Sprintf(qbuf, "There %s %s here; %s %s?",
-                               (otmp->quan == 1L) ? "is" : "are",
+                               otense(otmp, "are"),
                                doname(otmp), verb,
                                (otmp->quan == 1L) ? "it" : "one");
                        if((c = yn_function(qbuf,ynqchars,'n')) == 'y')
index 64cb4a63bf9358cbbc651f2adea8505fb771acac..fc26a84cbfb497d0f2b62680b5565d0a18f2207b 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -898,7 +898,7 @@ boolean identified, all_containers;
                    if (all_containers)
                        container_contents(box->cobj, identified, TRUE);
                } else {
-                   pline("%s is empty.", The(xname(box)));
+                   pline("%s empty.", Tobjnam(box, "are"));
                    display_nhwindow(WIN_MESSAGE, FALSE);
                }
            }
index 43e563d010b617a105377f839fe97e005d097e2f..c8840b6bb11a18fcd24c27f47c5989db3b86c182 100644 (file)
@@ -785,15 +785,16 @@ doengrave()
                                if (!Blind)
                                    You("wipe out the message here.");
                                else
-                                   Your("%s gets %s.", xname(otmp),
-                                         is_ice(u.ux,u.uy) ?
-                                         "frosty" : "dusty");
+                                   Your("%s %s %s.", xname(otmp),
+                                        otense(otmp, "get"),
+                                        is_ice(u.ux,u.uy) ?
+                                        "frosty" : "dusty");
                                dengr = TRUE;
                            } else
                                Your("%s can't wipe out this engraving.",
                                     xname(otmp));
                        else
-                           Your("%s gets %s.", xname(otmp),
+                           Your("%s %s %s.", xname(otmp), otense(otmp, "get"),
                                  is_ice(u.ux,u.uy) ? "frosty" : "dusty");
                        break;
                    default:
@@ -968,7 +969,8 @@ doengrave()
        if (len == 0 || index(ebuf, '\033')) {
            if (zapwand) {
                if (!Blind)
-                   pline("%s glows, then fades.", The(xname(otmp)));
+                   pline("%s, then %s.",
+                         Tobjnam(otmp, "glow"), otense(otmp, "fade"));
                return(1);
            } else {
                pline(Never_mind);
index 2e7371405fd6fad49561eb7b26e372e3247fb800..9b76dcbfdd55a7e503b014ad61395c12d7e4be48 100644 (file)
@@ -284,9 +284,9 @@ int expltype;
                        int mdam = dam;
 
                        if (resist(mtmp, olet, 0, FALSE)) {
-                               if (cansee(i+x-1,j+y-1))
-                                   pline("%s resists the %s!", Monnam(mtmp), str);
-                               mdam = dam/2;
+                           if (cansee(i+x-1,j+y-1))
+                               pline("%s resists the %s!", Monnam(mtmp), str);
+                           mdam = dam/2;
                        }
                        if (mtmp == u.ustuck)
                                mdam *= 2;
@@ -437,7 +437,7 @@ struct obj *obj;                    /* only scatter this obj        */
                        && ((otmp->otyp == BOULDER) || (otmp->otyp == STATUE))
                        && rn2(10)) {
                if (otmp->otyp == BOULDER) {
-                   pline("%s breaks apart.",The(xname(otmp)));
+                   pline("%s apart.", Tobjnam(otmp, "break"));
                    fracture_rock(otmp);
                    place_object(otmp, sx, sy); /* put fragments on floor */
                    if ((otmp = sobj_at(BOULDER, sx, sy)) != 0) {
@@ -450,7 +450,7 @@ struct obj *obj;                    /* only scatter this obj        */
 
                    if ((trap = t_at(sx,sy)) && trap->ttyp == STATUE_TRAP)
                            deltrap(trap);
-                   pline("%s crumbles.",The(xname(otmp)));
+                   pline("%s.", Tobjnam(otmp, "crumble"));
                    (void) break_statue(otmp);
                    place_object(otmp, sx, sy); /* put fragments on floor */
                }
index 8810578e4d793c3375647808e119de1550254e18..858b4cc170a00e016757b368f3b6bef83c988f80 100644 (file)
@@ -133,8 +133,8 @@ moverock()
                switch(ttmp->ttyp) {
                case LANDMINE:
                    if (rn2(10)) {
-                       pline("KAABLAMM!!!  %s triggers %s land mine.",
-                               The(xname(otmp)),
+                       pline("KAABLAMM!!!  %s %s land mine.",
+                               Tobjnam(otmp, "trigger"),
                                ttmp->madeby_u ? "your" : "a");
                        obj_extract_self(otmp);
                        place_object(otmp, rx, ry);
@@ -162,10 +162,12 @@ moverock()
                    if (Blind)
                        pline("Kerplunk!  You no longer feel %s.",
                                the(xname(otmp)));
-                   else 
-                       pline("%s %s and plugs a %s in the %s!",
-                         The(xname(otmp)),
-                         (ttmp->ttyp == TRAPDOOR) ? "triggers" : "falls into",
+                   else
+                       pline("%s%s and %s a %s in the %s!",
+                         Tobjnam(otmp,
+                          (ttmp->ttyp == TRAPDOOR) ? "trigger" : "fall"),
+                         (ttmp->ttyp == TRAPDOOR) ? nul : " into",
+                         otense(otmp, "plug"),
                          (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole",
                          surface(rx, ry));
                    deltrap(ttmp);
@@ -2078,7 +2080,7 @@ struct obj *otmp;
         while(otmp) {
                /* Must change when silver & copper is implemented: */
                if (otmp->oclass == GOLD_CLASS) return otmp->quan;
-               otmp = otmp->nobj;       
+               otmp = otmp->nobj;
        }
        return 0;
 }
index a1db552591405b1d2d063362de0e086f41273bc7..8ad23afc7b45597b6e9b55fb17ef637295f8a662 100644 (file)
@@ -343,7 +343,7 @@ mattacku(mtmp)
                        newsym(u.ux,u.uy);
                    } else {
                        pline("%s is killed by a falling %s (you)!",
-                                               Monnam(mtmp), youmonst.data->mname);
+                                       Monnam(mtmp), youmonst.data->mname);
                        killed(mtmp);
                        newsym(u.ux,u.uy);
                        if (mtmp->mhp > 0) return 0;
@@ -1526,10 +1526,9 @@ gulpmu(mtmp, mattk)      /* monster swallows you, or damage if u.uswallow */
 
                i = number_leashed();
                if (i > 0) {
-                       pline_The("leash%s snap%s loose.",
-                                       (i > 1) ? "es" : "",
-                                       (i > 1) ? "" : "s");
-                       unleash_all();
+                   char *s = (i > 1) ? "leashes" : "leash";
+                   pline_The("%s %s loose.", s, vtense(s, "snap"));
+                   unleash_all();
                }
 
                if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
index e3c34a36ed3a93966779671b3dc53398e4c1151c..1943b3d82754ab9fe87f7e5d315844ef192c03f8 100644 (file)
@@ -294,8 +294,8 @@ m_throw(mon, x, y, dx, dy, range, obj)
                if(is_ammo(singleobj))
                    pline("%s misfires!", Monnam(mon));
                else
-                   pline("%s slips as %s throws it!",
-                         The(xname(singleobj)), mon_nam(mon));
+                   pline("%s as %s throws it!",
+                         Tobjnam(singleobj, "slip"), mon_nam(mon));
            }
            dx = rn2(3)-1;
            dy = rn2(3)-1;
index 97d1b03eca9a20b2d30dd393cf91b81537bfc754..79b4a0032a8e1b2c64b55d693cbb410b5ffd5c0e 100644 (file)
@@ -1803,7 +1803,7 @@ skipmsg:
                          The_whip, the_weapon);
                    if (welded(obj)) {
                        pline("%s welded to your %s%c",
-                             (obj->quan == 1L) ? "It is" : "They are",
+                             is_plural(obj) ? "It is" : "They are",
                              hand, !obj->bknown ? '!' : '.');
                        /* obj->bknown = 1; */ /* welded() takes care of this */
                        where_to = 0;
index fc84d21f0b94cf5d5b2906e1f0fd2b79d0fe4e53..017288f6aa86128689256e04d2bede95c55a0e6e 100644 (file)
@@ -392,8 +392,7 @@ struct obj *instr;
            } /* else FALLTHRU */
        case WOODEN_FLUTE:              /* May charm snakes */
            do_spec &= (rn2(ACURR(A_DEX)) + u.ulevel > 25);
-           pline("%s %s.", The(xname(instr)),
-                 do_spec ? "trills" : "toots");
+           pline("%s.", Tobjnam(instr, do_spec ? "trill" : "toot"));
            if (do_spec) charm_snakes(u.ulevel * 3);
            exercise(A_DEX, TRUE);
            break;
@@ -403,7 +402,7 @@ struct obj *instr;
                check_unpaid(instr);
                instr->spe--;
                if (!getdir((char *)0)) {
-                   pline("%s vibrates.", The(xname(instr)));
+                   pline("%s.", Tobjnam(instr, "vibrate"));
                    break;
                } else if (!u.dx && !u.dy && !u.dz) {
                    if ((damage = zapyourself(instr, TRUE)) != 0) {
@@ -432,8 +431,7 @@ struct obj *instr;
            if (do_spec && instr->spe > 0) {
                check_unpaid(instr);
                instr->spe--;
-               pline("%s produces very attractive music.",
-                     The(xname(instr)));
+               pline("%s very attractive music.", Tobjnam(instr, "produce"));
                charm_monsters((u.ulevel - 1) / 3 + 1);
                exercise(A_DEX, TRUE);
                break;
index 8da02025c2f92b1c1c2b51c78cc4d9d053c8b28c..5920bf00a0a92a5791c681751831a71180bb8c93 100644 (file)
@@ -7,6 +7,7 @@
 /* "an uncursed greased partly eaten guardian naga hatchling [corpse]" */
 #define PREFIX 80      /* (56) */
 #define SCHAR_LIM 127
+#define NUMOBUF 12
 
 STATIC_DCL char *FDECL(strprepend,(char *,const char *));
 #ifdef OVL0
@@ -15,6 +16,7 @@ static boolean FDECL(the_unique_obj, (struct obj *obj));
 #ifdef OVLB
 static boolean FDECL(wishymatch, (const char *,const char *,BOOLEAN_P));
 #endif
+static char *NDECL(nextobuf);
 static void FDECL(add_erosion_words, (struct obj *, char *));
 
 struct Jitem {
@@ -78,22 +80,28 @@ register const char *pref;
 #endif /* OVL1 */
 #ifdef OVLB
 
+/* manage a pool of BUFSZ buffers, so callers don't have to */
+static char *
+nextobuf()
+{
+       static char NEARDATA bufs[NUMOBUF][BUFSZ];
+       static int bufidx = 0;
+
+       bufidx = (bufidx + 1) % NUMOBUF;
+       return bufs[bufidx];
+}
+
 char *
 obj_typename(otyp)
 register int otyp;
 {
-#ifdef LINT    /* static char buf[BUFSZ]; */
-       char buf[BUFSZ];
-#else
-       static char NEARDATA buf[BUFSZ];
-#endif
+       char *buf = nextobuf();
        register struct objclass *ocl = &objects[otyp];
        register const char *actualn = OBJ_NAME(*ocl);
        register const char *dn = OBJ_DESCR(*ocl);
        register const char *un = ocl->oc_uname;
        register int nn = ocl->oc_name_known;
 
-
        if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp))
                actualn = Japanese_item_name(otyp);
        switch(ocl->oc_class) {
@@ -212,12 +220,7 @@ char *
 xname(obj)
 register struct obj *obj;
 {
-#ifdef LINT    /* lint may handle static decl poorly -- static char bufr[]; */
-       char bufr[BUFSZ];
-#else
-       static char bufr[BUFSZ];
-#endif
-       register char *buf = &(bufr[PREFIX]);   /* leave room for "17 -3 " */
+       register char *buf;
        register int typ = obj->otyp;
        register struct objclass *ocl = &objects[typ];
        register int nn = ocl->oc_name_known;
@@ -225,6 +228,7 @@ register struct obj *obj;
        register const char *dn = OBJ_DESCR(*ocl);
        register const char *un = ocl->oc_uname;
 
+       buf = nextobuf() + PREFIX;      /* leave room for "17 -3 " */
        if (Role_if(PM_SAMURAI) && Japanese_item_name(typ))
                actualn = Japanese_item_name(typ);
 
@@ -797,17 +801,13 @@ register struct obj *otmp;
                         is_flammable(otmp));
 }
 
-/* The result is actually modifiable, but caller shouldn't rely on that
- * due to the small buffer size.
- */
-const char *
+char *
 corpse_xname(otmp, ignore_oquan)
 struct obj *otmp;
 boolean ignore_oquan;  /* to force singular */
 {
-       static char NEARDATA nambuf[40];
+       char *nambuf = nextobuf();
 
-     /* assert( strlen(mons[otmp->corpsenm].mname) <= 32 ); */
        Sprintf(nambuf, "%s corpse", mons[otmp->corpsenm].mname);
 
        if (ignore_oquan || otmp->quan < 2)
@@ -842,7 +842,7 @@ char *
 an(str)
 register const char *str;
 {
-       static char NEARDATA buf[BUFSZ];
+       char *buf = nextobuf();
 
        buf[0] = '\0';
 
@@ -881,7 +881,7 @@ char *
 the(str)
 const char *str;
 {
-       static char NEARDATA buf[BUFSZ];
+       char *buf = nextobuf();
        boolean insert_the = FALSE;
 
        if (!strncmpi(str, "the ", 4)) {
@@ -933,6 +933,7 @@ const char *str;
     return tmp;
 }
 
+/* returns "count xname(otmp)" or just xname(otmp) if count == 1 */
 char *
 aobjnam(otmp,verb)
 register struct obj *otmp;
@@ -947,20 +948,122 @@ register const char *verb;
        }
 
        if(verb) {
-               /* verb is given in plural (without trailing s) */
-               Strcat(bp, " ");
-               if(otmp->quan != 1L)
-                       Strcat(bp, verb);
-               else if(!strcmp(verb, "are"))
-                       Strcat(bp, "is");
-               else {
-                       Strcat(bp, verb);
-                       Strcat(bp, "s");
-               }
+           Strcat(bp, " ");
+           Strcat(bp, otense(otmp, verb));
+       }
+       return(bp);
+}
+
+/* like aobjnam, but prepend "The", not count */
+char *
+Tobjnam(otmp, verb)
+register struct obj *otmp;
+register const char *verb;
+{
+       char *bp = The(xname(otmp));
+
+       if(verb) {
+           Strcat(bp, " ");
+           Strcat(bp, otense(otmp, verb));
        }
        return(bp);
 }
 
+/* return form of the verb (input plural) if xname(otmp) were the subject */
+char *
+otense(otmp, verb)
+register struct obj *otmp;
+register const char *verb;
+{
+       char *buf;
+
+       /*
+        * verb is given in plural (without trailing s).  Return as input
+        * if the result of xname(otmp) would be plural.  Don't bother
+        * recomputing xname(otmp) at this time.
+        */
+       if (!is_plural(otmp))
+           return vtense((char *)0, verb);
+
+       buf = nextobuf();
+       Strcpy(buf, verb);
+       return buf;
+}
+
+/* return form of the verb (input plural) for present tense 3rd person subj */
+char *
+vtense(subj, verb)
+register const char *subj;
+register const char *verb;
+{
+       char *buf = nextobuf();
+       int len;
+       const char *spot;
+       const char *sp;
+
+       /*
+        * verb is given in plural (without trailing s).  Return as input
+        * if subj appears to be plural.  Add special cases as necessary.
+        * Many hard cases can already be handled by using otense() instead.
+        * If this gets much bigger, consider decomposing makeplural.
+        * Note: monster names are not expected here (except before corpse).
+        *
+        * special case: allow null sobj to get the singular 3rd person
+        * present tense form so we don't duplicate this code elsewhere.
+        */
+       if (subj) {
+           spot = (const char *)0;
+           for (sp = subj; (sp = index(sp, ' ')) != 0; ++sp) {
+               if (!strncmp(sp, " of ", 4) ||
+                   !strncmp(sp, " called ", 8) ||
+                   !strncmp(sp, " named ", 7) ||
+                   !strncmp(sp, " labeled ", 9)) {
+                   if (sp != subj) spot = sp - 1;
+                   break;
+               }
+           }
+           len = strlen(subj);
+           if (!spot) spot = subj + len - 1;
+
+           /*
+            * plural: anything that ends in 's', but not '*us'.
+            * Guess at a few other special cases that makeplural creates.
+            */
+           if ((*spot == 's' && spot != subj && *(spot-1) != 'u') ||
+               ((spot - subj) >= 4 && strncmp(spot-3, "eeth", 4)) ||
+               ((spot - subj) >= 3 && strncmp(spot-3, "feet", 4)) ||
+               ((spot - subj) >= 2 && strncmp(spot-1, "ia", 2)) ||
+               ((spot - subj) >= 2 && strncmp(spot-1, "ae", 2))) {
+               Strcpy(buf, verb);
+               return buf;
+           }
+       }
+
+       len = strlen(verb);
+       spot = verb + len - 1;
+
+       if (!strcmp(verb, "are"))
+           Strcpy(buf, "is");
+       else if (!strcmp(verb, "have"))
+           Strcpy(buf, "has");
+       else if (index("zxs", *spot) ||
+                (len >= 2 && *spot=='h' && index("cs", *(spot-1))) ||
+                (len == 2 && *spot == 'o')) {
+           /* Ends in z, x, s, ch, sh; add an "es" */
+           Strcpy(buf, verb);
+           Strcat(buf, "es");
+       } else if (*spot == 'y' && (!index(vowels, *(spot-1)))) {
+           /* like "y" case in makeplural */
+           Strcpy(buf, verb);
+           Strcat(buf + len - 1, "ies");
+       } else {
+           Strcpy(buf, verb);
+           Strcat(buf, "s");
+       }
+
+       return buf;
+}
+
 /* capitalized variant of doname() */
 char *
 Doname2(obj)
@@ -977,9 +1080,9 @@ char *
 yname(obj)
 struct obj *obj;
 {
-       static char outbuf[BUFSZ];
+       char *outbuf = nextobuf();
        char *s = shk_your(outbuf, obj);        /* assert( s == outbuf ); */
-       int space_left = sizeof outbuf - strlen(s) - sizeof " ";
+       int space_left = BUFSZ - strlen(s) - sizeof " ";
 
        return strncat(strcat(s, " "), xname(obj), space_left);
 }
@@ -1027,7 +1130,7 @@ const char *oldstr;
 {
        /* Note: cannot use strcmpi here -- it'd give MATZot, CAVEMeN,... */
        register char *spot;
-       static char NEARDATA str[BUFSZ];
+       char *str = nextobuf();
        const char *excess = (char *)0;
        int len;
 
@@ -1040,14 +1143,11 @@ const char *oldstr;
        Strcpy(str, oldstr);
 
        /*
-       Skip changing "pair of" to "pairs of".  According to Webster, usual
-       English usage is use pairs for humans, e.g. 3 pairs of dancers,
-       and pair for objects and non-humans, e.g. 3 pair of boots.  We don't
-       refer to pairs of humans in this game so just skip to the bottom.
-
-       Actually, none of the "pair" objects -- gloves, boots, and lenses --
-       currently merge, so this isn't used.
-       */
+        * Skip changing "pair of" to "pairs of".  According to Webster, usual
+        * English usage is use pairs for humans, e.g. 3 pairs of dancers,
+        * and pair for objects and non-humans, e.g. 3 pair of boots.  We don't
+        * refer to pairs of humans in this game so just skip to the bottom.
+        */
        if (!strncmp(str, "pair of ", 8))
                goto bottom;
 
@@ -1291,13 +1391,12 @@ STATIC_OVL NEARDATA const struct o_range o_ranges[] = {
  * of readobjnam, and is also used in pager.c to singularize the string
  * for which help is sought.
  */
-
 char *
 makesingular(oldstr)
 const char *oldstr;
 {
        register char *p, *bp;
-       static char NEARDATA str[BUFSZ];
+       char *str = nextobuf();
 
        if (!oldstr || !*oldstr) {
                impossible("singular of null?");
index 27931686b9bd34773c8df19cdc67e2d90858b83b..e0412220d7466985a8ba0ebf81267b8c661fd006 100644 (file)
@@ -1047,7 +1047,7 @@ int *wt_before, *wt_after;
        suffx  = "";
     }
     There("%s %s %s, but %s%s%s%s.",
-         (obj->quan == 1L) ? "is" : "are", obj_nambuf, where,
+         otense(obj, "are"), obj_nambuf, where,
          prefx1, prefx2, verb, suffx);
 
  /* *wt_after = iw; */
@@ -1161,7 +1161,7 @@ boolean telekinesis;      /* not picking it up directly by hand */
            if (gold_capacity <= 0L) {
                pline(
               "There %s %ld gold piece%s %s, but you cannot carry any more.",
-                     (obj->quan == 1L) ? "is" : "are",
+                     otense(obj, "are"),
                      obj->quan, plur(obj->quan), where);
                return 0;
            } else if (gold_capacity < count) {
@@ -1200,9 +1200,8 @@ boolean telekinesis;      /* not picking it up directly by hand */
                else {
                        char kbuf[BUFSZ];
 
-                       pline("Touching %s corpse is a fatal mistake.",
-                                       an(mons[obj->corpsenm].mname));
-                       Sprintf(kbuf, "%s corpse", an(mons[obj->corpsenm].mname));
+                       Strcpy(kbuf, an(corpse_xname(obj, TRUE)));
+                       pline("Touching %s is a fatal mistake.", kbuf);
                        instapetrify(kbuf);
                    return -1;
                }
@@ -1217,8 +1216,8 @@ boolean telekinesis;      /* not picking it up directly by hand */
            if (obj->blessed) obj->blessed = 0;
            else if (!obj->spe && !obj->cursed) obj->spe = 1;
            else {
-               pline_The("scroll%s turn%s to dust as you %s %s up.",
-                       plur(obj->quan), (obj->quan == 1L) ? "s" : "",
+               pline_The("scroll%s %s to dust as you %s %s up.",
+                       plur(obj->quan), otense(obj, "turn"),
                        telekinesis ? "raise" : "pick",
                        (obj->quan == 1L) ? "it" : "them");
                if (!(objects[SCR_SCARE_MONSTER].oc_name_known) &&
@@ -1685,7 +1684,7 @@ register struct obj *obj;
            pline("%s cannot be confined in such trappings.", The(xname(obj)));
            return 0;
        } else if (obj->otyp == LEASH && obj->leashmon != 0) {
-               pline("%s is attached to your pet.", The(xname(obj)));
+               pline("%s attached to your pet.", Tobjnam(obj, "are"));
                return 0;
        } else if (obj == uwep) {
                if (welded(obj)) {
@@ -1710,9 +1709,8 @@ register struct obj *obj;
                else {
                    char kbuf[BUFSZ];
 
-                   pline("Touching %s corpse is a fatal mistake.",
-                         an(mons[obj->corpsenm].mname));
-                   Sprintf(kbuf, "%s corpse", an(mons[obj->corpsenm].mname));
+                   Strcpy(kbuf, an(corpse_xname(obj, TRUE)));
+                   pline("Touching %s is a fatal mistake.", kbuf);
                    instapetrify(kbuf);
                    return -1;
                }
@@ -1827,9 +1825,8 @@ register struct obj *obj;
                else {
                    char kbuf[BUFSZ];
 
-                   pline("Touching %s corpse is a fatal mistake.",
-                         an(mons[obj->corpsenm].mname));
-                   Sprintf(kbuf, "%s corpse", an(mons[obj->corpsenm].mname));
+                   Strcpy(kbuf, an(corpse_xname(obj, TRUE)));
+                   pline("Touching %s is a fatal mistake.", kbuf);
                    instapetrify(kbuf);
                    return -1;
                }
@@ -1902,7 +1899,7 @@ register int held;
            menu_on_request;
 
        if (obj->olocked) {
-           pline("%s seems to be locked.", The(xname(obj)));
+           pline("%s to be locked.", Tobjnam(obj, "seem"));
            if (held) You("must put it down to unlock.");
            return 0;
        } else if (obj->otrapped) {
@@ -1989,7 +1986,7 @@ register int held;
        obj->owt = weight(obj);
 
        if (!cnt) {
-           pline("%s is empty.", Yname2(obj));
+           pline("%s %s empty.", Yname2(obj), otense(obj, "are"));
        } else {
            Sprintf(qbuf, "Do you want to take %s out of %s?",
                    something, yname(obj));
index cbf7b3f18c77804872108f7e7f4f4454447155a4..dd65e0fd302f985e3013842aca63fac2620f1c5d 100644 (file)
@@ -973,7 +973,7 @@ boolean your_fault;
 
        /* oil doesn't instantly evaporate */
        if (obj->otyp != POT_OIL && cansee(mon->mx,mon->my))
-               pline("%s evaporates.", The(xname(obj)));
+               pline("%s.", Tobjnam(obj, "evaporate"));
 
     if (isyou) {
        switch (obj->otyp) {
@@ -1407,7 +1407,7 @@ register struct obj *obj;
        if (snuff_lit(obj)) return(TRUE);
 
        if (obj->greased) {
-               grease_protect(obj,(char *)0,FALSE,&youmonst);
+               grease_protect(obj,(char *)0,&youmonst);
                return(FALSE);
        }
        (void) Shk_Your(Your_buf, obj);
@@ -1459,9 +1459,8 @@ register struct obj *obj;
                    ) {
                        if (!Blind) {
                                boolean oq1 = obj->quan == 1L;
-                               pline_The("scroll%s fade%s.",
-                                       oq1 ? "" : "s",
-                                       oq1 ? "s" : "");
+                               pline_The("scroll%s %s.",
+                                         oq1 ? "" : "s", otense(obj, "fade"));
                        }
                        if(obj->unpaid && costly_spot(u.ux, u.uy)) {
                            You("erase it, you pay for it.");
@@ -1482,7 +1481,7 @@ register struct obj *obj;
                            if (!Blind) {
                                    boolean oq1 = obj->quan == 1L;
                                    pline_The("spellbook%s fade%s.",
-                                       oq1 ? "" : "s", oq1 ? "s" : "");
+                                       oq1 ? "" : "s", otense(obj, "fade"));
                            }
                            if(obj->unpaid && costly_spot(u.ux, u.uy)) {
                                You("erase it, you pay for it.");
@@ -1736,9 +1735,8 @@ dodip()
                if (obj->oerodeproof || obj_resists(obj, 5, 95) ||
                        /* `METAL' should not be confused with is_metallic() */
                        omat == METAL || omat == MITHRIL || omat == BONE) {
-                   pline("%s seem%s to burn for a moment.",
-                         Yname2(obj),
-                         (obj->quan > 1L) ? "" : "s");
+                   pline("%s %s to burn for a moment.",
+                         Yname2(obj), otense(obj, "seem"));
                } else {
                    if (omat == PLASTIC) obj->oeroded = MAX_ERODE;
                    pline_The("burning oil %s %s.",
@@ -1763,15 +1761,13 @@ dodip()
             * material, but dipping in oil shouldn't repair them.
             */
            } else if ((!is_rustprone(obj) && !is_corrodeable(obj)) ||
-                               is_ammo(obj) || (!obj->oeroded && !obj->oeroded2)) {
+                       is_ammo(obj) || (!obj->oeroded && !obj->oeroded2)) {
                /* uses up potion, doesn't set obj->greased */
-               pline("%s gleam%s with an oily sheen.",
-                     Yname2(obj),
-                     (obj->quan > 1L) ? "" : "s");
+               pline("%s %s with an oily sheen.",
+                     Yname2(obj), otense(obj, "gleam"));
            } else {
                pline("%s %s less %s.",
-                     Yname2(obj),
-                     (obj->quan > 1L) ? "are" : "is",
+                     Yname2(obj), otense(obj, "are"),
                      (obj->oeroded && obj->oeroded2) ? "corroded and rusty" :
                        obj->oeroded ? "rusty" : "corroded");
                if (obj->oeroded > 0) obj->oeroded--;
@@ -1800,7 +1796,7 @@ dodip()
                obj->age = 0;
            }
            if (obj->age > 1000L) {
-               pline("%s is full.", Yname2(obj));
+               pline("%s %s full.", Yname2(obj), otense(obj, "are"));
            } else {
                You("fill %s with oil.", yname(obj));
                check_unpaid(potion);   /* Yendorian Fuel Tax */
index 6596805a6781da6d86454df2cf223e16df7b0092..df938135fc3ea017b36dd840f1fafc90caf8eed1 100644 (file)
@@ -336,7 +336,7 @@ decurse:
                    if (!Blind)
                            Your("%s %s.",
                                 what ? what :
-                                (const char *)aobjnam (otmp, "softly glow"),
+                                (const char *)aobjnam(otmp, "softly glow"),
                                 hcolor(amber));
                    break;
            case TROUBLE_POISONED:
@@ -546,11 +546,11 @@ at_your_feet(str)
        if (Blind) str = Something;
        if (u.uswallow) {
            /* barrier between you and the floor */
-           pline("%s drops into %s %s.", str,
+           pline("%s %s into %s %s.", str, vtense(str, "drop"),
                  s_suffix(mon_nam(u.ustuck)), mbodypart(u.ustuck, STOMACH));
        } else {
            pline("%s %s %s your %s!", str,
-                 Blind ? "lands" : "appears",
+                 Blind ? "lands" : vtense(str, "appear"),
                  Levitation ? "beneath" : "at",
                  makeplural(body_part(FOOT)));
        }
@@ -777,7 +777,7 @@ pleased(g_align)
                *repair_buf = '\0';
                if (uwep->oeroded || uwep->oeroded2)
                    Sprintf(repair_buf, " and %s now as good as new",
-                           uwep->quan == 1L ? "is" : "are");
+                           otense(uwep, "are"));
 
                if (uwep->cursed) {
                    uncurse(uwep);