]> granicus.if.org Git - nethack/commitdiff
Sting vs level teleport revisted
authorPatR <rankin@nethack.org>
Mon, 27 Apr 2020 17:49:34 +0000 (10:49 -0700)
committerPatR <rankin@nethack.org>
Mon, 27 Apr 2020 17:49:34 +0000 (10:49 -0700)
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.

include/extern.h
include/flag.h
src/artifact.c
src/display.c
src/do.c

index a7d415102abe6283afc91ef4907ab1a5bcd910e6..a00a180ed90839b5e141c1a5f913757f1217e07a 100644 (file)
@@ -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);
index 92def843e913d85d0290a1f072dcd65afb930dfb..5ba296d469afef8a687433716b4324e5e30383f7 100644 (file)
@@ -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 */
index 7771a6102d9985107520587a37c29443acf61a06..a0b9c2c18d50d1097130f7184f85e72e2b4d44c7 100644 (file)
@@ -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),
index 1cafeb90c9f16b46a5ac9db5f0d0aed6b5a2744d..482e9f9015ea177fb6ec512c3808762175e16afd 100644 (file)
@@ -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 */
index d1d966817c68196416880f4a976e43c40ff99aa3..8877fda6fdecc15e272f5d1082f484bc074bab06 100644 (file)
--- 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()
 {