From eed7c4bdd112edf6cc43c5b6e63def538b099299 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 29 Dec 2018 12:26:33 -0500 Subject: [PATCH] nttty topten output processing switch back to using the safe routines after tty port exits on Windows console tty port. Fixes H7758 1613 --- include/extern.h | 1 + sys/winnt/nttty.c | 16 ++++++++++++++-- sys/winnt/windmain.c | 20 +++++++++++++++----- win/tty/wintty.c | 3 +++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/extern.h b/include/extern.h index 991070194..dbef64c22 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1639,6 +1639,7 @@ E int FDECL(ntposkey, (int *, int *, int *)); E void FDECL(set_output_mode, (int)); E void NDECL(synch_cursor); E void NDECL(nethack_enter_nttty); +E void NDECL(nttty_exit); #endif /* ### o_init.c ### */ diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index b71133af2..72354c967 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -83,6 +83,7 @@ static void NDECL(check_and_set_font); static boolean NDECL(check_font_widths); static void NDECL(set_known_good_console_font); static void NDECL(restore_original_console_font); +extern void NDECL(safe_routines); /* Win32 Screen buffer,coordinate,console I/O information */ COORD ntcoord; @@ -413,6 +414,13 @@ int mode; // unused really_move_cursor(); } +void +nttty_exit() +{ + /* go back to using the safe routines */ + safe_routines(); +} + int process_keystroke(ir, valid, numberpad, portdebug) INPUT_RECORD *ir; @@ -1701,6 +1709,7 @@ void set_cp_map() } } +#if 0 /* early_raw_print() is used during early game intialization prior to the * setting up of the windowing system. This allows early errors and panics * to have there messages displayed. @@ -1760,8 +1769,10 @@ void early_raw_print(const char *s) SetConsoleCursorPosition(console.hConOut, console.cursor); } +#endif -/* nethack_enter_nttty() is the first thing that is called from main. +/* nethack_enter_nttty() is the first thing that is called from main + * once the tty port is confirmed. * * We initialize all console state to support rendering to the console * through out flipping support at this time. This allows us to support @@ -1787,9 +1798,10 @@ void early_raw_print(const char *s) void nethack_enter_nttty() { +#if 0 /* set up state needed by early_raw_print() */ windowprocs.win_raw_print = early_raw_print; - +#endif console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE); nhassert(console.hConOut != NULL); // NOTE: this assert will not print diff --git a/sys/winnt/windmain.c b/sys/winnt/windmain.c index b70cd456d..2b3b4ddcd 100644 --- a/sys/winnt/windmain.c +++ b/sys/winnt/windmain.c @@ -47,6 +47,7 @@ void FDECL(windows_raw_print, (const char *)); char FDECL(windows_yn_function, (const char *, const char *, CHAR_P)); void FDECL(windows_getlin, (const char *, char *)); extern int NDECL(windows_console_custom_nhgetch); +void NDECL(safe_routines); char orgdir[PATHLEN]; char *dir; @@ -93,11 +94,7 @@ char *argv[]; * Get a set of valid safe windowport function * pointers during early startup initialization. */ - if (!WINDOWPORT("safe-startup")) - windowprocs = *get_safe_procs(1); - if (!GUILaunched) - windowprocs.win_nhgetch = windows_console_custom_nhgetch; - + safe_routines(); sys_early_init(); #ifdef _MSC_VER # ifdef DEBUG @@ -570,6 +567,19 @@ nhusage() #undef ADD_USAGE } +void +safe_routines(VOID_ARGS) +{ + /* + * Get a set of valid safe windowport function + * pointers during early startup initialization. + */ + if (!WINDOWPORT("safe-startup")) + windowprocs = *get_safe_procs(1); + if (!GUILaunched) + windowprocs.win_nhgetch = windows_console_custom_nhgetch; +} + #ifdef PORT_HELP void port_help() diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 6116c467f..50e67c500 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1355,6 +1355,9 @@ const char *str; #ifndef NO_TERMS /*(until this gets added to the window interface)*/ tty_shutdown(); /* cleanup termcap/terminfo/whatever */ +#endif +#ifdef WIN32 + nttty_exit(); #endif iflags.window_inited = 0; } -- 2.40.0