Revert "Change Windows startup"
This reverts commit acb85b18cf.
Some optlist issues arose on some platforms, but not all.
I need to investigate the cause of those.
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
#include <errno.h>
|
||||
#include <ShlObj.h>
|
||||
|
||||
#if !defined(SAFEPROCS)
|
||||
#error You must #define SAFEPROCS to build windmain.c
|
||||
#endif
|
||||
|
||||
static void nhusage(void);
|
||||
char *exename(void);
|
||||
boolean fakeconsole(void);
|
||||
@@ -63,6 +67,7 @@ char windows_yn_function(const char *, const char *, char);
|
||||
|
||||
#ifdef WIN32CON
|
||||
extern int windows_console_custom_nhgetch(void);
|
||||
void safe_routines(void);
|
||||
int tty_self_recover_prompt(void);
|
||||
#endif
|
||||
|
||||
@@ -101,13 +106,6 @@ void update_file(const char *, const char *,
|
||||
const char *, const char *, BOOL);
|
||||
void windows_raw_print_bold(const char *);
|
||||
|
||||
staticfn void set_emergency_io(void);
|
||||
staticfn void stdio_wait_synch(void);
|
||||
staticfn void stdio_raw_print(const char *str);
|
||||
staticfn void stdio_nonl_raw_print(const char *str);
|
||||
staticfn void stdio_raw_print_bold(const char *str);
|
||||
staticfn int stdio_nhgetch(void);
|
||||
|
||||
#ifdef PORT_HELP
|
||||
void port_help(void);
|
||||
#endif
|
||||
@@ -161,9 +159,18 @@ MAIN(int argc, char *argv[])
|
||||
char *dir = NULL;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||
#endif
|
||||
|
||||
#ifdef WIN32CON
|
||||
/*
|
||||
* Get a set of valid safe windowport function
|
||||
* pointers during early startup initialization.
|
||||
*/
|
||||
// safe_routines();
|
||||
#endif /* WIN32CON */
|
||||
|
||||
|
||||
/* setting iflags.colorcount has to be after early_init()
|
||||
* because it zeros out all of iflags */
|
||||
hwnd = GetDesktopWindow();
|
||||
@@ -201,9 +208,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
#ifndef MSWIN_GRAPHICS
|
||||
early_init(argc, argv); /* already in WinMain for MSWIN_GRAPHICS */
|
||||
#endif
|
||||
set_default_prefix_locations(
|
||||
argv[0]); /* must be re-done after initoptions_init()
|
||||
* which clears out gp.fqn_prefix[] */
|
||||
set_default_prefix_locations(argv[0]); /* must be re-done after initoptions_init()
|
||||
* which clears out gp.fqn_prefix[] */
|
||||
copy_sysconf_content();
|
||||
copy_symbols_content();
|
||||
/* Now that sysconf has had a chance to set the TROUBLEPREFIX, don't
|
||||
@@ -211,20 +217,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
fqn_prefix_locked[TROUBLEPREFIX] = TRUE;
|
||||
copy_config_content();
|
||||
|
||||
// if (iflags.windowtype_deferred && gc.chosen_windowtype[0])
|
||||
// windowtype = gc.chosen_windowtype;
|
||||
// windowtype = gc.chosen_windowtype;
|
||||
// if (iflags.windowtype_deferred && gc.chosen_windowtype[0])
|
||||
// windowtype = gc.chosen_windowtype;
|
||||
// windowtype = gc.chosen_windowtype;
|
||||
|
||||
#if !defined(MSWIN_GRAPHICS)
|
||||
nethack_enter_consoletty();
|
||||
consoletty_open(1);
|
||||
#endif
|
||||
set_emergency_io();
|
||||
|
||||
#ifdef EARLY_CONFIGFILE_PASS
|
||||
rcfile_interface_options();
|
||||
if (gc.chosen_windowtype && *gc.chosen_windowtype)
|
||||
windowtype = gc.chosen_windowtype;
|
||||
nethack_enter_consoletty();
|
||||
#endif
|
||||
|
||||
if (!windowtype) {
|
||||
@@ -234,10 +233,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
windowtype = "tty";
|
||||
#endif
|
||||
}
|
||||
choose_windows(
|
||||
windowtype); /* sets all the window port function pointers */
|
||||
|
||||
init_nhwindows(&argc, argv);
|
||||
choose_windows(windowtype); /* sets all the window port function pointers */
|
||||
|
||||
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
|
||||
/* Save current directory and make sure it gets restored when
|
||||
@@ -247,9 +243,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
error("NetHack: current directory path too long");
|
||||
#endif
|
||||
initoptions_init(); // This allows OPTIONS in syscf on Windows.
|
||||
set_default_prefix_locations(
|
||||
argv[0]); /* must be re-done after initoptions_init()
|
||||
* which clears out gp.fqn_prefix[] */
|
||||
set_default_prefix_locations(argv[0]); /* must be re-done after initoptions_init()
|
||||
* which clears out gp.fqn_prefix[] */
|
||||
iflags.windowtype_deferred = TRUE;
|
||||
|
||||
program_state.early_options = 1;
|
||||
@@ -291,6 +286,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
&& (strstri(argv[0], "nethackw.exe") || GUILaunched))
|
||||
iflags.windowtype_locked = TRUE;
|
||||
#endif
|
||||
windowtype = default_window_sys;
|
||||
|
||||
#ifdef DLB
|
||||
if (!dlb_init()) {
|
||||
@@ -305,6 +301,18 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!iflags.windowtype_locked) {
|
||||
#if defined(TTY_GRAPHICS)
|
||||
Strcpy(default_window_sys, "tty");
|
||||
#else
|
||||
#if defined(CURSES_GRAPHICS) && !defined(MSWIN_GRAPHICS)
|
||||
Strcpy(default_window_sys, "curses");
|
||||
#endif /* CURSES */
|
||||
#endif /* TTY */
|
||||
// if (iflags.windowtype_deferred && gc.chosen_windowtype[0])
|
||||
// windowtype = gc.chosen_windowtype;
|
||||
}
|
||||
// choose_windows(windowtype);
|
||||
#if defined(SND_LIB_FMOD)
|
||||
assign_soundlib(soundlib_fmod);
|
||||
#elif defined(SND_LIB_WINDSOUND)
|
||||
@@ -314,14 +322,19 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
u.uhp = 1; /* prevent RIP on early quits */
|
||||
u.ux = 0; /* prevent flush_screen() */
|
||||
|
||||
nethack_enter(argc, argv);
|
||||
iflags.use_background_glyph = FALSE;
|
||||
if (WINDOWPORT(mswin))
|
||||
iflags.use_background_glyph = TRUE;
|
||||
#ifdef WIN32CON
|
||||
if (WINDOWPORT(tty))
|
||||
consoletty_open(1);
|
||||
#endif
|
||||
#ifdef WINCHAIN
|
||||
commit_windowchain();
|
||||
#endif
|
||||
|
||||
// init_nhwindows(&argc, argv);
|
||||
init_nhwindows(&argc, argv);
|
||||
|
||||
#ifdef WIN32CON
|
||||
if (WINDOWPORT(tty))
|
||||
@@ -824,6 +837,20 @@ copy_hack_content(void)
|
||||
gf.fqn_prefix[DATAPREFIX], OPTIONFILE, FALSE);
|
||||
}
|
||||
|
||||
#ifdef WIN32CON
|
||||
void
|
||||
safe_routines(void)
|
||||
{
|
||||
/*
|
||||
* Get a set of valid safe windowport function
|
||||
* pointers during early startup initialization.
|
||||
*/
|
||||
if (!WINDOWPORT(safestartup))
|
||||
windowprocs = *get_safe_procs(1);
|
||||
if (!GUILaunched)
|
||||
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PORT_HELP
|
||||
void
|
||||
@@ -1178,7 +1205,9 @@ tty_self_recover_prompt(void)
|
||||
c = 'n';
|
||||
ct = 0;
|
||||
saved_procs = windowprocs;
|
||||
|
||||
if (!WINDOWPORT(safestartup))
|
||||
windowprocs = *get_safe_procs(2); /* arg 2 uses no-newline variant */
|
||||
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
||||
raw_print("\n");
|
||||
raw_print("\n");
|
||||
raw_print("\n");
|
||||
@@ -1311,60 +1340,4 @@ chdirx(const char *dir, boolean wr)
|
||||
}
|
||||
#endif /* CHDIR */
|
||||
|
||||
void
|
||||
set_emergency_io(void)
|
||||
{
|
||||
windowprocs.win_raw_print = stdio_raw_print;
|
||||
windowprocs.win_raw_print_bold = stdio_raw_print_bold;
|
||||
windowprocs.win_nhgetch = stdio_nhgetch;
|
||||
windowprocs.win_wait_synch = stdio_wait_synch;
|
||||
}
|
||||
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print = stdio_wait_synch; */
|
||||
void
|
||||
stdio_wait_synch(void)
|
||||
{
|
||||
char valid[] = { ' ', '\n', '\r', '\033', '\0' };
|
||||
|
||||
fprintf(stdout, "--More--");
|
||||
(void) fflush(stdout);
|
||||
while (!strchr(valid, nhgetch()))
|
||||
;
|
||||
}
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print = stdio_raw_print; */
|
||||
void
|
||||
stdio_raw_print(const char *str)
|
||||
{
|
||||
if (str)
|
||||
fprintf(stdout, "%s\n", str);
|
||||
return;
|
||||
}
|
||||
|
||||
/* no newline variation, add to your code:
|
||||
windowprocs.win_raw_print = stdio_nonl_raw_print; */
|
||||
void
|
||||
stdio_nonl_raw_print(const char *str)
|
||||
{
|
||||
if (str)
|
||||
fprintf(stdout, "%s", str);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print_bold = stdio_raw_print_bold; */
|
||||
void
|
||||
stdio_raw_print_bold(const char *str)
|
||||
{
|
||||
stdio_raw_print(str);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add to your code: windowprocs.win_nhgetch = stdio_nhgetch; */
|
||||
int
|
||||
stdio_nhgetch(void)
|
||||
{
|
||||
return getchar();
|
||||
}
|
||||
|
||||
/*windmain.c*/
|
||||
/*windmain.c*/
|
||||
|
||||
Reference in New Issue
Block a user