]> granicus.if.org Git - nethack/commitdiff
integrate 'msgtype' option and Norep()
authorPatR <rankin@nethack.org>
Fri, 8 Jan 2016 08:38:34 +0000 (00:38 -0800)
committerPatR <rankin@nethack.org>
Fri, 8 Jan 2016 08:38:34 +0000 (00:38 -0800)
Allow 'msgtype=show' for messages that nethack uses Norep() for.
I don't know whether anyone will ever want to do that, but if felt
strange to have two different message suppression mechanisms that
were completely disconnected from each other.

For a user with no msgtype filter, there'll be no difference in
behavior.

include/extern.h
src/options.c
src/pline.c

index 3e58ee565e1447dff3c5aa65eb78508945ff59d8..70ce04b3113adf8a51d6692df5ac6efd7f5c1132 100644 (file)
@@ -1662,7 +1662,7 @@ E boolean FDECL(add_menu_coloring, (char *));
 E boolean FDECL(get_menu_coloring, (char *, int *, int *));
 E void NDECL(free_menu_coloring);
 E boolean FDECL(msgtype_parse_add, (char *));
-E int FDECL(msgtype_type, (const char *));
+E int FDECL(msgtype_type, (const char *, BOOLEAN_P));
 E void NDECL(msgtype_free);
 
 /* ### pager.c ### */
index 11a26c07479599701eade5eb8622f97ae35caad0..f706d2c0a1037af7e1834d9261cc91a5a3ce642d 100644 (file)
@@ -1455,8 +1455,9 @@ int idx; /* 0 .. */
 }
 
 int
-msgtype_type(msg)
+msgtype_type(msg, norepeat)
 const char *msg;
+boolean norepeat; /* called from Norep(via pline) */
 {
     struct plinemsg_type *tmp = plinemsg_types;
 
@@ -1465,7 +1466,7 @@ const char *msg;
             return tmp->msgtype;
         tmp = tmp->next;
     }
-    return MSGTYP_NORMAL;
+    return norepeat ? MSGTYP_NOREP : MSGTYP_NORMAL;
 }
 
 int
index ce4b6070224ae459ac29ba09212c9d7436bef767..4ada9bff78e2bc2e033537e533a1ad7c468faf6d 100644 (file)
@@ -83,22 +83,22 @@ VA_DECL(const char *, line)
         iflags.last_msg = PLNMSG_UNKNOWN;
         return;
     }
-#ifndef MAC
-    if (no_repeat && !strcmp(line, toplines))
+
+    msgtyp = msgtype_type(line, no_repeat);
+    if (msgtyp == MSGTYP_NOSHOW
+        || (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
         return;
-#endif /* MAC */
     if (vision_full_recalc)
         vision_recalc(0);
     if (u.ux)
         flush_screen(1); /* %% */
-    msgtyp = msgtype_type(line);
-    if (msgtyp == MSGTYP_NOSHOW) return;
-    if (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)) return;
+
     putstr(WIN_MESSAGE, 0, line);
     /* this gets cleared after every pline message */
     iflags.last_msg = PLNMSG_UNKNOWN;
-    strncpy(prevmsg, line, BUFSZ);
-    if (msgtyp == MSGTYP_STOP) display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
+    strncpy(prevmsg, line, BUFSZ), prevmsg[BUFSZ - 1] = '\0';
+    if (msgtyp == MSGTYP_STOP)
+        display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
 
 #if !(defined(USE_STDARG) || defined(USE_VARARGS))
     /* provide closing brace for the nested block