fix windows bugs H4030 and H4045 (123 and 138)
Changes to be committed: modified: sys/share/pcmain.c modified: sys/winnt/nttty.c modified: sys/winnt/stubs.c Bug 123 Report 4030: Minor thing I've noticed - if I quit the game, at the "Hit <Enter> to end." prompt, if I close the window rather than pressing Enter, I get the following: Bug 138 - #H4045: "nethack -s" leads to "-s is not supported for the Graphical Interface". That's wrong. (The Graphical Interface comes with "nethackw".)
This commit is contained in:
+81
-3
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 pcmain.c $NHDT-Date: 1449116336 2015/12/03 04:18:56 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.66 $ */
|
/* NetHack 3.6 pcmain.c $NHDT-Date: 1449893255 2015/12/12 04:07:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.67 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -55,8 +55,12 @@ extern void FDECL(nethack_exit, (int));
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
||||||
extern int redirect_stdout; /* from sys/share/pcsys.c */
|
extern int redirect_stdout; /* from sys/share/pcsys.c */
|
||||||
|
extern int GUILaunched;
|
||||||
|
HANDLE hStdOut;
|
||||||
char *NDECL(exename);
|
char *NDECL(exename);
|
||||||
char default_window_sys[] = "mswin";
|
char default_window_sys[] = "mswin";
|
||||||
|
boolean NDECL(fakeconsole);
|
||||||
|
void NDECL(freefakeconsole);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MSWIN_GRAPHICS)
|
#if defined(MSWIN_GRAPHICS)
|
||||||
@@ -279,16 +283,30 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
|||||||
Strcpy(hackdir, dir);
|
Strcpy(hackdir, dir);
|
||||||
}
|
}
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
|
#if defined(WIN32)
|
||||||
|
int sfd = 0;
|
||||||
|
boolean tmpconsole = FALSE;
|
||||||
|
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Now we know the directory containing 'record' and
|
* Now we know the directory containing 'record' and
|
||||||
* may do a prscore().
|
* may do a prscore().
|
||||||
*/
|
*/
|
||||||
if (!strncmp(argv[1], "-s", 2)) {
|
if (!strncmp(argv[1], "-s", 2)) {
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
int sfd = (int) _fileno(stdout);
|
|
||||||
|
#if 0
|
||||||
|
if (!hStdOut) {
|
||||||
|
tmpconsole = fakeconsole();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Check to see if we're redirecting to a file.
|
||||||
|
*/
|
||||||
|
sfd = (int) _fileno(stdout);
|
||||||
redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0;
|
redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0;
|
||||||
|
|
||||||
if (!redirect_stdout) {
|
if (!redirect_stdout && !hStdOut) {
|
||||||
raw_printf(
|
raw_printf(
|
||||||
"-s is not supported for the Graphical Interface\n");
|
"-s is not supported for the Graphical Interface\n");
|
||||||
nethack_exit(EXIT_SUCCESS);
|
nethack_exit(EXIT_SUCCESS);
|
||||||
@@ -302,6 +320,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
|||||||
initoptions();
|
initoptions();
|
||||||
#endif
|
#endif
|
||||||
prscore(argc, argv);
|
prscore(argc, argv);
|
||||||
|
#ifdef WIN32
|
||||||
|
if (tmpconsole) {
|
||||||
|
getreturn("to exit");
|
||||||
|
freefakeconsole();
|
||||||
|
tmpconsole = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
nethack_exit(EXIT_SUCCESS);
|
nethack_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +338,21 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
|||||||
#endif
|
#endif
|
||||||
/* Don't initialize the window system just to print usage */
|
/* Don't initialize the window system just to print usage */
|
||||||
if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) {
|
if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) {
|
||||||
|
#if 0
|
||||||
|
if (!hStdOut) {
|
||||||
|
GUILaunched = 0;
|
||||||
|
tmpconsole = fakeconsole();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
nhusage();
|
nhusage();
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (tmpconsole) {
|
||||||
|
getreturn("to exit");
|
||||||
|
freefakeconsole();
|
||||||
|
tmpconsole = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
nethack_exit(EXIT_SUCCESS);
|
nethack_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -804,6 +843,9 @@ authorize_wizard_mode()
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static char exenamebuf[PATHLEN];
|
static char exenamebuf[PATHLEN];
|
||||||
|
extern HANDLE hConIn;
|
||||||
|
extern HANDLE hConOut;
|
||||||
|
boolean has_fakeconsole;
|
||||||
|
|
||||||
char *
|
char *
|
||||||
exename()
|
exename()
|
||||||
@@ -826,6 +868,42 @@ exename()
|
|||||||
tmp2++;
|
tmp2++;
|
||||||
return tmp2;
|
return tmp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean
|
||||||
|
fakeconsole(void)
|
||||||
|
{
|
||||||
|
if (!hStdOut) {
|
||||||
|
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
|
||||||
|
if (!hStdOut && !hStdIn) {
|
||||||
|
/* Bool rval; */
|
||||||
|
AllocConsole();
|
||||||
|
AttachConsole(GetCurrentProcessId());
|
||||||
|
/* rval = SetStdHandle(STD_OUTPUT_HANDLE, hWrite); */
|
||||||
|
freopen("CON", "w", stdout);
|
||||||
|
freopen("CON", "r", stdin);
|
||||||
|
}
|
||||||
|
has_fakeconsole = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Obtain handles for the standard Console I/O devices */
|
||||||
|
hConIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
#if 0
|
||||||
|
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) {
|
||||||
|
/* Unable to set control handler */
|
||||||
|
cmode = 0; /* just to have a statement to break on for debugger */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return has_fakeconsole;
|
||||||
|
}
|
||||||
|
void freefakeconsole()
|
||||||
|
{
|
||||||
|
if (has_fakeconsole) {
|
||||||
|
FreeConsole();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EXEPATHBUFSZ 256
|
#define EXEPATHBUFSZ 256
|
||||||
|
|||||||
+12
-13
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 nttty.c $NHDT-Date: 1431737067 2015/05/16 00:44:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */
|
/* NetHack 3.6 nttty.c $NHDT-Date: 1449893262 2015/12/12 04:07:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.64 $ */
|
||||||
/* Copyright (c) NetHack PC Development Team 1993 */
|
/* Copyright (c) NetHack PC Development Team 1993 */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -258,6 +258,8 @@ int mode;
|
|||||||
DWORD cmode;
|
DWORD cmode;
|
||||||
long mask;
|
long mask;
|
||||||
|
|
||||||
|
GUILaunched = 0;
|
||||||
|
|
||||||
try :
|
try :
|
||||||
/* The following lines of code were suggested by
|
/* The following lines of code were suggested by
|
||||||
* Bob Landau of Microsoft WIN32 Developer support,
|
* Bob Landau of Microsoft WIN32 Developer support,
|
||||||
@@ -265,14 +267,10 @@ int mode;
|
|||||||
* we were launched from the command prompt, or from
|
* we were launched from the command prompt, or from
|
||||||
* the NT program manager. M. Allison
|
* the NT program manager. M. Allison
|
||||||
*/
|
*/
|
||||||
hStdOut
|
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
= GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
if (hStdOut) {
|
if (hStdOut) {
|
||||||
GetConsoleScreenBufferInfo(hStdOut, &origcsbi);
|
GetConsoleScreenBufferInfo(hStdOut, &origcsbi);
|
||||||
GUILaunched = ((origcsbi.dwCursorPosition.X == 0)
|
|
||||||
&& (origcsbi.dwCursorPosition.Y == 0));
|
|
||||||
if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0))
|
|
||||||
GUILaunched = 0;
|
|
||||||
} else if (mode) {
|
} else if (mode) {
|
||||||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
@@ -286,10 +284,14 @@ int mode;
|
|||||||
freopen("CON", "r", stdin);
|
freopen("CON", "r", stdin);
|
||||||
}
|
}
|
||||||
mode = 0;
|
mode = 0;
|
||||||
goto try
|
goto try;
|
||||||
;
|
} else {
|
||||||
} else
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Obtain handles for the standard Console I/O devices */
|
||||||
|
hConIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
load_keyboard_handler();
|
load_keyboard_handler();
|
||||||
/* Initialize the function pointer that points to
|
/* Initialize the function pointer that points to
|
||||||
@@ -297,9 +299,6 @@ int mode;
|
|||||||
*/
|
*/
|
||||||
nt_kbhit = nttty_kbhit;
|
nt_kbhit = nttty_kbhit;
|
||||||
|
|
||||||
/* Obtain handles for the standard Console I/O devices */
|
|
||||||
hConIn = GetStdHandle(STD_INPUT_HANDLE);
|
|
||||||
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
#if 0
|
#if 0
|
||||||
hConIn = CreateFile("CONIN$",
|
hConIn = CreateFile("CONIN$",
|
||||||
GENERIC_READ |GENERIC_WRITE,
|
GENERIC_READ |GENERIC_WRITE,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
int GUILaunched;
|
int GUILaunched;
|
||||||
struct window_procs mswin_procs = { "guistubs" };
|
struct window_procs mswin_procs = { "guistubs" };
|
||||||
|
|
||||||
void
|
void
|
||||||
mswin_destroy_reg()
|
mswin_destroy_reg()
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,7 @@ char *argv[];
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* GUISTUB */
|
#endif /* GUISTUB */
|
||||||
|
|
||||||
/* =============================================== */
|
/* =============================================== */
|
||||||
@@ -43,7 +45,10 @@ char *argv[];
|
|||||||
#ifdef TTYSTUB
|
#ifdef TTYSTUB
|
||||||
|
|
||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
|
#include "win32api.h"
|
||||||
|
|
||||||
|
HANDLE hConIn;
|
||||||
|
HANDLE hConOut;
|
||||||
int GUILaunched;
|
int GUILaunched;
|
||||||
struct window_procs tty_procs = { "ttystubs" };
|
struct window_procs tty_procs = { "ttystubs" };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user