]> granicus.if.org Git - nethack/commitdiff
display cleanup only targets the right-most field where it's needed
authornhmall <nhmall@nethack.org>
Fri, 28 Sep 2018 16:55:30 +0000 (12:55 -0400)
committernhmall <nhmall@nethack.org>
Fri, 28 Sep 2018 16:55:30 +0000 (12:55 -0400)
doc/fixes36.2
include/wintty.h
win/tty/wintty.c

index e5e7df4a9bc2e6cde9003502beda8cb3792507b7..a56ab4b9f2430634aa64364f7ed46339a65b3234 100644 (file)
@@ -169,6 +169,7 @@ tty: ensure that current status fields are always copied to prior status
        values so that comparisons are correct
 tty: fix an out of bounds error in tty_status_update() for BL_HUNGER case
 tty: fix leftover display artifact when last field on the row got smaller
+       and optimize so only the right-most field requires the cleanup code
 X11: its use of genl_status_update exposed a negative index use that could
        lead to a segfault
 
index b121c4d6e6cbe34279db626a74f6c0f3faef434f..9a375145e834c0d0d19e186d38c09c515b4c5203 100644 (file)
@@ -229,6 +229,8 @@ E short FDECL(set_tty_font_name, (winid, char *));
 #endif
 E char *NDECL(tty_get_color_string);
 #endif
+E void FDECL(tty_status_enablefield,
+             (int, const char *, const char *, BOOLEAN_P));
 E void NDECL(tty_status_init);
 E void FDECL(tty_status_update, (int, genericptr_t, int, int, int, unsigned long *));
 
index d888f6d6721022f562f2da316b9a27b492648813..145a535fe4403ad94398467d43468690961acbb7 100644 (file)
@@ -103,7 +103,7 @@ struct window_procs tty_procs = {
 #endif
     tty_getmsghistory, tty_putmsghistory,
     tty_status_init,
-    genl_status_finish, genl_status_enablefield,
+    genl_status_finish, tty_status_enablefield,
 #ifdef STATUS_HILITES
     tty_status_update,
 #else
@@ -3599,6 +3599,18 @@ tty_status_init()
     genl_status_init();
 }
 
+void
+tty_status_enablefield(fieldidx, nm, fmt, enable)
+int fieldidx;
+const char *nm;
+const char *fmt;
+boolean enable;
+{
+    genl_status_enablefield(fieldidx, nm, fmt, enable);
+    /* force re-evaluation of last field on the row */
+    setlast = FALSE;
+}
+
 void
 do_setlast()
 {
@@ -3606,7 +3618,7 @@ do_setlast()
 
     setlast = TRUE;
     for (row = 0; row < 2; ++row)
-        for (i = MAX_PER_ROW - 1; i ; --i) {
+        for (i = MAX_PER_ROW - 1; i > 0; --i) {
            fld = fieldorder[row][i];
 
            if (fld == BL_FLUSH || !status_activefields[fld])