steed name handling

I was about to add a message referring to your steed and discovered
that the name handling for that is somewhat messy.  Simplify it by using
the pet name handling routine.
This commit is contained in:
nethack.rankin
2002-09-20 07:01:19 +00:00
parent bebec915d8
commit dbaba6bcc2
2 changed files with 43 additions and 57 deletions
+14 -5
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)do_name.c 3.4 2002/06/24 */ /* SCCS Id: @(#)do_name.c 3.4 2002/09/19 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -712,12 +712,12 @@ boolean called;
name_at_start = (boolean)type_is_pname(mdat); name_at_start = (boolean)type_is_pname(mdat);
} }
if (name_at_start && !has_adjectives) { if (name_at_start && (article == ARTICLE_YOUR || !has_adjectives)) {
if (mdat == &mons[PM_WIZARD_OF_YENDOR]) if (mdat == &mons[PM_WIZARD_OF_YENDOR])
article = ARTICLE_THE; article = ARTICLE_THE;
else else
article = ARTICLE_NONE; article = ARTICLE_NONE;
} else if (mons[monsndx(mdat)].geno & G_UNIQ && } else if ((mons[monsndx(mdat)].geno & G_UNIQ) &&
article == ARTICLE_A) { article == ARTICLE_A) {
article = ARTICLE_THE; article = ARTICLE_THE;
} }
@@ -813,8 +813,17 @@ char *
y_monnam(mtmp) y_monnam(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
return x_monnam(mtmp, ARTICLE_YOUR, (char *)0, int prefix, suppression_flag;
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, FALSE);
prefix = mtmp->mtame ? ARTICLE_YOUR : ARTICLE_THE;
suppression_flag = (mtmp->mnamelth
#ifdef STEED
/* "saddled" is redundant when mounted */
|| mtmp == u.usteed
#endif
) ? SUPPRESS_SADDLE : 0;
return x_monnam(mtmp, prefix, (char *)0, suppression_flag, FALSE);
} }
#endif /* OVL0 */ #endif /* OVL0 */
+29 -52
View File
@@ -124,7 +124,7 @@ moverock()
if (flags.verbose) if (flags.verbose)
pline("Perhaps that's why %s cannot move it.", pline("Perhaps that's why %s cannot move it.",
#ifdef STEED #ifdef STEED
u.usteed ? mon_nam(u.usteed) : u.usteed ? y_monnam(u.usteed) :
#endif #endif
"you"); "you");
goto cannot_push; goto cannot_push;
@@ -181,7 +181,7 @@ moverock()
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
pline("%s pushes %s and suddenly it disappears!", pline("%s pushes %s and suddenly it disappears!",
Monnam(u.usteed), the(xname(otmp))); upstart(y_monnam(u.usteed)), the(xname(otmp)));
else else
#endif #endif
You("push %s and suddenly it disappears!", You("push %s and suddenly it disappears!",
@@ -222,10 +222,9 @@ moverock()
long lastmovetime; long lastmovetime;
lastmovetime = 0; lastmovetime = 0;
#else #else
/* note: reset to zero after save/restore cycle */
static NEARDATA long lastmovetime; static NEARDATA long lastmovetime;
#endif #endif
/* note: this var contains garbage initially and
after a restore */
#ifdef STEED #ifdef STEED
if (!u.usteed) { if (!u.usteed) {
#endif #endif
@@ -236,7 +235,8 @@ moverock()
exercise(A_STR, TRUE); exercise(A_STR, TRUE);
#ifdef STEED #ifdef STEED
} else } else
pline("%s moves %s.", Monnam(u.usteed), the(xname(otmp))); pline("%s moves %s.",
upstart(y_monnam(u.usteed)), the(xname(otmp)));
#endif #endif
lastmovetime = moves; lastmovetime = moves;
} }
@@ -256,7 +256,7 @@ moverock()
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
pline("%s tries to move %s, but cannot.", pline("%s tries to move %s, but cannot.",
Monnam(u.usteed), the(xname(otmp))); upstart(y_monnam(u.usteed)), the(xname(otmp)));
else else
#endif #endif
You("try to move %s, but in vain.", the(xname(otmp))); You("try to move %s, but in vain.", the(xname(otmp)));
@@ -268,7 +268,7 @@ moverock()
You("aren't skilled enough to %s %s from %s.", You("aren't skilled enough to %s %s from %s.",
(flags.pickup && !In_sokoban(&u.uz)) (flags.pickup && !In_sokoban(&u.uz))
? "pick up" : "push aside", ? "pick up" : "push aside",
the(xname(otmp)), mon_nam(u.usteed)); the(xname(otmp)), y_monnam(u.usteed));
} else } else
#endif #endif
{ {
@@ -598,9 +598,7 @@ int mode;
#ifdef STEED #ifdef STEED
if (u.usteed) { if (u.usteed) {
You_cant("lead %s through that closed door.", You_cant("lead %s through that closed door.",
x_monnam(u.usteed, y_monnam(u.usteed));
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE));
} else } else
#endif #endif
{ {
@@ -1088,10 +1086,7 @@ domove()
/* not attacking an animal, so we try to move */ /* not attacking an animal, so we try to move */
#ifdef STEED #ifdef STEED
if (u.usteed && !u.usteed->mcanmove && (u.dx || u.dy)) { if (u.usteed && !u.usteed->mcanmove && (u.dx || u.dy)) {
pline("%s won't move!", pline("%s won't move!", upstart(y_monnam(u.usteed)));
upstart(x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)));
nomul(0); nomul(0);
return; return;
} else } else
@@ -1123,10 +1118,8 @@ domove()
} else if (flags.verbose) { } else if (flags.verbose) {
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
Norep("%s is still in a pit.", Norep("%s is still in a pit.",
upstart(x_monnam(u.usteed, upstart(y_monnam(u.usteed)));
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)));
else else
#endif #endif
Norep( (Hallucination && !rn2(5)) ? Norep( (Hallucination && !rn2(5)) ?
@@ -1138,11 +1131,8 @@ domove()
char *predicament = "stuck in the lava"; char *predicament = "stuck in the lava";
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
Norep("%s is %s.", Norep("%s is %s.", upstart(y_monnam(u.usteed)),
upstart(x_monnam(u.usteed, predicament);
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)),
predicament);
else else
#endif #endif
Norep("You are %s.", predicament); Norep("You are %s.", predicament);
@@ -1153,9 +1143,7 @@ domove()
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
You("lead %s to the edge of the lava.", You("lead %s to the edge of the lava.",
x_monnam(u.usteed, y_monnam(u.usteed));
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE));
else else
#endif #endif
You("pull yourself to the edge of the lava."); You("pull yourself to the edge of the lava.");
@@ -1174,11 +1162,8 @@ domove()
char *predicament = "stuck to the web"; char *predicament = "stuck to the web";
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
Norep("%s is %s.", Norep("%s is %s.", upstart(y_monnam(u.usteed)),
upstart(x_monnam(u.usteed, predicament);
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)),
predicament);
else else
#endif #endif
Norep("You are %s.", predicament); Norep("You are %s.", predicament);
@@ -1186,10 +1171,8 @@ domove()
} else { } else {
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
pline("%s breaks out of the web.", pline("%s breaks out of the web.",
upstart(x_monnam(u.usteed, upstart(y_monnam(u.usteed)));
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)));
else else
#endif #endif
You("disentangle yourself."); You("disentangle yourself.");
@@ -1200,22 +1183,19 @@ domove()
char *predicament = "stuck in the"; char *predicament = "stuck in the";
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
Norep("%s is %s %s.", Norep("%s is %s %s.",
upstart(x_monnam(u.usteed, upstart(y_monnam(u.usteed)),
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE, predicament, surface(u.ux, u.uy));
(char *)0, SUPPRESS_SADDLE, FALSE)),
predicament, surface(u.ux, u.uy));
else else
#endif #endif
Norep("You are %s %s.", predicament, surface(u.ux, u.uy)); Norep("You are %s %s.", predicament,
surface(u.ux, u.uy));
} }
} else { } else {
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
pline("%s finally wiggles free.", pline("%s finally wiggles free.",
upstart(x_monnam(u.usteed, upstart(y_monnam(u.usteed)));
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)));
else else
#endif #endif
You("finally wiggle free."); You("finally wiggle free.");
@@ -1225,11 +1205,8 @@ domove()
char *predicament = "caught in a bear trap"; char *predicament = "caught in a bear trap";
#ifdef STEED #ifdef STEED
if (u.usteed) if (u.usteed)
Norep("%s is %s.", Norep("%s is %s.", upstart(y_monnam(u.usteed)),
upstart(x_monnam(u.usteed, predicament);
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)),
predicament);
else else
#endif #endif
Norep("You are %s.", predicament); Norep("You are %s.", predicament);
@@ -1850,8 +1827,8 @@ dopickup()
if (!can_reach_floor()) { if (!can_reach_floor()) {
#ifdef STEED #ifdef STEED
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
You("aren't skilled enough to reach from %s.", You("aren't skilled enough to reach from %s.",
mon_nam(u.usteed)); y_monnam(u.usteed));
else else
#endif #endif
You("cannot reach the %s.", surface(u.ux,u.uy)); You("cannot reach the %s.", surface(u.ux,u.uy));