From bb8656c190c8c1623e6c16bd5d3c345cc15e34d7 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 18 Jan 2023 23:33:21 +0200 Subject: [PATCH] Move familiar level message into function --- src/do.c | 62 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/do.c b/src/do.c index 2461506a9..64c001e83 100644 --- a/src/do.c +++ b/src/do.c @@ -17,6 +17,7 @@ static boolean danger_uprops(void); static int wipeoff(void); static int menu_drop(int); static NHFILE *currentlevel_rewrite(void); +static void familiar_level_msg(void); static void final_level(void); /* static boolean badspot(coordxy,coordxy); */ @@ -1337,7 +1338,36 @@ u_collide_m(struct monst *mtmp) } } -DISABLE_WARNING_FORMAT_NONLITERAL +static void +familiar_level_msg(void) +{ + static const char *const fam_msgs[4] = { + "You have a sense of deja vu.", + "You feel like you've been here before.", + "This place %s familiar...", 0 /* no message */ + }; + static const char *const halu_fam_msgs[4] = { + "Whoa! Everything %s different.", + "You are surrounded by twisty little passages, all alike.", + "Gee, this %s like uncle Conan's place...", 0 /* no message */ + }; + const char *mesg; + char buf[BUFSZ]; + int which = rn2(4); + + if (Hallucination) + mesg = halu_fam_msgs[which]; + else + mesg = fam_msgs[which]; + if (mesg && strchr(mesg, '%')) { + DISABLE_WARNING_FORMAT_NONLITERAL + Sprintf(buf, mesg, !Blind ? "looks" : "seems"); + RESTORE_WARNING_FORMAT_NONLITERAL + mesg = buf; + } + if (mesg) + pline1(mesg); +} void goto_level( @@ -1720,32 +1750,8 @@ goto_level( if (Inhell && !Is_valley(&u.uz)) u.uevent.gehennom_entered = 1; - if (familiar) { - static const char *const fam_msgs[4] = { - "You have a sense of deja vu.", - "You feel like you've been here before.", - "This place %s familiar...", 0 /* no message */ - }; - static const char *const halu_fam_msgs[4] = { - "Whoa! Everything %s different.", - "You are surrounded by twisty little passages, all alike.", - "Gee, this %s like uncle Conan's place...", 0 /* no message */ - }; - const char *mesg; - char buf[BUFSZ]; - int which = rn2(4); - - if (Hallucination) - mesg = halu_fam_msgs[which]; - else - mesg = fam_msgs[which]; - if (mesg && strchr(mesg, '%')) { - Sprintf(buf, mesg, !Blind ? "looks" : "seems"); - mesg = buf; - } - if (mesg) - pline1(mesg); - } + if (familiar) + familiar_level_msg(); /* special location arrival messages/events */ if (In_endgame(&u.uz)) { @@ -1859,8 +1865,6 @@ goto_level( return; } -RESTORE_WARNING_FORMAT_NONLITERAL - /* give a message when entering a Gehennom level other than the Valley; also given if restoring a game in that situation */ void -- 2.50.0