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
+1
View File
@@ -1989,6 +1989,7 @@ extern void dumplogfreemessages(void);
#endif #endif
extern void pline(const char *, ...) PRINTF_F(1, 2); extern void pline(const char *, ...) PRINTF_F(1, 2);
extern void custompline(unsigned, const char *, ...) PRINTF_F(2, 3); 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 Norep(const char *, ...) PRINTF_F(1, 2);
extern void free_youbuf(void); extern void free_youbuf(void);
extern void You(const char *, ...) PRINTF_F(1, 2); extern void You(const char *, ...) PRINTF_F(1, 2);
+1 -1
View File
@@ -3281,7 +3281,7 @@ losehp(int n, const char *knam, boolean k_format)
g.killer.format = k_format; g.killer.format = k_format;
if (g.killer.name != knam) /* the thing that killed you */ if (g.killer.name != knam) /* the thing that killed you */
Strcpy(g.killer.name, knam ? knam : ""); Strcpy(g.killer.name, knam ? knam : "");
custompline(URGENT_MESSAGE, "You die..."); urgent_pline("You die...");
done(DIED); done(DIED);
} else if (n > 0 && u.uhp * 10 < u.uhpmax) { } else if (n > 0 && u.uhp * 10 < u.uhpmax) {
maybe_wail(); maybe_wail();
+7 -8
View File
@@ -1838,12 +1838,11 @@ doseduce(struct monst *mon)
} }
naked = (!uarmc && !uarmf && !uarmg && !uarms && !uarmh && !uarmu); naked = (!uarmc && !uarmf && !uarmg && !uarms && !uarmh && !uarmu);
custompline(URGENT_MESSAGE, urgent_pline("%s %s%s.", Who,
"%s %s%s.", Who, Deaf ? "seems to murmur into your ear"
Deaf ? "seems to murmur into your ear" : naked ? "murmurs sweet nothings into your ear"
: naked ? "murmurs sweet nothings into your ear" : "murmurs in your ear",
: "murmurs in your ear", naked ? "" : ", while helping you undress");
naked ? "" : ", while helping you undress");
mayberem(mon, Who, uarmc, cloak_simple_name(uarmc)); mayberem(mon, Who, uarmc, cloak_simple_name(uarmc));
if (!uarmc) if (!uarmc)
mayberem(mon, Who, uarm, suit_simple_name(uarm)); mayberem(mon, Who, uarm, suit_simple_name(uarm));
@@ -1894,9 +1893,9 @@ doseduce(struct monst *mon)
adjalign(1); adjalign(1);
/* by this point you have discovered mon's identity, blind or not... */ /* 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...", "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 /* 3.6.1: a combined total for charisma plus intelligence of 35-1
used to guarantee successful outcome; now total maxes out at 32 used to guarantee successful outcome; now total maxes out at 32
as far as deciding what will happen; chance for bad outcome when as far as deciding what will happen; chance for bad outcome when
+2 -2
View File
@@ -2392,9 +2392,9 @@ in_container(struct obj *obj)
} }
} else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) { } else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) {
/* explicitly mention what item is triggering the explosion */ /* 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!", "As you put %s inside, you are blasted by a magical explosion!",
doname(obj)); doname(obj));
/* did not actually insert obj yet */ /* did not actually insert obj yet */
if (was_unpaid) if (was_unpaid)
addtobill(obj, FALSE, FALSE, TRUE); addtobill(obj, FALSE, FALSE, TRUE);
+17 -1
View File
@@ -207,7 +207,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL
message history (tty interface uses pline() to issue prompts and message history (tty interface uses pline() to issue prompts and
they shouldn't be blockable via MSGTYPE=hide) */ they shouldn't be blockable via MSGTYPE=hide) */
void void
custompline(unsigned pflags, const char * line, ...) custompline(unsigned pflags, const char *line, ...)
{ {
va_list the_args; va_list the_args;
@@ -218,6 +218,22 @@ custompline(unsigned pflags, const char * line, ...)
va_end(the_args); 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 void
Norep(const char *line, ...) Norep(const char *line, ...)
{ {
+2 -2
View File
@@ -2467,7 +2467,7 @@ do_class_genocide(void)
u.mh = -1; u.mh = -1;
if (Unchanging) { if (Unchanging) {
if (!feel_dead++) if (!feel_dead++)
custompline(URGENT_MESSAGE, "You die."); urgent_pline("You die.");
/* finish genociding this class of /* finish genociding this class of
monsters before ultimately dying */ monsters before ultimately dying */
gameover = TRUE; gameover = TRUE;
@@ -2484,7 +2484,7 @@ do_class_genocide(void)
You_feel("%s inside.", udeadinside()); You_feel("%s inside.", udeadinside());
} else { } else {
if (!feel_dead++) if (!feel_dead++)
custompline(URGENT_MESSAGE, "You die."); urgent_pline("You die.");
gameover = TRUE; gameover = TRUE;
} }
} }
+17 -20
View File
@@ -428,23 +428,21 @@ steal(struct monst* mtmp, char* objnambuf)
unmul((char *) 0); unmul((char *) 0);
slowly = (armordelay >= 1 || g.multi < 0); slowly = (armordelay >= 1 || g.multi < 0);
if (flags.female) if (flags.female)
custompline(URGENT_MESSAGE, urgent_pline("%s charms you. You gladly %s your %s.",
"%s charms you. You gladly %s your %s.", !seen ? "She" : Monnam(mtmp),
!seen ? "She" : Monnam(mtmp), curssv ? "let her take"
curssv ? "let her take" : !slowly ? "hand over"
: !slowly ? "hand over" : was_doffing ? "continue removing"
: was_doffing ? "continue removing" : "start removing",
: "start removing", equipname(otmp));
equipname(otmp));
else else
custompline(URGENT_MESSAGE, urgent_pline("%s seduces you and %s off your %s.",
"%s seduces you and %s off your %s.", !seen ? "She" : Adjmonnam(mtmp, "beautiful"),
!seen ? "She" : Adjmonnam(mtmp, "beautiful"), curssv ? "helps you to take"
curssv ? "helps you to take" : !slowly ? "you take"
: !slowly ? "you take" : was_doffing ? "you continue taking"
: was_doffing ? "you continue taking" : "you start taking",
: "you start taking", equipname(otmp));
equipname(otmp));
named++; named++;
/* the following is to set multi for later on */ /* the following is to set multi for later on */
nomul(-armordelay); nomul(-armordelay);
@@ -479,10 +477,9 @@ steal(struct monst* mtmp, char* objnambuf)
subfrombill(otmp, shop_keeper(*u.ushops)); subfrombill(otmp, shop_keeper(*u.ushops));
freeinv(otmp); freeinv(otmp);
/* if attached ball was taken, uball and uchain are now Null */ /* if attached ball was taken, uball and uchain are now Null */
custompline(URGENT_MESSAGE, urgent_pline("%s%s stole %s.", named ? "She" : Monnam(mtmp),
"%s%s stole %s.", named ? "She" : Monnam(mtmp), (was_punished && !Punished) ? " removed your chain and" : "",
(was_punished && !Punished) ? " removed your chain and" : "", doname(otmp));
doname(otmp));
could_petrify = (otmp->otyp == CORPSE could_petrify = (otmp->otyp == CORPSE
&& touch_petrifies(&mons[otmp->corpsenm])); && touch_petrifies(&mons[otmp->corpsenm]));
(void) mpickobj(mtmp, otmp); /* may free otmp */ (void) mpickobj(mtmp, otmp); /* may free otmp */
+4 -2
View File
@@ -2634,8 +2634,10 @@ zapyourself(struct obj *obj, boolean ordinary)
learn_it = TRUE; learn_it = TRUE;
Sprintf(g.killer.name, "shot %sself with a death ray", uhim()); Sprintf(g.killer.name, "shot %sself with a death ray", uhim());
g.killer.format = NO_KILLER_PREFIX; g.killer.format = NO_KILLER_PREFIX;
You("irradiate yourself with pure energy!"); /* probably don't need these to be urgent; player just gave input
custompline(URGENT_MESSAGE, "You die."); 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 */ /* They might survive with an amulet of life saving */
done(DIED); done(DIED);
break; break;