simplify issuing urgent messages

Change
 custompline(URGENT_MESSAGE, mesg, ...);
calls to new
 urgent_pline(mesg, ...);
This commit is contained in:
PatR
2021-12-20 08:30:48 -08:00
parent aaed434d46
commit 2278434228
8 changed files with 51 additions and 36 deletions

View File

@@ -1989,6 +1989,7 @@ extern void dumplogfreemessages(void);
#endif
extern void pline(const char *, ...) PRINTF_F(1, 2);
extern void custompline(unsigned, const char *, ...) PRINTF_F(2, 3);
extern void urgent_pline(const char *, ...) PRINTF_F(1, 2);
extern void Norep(const char *, ...) PRINTF_F(1, 2);
extern void free_youbuf(void);
extern void You(const char *, ...) PRINTF_F(1, 2);

View File

@@ -3281,7 +3281,7 @@ losehp(int n, const char *knam, boolean k_format)
g.killer.format = k_format;
if (g.killer.name != knam) /* the thing that killed you */
Strcpy(g.killer.name, knam ? knam : "");
custompline(URGENT_MESSAGE, "You die...");
urgent_pline("You die...");
done(DIED);
} else if (n > 0 && u.uhp * 10 < u.uhpmax) {
maybe_wail();

View File

@@ -1838,12 +1838,11 @@ doseduce(struct monst *mon)
}
naked = (!uarmc && !uarmf && !uarmg && !uarms && !uarmh && !uarmu);
custompline(URGENT_MESSAGE,
"%s %s%s.", Who,
Deaf ? "seems to murmur into your ear"
: naked ? "murmurs sweet nothings into your ear"
: "murmurs in your ear",
naked ? "" : ", while helping you undress");
urgent_pline("%s %s%s.", Who,
Deaf ? "seems to murmur into your ear"
: naked ? "murmurs sweet nothings into your ear"
: "murmurs in your ear",
naked ? "" : ", while helping you undress");
mayberem(mon, Who, uarmc, cloak_simple_name(uarmc));
if (!uarmc)
mayberem(mon, Who, uarm, suit_simple_name(uarm));
@@ -1894,9 +1893,9 @@ doseduce(struct monst *mon)
adjalign(1);
/* by this point you have discovered mon's identity, blind or not... */
custompline(URGENT_MESSAGE,
urgent_pline(
"Time stands still while you and %s lie in each other's arms...",
noit_mon_nam(mon));
noit_mon_nam(mon));
/* 3.6.1: a combined total for charisma plus intelligence of 35-1
used to guarantee successful outcome; now total maxes out at 32
as far as deciding what will happen; chance for bad outcome when

View File

@@ -2392,9 +2392,9 @@ in_container(struct obj *obj)
}
} else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) {
/* explicitly mention what item is triggering the explosion */
custompline(URGENT_MESSAGE,
urgent_pline(
"As you put %s inside, you are blasted by a magical explosion!",
doname(obj));
doname(obj));
/* did not actually insert obj yet */
if (was_unpaid)
addtobill(obj, FALSE, FALSE, TRUE);

View File

@@ -207,7 +207,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL
message history (tty interface uses pline() to issue prompts and
they shouldn't be blockable via MSGTYPE=hide) */
void
custompline(unsigned pflags, const char * line, ...)
custompline(unsigned pflags, const char *line, ...)
{
va_list the_args;
@@ -218,6 +218,22 @@ custompline(unsigned pflags, const char * line, ...)
va_end(the_args);
}
/* if player has dismissed --More-- with ESC to suppress further messages
until next input request, tell the interface that it should override that
and re-enable them; equivalent to custompline(URGENT_MESSAGE, line, ...)
but slightly simpler to use */
void
urgent_pline(const char *line, ...)
{
va_list the_args;
va_start(the_args, line);
g.pline_flags = URGENT_MESSAGE;
vpline(line, the_args);
g.pline_flags = 0;
va_end(the_args);
}
void
Norep(const char *line, ...)
{

View File

@@ -2467,7 +2467,7 @@ do_class_genocide(void)
u.mh = -1;
if (Unchanging) {
if (!feel_dead++)
custompline(URGENT_MESSAGE, "You die.");
urgent_pline("You die.");
/* finish genociding this class of
monsters before ultimately dying */
gameover = TRUE;
@@ -2484,7 +2484,7 @@ do_class_genocide(void)
You_feel("%s inside.", udeadinside());
} else {
if (!feel_dead++)
custompline(URGENT_MESSAGE, "You die.");
urgent_pline("You die.");
gameover = TRUE;
}
}

View File

@@ -428,23 +428,21 @@ steal(struct monst* mtmp, char* objnambuf)
unmul((char *) 0);
slowly = (armordelay >= 1 || g.multi < 0);
if (flags.female)
custompline(URGENT_MESSAGE,
"%s charms you. You gladly %s your %s.",
!seen ? "She" : Monnam(mtmp),
curssv ? "let her take"
: !slowly ? "hand over"
: was_doffing ? "continue removing"
: "start removing",
equipname(otmp));
urgent_pline("%s charms you. You gladly %s your %s.",
!seen ? "She" : Monnam(mtmp),
curssv ? "let her take"
: !slowly ? "hand over"
: was_doffing ? "continue removing"
: "start removing",
equipname(otmp));
else
custompline(URGENT_MESSAGE,
"%s seduces you and %s off your %s.",
!seen ? "She" : Adjmonnam(mtmp, "beautiful"),
curssv ? "helps you to take"
: !slowly ? "you take"
: was_doffing ? "you continue taking"
: "you start taking",
equipname(otmp));
urgent_pline("%s seduces you and %s off your %s.",
!seen ? "She" : Adjmonnam(mtmp, "beautiful"),
curssv ? "helps you to take"
: !slowly ? "you take"
: was_doffing ? "you continue taking"
: "you start taking",
equipname(otmp));
named++;
/* the following is to set multi for later on */
nomul(-armordelay);
@@ -479,10 +477,9 @@ steal(struct monst* mtmp, char* objnambuf)
subfrombill(otmp, shop_keeper(*u.ushops));
freeinv(otmp);
/* if attached ball was taken, uball and uchain are now Null */
custompline(URGENT_MESSAGE,
"%s%s stole %s.", named ? "She" : Monnam(mtmp),
(was_punished && !Punished) ? " removed your chain and" : "",
doname(otmp));
urgent_pline("%s%s stole %s.", named ? "She" : Monnam(mtmp),
(was_punished && !Punished) ? " removed your chain and" : "",
doname(otmp));
could_petrify = (otmp->otyp == CORPSE
&& touch_petrifies(&mons[otmp->corpsenm]));
(void) mpickobj(mtmp, otmp); /* may free otmp */

View File

@@ -2634,8 +2634,10 @@ zapyourself(struct obj *obj, boolean ordinary)
learn_it = TRUE;
Sprintf(g.killer.name, "shot %sself with a death ray", uhim());
g.killer.format = NO_KILLER_PREFIX;
You("irradiate yourself with pure energy!");
custompline(URGENT_MESSAGE, "You die.");
/* probably don't need these to be urgent; player just gave input
without subsequent opportunity to dismiss --More-- with ESC */
urgent_pline("You irradiate yourself with pure energy!");
urgent_pline("You die.");
/* They might survive with an amulet of life saving */
done(DIED);
break;