From 14d8ed199ec95f6a5c130183fd01e568d63e2bb4 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 29 Mar 2019 14:35:36 -0700 Subject: [PATCH] tty: panning while clipped Noticed while testing statuslines on a small terminal window. Using the cursor to pick locations that panned the map to view a new subset would end up showing a new view of the regular map rather than a different section of what was currently displayed. For farlook that caused monsters to take on new hallucinatory forms which was fairly inconsequential, but for #terrain and various forms of detection it reverted to the ordinary map instead of showing the map features that the player requested or the temporarily revealed monsters and such. Most interfaces keep track of the whole map and just show their view of the new subset when panning, similar to redisplay after being covered up and then re-exposed, but tty isn't doing that. I made same change to Amiga as to tty since the code it was using was very similar. I haven't touched any of the other interfaces and assume that they don't need this. I've verified that curses and X11 don't. --- doc/fixes36.2 | 7 +++++- include/extern.h | 3 ++- src/display.c | 58 +++++++++++++++++++++++++++++++++----------- sys/amiga/winfuncs.c | 10 +++----- win/tty/wintty.c | 6 ++--- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index c05935508..ce18f2e31 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.288 $ $NHDT-Date: 1553885439 2019/03/29 18:50:39 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.289 $ $NHDT-Date: 1553895318 2019/03/29 21:35:18 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -488,6 +488,11 @@ tty: when status condition names were abbreviated due to lack of room, they tty: when encumbrance state was abbreviated due to lack of room, there was no separation from preceding status field and the value would not update when the state changed (except for removal on change to unencumbered) +tty: when clipping was used to show a subset of the map on a small display, + panning into a new subset while using the cursor to pick a location + would ask the core to generate a new view of the map rather than use + whatever was currently shown, bringing back suppressed monsters/ + objects/traps for #terrain and new hallucinatory monsters for farlook X11: its use of genl_status_update exposed a negative index use that could lead to a segfault X11: rollback disabling of keystroke input for PICK_NONE menus (for scrolling) diff --git a/include/extern.h b/include/extern.h index f35623f9a..9fa6dfc0b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1552945074 2019/03/18 21:37:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.695 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1553895318 2019/03/29 21:35:18 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.696 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -351,6 +351,7 @@ E void NDECL(see_traps); E void NDECL(curs_on_u); E int NDECL(doredraw); E void NDECL(docrt); +E void NDECL(redraw_map); E void FDECL(show_glyph, (int, int, int)); E void NDECL(clear_glyph_buffer); E void FDECL(row_refresh, (int, int, int)); diff --git a/src/display.c b/src/display.c index 281b5f57e..7666aa928 100644 --- a/src/display.c +++ b/src/display.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 display.c $NHDT-Date: 1551138503 2019/02/25 23:48:23 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.97 $ */ +/* NetHack 3.6 display.c $NHDT-Date: 1553895319 2019/03/29 21:35:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.98 $ */ /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */ /* and Dave Cohrs, 1990. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1213,8 +1213,7 @@ int mode; } } -/* ========================================================================= - */ +/* ======================================================================== */ /* * Loop through all of the monsters and update them. Called when: @@ -1380,10 +1379,39 @@ docrt() context.botlx = 1; /* force a redraw of the bottom line */ } -/* ========================================================================= - */ -/* Glyph Buffering (3rd screen) ============================================ - */ +/* for panning beyond a clipped region; resend the current map data to + the interface rather than use docrt()'s regeneration of that data */ +void +redraw_map() +{ + int x, y, glyph; + + /* + * Not sure whether this is actually necessary; save and restore did + * used to get much too involved with each dungeon level as it was + * read and written. + * + * !u.ux: display isn't ready yet; (restoring || !on_level()): was part + * of cliparound() but interface shouldn't access this much internals + */ + if (!u.ux || restoring || !on_level(&u.uz0, &u.uz)) + return; + + /* + * This yields sensible clipping when #terrain+getpos is in + * progress and the screen displays something other than what + * the map would currently be showing. + */ + for (y = 0; y < ROWNO; ++y) + for (x = 1; x < COLNO; ++x) { + glyph = glyph_at(x, y); /* not levl[x][y].glyph */ + print_glyph(WIN_MAP, x, y, glyph, get_bk_glyph(x, y)); + } + flush_screen(1); +} + +/* ======================================================================== */ +/* Glyph Buffering (3rd screen) =========================================== */ typedef struct { xchar new; /* perhaps move this bit into the rm structure. */ @@ -1536,7 +1564,7 @@ int start, stop, y; for (x = start; x <= stop; x++) if (gbuf[y][x].glyph != cmap_to_glyph(S_stone)) - print_glyph(WIN_MAP, x, y, gbuf[y][x].glyph, get_bk_glyph(x,y)); + print_glyph(WIN_MAP, x, y, gbuf[y][x].glyph, get_bk_glyph(x, y)); } void @@ -1599,8 +1627,7 @@ int cursor_on_u; bot(); } -/* ========================================================================= - */ +/* ======================================================================== */ /* * back_to_glyph() @@ -1804,16 +1831,19 @@ xchar x, y; /* * This will be used to get the glyph for the background so that - * it can potentially be merged into graphical window ports - * to improve the appearance of stuff on dark room - * squares and the plane of air etc. + * it can potentially be merged into graphical window ports to + * improve the appearance of stuff on dark room squares and the + * plane of air etc. * * Until that is working correctly in the branch, however, for now * we just return NO_GLYPH as an indicator to ignore it. + * + * [This should be using background as recorded for #overview rather + * than current data from the map.] */ STATIC_OVL int -get_bk_glyph(x,y) +get_bk_glyph(x, y) xchar x, y; { int idx, bkglyph = NO_GLYPH; diff --git a/sys/amiga/winfuncs.c b/sys/amiga/winfuncs.c index d565b1af4..84838ed22 100644 --- a/sys/amiga/winfuncs.c +++ b/sys/amiga/winfuncs.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 winfuncs.c $NHDT-Date: 1433806596 2015/06/08 23:36:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */ +/* NetHack 3.6 winfuncs.c $NHDT-Date: 1553895320 2019/03/29 21:35:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.16 $ */ /* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993,1996. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2131,13 +2131,13 @@ void amii_cliparound(x, y) register int x, y; { - extern boolean restoring; #ifdef CLIPPING int oldx = clipx, oldy = clipy; int oldxmax = clipxmax, oldymax = clipymax; int COx, LIx; #define SCROLLCNT 1 /* Get there in 3 moves... */ int scrollcnt = SCROLLCNT; /* ...or 1 if we changed level */ + if (!clipping) /* And 1 in anycase, cleaner, simpler, quicker */ return; @@ -2306,8 +2306,7 @@ register int x, y; clipymax += incy; /* Draw the exposed portion */ - if (on_level(&u.uz0, &u.uz) && !restoring) - (void) doredraw(); + redraw_map(); flush_glyph_buffer(amii_wins[WIN_MAP]->win); } } @@ -2317,8 +2316,7 @@ register int x, y; clipymax = saveymax; clipxmax = savexmax; #endif - if (on_level(&u.uz0, &u.uz) && !restoring && moves > 1) - (void) doredraw(); + redraw_map(); flush_glyph_buffer(amii_wins[WIN_MAP]->win); } reclip = 0; diff --git a/win/tty/wintty.c b/win/tty/wintty.c index fe06b8180..7520b14ff 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintty.c $NHDT-Date: 1553858474 2019/03/29 11:21:14 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.199 $ */ +/* NetHack 3.6 wintty.c $NHDT-Date: 1553895321 2019/03/29 21:35:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.200 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -3315,7 +3315,6 @@ void tty_cliparound(x, y) int x, y; { - extern boolean restoring; int oldx = clipx, oldy = clipy; HUPSKIP(); @@ -3336,8 +3335,7 @@ int x, y; clipy = clipymax - (LI - 1 - iflags.wc2_statuslines); } if (clipx != oldx || clipy != oldy) { - if (on_level(&u.uz0, &u.uz) && !restoring) - (void) doredraw(); + redraw_map(); /* ask the core to resend the map window's data */ } } #endif /* CLIPPING */ -- 2.40.0