]> granicus.if.org Git - nethack/commitdiff
split "letknow" into separate function
authorSHIRAKATA Kentaro <argrath@ub32.org>
Sun, 26 Jun 2022 13:58:05 +0000 (22:58 +0900)
committerPatR <rankin@nethack.org>
Fri, 22 Jul 2022 20:07:22 +0000 (13:07 -0700)
src/vault.c

index 9e14fae23040c3cf0cbe3328ec2691fa56d7557c..eda5b47e3ce3f31210af91aaafb1ba01743693ff 100644 (file)
@@ -16,6 +16,7 @@ static void wallify_vault(struct monst *);
 static void gd_mv_monaway(struct monst *, int, int);
 static void gd_pick_corridor_gold(struct monst *, int, int);
 static int gd_move_cleanup(struct monst *, boolean, boolean);
+static void gd_letknow(struct monst *);
 
 void
 newegd(struct monst *mtmp)
@@ -805,6 +806,22 @@ gd_move_cleanup(
     return -2;
 }
 
+static void
+gd_letknow(struct monst *grd)
+{
+    if (!cansee(grd->mx, grd->my) || !mon_visible(grd))
+        You_hear("%s.",
+                    m_carrying(grd, TIN_WHISTLE)
+                        ? "the shrill sound of a guard's whistle"
+                        : "angry shouting");
+    else
+        You(um_dist(grd->mx, grd->my, 2)
+                ? "see %s approaching."
+                : "are confronted by %s.",
+            /* "an angry guard" */
+            x_monnam(grd, ARTICLE_A, "angry", 0, FALSE));
+}
+
 /*
  * return  1: guard moved,  0: guard didn't,  -1: let m_move do it,  -2: died
  */
@@ -844,7 +861,8 @@ gd_move(struct monst *grd)
             wallify_vault(grd);
             if (!in_fcorridor(grd, grd->mx, grd->my))
                 (void) clear_fcorr(grd, TRUE);
-            goto letknow;
+            gd_letknow(grd);
+            return -1;
         }
         if (!in_fcorridor(grd, grd->mx, grd->my))
             (void) clear_fcorr(grd, TRUE);
@@ -899,18 +917,7 @@ gd_move(struct monst *grd)
                 levl[m][n].flags = egrd->fakecorr[0].flags;
                 newsym(m, n);
                 grd->mpeaceful = 0;
- letknow:
-                if (!cansee(grd->mx, grd->my) || !mon_visible(grd))
-                    You_hear("%s.",
-                             m_carrying(grd, TIN_WHISTLE)
-                                 ? "the shrill sound of a guard's whistle"
-                                 : "angry shouting");
-                else
-                    You(um_dist(grd->mx, grd->my, 2)
-                            ? "see %s approaching."
-                            : "are confronted by %s.",
-                        /* "an angry guard" */
-                        x_monnam(grd, ARTICLE_A, "angry", 0, FALSE));
+                gd_letknow(grd);
                 return -1;
             } else {
                 if (!Deaf)