"your" artifacts

This patch introduces a change to yname() and Yname2() that avoids the
possessive "your" for the hero's normal, fully identified artifacts.
Quest artifacts still get the possessive, as do all other objects and all
objects not in the hero's possession.  shk_your()/Shk_Your() are used in
many places with a specific, generalized name for the object, so I didn't
introduce the artifact behavior there, although I did change them to append
a space, which simplified some other code.  Through added use of yname(),
there may be some places that used to just say "corpse" that will now be more
descriptive via yname()'s use of cxname().  I'm sure <Someone> will point
out any such places that are too onerous, although nothing obviously is.

I took the opportunity to inspect many uses of "your" and even Your().  Two
new functions are also introduced, yobjnam() and Yobjnam2(), which work
like aobjnam() and yname() combined, because I found that many uses of
aobjnam() were preceeded by "your" and I couldn't generally provide the
desired behavior for artifacts (or future artifacts) without a combined
function.  In some cases, this change allowed better sharing of code.

rust_dmg() still takes a string as input which is sometimes initialized
from xname() and often prepends "your" to it.  Currently, this isn't a
problem since there currently are no normal, armor artifacts.  If/when any
are introduced, rust_dmg() will need to be addressed.

The patch is for the trunk only.  A lot of research was required and I
didn't feel the upside was there for repeating it in the 3.4.3 branch.
This commit is contained in:
cohrs
2003-09-18 02:52:40 +00:00
parent 9402d6dc54
commit 5e443536d8
28 changed files with 274 additions and 285 deletions

View File

@@ -1011,6 +1011,39 @@ register const char *verb;
return(bp);
}
/* combine yname and aobjnam eg "your count cxname(otmp)" */
char *
yobjnam(obj,verb)
struct obj *obj;
const char *verb;
{
char *s = aobjnam(obj, verb);
/* leave off "your" for most of your artifacts, but prepend
* "your" for unique objects and "foo of bar" quest artifacts */
if (!carried(obj) || !obj_is_pname(obj) ||
obj->oartifact >= ART_ORB_OF_DETECTION) {
char *outbuf = shk_your(nextobuf(), obj);
int space_left = BUFSZ - 1 - strlen(outbuf);
s = strncat(outbuf, s, space_left);
}
return s;
}
/* combine Yname2 and aobjnam eg "Your count cxname(otmp)" */
char *
Yobjnam2(obj,verb)
struct obj *obj;
const char *verb;
{
register char *s = yobjnam(obj,verb);
*s = highc(*s);
return(s);
}
/* like aobjnam, but prepend "The", not count, and use xname */
char *
Tobjnam(otmp, verb)
@@ -1166,16 +1199,24 @@ register struct obj *obj;
return(s);
}
/* returns "your xname(obj)" or "Foobar's xname(obj)" or "the xname(obj)" */
/* returns "[your ]xname(obj)" or "Foobar's xname(obj)" or "the xname(obj)" */
char *
yname(obj)
struct obj *obj;
{
char *outbuf = nextobuf();
char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */
int space_left = BUFSZ - strlen(s) - sizeof " ";
char *s = cxname(obj);
return strncat(strcat(s, " "), cxname(obj), space_left);
/* leave off "your" for most of your artifacts, but prepend
* "your" for unique objects and "foo of bar" quest artifacts */
if (!carried(obj) || !obj_is_pname(obj) ||
obj->oartifact >= ART_ORB_OF_DETECTION) {
char *outbuf = shk_your(nextobuf(), obj);
int space_left = BUFSZ - 1 - strlen(outbuf);
s = strncat(outbuf, s, space_left);
}
return s;
}
/* capitalized variant of yname() */
@@ -1199,9 +1240,9 @@ struct obj *obj;
{
char *outbuf = nextobuf();
char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */
int space_left = BUFSZ - strlen(s) - sizeof " ";
int space_left = BUFSZ - 1 - strlen(s);
return strncat(strcat(s, " "), simple_typename(obj->otyp), space_left);
return strncat(s, simple_typename(obj->otyp), space_left);
}
/* capitalized variant of ysimple_name() */