curses clipped map 'scrollbars'

The position bars shown by curses when the map is clipped weren't
being drawn as intended (integer arithmetic).  Changing parentheses
was enough to get it working, but it didn't handle the edge case
where non-zero got rounded to 0 (so when map was panned down, the
uppermost character of the vertical position bar still showed '*',
falsely indicating that top of map was currently within view.
This commit is contained in:
PatR
2019-06-25 03:17:47 -07:00
parent 3bd46a3536
commit 4f0b1262c5
2 changed files with 22 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.70 $ $NHDT-Date: 1561455021 2019/06/25 09:30:21 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.71 $ $NHDT-Date: 1561457861 2019/06/25 10:17:41 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -151,6 +151,11 @@ curses: make text windows wider so that help feedback is more readable
curses: using ':' for search string matching to toggle menu items in a multple
page menu would highlight arbitrary items on the currently visible
page in sync with the lines that matching items had on other pages
curses: when map window was clipped, the 'scrollbars' shown to indicate which
part of the map was in view didn't work as intended, always drawing
"*--------------" for horizontal (and comparable '*' with multiple '|'
underneath for vertical) when it meant to show "---******------" if
the 2nd and 3rd fifths (for example) were currently within view
curses+'perm_invent': entries were wrapping without any control; usually not
noticeable because next entry overwrote, but visible for final entry
when whole inventory fit within the available height; looked ok with

View File

@@ -624,9 +624,14 @@ curses_draw_map(int sx, int sy, int ex, int ey)
vsb_bar.attr = A_NORMAL;
/* Horizontal scrollbar */
if ((sx > 0) || (ex < (COLNO - 1))) {
sbsx = (sx * ((long) (ex - sx + 1) / COLNO));
sbex = (ex * ((long) (ex - sx + 1) / COLNO));
if (sx > 0 || ex < (COLNO - 1)) {
sbsx = (int) (((long) sx * (long) (ex - sx + 1)) / (long) COLNO);
sbex = (int) (((long) ex * (long) (ex - sx + 1)) / (long) COLNO);
if (sx > 0 && sbsx == 0)
++sbsx;
if (ex < ROWNO - 1 && sbex == ROWNO - 1)
--sbex;
for (count = 0; count < sbsx; count++) {
write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back);
@@ -642,9 +647,14 @@ curses_draw_map(int sx, int sy, int ex, int ey)
}
/* Vertical scrollbar */
if ((sy > 0) || (ey < (ROWNO - 1))) {
sbsy = (sy * ((long) (ey - sy + 1) / ROWNO));
sbey = (ey * ((long) (ey - sy + 1) / ROWNO));
if (sy > 0 || ey < (ROWNO - 1)) {
sbsy = (int) (((long) sy * (long) (ey - sy + 1)) / (long) ROWNO);
sbey = (int) (((long) ey * (long) (ey - sy + 1)) / (long) ROWNO);
if (sy > 0 && sbsy == 0)
++sbsy;
if (ey < ROWNO - 1 && sbey == ROWNO - 1)
--sbey;
for (count = 0; count < sbsy; count++) {
write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_back);