From bba487244706ecb7bcd0b02494d2f70162658cc9 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Fri, 9 May 2003 01:19:29 +0000 Subject: [PATCH] yet more qbuf --- include/extern.h | 2 ++ src/objnam.c | 26 ++++++++++++++++++++++++++ src/pickup.c | 16 +++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/extern.h b/include/extern.h index 0b1d7cf02..4c47a70b9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1363,6 +1363,8 @@ E char *FDECL(vtense, (const char *,const char *)); E char *FDECL(Doname2, (struct obj *)); E char *FDECL(yname, (struct obj *)); E char *FDECL(Yname2, (struct obj *)); +E char *FDECL(ysimple_name, (struct obj *)); +E char *FDECL(Ysimple_name2, (struct obj *)); E char *FDECL(makeplural, (const char *)); E char *FDECL(makesingular, (const char *)); E struct obj *FDECL(readobjnam, (char *,struct obj *,BOOLEAN_P)); diff --git a/src/objnam.c b/src/objnam.c index 30052f91a..bd9e0a6fc 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1171,6 +1171,32 @@ struct obj *obj; return s; } +/* returns "your simple_typename(obj->otyp)" + * or "Foobar's simple_typename(obj->otyp)" + * or "the simple_typename(obj-otyp)" + */ +char * +ysimple_name(obj) +struct obj *obj; +{ + char *outbuf = nextobuf(); + char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */ + int space_left = BUFSZ - strlen(s) - sizeof " "; + + return strncat(strcat(s, " "), simple_typename(obj->otyp), space_left); +} + +/* capitalized variant of ysimple_name() */ +char * +Ysimple_name2(obj) +struct obj *obj; +{ + char *s = ysimple_name(obj); + + *s = highc(*s); + return s; +} + static const char *wrp[] = { "wand", "ring", "potion", "scroll", "gem", "amulet", "spellbook", "spell book", diff --git a/src/pickup.c b/src/pickup.c index 848706b7b..e64c51d55 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)pickup.c 3.4 2003/04/26 */ +/* SCCS Id: @(#)pickup.c 3.4 2003/05/08 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -538,7 +538,9 @@ menu_pickup: if (!all_of_a_type) { char qbuf[BUFSZ]; - Sprintf(qbuf, "Pick up %s?", doname(obj)); + Sprintf(qbuf, "Pick up %s?", + safe_qbuf(qbuf, sizeof("Pick up ?"), doname(obj), + an(simple_typename(obj->otyp)), something)); switch ((obj->quan < 2L) ? ynaq(qbuf) : ynNaq(qbuf)) { case 'q': goto end_query; /* out 2 levels */ case 'n': continue; @@ -1476,7 +1478,10 @@ lootcont: nobj = cobj->nexthere; if (Is_container(cobj)) { - Sprintf(qbuf, "There is %s here, loot it?", doname(cobj)); + Sprintf(qbuf, "There is %s here, loot it?", + safe_qbuf(qbuf, sizeof("There is here, loot it?"), + doname(cobj), an(simple_typename(cobj->otyp)), + "a container")); c = ynq(qbuf); if (c == 'q') return (timepassed); if (c == 'n') continue; @@ -2056,8 +2061,9 @@ register int held; if (!cnt) Sprintf(emptymsg, "%s is empty.", Yname2(obj)); if (cnt || flags.menu_style == MENU_FULL) { - Sprintf(qbuf, "Do you want to take %s out of %s?", - something, yname(obj)); + Strcpy(qbuf, "Do you want to take something out of "); + Sprintf(eos(qbuf), "%s?", + safe_qbuf(qbuf, 1, yname(obj), ysimple_name(obj), "it")); if (flags.menu_style != MENU_TRADITIONAL) { if (flags.menu_style == MENU_FULL) { int t; -- 2.40.0