From 50df01c3e19523bbe1093bf83daf57afc95d17d4 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 23 Jan 2024 17:24:14 +0200 Subject: [PATCH] Split out empty hands menu option text --- src/invent.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/invent.c b/src/invent.c index 0b985fb06..0270c6738 100644 --- a/src/invent.c +++ b/src/invent.c @@ -26,6 +26,7 @@ static boolean only_here(struct obj *); static void compactify(char *); static boolean taking_off(const char *); static void mime_action(const char *); +static char *getobj_hands_txt(const char *); static int ckvalidcat(struct obj *); static int ckunpaid(struct obj *); static char *safeq_xprname(struct obj *); @@ -1669,6 +1670,29 @@ any_obj_ok(struct obj *obj) return GETOBJ_EXCLUDE; } +/* return string describing you hands based on action. */ +static char * +getobj_hands_txt(const char *action) +{ + static char qbuf[QBUFSZ]; + + if (!strcmp(action, "grease")) { + Sprintf(qbuf, "your %s", fingers_or_gloves(FALSE)); + } else if (!strcmp(action, "write with")) { + Sprintf(qbuf, "your %s", body_part(FINGERTIP)); + } else if (!strcmp(action, "wield")) { + Sprintf(qbuf, "your %s %s%s", uarmg ? "gloved" : "bare", + makeplural(body_part(HAND)), + !uwep ? " (wielded)" : ""); + } else if (!strcmp(action, "ready")) { + Sprintf(qbuf, "empty quiver%s", + !uquiver ? " (nothing readied)" : ""); + } else { + Sprintf(qbuf, "your %s", makeplural(body_part(HAND))); + } + return qbuf; +} + /* * getobj returns: * struct obj *xxx: object to do something with. @@ -1897,6 +1921,7 @@ getobj( char *allowed_choices = (ilet == '?') ? lets : (char *) 0; long ctmp = 0; char menuquery[QBUFSZ]; + char *handsbuf = (char *) 0; if (ilet == '?' && !*lets && *altlets) allowed_choices = altlets; @@ -1904,23 +1929,10 @@ getobj( menuquery[0] = qbuf[0] = '\0'; if (iflags.force_invmenu) Sprintf(menuquery, "What do you want to %s?", word); - if (!allowed_choices || *allowed_choices == '-' || *buf == '-') { - if (!strcmp(word, "grease")) { - Sprintf(qbuf, "your %s", fingers_or_gloves(FALSE)); - } else if (!strcmp(word, "write with")) { - Sprintf(qbuf, "your %s", body_part(FINGERTIP)); - } else if (!strcmp(word, "wield")) { - Sprintf(qbuf, "your %s %s%s", uarmg ? "gloved" : "bare", - makeplural(body_part(HAND)), - !uwep ? " (wielded)" : ""); - } else if (!strcmp(word, "ready")) { - Sprintf(qbuf, "empty quiver%s", - !uquiver ? " (nothing readied)" : ""); - } else { - Sprintf(qbuf, "your %s", makeplural(body_part(HAND))); - } - } - ilet = display_pickinv(allowed_choices, *qbuf ? qbuf : (char *) 0, + if (!allowed_choices || *allowed_choices == HANDS_SYM + || *buf == HANDS_SYM) + handsbuf = getobj_hands_txt(word); + ilet = display_pickinv(allowed_choices, handsbuf, menuquery, allownone, TRUE, allowcnt ? &ctmp : (long *) 0); if (!ilet) {