From: nethack.allison Date: Sun, 11 Apr 2004 15:34:04 +0000 (+0000) Subject: lifting vs removing X-Git-Tag: MOVE2GIT~1477 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1194454b2f7a4fa3c0b49c2adcc25f7a3350f461;p=nethack lifting vs removing wrote: > You have much trouble removing u - a helmet. > You have much trouble lifting a plate mail. Continue? [ynq] (q) > You have much trouble removing R - a plate mail. > You have much trouble removing N - a leather cloak. > Why am I told that I have trouble "lifting" a plate mail? 1. Add strsubst() routine to hacklib to replace a word or phrase in a string in place. 2. Correct the inconsistency reported. --- diff --git a/doc/fixes34.4 b/doc/fixes34.4 index e90e8a94b..dd4edf02b 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -20,6 +20,9 @@ player polymorphed as a xorn could not pick up items in pits don't display "turns to flee" message for a mimicing mimic dipping acid in a fountain could cause an explosion but not destroy the potion if your blindfold glows and you're not otherwise blinded, you can see it +added strsubst() to hacklib +be consistent with use of "removing" rather than "lifting" for encumber + messages associated with taking things out of a bag of holding Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 81e6c958e..ff09d477b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -757,6 +757,7 @@ E char *FDECL(xcrypt, (const char *,char *)); E boolean FDECL(onlyspace, (const char *)); E char *FDECL(tabexpand, (char *)); E char *FDECL(visctrl, (CHAR_P)); +E char *FDECL(strsubst, (char *,const char *,const char *)); E const char *FDECL(ordin, (int)); E char *FDECL(sitoa, (int)); E int FDECL(sgn, (int)); diff --git a/src/hacklib.c b/src/hacklib.c index f94a9528c..b8a1c5295 100644 --- a/src/hacklib.c +++ b/src/hacklib.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)hacklib.c 3.4 2002/12/13 */ +/* SCCS Id: @(#)hacklib.c 3.4 2004/04/11 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Robert Patrick Rankin, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -24,6 +24,7 @@ NetHack, except that rounddiv may call panic(). boolean onlyspace (const char *) char * tabexpand (char *) char * visctrl (char) + char * strsubst (char *, const char *, const char *) const char * ordin (int) char * sitoa (int) int sgn (int) @@ -223,6 +224,27 @@ visctrl(c) /* make a displayable string from a character */ return ccc; } +/* substitute a word or phrase in a string (in place) */ +/* caller is responsible for ensuring that bp points to big enough buffer */ +char * +strsubst(bp, orig, replacement) + char *bp; + const char *orig, *replacement; +{ + char *found, buf[BUFSZ]; + + if (bp) { + found = strstr(bp, orig); + if (found) { + Strcpy(buf, found + strlen(orig)); + Strcpy(found, replacement); + Strcat(bp, buf); + } + } + return bp; +} + + const char * ordin(n) /* return the ordinal suffix of a number */ int n; /* note: should be non-negative */ diff --git a/src/pickup.c b/src/pickup.c index 23cb0272b..429d2f4da 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1175,6 +1175,7 @@ boolean telekinesis; (next_encumbr > HVY_ENCUMBER) ? overloadmsg : (next_encumbr > MOD_ENCUMBER) ? nearloadmsg : moderateloadmsg); + if (container) (void) strsubst(qbuf,"lifting","removing"); Sprintf(eos(qbuf), " %s. Continue?", safe_qbuf(qbuf, sizeof(" . Continue?"), doname(obj), an(simple_typename(obj->otyp)), "something"));