clean up Windows exit routines

This commit is contained in:
nhmall
2018-12-08 22:34:50 -05:00
parent afc34d3016
commit 8d516d4358
2 changed files with 38 additions and 12 deletions

View File

@@ -43,6 +43,9 @@ boolean win32_cursorblink;
/* globals required within here */
HANDLE ffhandle = (HANDLE) 0;
WIN32_FIND_DATA ffd;
extern int GUILaunched;
boolean getreturn_enabled;
int redirect_stdout;
typedef HWND(WINAPI *GETCONSOLEWINDOW)();
static HWND GetConsoleHandle(void);
@@ -495,6 +498,38 @@ void nhassert_failed(const char * exp, const char * file, int line)
error(message);
}
void
nethack_exit(code)
int code;
{
/* Only if we started from the GUI, not the command prompt,
* we need to get one last return, so the score board does
* not vanish instantly after being created.
* GUILaunched is defined and set in nttty.c.
*/
synch_cursor();
if (GUILaunched)
getreturn("to end");
synch_cursor();
getreturn_enabled = TRUE;
wait_synch();
exit(code);
}
void
getreturn(str)
const char *str;
{
char buf[BUFSZ];
if (!getreturn_enabled)
return;
Sprintf(buf,"Hit <Enter> %s.", str);
raw_print(buf);
wait_synch();
return;
}
/* nethack_enter_winnt() is called from main immediately after
initializing the window port */
void nethack_enter_winnt()