Changes to be committed: modified: include/winprocs.h modified: src/options.c modified: sys/share/pcmain.c new file: sys/share/safeproc.c modified: sys/winnt/Makefile.msc modified: sys/winnt/stubs.c new file: sys/winnt/windmain.c modified: sys/winnt/winnt.c modified: win/win32/vs2017/NetHack.vcxproj modified: win/win32/vs2017/NetHackW.vcxproj modified: win/win32/winhack.c Because multiple window ports are supported on Windows now, even in the same executable and selectable via config file in some cases, some adjustments became necessary. There will likely be some further refining of this over the next day or two. List of changes: Move Windows startup from sys/share/pcmain.c and into its own sys/winnt/windmain.c so that it can be modified to fix some current breakage, and allow altering the order of some things. There is startup processing code that is common to all of the Windows WindowPorts, but that startup processing code needs to have no dependency on any one of those WindowPorts. Yet, during startup processing, some of the initialization routines can end up calling NetHack functions that expect an active Window port underneath, and if there isn't one, routines like pline, impossible, panic can end up invoking null function pointers. Place a new file sys/share/safeproc.c, in which a complete window port is available for early startup processing purposes. It's WindowPort name field is set to "safe-startup" just for reference. The prototypes in include/winprocs.h require that SAFEPROCS be Usage: windowprocs = get_safe_procs(0); initializes a set of winprocs function pointers that ensure none of the function pointers are left null, but that's all it does. windowprocs = get_safe_procs(1); initializes a set of winprocs functions pointers that ensure none of the function pointers are left null, but also provides some basic output and input functionality using nothing other than C stdio routines (no platform or OS specific code). The conditional code related to WIN32 has been removed from sys/share/pcmain.c The code common to all of the Windows WindowPorts calls get_safe_procs() almost immediately to ensure that there is a set of WindowPort winprocs available.
187 lines
2.4 KiB
C
187 lines
2.4 KiB
C
/* NetHack 3.6 stubs.c $NHDT-Date: 1524689357 2018/04/25 20:49:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.3 $ */
|
|
/* Copyright (c) 2015 by Michael Allison */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#include "win32api.h"
|
|
#include "hack.h"
|
|
|
|
#ifdef GUISTUB
|
|
#ifdef TTYSTUB
|
|
#error You cannot compile this with both GUISTUB and TTYSTUB defined.
|
|
#endif
|
|
|
|
int GUILaunched;
|
|
struct window_procs mswin_procs = { "guistubs" };
|
|
|
|
#ifdef QT_GRAPHICS
|
|
struct window_procs Qt_procs = { "guistubs" };
|
|
int qt_tilewidth, qt_tileheight, qt_fontsize, qt_compact_mode;
|
|
#endif
|
|
void
|
|
mswin_destroy_reg()
|
|
{
|
|
return;
|
|
}
|
|
|
|
/* MINGW32 has trouble with both a main() and WinMain()
|
|
* so we move main for the MINGW tty version into this stub
|
|
* so that it is out of sight for the gui linkage.
|
|
*/
|
|
#ifdef __MINGW32__
|
|
extern char default_window_sys[];
|
|
extern int mingw_main(int argc, char **argv);
|
|
|
|
int
|
|
main(argc, argv)
|
|
int argc;
|
|
char *argv[];
|
|
{
|
|
boolean resuming;
|
|
|
|
resuming = mingw_main(argc, argv);
|
|
nethack_exit(EXIT_SUCCESS);
|
|
/*NOTREACHED*/
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* GUISTUB */
|
|
|
|
/* =============================================== */
|
|
|
|
#ifdef TTYSTUB
|
|
|
|
HANDLE hConIn;
|
|
HANDLE hConOut;
|
|
int GUILaunched;
|
|
struct window_procs tty_procs = { "ttystubs" };
|
|
|
|
void
|
|
win_tty_init(dir)
|
|
int dir;
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
nttty_open(mode)
|
|
int mode;
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
xputc(ch)
|
|
char ch;
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
xputs(s)
|
|
const char *s;
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
raw_clear_screen()
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
clear_screen()
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
backsp()
|
|
{
|
|
return;
|
|
}
|
|
|
|
int
|
|
has_color(int color)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
#ifndef NO_MOUSE_ALLOWED
|
|
void
|
|
toggle_mouse_support()
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
#ifdef PORT_DEBUG
|
|
void
|
|
win32con_debug_keystrokes()
|
|
{
|
|
return;
|
|
}
|
|
void
|
|
win32con_handler_info()
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
void
|
|
map_subkeyvalue(op)
|
|
register char *op;
|
|
{
|
|
return;
|
|
}
|
|
|
|
/* this is used as a printf() replacement when the window
|
|
* system isn't initialized yet
|
|
*/
|
|
void msmsg
|
|
VA_DECL(const char *, fmt)
|
|
{
|
|
VA_START(fmt);
|
|
VA_INIT(fmt, const char *);
|
|
VA_END();
|
|
return;
|
|
}
|
|
|
|
/*VARARGS1*/
|
|
void nttty_error
|
|
VA_DECL(const char *, s)
|
|
{
|
|
VA_START(s);
|
|
VA_INIT(s, const char *);
|
|
VA_END();
|
|
return;
|
|
}
|
|
|
|
#ifdef TTY_GRAPHICS
|
|
void
|
|
synch_cursor()
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
void
|
|
more()
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
nethack_enter_nttty()
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
set_altkeyhandler(const char *inName)
|
|
{
|
|
return;
|
|
}
|
|
#endif /* TTYSTUBS */
|