From: PatR Date: Mon, 27 Apr 2020 17:49:34 +0000 (-0700) Subject: Sting vs level teleport revisted X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c17301a75c12681631fb45b404048d2be3716162;p=nethack Sting vs level teleport revisted This reverses all of c67f1dd71044b7d0ec98a6e4645b1c20915467f0 except for the fixes37.0 entry and does a better job in a cleaner fashion. If Sting is going to start glowing and "you materialize on a different level" is pending, give the materialize message before the glowing message. Otherwise handle both stop-glowing and/or you-materialize in the normal fashion. --- diff --git a/include/extern.h b/include/extern.h index a7d415102..a00a180ed 100644 --- a/include/extern.h +++ b/include/extern.h @@ -416,6 +416,7 @@ E void NDECL(save_currentstate); #endif E void FDECL(u_collide_m, (struct monst *)); E void FDECL(goto_level, (d_level *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P)); +E void NDECL(maybe_lvltport_feedback); E void FDECL(schedule_goto, (d_level *, BOOLEAN_P, BOOLEAN_P, int, const char *, const char *)); E void NDECL(deferred_goto); diff --git a/include/flag.h b/include/flag.h index 92def843e..5ba296d46 100644 --- a/include/flag.h +++ b/include/flag.h @@ -219,7 +219,6 @@ struct instance_flags { int failing_untrap; /* move_into_trap() -> spoteffects() -> dotrap() */ int in_lava_effects; /* hack for Boots_off() */ int last_msg; /* indicator of last message player saw */ - int no_glow; /* controls see_monster()'s Sting_effects() */ int override_ID; /* true to force full identification of objects */ int parse_config_file_src; /* hack for parse_config_line() */ int purge_monsters; /* # of dead monsters still on fmon list */ diff --git a/src/artifact.c b/src/artifact.c index 7771a6102..a0b9c2c18 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1907,6 +1907,11 @@ int orc_count; /* new count (warn_obj_cnt is old count); -1 is a flag value */ pline("%s is %s.", bare_artifactname(uwep), glow_verb(Blind ? 0 : g.warn_obj_cnt, TRUE)); } else if (newstr > 0 && newstr != oldstr) { + /* goto_level() -> docrt() -> see_monsters() -> Sting_effects(); + if "you materialize on another level" is pending, give it + now so that start-glowing message comes after it */ + maybe_lvltport_feedback(); /* usually called by goto_level() */ + /* 'start' message */ if (!Blind) pline("%s %s %s%c", bare_artifactname(uwep), diff --git a/src/display.c b/src/display.c index 1cafeb90c..482e9f901 100644 --- a/src/display.c +++ b/src/display.c @@ -1296,18 +1296,12 @@ see_monsters() new_warn_obj_cnt++; } - /* message sequencing: when changing levels via level teleport, - the start-glow/stop-glow message from Sting_effects() would come - too soon so we suppress it for docrt() -> see_monsters() then - reenable it and call see_monsters() a second time */ - if (!iflags.no_glow) { - /* - * Make Sting glow blue or stop glowing if required. - */ - if (new_warn_obj_cnt != g.warn_obj_cnt) { - Sting_effects(new_warn_obj_cnt); - g.warn_obj_cnt = new_warn_obj_cnt; - } + /* + * Make Sting glow blue or stop glowing if required. + */ + if (new_warn_obj_cnt != g.warn_obj_cnt) { + Sting_effects(new_warn_obj_cnt); + g.warn_obj_cnt = new_warn_obj_cnt; } /* when mounted, hero's location gets caught by monster loop */ diff --git a/src/do.c b/src/do.c index d1d966817..8877fda6f 100644 --- a/src/do.c +++ b/src/do.c @@ -1265,7 +1265,7 @@ boolean at_stairs, falling, portal; int l_idx, save_mode; NHFILE *nhfp; xchar new_ledger; - boolean cant_go_back, great_effort, materializing, + boolean cant_go_back, great_effort, up = (depth(newlevel) < depth(&u.uz)), newdungeon = (u.uz.dnum != newlevel->dnum), was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz), @@ -1613,15 +1613,9 @@ boolean at_stairs, falling, portal; else if (Is_firelevel(&u.uz)) fumaroles(); - /* to control message sequencing hack for Sting_effects() */ - materializing = (g.dfr_post_msg - && !strncmpi(g.dfr_post_msg, "You materialize", 15)); - /* Reset the screen. */ vision_reset(); /* reset the blockages */ g.glyphmap_perlevel_flags = 0L; /* force per-level mapglyph() changes */ - if (materializing) - iflags.no_glow++; /* to suppress see_monster()'s Sting_effects() */ docrt(); /* does a full vision recalc */ flush_screen(-1); @@ -1630,14 +1624,14 @@ boolean at_stairs, falling, portal; */ /* deferred arrival message for level teleport looks odd if given - after the various messages below so give it before them */ - if (materializing) { - pline("%s", g.dfr_post_msg); - free((genericptr_t) g.dfr_post_msg), g.dfr_post_msg = 0; - - iflags.no_glow--; - see_monsters(); /* docrt() did this but we need to repeat it */ - } + after the various messages below, so give it before them; + [it might have already been delivered via docrt() -> see_monsters() + -> Sting_effects() -> maybe_lvltport_feedback(), in which case + 'dfr_post_msg' has already been reset to Null]; + if 'dfr_post_msg' is "you materialize on another level" then + maybe_lvltport_feedback() will deliver it now and then free it */ + if (g.dfr_post_msg) + maybe_lvltport_feedback(); /* potentially called by Sting_effects() */ /* special levels can have a custom arrival message */ deliver_splev_message(); @@ -1758,6 +1752,17 @@ boolean at_stairs, falling, portal; (void) pickup(1); } +/* usually called from goto_level(); might be called from Sting_effects() */ +void +maybe_lvltport_feedback() +{ + if (g.dfr_post_msg && !strncmpi(g.dfr_post_msg, "You materialize", 15)) { + /* "You materialize on a different level." */ + pline("%s", g.dfr_post_msg); + free((genericptr_t) g.dfr_post_msg), g.dfr_post_msg = 0; + } +} + static void final_level() {