]> granicus.if.org Git - nethack/commitdiff
Split direction key showing into separate function
authorPasi Kallinen <paxed@alt.org>
Fri, 3 Jun 2016 18:08:43 +0000 (21:08 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 3 Jun 2016 18:08:43 +0000 (21:08 +0300)
src/cmd.c

index ae2b2bb8473d1ebf845b4f5c976c720254ddd384..475010512638a24bc8909003258eb1483fd73415 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -183,6 +183,7 @@ static const char *readchar_queue = "";
 static coord clicklook_cc;
 
 STATIC_DCL char *NDECL(parse);
+STATIC_DCL void FDECL(show_direction_keys, (winid, boolean));
 STATIC_DCL boolean FDECL(help_dir, (CHAR_P, const char *));
 
 STATIC_PTR int
@@ -3790,6 +3791,37 @@ retry:
     return 1;
 }
 
+STATIC_OVL void
+show_direction_keys(win, nodiag)
+winid win;
+boolean nodiag;
+{
+    char buf[BUFSZ];
+
+    if (nodiag) {
+        Sprintf(buf, "             %c   ", Cmd.move_N);
+        putstr(win, 0, buf);
+        putstr(win, 0, "             |   ");
+        Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
+        putstr(win, 0, buf);
+        putstr(win, 0, "             |   ");
+        Sprintf(buf, "             %c   ", Cmd.move_S);
+        putstr(win, 0, buf);
+    } else {
+        Sprintf(buf, "          %c  %c  %c", Cmd.move_NW, Cmd.move_N,
+                Cmd.move_NE);
+        putstr(win, 0, buf);
+        putstr(win, 0, "           \\ | / ");
+        Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
+        putstr(win, 0, buf);
+        putstr(win, 0, "           / | \\ ");
+        Sprintf(buf, "          %c  %c  %c", Cmd.move_SW, Cmd.move_S,
+                Cmd.move_SE);
+        putstr(win, 0, buf);
+    };
+}
+
+
 STATIC_OVL boolean
 help_dir(sym, msg)
 char sym;
@@ -3828,29 +3860,12 @@ const char *msg;
             putstr(win, 0, "");
         }
     }
-    if (NODIAG(u.umonnum)) {
-        putstr(win, 0, "Valid direction keys in your current form are:");
-        Sprintf(buf, "             %c   ", Cmd.move_N);
-        putstr(win, 0, buf);
-        putstr(win, 0, "             |   ");
-        Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
-        putstr(win, 0, buf);
-        putstr(win, 0, "             |   ");
-        Sprintf(buf, "             %c   ", Cmd.move_S);
-        putstr(win, 0, buf);
-    } else {
-        putstr(win, 0, "Valid direction keys are:");
-        Sprintf(buf, "          %c  %c  %c", Cmd.move_NW, Cmd.move_N,
-                Cmd.move_NE);
-        putstr(win, 0, buf);
-        putstr(win, 0, "           \\ | / ");
-        Sprintf(buf, "          %c- . -%c", Cmd.move_W, Cmd.move_E);
-        putstr(win, 0, buf);
-        putstr(win, 0, "           / | \\ ");
-        Sprintf(buf, "          %c  %c  %c", Cmd.move_SW, Cmd.move_S,
-                Cmd.move_SE);
-        putstr(win, 0, buf);
-    };
+
+    Sprintf(buf, "Valid direction keys %sare:",
+            NODIAG(u.umonnum) ? "in your current form " : "");
+    putstr(win, 0, buf);
+    show_direction_keys(win, NODIAG(u.umonnum));
+
     putstr(win, 0, "");
     putstr(win, 0, "          <  up");
     putstr(win, 0, "          >  down");