lifting vs removing
<Someone> 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.
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user