From ae6a391997149f2892d54c8a5b04f24573ce130f Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 11 Mar 2018 23:38:00 -0400 Subject: [PATCH] fix an out of range issue on WIN32 tty --- sys/winnt/nttty.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index 3ac469ea8..1d2d8c89f 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 nttty.c $NHDT-Date: 1454381842 2016/02/02 02:57:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.67 $ */ +/* NetHack 3.6 nttty.c $NHDT-Date: 1520825872 2018/03/12 03:37:52 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.70 $ */ /* Copyright (c) NetHack PC Development Team 1993 */ /* NetHack may be freely redistributed. See license for details. */ @@ -366,11 +366,16 @@ nttty_kbhit() void get_scr_size() { + int lines, cols; + GetConsoleScreenBufferInfo(hConOut, &csbi); + + lines = csbi.srWindow.Bottom - (csbi.srWindow.Top + 1); + cols = csbi.srWindow.Right - (csbi.srWindow.Left + 1); - LI = csbi.srWindow.Bottom - (csbi.srWindow.Top + 1); - CO = csbi.srWindow.Right - (csbi.srWindow.Left + 1); - + LI = lines; + CO = min(cols, 80); + if ((LI < 25) || (CO < 80)) { COORD newcoord; -- 2.40.0