From: nethack.allison Date: Mon, 21 Jan 2002 03:35:04 +0000 (+0000) Subject: The word "zorkmid" was hard-coded in format strings all X-Git-Tag: MOVE2GIT~3408 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2fe0a3d5cd7d01d51578644dd7655d9ebd81beb;p=nethack The word "zorkmid" was hard-coded in format strings all over the place. Often they would use "%ld zorkmid%s", amt, plur(amt) but not consistently, so some of the hard-coded usage could result in "1 zorkmids" This adds the function currency(long) to return the name of the currency, either plural or singular depending on the argument passed to it. That eliminates the need for the extra %s in the format string and the use of the plur() macro. --- diff --git a/include/extern.h b/include/extern.h index f786e60db..7b2e43a51 100644 --- a/include/extern.h +++ b/include/extern.h @@ -785,6 +785,7 @@ E int NDECL(doorganize); E int FDECL(count_unpaid, (struct obj *)); E int FDECL(count_buc, (struct obj *,int)); E void FDECL(carry_obj_effects, (struct obj *)); +E const char *FDECL(currency, (long)); /* ### ioctl.c ### */ diff --git a/src/dokick.c b/src/dokick.c index 35f86fa20..6e76f7777 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -285,9 +285,9 @@ register struct obj *gold; #else ESHK(mtmp)->credit += value; #endif - You("have %ld zorkmid%s in credit.", + You("have %ld %s in credit.", ESHK(mtmp)->credit, - plur(ESHK(mtmp)->credit)); + currency(ESHK(mtmp)->credit)); } else verbalize("Thanks, scum!"); } } else if (mtmp->ispriest) { @@ -449,11 +449,11 @@ xchar x, y; } if(costly && loss) { if(!insider) { - You("caused %ld zorkmids worth of damage!", loss); + You("caused %ld %s worth of damage!", loss, currency(loss)); make_angry_shk(shkp, x, y); } else { - You("owe %s %ld zorkmids for objects destroyed.", - mon_nam(shkp), loss); + You("owe %s %ld %s for objects destroyed.", + mon_nam(shkp), loss, currency(loss)); } } @@ -1179,7 +1179,7 @@ xchar x, y, dlev; if(costly && shkp && price) { if(ESHK(shkp)->robbed > robbed) { - You("removed %ld zorkmids worth of goods!", price); + You("removed %ld %s worth of goods!", price, currency(price)); if(cansee(shkp->mx, shkp->my)) { if(ESHK(shkp)->customer[0] == 0) (void) strncpy(ESHK(shkp)->customer, @@ -1192,10 +1192,12 @@ xchar x, y, dlev; (void) angry_guards(FALSE); return; } - if(ESHK(shkp)->debit > debit) - You("owe %s %ld zorkmids for goods lost.", + if(ESHK(shkp)->debit > debit) { + long amt = (ESHK(shkp)->debit - debit); + You("owe %s %ld %s for goods lost.", Monnam(shkp), - (ESHK(shkp)->debit - debit)); + amt, currency(amt)); + } } } diff --git a/src/end.c b/src/end.c index d1643e67f..1a1ff9378 100644 --- a/src/end.c +++ b/src/end.c @@ -463,10 +463,10 @@ winid endwin; otmp->known = otmp->bknown = otmp->dknown = otmp->rknown = 1; /* assumes artifacts don't have quan>1 */ - Sprintf(pbuf, "%s (worth %ld zorkmids and %ld points)", + Sprintf(pbuf, "%s (worth %ld %s and %ld points)", otmp->oartifact ? artifact_name(xname(otmp), &dummy) : OBJ_NAME(objects[otmp->otyp]), - 100L * (long)objects[otmp->otyp].oc_cost, + 100L * (long)objects[otmp->otyp].oc_cost, currency(2L), 250L * (long)objects[otmp->otyp].oc_cost); putstr(endwin, 0, pbuf); } @@ -561,7 +561,7 @@ die: * smiling... :-) -3. */ if (moves <= 1 && how < PANICKED) /* You die... --More-- */ - pline("Do not pass go. Do not collect 200 zorkmids."); + pline("Do not pass go. Do not collect 200 %s.", currency(200L)); if (have_windows) wait_synch(); /* flush screen output */ #ifndef NO_SIGNAL @@ -769,9 +769,9 @@ die: otmp->dknown = 1; /* seen it (blindness fix) */ otmp->onamelth = 0; otmp->quan = count; - Sprintf(pbuf, "%8ld %s (worth %ld zorkmids),", + Sprintf(pbuf, "%8ld %s (worth %ld %s),", count, xname(otmp), - count * (long)objects[typ].oc_cost); + count * (long)objects[typ].oc_cost, currency(2L)); obfree(otmp, (struct obj *)0); } else { Sprintf(pbuf, diff --git a/src/invent.c b/src/invent.c index 2d15caee1..b349c748f 100644 --- a/src/invent.c +++ b/src/invent.c @@ -573,6 +573,14 @@ register int type; return((struct obj *) 0); } +const char * +currency(amount) +long amount; +{ + if (amount == 1) return "zorkmid"; + else return "zorkmids"; +} + boolean have_lizard() { @@ -1442,9 +1450,9 @@ long quan; /* if non-0, print this quantity, not obj->quan */ */ if (cost != 0 || let == '*') { /* if dot is true, we're doing Iu, otherwise Ix */ - Sprintf(li, "%c - %-45s %6ld zorkmid%s", + Sprintf(li, "%c - %-45s %6ld %s", (dot && use_invlet ? obj->invlet : let), - (txt ? txt : doname(obj)), cost, plur(cost)); + (txt ? txt : doname(obj)), cost, currency(cost)); #ifndef GOLDOBJ } else if (obj && obj->oclass == GOLD_CLASS) { Sprintf(li, "%ld gold piece%s%s", obj->quan, plur(obj->quan), @@ -2193,7 +2201,7 @@ doprgold() if(!umoney) Your("wallet is empty."); else - Your("wallet contains %ld zorkmid%s.", umoney, plur(umoney)); + Your("wallet contains %ld %s.", umoney, currency(umoney)); #endif shopper_financial_report(); return 0; diff --git a/src/lock.c b/src/lock.c index a79848d7a..f85fd99ee 100644 --- a/src/lock.c +++ b/src/lock.c @@ -201,7 +201,7 @@ forcelock() /* try to force a locked chest */ if (costly) loss += stolen_value(xlock.box, u.ux, u.uy, (boolean)shkp->mpeaceful, TRUE); - if(loss) You("owe %ld zorkmids for objects destroyed.", loss); + if(loss) You("owe %ld %s for objects destroyed.", loss, currency(loss)); delobj(xlock.box); } exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE); diff --git a/src/mhitu.c b/src/mhitu.c index 001e9dff9..5f998085f 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -2215,8 +2215,8 @@ register struct monst *mon; if (cost > u.ugold) cost = u.ugold; if (!cost) verbalize("It's on the house!"); else { - pline("%s takes %ld zorkmid%s for services rendered!", - Monnam(mon), cost, plur(cost)); + pline("%s takes %ld %s for services rendered!", + Monnam(mon), cost, currency(cost)); u.ugold -= cost; mon->mgold += cost; flags.botl = 1; @@ -2236,8 +2236,8 @@ register struct monst *mon; if (cost > umoney) cost = umoney; if (!cost) verbalize("It's on the house!"); else { - pline("%s takes %ld zorkmid%s for services rendered!", - Monnam(mon), cost, plur(cost)); + pline("%s takes %ld %s for services rendered!", + Monnam(mon), cost, currency(cost)); money2mon(mon, cost); flags.botl = 1; } diff --git a/src/minion.c b/src/minion.c index 551c39174..f9865d095 100644 --- a/src/minion.c +++ b/src/minion.c @@ -140,8 +140,8 @@ register struct monst *mtmp; if (!demand) /* you have no gold */ return mtmp->mpeaceful = 0; else { - pline("%s demands %ld zorkmid%s for safe passage.", - Amonnam(mtmp), demand, plur(demand)); + pline("%s demands %ld %s for safe passage.", + Amonnam(mtmp), demand, currency(demand)); if ((offer = bribe(mtmp)) >= demand) { pline("%s vanishes, laughing about cowardly mortals.", @@ -185,8 +185,8 @@ struct monst *mtmp; } else if (offer >= u.ugold) { You("give %s all your gold.", mon_nam(mtmp)); offer = u.ugold; - } else You("give %s %ld zorkmid%s.", mon_nam(mtmp), offer, - plur(offer)); + } else You("give %s %ld %s.", mon_nam(mtmp), offer, + currency(offer)); u.ugold -= offer; mtmp->mgold += offer; @@ -194,8 +194,8 @@ struct monst *mtmp; } else if (offer >= umoney) { You("give %s all your gold.", mon_nam(mtmp)); offer = umoney; - } else You("give %s %ld zorkmid%s.", mon_nam(mtmp), offer, - plur(offer)); + } else You("give %s %ld %s.", mon_nam(mtmp), offer, + currency(offer)); money2mon(mtmp, offer); #endif diff --git a/src/pickup.c b/src/pickup.c index 9d51ce6c9..7e36b0e4d 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1983,8 +1983,8 @@ register int held; } if (cnt && loss) - You("owe %ld zorkmids for lost item%s.", - loss, lcnt > 1 ? "s" : ""); + You("owe %ld %s for lost item%s.", + loss, currency(loss), lcnt > 1 ? "s" : ""); obj->owt = weight(obj); diff --git a/src/rumors.c b/src/rumors.c index 6265d74a9..37b31bb1e 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -312,8 +312,8 @@ register struct monst *oracl; } Sprintf(qbuf, - "\"Wilt thou settle for a minor consultation?\" (%d zorkmids)", - minor_cost); + "\"Wilt thou settle for a minor consultation?\" (%d %s)", + minor_cost, currency(minor_cost)); switch (ynq(qbuf)) { default: case 'q': @@ -337,8 +337,8 @@ register struct monst *oracl; #endif (oracle_cnt == 1 || oracle_flg < 0)) return 0; Sprintf(qbuf, - "\"Then dost thou desire a major one?\" (%d zorkmids)", - major_cost); + "\"Then dost thou desire a major one?\" (%d %s)", + major_cost, currency(major_cost)); if (yn(qbuf) != 'y') return 0; #ifndef GOLDOBJ u_pay = (u.ugold < (long)major_cost ? (int)u.ugold diff --git a/src/shk.c b/src/shk.c index 3451e1942..53ec61db7 100644 --- a/src/shk.c +++ b/src/shk.c @@ -465,8 +465,8 @@ struct monst *shkp; eshkp = ESHK(shkp); total = (addupbill(shkp) + eshkp->debit); if (eshkp->credit >= total) { - Your("credit of %ld zorkmid%s is used to cover your shopping bill.", - eshkp->credit, plur(eshkp->credit)); + Your("credit of %ld %s is used to cover your shopping bill.", + eshkp->credit, currency(eshkp->credit)); total = 0L; /* credit gets cleared by setpaid() */ } else { You("escaped the shop without paying!"); @@ -477,8 +477,8 @@ struct monst *shkp; /* by this point, we know an actual robbery has taken place */ eshkp->robbed += total; - You("stole %ld zorkmid%s worth of merchandise.", - total, plur(total)); + You("stole %ld %s worth of merchandise.", + total, currency(total)); if (!Role_if(PM_ROGUE)) /* stealing is unlawful */ adjalign(-sgn(u.ualign.type)); @@ -674,14 +674,14 @@ shopper_financial_report() if ((shkp != this_shkp) ^ pass) continue; eshkp = ESHK(shkp); if ((amt = eshkp->credit) != 0) - You("have %ld zorkmid%s credit at %s %s.", - amt, plur(amt), s_suffix(shkname(shkp)), + You("have %ld %s credit at %s %s.", + amt, currency(amt), s_suffix(shkname(shkp)), shtypes[eshkp->shoptype - SHOPBASE].name); else if (shkp == this_shkp) You("have no credit in here."); if ((amt = shop_debt(eshkp)) != 0) - You("owe %s %ld zorkmid%s.", - shkname(shkp), amt, plur(amt)); + You("owe %s %ld %s.", + shkname(shkp), amt, currency(amt)); else if (shkp == this_shkp) You("don't owe any money here."); } @@ -1297,8 +1297,8 @@ proceed: #ifdef GOLDOBJ umoney = money_cnt(invent); #endif - Sprintf(sbuf, "You owe %s %ld zorkmid%s ", - shkname(shkp), dtmp, plur(dtmp)); + Sprintf(sbuf, "You owe %s %ld %s ", + shkname(shkp), dtmp, currency(dtmp)); if(loan) { if(loan == dtmp) Strcat(sbuf, "you picked up in the store."); @@ -1493,8 +1493,8 @@ boolean itemize; if (itemize) { char qbuf[BUFSZ]; - Sprintf(qbuf,"%s for %ld zorkmid%s. Pay?", quan == 1L ? - Doname2(obj) : doname(obj), ltmp, plur(ltmp)); + Sprintf(qbuf,"%s for %ld %s. Pay?", quan == 1L ? + Doname2(obj) : doname(obj), ltmp, currency(ltmp)); if (yn(qbuf) == 'n') { buy = PAY_SKIP; /* don't want to buy */ } else if (quan < bp->bquan && !consumed) { /* partly used goods */ @@ -1673,9 +1673,9 @@ boolean croaked; money2mon(shkp, loss); #endif flags.botl = 1; - pline("%s %s the %ld zorkmid%s %sowed %s.", + pline("%s %s the %ld %s %sowed %s.", Monnam(shkp), takes, - loss, plur(loss), + loss, currency(loss), strncmp(eshkp->customer, plname, PL_NSIZ) ? "" : "you ", shkp->female ? "her" : "him"); @@ -2230,12 +2230,12 @@ speak: (quan > 1L) ? "per" : "for this", xname(obj)); obj->quan = quan; } else - pline("%s will cost you %ld zorkmid%s%s.", - The(xname(obj)), ltmp, plur(ltmp), + pline("%s will cost you %ld %s%s.", + The(xname(obj)), ltmp, currency(ltmp), (obj->quan > 1L) ? " each" : ""); } else if(!silent) { - if(ltmp) pline_The("list price of %s is %ld zorkmid%s%s.", - the(xname(obj)), ltmp, plur(ltmp), + if(ltmp) pline_The("list price of %s is %ld %s%s.", + the(xname(obj)), ltmp, currency(ltmp), (obj->quan > 1L) ? " each" : ""); else pline("%s does not notice.", Monnam(shkp)); } @@ -2423,8 +2423,8 @@ register boolean peaceful, silent; char *still = ""; if (credit_use) { if (ESHK(shkp)->credit) { - You("have %ld zorkmids credit remaining.", - ESHK(shkp)->credit); + You("have %ld %s credit remaining.", + ESHK(shkp)->credit, currency(ESHK(shkp)->credit)); return value; } else if (!value) { You("have no credit remaining."); @@ -2433,10 +2433,10 @@ register boolean peaceful, silent; still = "still "; } if(obj->oclass == GOLD_CLASS) - You("%sowe %s %ld zorkmids!", still, mon_nam(shkp), value); - else You("%sowe %s %ld zorkmids for %s!", still, + You("%sowe %s %ld %s!", still, mon_nam(shkp), value, currency(value)); + else You("%sowe %s %ld %s for %s!", still, mon_nam(shkp), - value, + value, currency(value), obj->quan > 1L ? "them" : "it"); } } else { @@ -2588,8 +2588,8 @@ xchar x, y; eshkp->loan = 0L; Your("debt is paid off."); } - pline("%ld zorkmid%s added to your credit.", - delta, delta > 1L ? "s are" : " is"); + pline("%ld %s %s added to your credit.", + delta, currency(delta), delta > 1L ? "are" : "is"); } if(offer) goto move_on; else { @@ -2631,8 +2631,8 @@ move_on: } else if (sell_response != 'n') { pline("%s cannot pay you at present.", Monnam(shkp)); Sprintf(qbuf, - "Will you accept %ld zorkmid%s in credit for %s?", - tmpcr, plur(tmpcr), doname(obj)); + "Will you accept %ld %s in credit for %s?", + tmpcr, currency(tmpcr), doname(obj)); /* won't accept 'a' response here */ /* KLY - 3/2000 yes, we will, it's a damn nuisance to have to constantly hit 'y' to sell for credit */ @@ -3497,8 +3497,8 @@ getcad: } if (Invis) Your("invisibility does not fool %s!", shkname(shkp)); - Sprintf(qbuf,"\"Cad! You did %ld zorkmids worth of damage!\" Pay? ", - cost_of_damage); + Sprintf(qbuf,"\"Cad! You did %ld %s worth of damage!\" Pay? ", + cost_of_damage, currency(cost_of_damage)); if(yn(qbuf) != 'n') { cost_of_damage = check_credit(cost_of_damage, shkp); #ifndef GOLDOBJ @@ -3584,7 +3584,7 @@ register struct obj *first_obj; if (!cost) { Strcpy(price, "no charge"); } else { - Sprintf(price, "%ld zorkmid%s%s", cost, plur(cost), + Sprintf(price, "%ld %s%s", cost, currency(cost), otmp->quan > 1L ? " each" : ""); } Sprintf(buf, "%s, %s", doname(otmp), price); @@ -3600,8 +3600,8 @@ register struct obj *first_obj; cost = get_cost(first_obj, (struct monst *)0); if (Has_contents(first_obj)) cost += contained_cost(first_obj, shkp, 0L, FALSE); - pline("%s, price %ld zorkmid%s%s%s", doname(first_obj), - cost, plur(cost), first_obj->quan > 1L ? " each" : "", + pline("%s, price %ld %s%s%s", doname(first_obj), + cost, currency(cost), first_obj->quan > 1L ? " each" : "", shk_embellish(first_obj, cost)); } } @@ -3692,15 +3692,15 @@ struct monst *shkp; } } else if (eshk->billct) { register long total = addupbill(shkp) + eshk->debit; - pline("%s says that your bill comes to %ld zorkmid%s.", - shkname(shkp), total, plur(total)); + pline("%s says that your bill comes to %ld %s.", + shkname(shkp), total, currency(total)); } else if (eshk->debit) - pline("%s reminds you that you owe %s %ld zorkmid%s.", + pline("%s reminds you that you owe %s %ld %s.", shkname(shkp), mhim(shkp), - eshk->debit, plur(eshk->debit)); + eshk->debit, currency(eshk->debit)); else if (eshk->credit) - pline("%s encourages you to use your %ld zorkmid%s of credit.", - shkname(shkp), eshk->credit, plur(eshk->credit)); + pline("%s encourages you to use your %ld %s of credit.", + shkname(shkp), eshk->credit, currency(eshk->credit)); else if (eshk->robbed) pline("%s complains about a recent robbery.", shkname(shkp)); #ifndef GOLDOBJ @@ -3823,19 +3823,19 @@ boolean altusage; arg1 = arg2 = ""; if (otmp->oclass == SPBOOK_CLASS) { - fmt = "%sYou owe%s %ld zorkmids."; + fmt = "%sYou owe%s %ld %s."; arg1 = rn2(2) ? "This is no free library, cad! " : ""; arg2 = ESHK(shkp)->debit > 0L ? " an additional" : ""; } else if (otmp->otyp == POT_OIL) { - fmt = "%s%sThat will cost you %ld zorkmids (Yendorian Fuel Tax)."; + fmt = "%s%sThat will cost you %ld %s (Yendorian Fuel Tax)."; } else { - fmt = "%s%sUsage fee, %ld zorkmids."; + fmt = "%s%sUsage fee, %ld %s."; if (!rn2(3)) arg1 = "Hey! "; if (!rn2(3)) arg2 = "Ahem. "; } if (shkp->mcanmove || !shkp->msleeping) - verbalize(fmt, arg1, arg2, tmp); + verbalize(fmt, arg1, arg2, tmp, currency(tmp)); ESHK(shkp)->debit += tmp; exercise(A_WIS, TRUE); /* you just got info */ } @@ -3864,8 +3864,8 @@ register long amount; eshkp = ESHK(shkp); if(eshkp->credit >= amount) { if(eshkp->credit > amount) - Your("credit is reduced by %ld zorkmid%s.", - amount, plur(amount)); + Your("credit is reduced by %ld %s.", + amount, currency(amount)); else Your("credit is erased."); eshkp->credit -= amount; } else { @@ -3873,10 +3873,10 @@ register long amount; if(eshkp->credit) Your("credit is erased."); if(eshkp->debit) - Your("debt increases by %ld zorkmid%s.", - delta, plur(delta)); - else You("owe %s %ld zorkmid%s.", - shkname(shkp), delta, plur(delta)); + Your("debt increases by %ld %s.", + delta, currency(delta)); + else You("owe %s %ld %s.", + shkname(shkp), delta, currency(delta)); eshkp->debit += delta; eshkp->loan += delta; eshkp->credit = 0L; diff --git a/src/trap.c b/src/trap.c index 7b7f2b41a..c31efe3c9 100644 --- a/src/trap.c +++ b/src/trap.c @@ -3298,11 +3298,11 @@ boolean disarm; exercise(A_STR, FALSE); if(costly && loss) { if(insider) - You("owe %ld zorkmids for objects destroyed.", - loss); + You("owe %ld %s for objects destroyed.", + loss, currency(loss)); else { - You("caused %ld zorkmids worth of damage!", - loss); + You("caused %ld %s worth of damage!", + loss, currency(loss)); make_angry_shk(shkp, ox, oy); } } diff --git a/src/vault.c b/src/vault.c index faa959d0d..3e8524d5a 100644 --- a/src/vault.c +++ b/src/vault.c @@ -763,13 +763,13 @@ paygd() #endif if (u.uinvault) { - Your("%ld zorkmid%s goes into the Magic Memory Vault.", + Your("%ld %s goes into the Magic Memory Vault.", #ifndef GOLDOBJ u.ugold, - plur(u.ugold)); + currency(u.ugold)); #else umoney, - plur(umoney)); + currency(umoney)); #endif gx = u.ux; gy = u.uy;