Merge branch 'paxed-lua-merged3' into paxed-lua-v2-merged

This commit is contained in:
nhmall
2019-11-06 12:56:21 -05:00
252 changed files with 9504 additions and 6526 deletions

View File

@@ -1015,7 +1015,11 @@ endif
#==========================================
$(O)pdcurses.a : $(PDCLIBOBJS) $(PDCOBJS)
ar rcs $@ $(PDCLIBOBJS) $(PDCOBJS)
ar rcS $@ $(PDCLIBOBJS1)
ar rcS $@ $(PDCLIBOBJS2)
ar rcS $@ $(PDCLIBOBJS3)
ar rcS $@ $(PDCLIBOBJS4)
ar rcs $@ $(PDCOBJS)
#==========================================
# Other Util Dependencies.
@@ -1147,6 +1151,76 @@ $(U)dlb_main.exe: $(DLBOBJS)
$(O)dlb_main.o: $(U)dlb_main.c $(INCL)/config.h $(DLB_H)
$(CC) $(cflags) -o$@ $(U)dlb_main.c
#==========================================
# Housekeeping.
#==========================================
clean:
$(subst /,\,if exist $(O)*.o del $(O)*.o)
$(subst /,\,if exist $(O)dat.tag del $(O)dat.tag)
$(subst /,\,if exist $(O)install.tag del $(O)install.tag)
$(subst /,\,if exist $(O)$(GAME).lnk del $(O)$(GAME).lnk)
$(subst /,\,if exist $(O)obj.tag del $(O)obj.tag)
$(subst /,\,if exist $(O)sp_lev.tag del $(O)sp_lev.tag)
$(subst /,\,if exist $(O)thintile.tag del $(O)thintile.tag)
$(subst /,\,if exist $(O)utility.tag del $(O)utility.tag)
$(subst /,\,if exist temp.a del temp.a)
spotless: clean
$(subst /,\,if exist $(U)dgn_flex.c del $(U)dgn_flex.c)
$(subst /,\,if exist $(U)dgn_lex.c del $(U)dgn_lex.c)
$(subst /,\,if exist $(U)makedefs.exe del $(U)makedefs.exe)
$(subst /,\,if exist $(U)dgn_comp.exe del $(U)dgn_comp.exe)
$(subst /,\,if exist $(U)recover.exe del $(U)recover.exe)
$(subst /,\,if exist $(U)tilemap.exe del $(U)tilemap.exe)
$(subst /,\,if exist $(U)tile2bmp.exe del $(U)tile2bmp.exe)
$(subst /,\,if exist $(U)tile2bin.exe del $(U)tile2bin.exe)
$(subst /,\,if exist $(U)til2bin2.exe del $(U)til2bin2.exe)
$(subst /,\,if exist $(U)thintile.exe del $(U)thintile.exe)
$(subst /,\,if exist $(U)dlb_main.exe del $(U)dlb_main.exe)
$(subst /,\,if exist $(INCL)/vis_tab.h del $(INCL)/vis_tab.h)
$(subst /,\,if exist $(INCL)/onames.h del $(INCL)/onames.h)
$(subst /,\,if exist $(INCL)/pm.h del $(INCL)/pm.h)
$(subst /,\,if exist $(INCL)/date.h del $(INCL)/date.h)
$(subst /,\,if exist $(INCL)/dgn_comp.h del $(INCL)/dgn_comp.h)
$(subst /,\,if exist $(INCL)/lev_comp.h del $(INCL)/lev_comp.h)
$(subst /,\,if exist $(SRC)/monstr.c del $(SRC)/monstr.c)
$(subst /,\,if exist $(SRC)/vis_tab.c del $(SRC)/vis_tab.c)
$(subst /,\,if exist $(SRC)/tile.c del $(SRC)/tile.c)
$(subst /,\,if exist $(DAT)/options del $(DAT)/options)
$(subst /,\,if exist $(DAT)/data del $(DAT)/data)
$(subst /,\,if exist $(DAT)/rumors del $(DAT)/rumors)
$(subst /,\,if exist $(DAT)/dungeon.pdf del $(DAT)/dungeon.pdf)
$(subst /,\,if exist $(DAT)/dungeon del $(DAT)/dungeon)
$(subst /,\,if exist $(DAT)/oracles del $(DAT)/oracles)
$(subst /,\,if exist $(DAT)/quest.dat del $(DAT)/quest.dat)
$(subst /,\,if exist $(DAT)/bogusmon del $(DAT)/bogusmon)
$(subst /,\,if exist $(DAT)/engrave del $(DAT)/engrave)
$(subst /,\,if exist $(DAT)/epitaph del $(DAT)/epitaph)
$(subst /,\,if exist $(DAT)/dlb.lst del $(DAT)/dlb.lst)
$(subst /,\,if exist $(DAT)/nhdat del $(DAT)/nhdat)
$(subst /,\,if exist $(DAT)/*.lev del $(DAT)/*.lev)
$(subst /,\,if exist $(TILE_BMP) del $(TILE_BMP))
$(subst /,\,if exist $(WSHR)/monthin.txt del $(WSHR)/monthin.txt)
$(subst /,\,if exist $(WSHR)/objthin.txt del $(WSHR)/objthin.txt)
$(subst /,\,if exist $(WSHR)/oththin.txt del $(WSHR)/oththin.txt)
#==========================================
# Create directory for holding object files
#==========================================
$(O)obj.tag:
-$(subst /,\,@if not exist $(OBJ)/*.* mkdir $(OBJ))
@$(subst /,\,@echo directory created > $@)
#===========================================
# Work around some djgpp long file name woes
#===========================================
$(PATCHLEV_H):
@$(subst /,\,if not exist $@ copy $(INCL)/patchlevel.h $(INCL)/patchlev.h)
#=============================================================
# LUA
#=============================================================

View File

@@ -49,12 +49,12 @@ void FDECL(get_cursor, (int *, int *));
/* direct bios calls are used only when iflags.BIOS is set */
STATIC_DCL char NDECL(DOSgetch);
STATIC_DCL char NDECL(BIOSgetch);
static char NDECL(DOSgetch);
static char NDECL(BIOSgetch);
#ifndef __GO32__
STATIC_DCL char *NDECL(getdta);
static char *NDECL(getdta);
#endif
STATIC_DCL unsigned int FDECL(dos_ioctl, (int, int, unsigned));
static unsigned int FDECL(dos_ioctl, (int, int, unsigned));
#ifdef USE_TILES
extern boolean FDECL(pckeys, (unsigned char, unsigned char)); /* pckeys.c */
#endif
@@ -243,7 +243,7 @@ static const char numeric_scanmap[] = { /* ... */
#define ALT 0x8
#endif /* PC9800 */
STATIC_OVL char
static char
BIOSgetch()
{
unsigned char scan, shift, ch = 0;
@@ -303,7 +303,7 @@ BIOSgetch()
return ch;
}
STATIC_OVL char
static char
DOSgetch()
{
union REGS regs;
@@ -406,7 +406,7 @@ foundfile_buffer()
}
/* Get disk transfer area */
STATIC_OVL char *
static char *
getdta()
{
union REGS regs;
@@ -503,7 +503,7 @@ enable_ctrlP()
return;
}
STATIC_OVL unsigned int
static unsigned int
dos_ioctl(handle, mode, setvalue)
int handle, mode;
unsigned setvalue;

View File

@@ -33,8 +33,8 @@
#include "tile.h"
#include "pctiles.h"
STATIC_VAR FILE *tilefile;
STATIC_VAR FILE *tilefile_O;
static FILE *tilefile;
static FILE *tilefile_O;
extern short glyph2tile[]; /* in tile.c (made from tilemap.c) */
#ifdef TILES_IN_RAM

View File

@@ -44,6 +44,7 @@
#define READ_ABSOLUTE_WORD(x) *(x)
#define WRITE_ABSOLUTE(x, y) *(x) = (y)
#define WRITE_ABSOLUTE_WORD(x, y) *(x) = (y)
#define WRITE_ABSOLUTE_DWORD(x, y) *(x) = (y)
#endif
#if defined(__GO32__) || defined(__DJGPP__)
@@ -57,6 +58,8 @@
_farpokeb(_go32_conventional_mem_selector(), (unsigned) x, (y))
#define WRITE_ABSOLUTE_WORD(x, y) \
_farpokew(_go32_conventional_mem_selector(), (unsigned) x, (y))
#define WRITE_ABSOLUTE_DWORD(x, y) \
_farpokel(_go32_conventional_mem_selector(), (unsigned) x, (y))
#endif
#ifdef OBSOLETE /* old djgpp V1.x way of mapping 1st MB */
@@ -66,6 +69,7 @@
#define READ_ABSOLUTE_WORD(x) *(x)
#define WRITE_ABSOLUTE(x, y) *(x) = (y)
#define WRITE_ABSOLUTE_WORD(x, y) *(x) = (y)
#define WRITE_ABSOLUTE_DWORD(x, y) *(x) = (y)
#endif
#endif /* MK_PTR */

View File

@@ -1,10 +1,10 @@
@echo off
REM NetHack 3.6 setup.bat $NHDT-Date: 1432512792 2015/05/25 00:13:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $
REM Copyright (c) NetHack PC Development Team 1990 - 2018
REM Copyright (c) NetHack PC Development Team 1990 - 2019
REM NetHack may be freely redistributed. See license for details.
echo.
echo Copyright (c) NetHack PC Development Team 1990 - 2018
echo Copyright (c) NetHack PC Development Team 1990 - 2019
echo NetHack may be freely redistributed. See license for details.
echo.
REM setup batch file for msdos, see Install.dos for details.
@@ -80,7 +80,7 @@ ren ..\..\sys\share\posixregex.c posixreg.c
goto long4ok
:long4b
echo "Renaming ..\..\sys\share\posixr~1.c -> ..\..\sys\share\posixreg.c"
ren ..\..\sys\share\posixr~1.h posixreg.c
ren ..\..\sys\share\posixr~1.c posixreg.c
:long4ok
if "%1"=="GCC" goto ok_gcc

View File

@@ -122,7 +122,7 @@ void FDECL(get_cursor, (int *, int *));
void FDECL(adjust_cursor_flags, (struct WinDesc *));
void FDECL(cmov, (int, int));
void FDECL(nocmov, (int, int));
STATIC_DCL void NDECL(init_ttycolor);
static void NDECL(init_ttycolor);
int savevmode; /* store the original video mode in here */
int curcol, currow; /* graphics mode current cursor locations */
@@ -571,8 +571,10 @@ const char *s;
}
}
void xputc(ch) /* write out character (and attribute) */
char ch;
/* same signature as 'putchar()' with potential failure result ignored */
int
xputc(ch) /* write out character (and attribute) */
int ch;
{
int i;
char attribute;
@@ -591,16 +593,17 @@ char ch;
vesa_xputc(ch, attribute);
#endif /*SCREEN_VESA*/
}
return 0;
}
void xputg(glyphnum, ch,
special) /* write out a glyph picture at current location */
/* write out a glyph picture at current location */
void xputg(glyphnum, ch, special)
int glyphnum;
int ch;
unsigned special;
{
if (!iflags.grmode || !iflags.tile_view) {
xputc((char) ch);
(void) xputc((char) ch);
#ifdef SCREEN_VGA
} else if (iflags.grmode && iflags.usevga) {
vga_xputg(glyphnum, ch, special);
@@ -719,7 +722,7 @@ char *schoice[3] = { "dark", "normal", "light" };
char *shade[3];
#endif /* VIDEOSHADES */
STATIC_OVL void
static void
init_ttycolor()
{
#ifdef VIDEOSHADES

View File

@@ -104,18 +104,18 @@
extern short glyph2tile[];
/* STATIC_DCL void FDECL(vga_NoBorder, (int)); */
/* static void FDECL(vga_NoBorder, (int)); */
void FDECL(vga_gotoloc, (int, int)); /* This should be made a macro */
void NDECL(vga_backsp);
#ifdef SCROLLMAP
STATIC_DCL void FDECL(vga_scrollmap, (BOOLEAN_P));
static void FDECL(vga_scrollmap, (BOOLEAN_P));
#endif
STATIC_DCL void FDECL(vga_redrawmap, (BOOLEAN_P));
static void FDECL(vga_redrawmap, (BOOLEAN_P));
static void FDECL(vga_cliparound, (int, int));
STATIC_OVL void FDECL(decal_planar, (struct planar_cell_struct *, unsigned));
static void FDECL(decal_planar, (struct planar_cell_struct *, unsigned));
#ifdef POSITIONBAR
STATIC_DCL void NDECL(positionbar);
static void NDECL(positionbar);
static void FDECL(vga_special, (int, int, int));
#endif
@@ -147,11 +147,11 @@ extern boolean inmap; /* in the map window */
* Global Variables
*/
STATIC_VAR unsigned char __far *font;
STATIC_VAR char *screentable[SCREENHEIGHT];
static unsigned char __far *font;
static char *screentable[SCREENHEIGHT];
STATIC_VAR const struct Pixel *paletteptr;
STATIC_VAR struct map_struct {
static const struct Pixel *paletteptr;
static struct map_struct {
int glyph;
int ch;
int attr;
@@ -171,13 +171,13 @@ STATIC_VAR struct map_struct {
}
#define TOP_MAP_ROW 1
STATIC_VAR int vgacmap[CLR_MAX] = { 1, 4, 6, 10, 5, 9, 0, 15,
static int vgacmap[CLR_MAX] = { 1, 4, 6, 10, 5, 9, 0, 15,
12, 3, 7, 8, 2, 9, 0, 14 };
STATIC_VAR int viewport_size = 40;
/* STATIC_VAR char masktable[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; */
/* STATIC_VAR char bittable[8]= {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; */
static int viewport_size = 40;
/* static char masktable[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; */
/* static char bittable[8]= {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; */
#if 0
STATIC_VAR char defpalette[] = { /* Default VGA palette */
static char defpalette[] = { /* Default VGA palette */
0x00, 0x00, 0x00,
0x00, 0x00, 0xaa,
0x00, 0xaa, 0x00,
@@ -202,10 +202,10 @@ int vp[SCREENPLANES] = { 8, 4, 2, 1 };
#endif
int vp2[SCREENPLANES] = { 1, 2, 4, 8 };
STATIC_VAR struct planar_cell_struct planecell;
STATIC_VAR struct overview_planar_cell_struct planecell_O;
static struct planar_cell_struct planecell;
static struct overview_planar_cell_struct planecell_O;
/* STATIC_VAR int g_attribute; */ /* Current attribute to use */
/* static int g_attribute; */ /* Current attribute to use */
void
vga_get_scr_size()
@@ -231,25 +231,20 @@ void
vga_clear_screen(colour)
int colour;
{
char __far *pch;
int y, j;
char volatile a;
unsigned long __far *pch;
unsigned j;
outportb(0x3ce, 5);
outportb(0x3cf, 2);
for (y = 0; y < SCREENHEIGHT; ++y) {
pch = screentable[y];
for (j = 0; j < SCREENBYTES; ++j) {
outportb(0x3ce, 8);
outportb(0x3cf, 255);
a = READ_ABSOLUTE(pch); /* Must read , then write */
WRITE_ABSOLUTE(pch, (char) colour);
++pch;
}
egawriteplane(colour);
pch = (unsigned long __far *) screentable[0];
for (j = 0; j < SCREENHEIGHT * SCREENBYTES / 4; ++j) {
WRITE_ABSOLUTE_DWORD(&pch[j], 0xFFFFFFFF);
}
outportb(0x3ce, 5);
outportb(0x3cf, 0);
egawriteplane(~colour);
pch = (unsigned long __far *) screentable[0];
for (j = 0; j < SCREENHEIGHT * SCREENBYTES / 4; ++j) {
WRITE_ABSOLUTE_DWORD(&pch[j], 0x00000000);
}
egawriteplane(15);
if (iflags.tile_view)
vga_clearmap();
vga_gotoloc(0, 0); /* is this needed? */
@@ -455,32 +450,26 @@ int x, y;
}
}
STATIC_OVL void
static void
vga_redrawmap(clearfirst)
boolean clearfirst;
{
int j, x, y, t;
char __far *pch;
char volatile a;
int x, y, t;
unsigned long __far *pch;
if (clearfirst) {
/* y here is in pixel rows */
outportb(0x3ce, 5);
outportb(0x3cf, 2);
unsigned j;
t = TOP_MAP_ROW * ROWS_PER_CELL;
for (y = t; y < (ROWNO * ROWS_PER_CELL) + t; ++y) {
pch = screentable[y];
for (j = 0; j < SCREENBYTES; ++j) {
outportb(0x3ce, 8);
outportb(0x3cf, 255);
/* On VGA mode2, must read first, then write */
a = READ_ABSOLUTE(pch);
WRITE_ABSOLUTE(pch, (char) BACKGROUND_VGA_COLOR);
++pch;
}
pch = (unsigned long __far *) screentable[t];
egawriteplane(BACKGROUND_VGA_COLOR);
for (j = 0; j < ROWNO * ROWS_PER_CELL * SCREENBYTES / 4; ++j) {
WRITE_ABSOLUTE_DWORD(&pch[j], 0xFFFFFFFF);
}
outportb(0x3ce, 5);
outportb(0x3cf, 0);
egawriteplane(~BACKGROUND_VGA_COLOR);
for (j = 0; j < ROWNO * ROWS_PER_CELL * SCREENBYTES / 4; ++j) {
WRITE_ABSOLUTE_DWORD(&pch[j], 0x00000000);
}
egawriteplane(15);
}
/* y here is in screen rows*/
#ifdef ROW_BY_ROW
@@ -578,7 +567,7 @@ vga_refresh()
}
#ifdef SCROLLMAP
STATIC_OVL void
static void
vga_scrollmap(left)
boolean left;
{
@@ -724,7 +713,7 @@ unsigned char (*indexes)[TILE_X];
}
}
STATIC_OVL void
static void
decal_planar(gp, special)
struct planar_cell_struct *gp;
unsigned special;
@@ -858,7 +847,7 @@ vga_Finish(void)
* to a more standard values - MJA 94/04/23.
*
*/
STATIC_OVL void
static void
vga_NoBorder(int bc)
{
union REGS regs;
@@ -941,36 +930,52 @@ int chr, col, row, colour;
int i;
int x, pixy;
char volatile tc;
char __far *cp;
unsigned char __far *fp = font;
unsigned char fnt;
int actual_colour = vgacmap[colour];
int vplane;
x = min(col, (CO - 1)); /* min() used protection from callers */
pixy = min(row, (LI - 1)) * 16; /* assumes 8 x 16 char set */
/* if (chr < ' ') chr = ' '; */ /* assumes ASCII set */
outportb(0x3ce, 5);
outportb(0x3cf, 2);
chr = chr << 4;
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
cp = screentable[pixy + i] + x;
fnt = READ_ABSOLUTE((fp + chr + i));
outportb(0x3ce, 8);
outportb(0x3cf, fnt);
tc = READ_ABSOLUTE(cp); /* wrt mode 2, must read, then write */
WRITE_ABSOLUTE(cp, (char) actual_colour);
outportb(0x3ce, 8);
outportb(0x3cf, ~fnt);
tc = READ_ABSOLUTE(cp); /* wrt mode 2, must read, then write */
WRITE_ABSOLUTE(cp, (char) BACKGROUND_VGA_COLOR);
vplane = ~actual_colour & ~BACKGROUND_VGA_COLOR & 0xF;
if (vplane != 0) {
egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
cp = screentable[pixy + i] + x;
WRITE_ABSOLUTE(cp, (char) 0x00);
}
}
outportb(0x3ce, 5);
outportb(0x3cf, 0);
outportb(0x3ce, 8);
outportb(0x3cf, 255);
vplane = actual_colour & ~BACKGROUND_VGA_COLOR & 0xF;
if (vplane != 0) {
egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
cp = screentable[pixy + i] + x;
fnt = READ_ABSOLUTE((fp + chr + i));
WRITE_ABSOLUTE(cp, (char) fnt);
}
}
vplane = ~actual_colour & BACKGROUND_VGA_COLOR & 0xF;
if (vplane != 0) {
egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
cp = screentable[pixy + i] + x;
fnt = ~READ_ABSOLUTE((fp + chr + i));
WRITE_ABSOLUTE(cp, (char) fnt);
}
}
vplane = actual_colour & BACKGROUND_VGA_COLOR & 0xF;
if (vplane != 0) {
egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
cp = screentable[pixy + i] + x;
WRITE_ABSOLUTE(cp, (char) 0xFF);
}
}
egawriteplane(15);
}
/*
@@ -1121,7 +1126,7 @@ char *posbar;
*p = 0;
}
STATIC_OVL void
static void
positionbar()
{
char *posbar = pbar;

View File

@@ -7,6 +7,7 @@
#include "hack.h"
#include "dlb.h"
#include "sfproto.h"
#ifndef NO_SIGNAL
#include <signal.h>
@@ -40,8 +41,8 @@ extern int bigscreen;
void NDECL(preserve_icon);
#endif
STATIC_DCL void FDECL(process_options, (int argc, char **argv));
STATIC_DCL void NDECL(nhusage);
static void FDECL(process_options, (int argc, char **argv));
static void NDECL(nhusage);
#if defined(MICRO) || defined(OS2)
extern void FDECL(nethack_exit, (int));
@@ -50,7 +51,7 @@ extern void FDECL(nethack_exit, (int));
#endif
#ifdef EXEPATH
STATIC_DCL char *FDECL(exepath, (char *));
static char *FDECL(exepath, (char *));
#endif
int FDECL(main, (int, char **));
@@ -530,7 +531,7 @@ attempt_restore:
return resuming;
}
STATIC_OVL void
static void
process_options(argc, argv)
int argc;
char *argv[];
@@ -661,7 +662,7 @@ char *argv[];
}
}
STATIC_OVL void
static void
nhusage()
{
char buf1[BUFSZ], buf2[BUFSZ], *bufptr;

View File

@@ -33,7 +33,7 @@ void FDECL(nethack_exit, (int));
#else
#define nethack_exit exit
#endif
STATIC_DCL void NDECL(msexit);
static void NDECL(msexit);
#ifdef MOVERLAY
extern void __far __cdecl _movepause(void);
@@ -45,9 +45,9 @@ extern unsigned short __far __cdecl _movefpaused;
#endif /* MOVERLAY */
#ifdef MFLOPPY
STATIC_DCL boolean NDECL(record_exists);
static boolean NDECL(record_exists);
#ifndef TOS
STATIC_DCL boolean NDECL(comspec_exists);
static boolean NDECL(comspec_exists);
#endif
#endif
@@ -305,7 +305,7 @@ int start;
}
/* Return 1 if the record file was found */
STATIC_OVL boolean
static boolean
record_exists()
{
FILE *fp;
@@ -324,7 +324,7 @@ record_exists()
#else
#ifdef MFLOPPY
/* Return 1 if the comspec was found */
STATIC_OVL boolean
static boolean
comspec_exists()
{
int fd;
@@ -492,7 +492,7 @@ int code;
extern boolean run_from_desktop; /* set in pcmain.c */
#endif
STATIC_OVL void
static void
msexit()
{
#ifdef CHDIR

View File

@@ -27,7 +27,7 @@ int FDECL(tgetnum, (const char *));
char *FDECL(tgetstr, (const char *, char **));
char *FDECL(tgoto, (const char *, int, int));
char *FDECL(tparam, (const char *, char *, int, int, int, int, int));
void FDECL(tputs, (const char *, int, int (*)()));
void FDECL(tputs, (const char *, int, int (*)(int)));
/* local support data */
static char *tc_entry;
@@ -502,9 +502,10 @@ int row, col, row2, col2;
/* send a string to the terminal, possibly padded with trailing NULs */
void
tputs(string, range, output_func)
const char *string; /* characters to output */
int range; /* number of lines affected, used for `*' delays */
int (*output_func)(); /* actual output routine; return value ignored */
const char *string; /* characters to output */
int range; /* number of lines affected, used for `*' delays */
int FDECL((*output_func),(int)); /* actual output routine;
* return value ignored */
{
register int c, num = 0;
register const char *p = string;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 unixtty.c $NHDT-Date: 1548372343 2019/01/24 23:25:43 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.6 unixtty.c $NHDT-Date: 1570652308 2019/10/09 20:18:28 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.26 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -243,6 +243,7 @@ const char *s;
iflags.cbreak = (CBRKON(inittyb.cbrkflgs & CBRKMASK)) ? ON : OFF;
curttyb.inputflags |= STRIPHI;
setioctls();
settty_needed = FALSE;
}
void
@@ -471,6 +472,9 @@ VA_DECL(const char *, s)
{
VA_START(s);
VA_INIT(s, const char *);
if (iflags.window_inited)
exit_nhwindows((char *) 0); /* for tty, will call settty() */
if (settty_needed)
settty((char *) 0);
Vprintf(s, VA_ARGS);

View File

@@ -1158,6 +1158,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 3189576821A1FCC100FB2ABE;
productRefGroup = 3189577221A1FCC100FB2ABE /* Products */;

View File

@@ -61,7 +61,15 @@ If you have problems, send us some email.
nethack-bugs@nethack.org
Recommended steps:
1. cd sys/unix
2. sh setup.sh hints/linux
3. cd ../..
4. make all; su; make install
The older instructions are retained below...
Steps used to build this binary release, in addition to the basic
instructions found in sys/unix/Install.unx. The step numbers below
@@ -69,7 +77,7 @@ correspond to the step numbers in sys/unix/Install.unx.
System: gcc-3.2, XFree86-libs-4.2.1, ncurses-5.2, glibc-2.3.2 (GLIBC_2.3)
3. Edit include/config.h and include/unixconf.h
1. Edit include/config.h and include/unixconf.h
config.h: define X11_GRAPHICS window support.
define USE_XPM support.
define COMPRESS as /bin/gzip as that is where it
@@ -80,12 +88,12 @@ System: gcc-3.2, XFree86-libs-4.2.1, ncurses-5.2, glibc-2.3.2 (GLIBC_2.3)
unixconf.h: define LINUX
define TIMED_DELAY
6. Makefile.src: define modern, non-BSD Linux and linux options throughout
2. Makefile.src: define modern, non-BSD Linux and linux options throughout
CC = gcc
LFLAGS = -L/usr/X11R6/lib
WINSRC = $(WINTTYSRC) $(WINX11SRC)
WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
WINTTYLIB = /usr/lib/libncurses.a
WINTTYLIB = -lncurses
WINX11LIB = -lXaw -lXmu -lXext -lXt -lXpm -lX11
WINLIB = $(WINTTYLIB) $(WINX11LIB)
@@ -96,7 +104,7 @@ System: gcc-3.2, XFree86-libs-4.2.1, ncurses-5.2, glibc-2.3.2 (GLIBC_2.3)
YACC = bison -y
LEX = flex
7. Makefile.top: GAMEGRP = games
3. Makefile.top: GAMEGRP = games
GAMEPERM = 02755
FILEPERM = 0664
EXEPERM = 0755
@@ -105,5 +113,5 @@ System: gcc-3.2, XFree86-libs-4.2.1, ncurses-5.2, glibc-2.3.2 (GLIBC_2.3)
make all; su; make install
9. Additional step: As discussed in win/X11/Install.X11, convert nh10.bdf
4. Additional step: As discussed in win/X11/Install.X11, convert nh10.bdf
and ibm.bdf to proper font files and place in font path.

View File

@@ -1,5 +1,5 @@
#
# NetHack 3.6 linux-qt4 $NHDT-Date: 1432512814 2015/05/25 00:13:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $
# NetHack 3.6 linux-qt4 $NHDT-Date: 1566346592 2019/08/21 00:16:32 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#
@@ -18,7 +18,7 @@ VARDIR = $(HACKDIR)
POSTINSTALL= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
CFLAGS=-g -O -I../include -DNOTPARMDECL
CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"

View File

@@ -1,5 +1,5 @@
#
# NetHack 3.6 linux-qt5 $NHDT-Date: 1432512814 2015/05/25 00:13:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $
# NetHack 3.6 linux-qt5 $NHDT-Date: 1566346602 2019/08/21 00:16:42 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#
@@ -18,7 +18,7 @@ VARDIR = $(HACKDIR)
POSTINSTALL= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
CFLAGS=-g -O -I../include -DNOTPARMDECL
CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"

View File

@@ -1,5 +1,5 @@
#
# NetHack 3.6 linux-x11 $NHDT-Date: 1432512814 2015/05/25 00:13:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $
# NetHack 3.6 linux-x11 $NHDT-Date: 1566346602 2019/08/21 00:16:42 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.24 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#
@@ -18,7 +18,7 @@ VARDIR = $(HACKDIR)
POSTINSTALL= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
CFLAGS=-g -O -I../include -DNOTPARMDECL
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\"

View File

@@ -1,13 +1,12 @@
#
# NetHack 3.6 macosx $NHDT-Date: 1447844580 2015/11/18 11:03:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $
# NetHack 3.6 macosx $NHDT-Date: 1566346603 2019/08/21 00:16:43 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.20 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.4.10 (Darwin 8.10). If this doesn't work for some
# other version of either Darwin or Mac OS X, make a new file for that OS,
# don't change this one. And let us know about it.
# This is for Mac OS X 10.4 (Darwin 8.10). Use one of the more specific
# hints files for later versions.
# Useful info: http://www.opensource.apple.com/darwinsource/index.html
# This hints file can build several different types of installations.
@@ -72,7 +71,7 @@ WINOBJ += $(WINX11OBJ)
WINLIB += $(WINX11LIB)
LFLAGS=-L/usr/X11R6/lib
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir)
POSTINSTALL= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev )
CFLAGS += -DX11_GRAPHICS
endif

View File

@@ -1,11 +1,11 @@
#
# NetHack 3.6 macosx10.11 $NHDT-Date: 1546220383 2018/12/31 01:39:43 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.51 $
# NetHack 3.6 macosx10.11 $NHDT-Date: 1566346603 2019/08/21 00:16:43 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.53 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.10 or later, and has been tested on 10.11
# This is for Mac OS X 10.10 through 10.13, and has been tested on 10.11
# (El Capitan) and 10.13. If this doesn't work for some other
# version of Mac OS X, make a new file for that OS, don't change this one.
# And let us know about it.
@@ -108,7 +108,8 @@ endif
ifdef WANT_WIN_X11
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; (cd $(HACKDIR); mkfontdir);
# -x: if built without dlb, some versions of mkfontdir think *.lev are fonts
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
# separate from CFLAGS so that we don't pass it to every file
X11CFLAGS = -I/opt/X11/include
CFLAGS += -DX11_GRAPHICS
@@ -204,7 +205,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -1,12 +1,12 @@
#
# NetHack 3.6 macosx10.11 $NHDT-Date: 1515549543 2018/01/10 01:59:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.48 $
# NetHack 3.6 macosx10.11 $NHDT-Date: 1566346604 2019/08/21 00:16:44 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.51 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.10 or later, and has been tested on 10.11
# (El Capitan). If this doesn't work for some other
# This is for the Qt interface on Mac OS X 10.10 through 10.13, and has
# been tested on 10.11 (El Capitan). If this doesn't work for some other
# version of Mac OS X, make a new file for that OS, don't change this one.
# And let us know about it.
# Useful info: http://www.opensource.apple.com/darwinsource/index.html
@@ -106,7 +106,7 @@ WINOBJ0 += $(WINX11OBJ)
WINLIB += $(WINX11LIB)
LFLAGS += -L/opt/X11/lib
VARDATND += x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; (cd $(HACKDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
CFLAGS += -DX11_GRAPHICS -I/opt/X11/include
# avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h>
CFLAGS += -Wno-variadic-macros
@@ -184,7 +184,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -1,5 +1,5 @@
#
# NetHack 3.6 macosx10.14 $NHDT-Date: 1546225353 2018/12/31 03:02:33 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.57 $
# NetHack 3.6 macosx10.14 $NHDT-Date: 1566346605 2019/08/21 00:16:45 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.59 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015.
# NetHack may be freely redistributed. See license for details.
#
@@ -108,7 +108,7 @@ endif
ifdef WANT_WIN_X11
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; (cd $(HACKDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
# separate from CFLAGS so that we don't pass it to every file
X11CFLAGS = -I/opt/X11/include
CFLAGS += -DX11_GRAPHICS
@@ -204,7 +204,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -1,11 +1,12 @@
#
# NetHack 3.6 macosx10.5 $NHDT-Date: 1546082882 2018/12/29 11:28:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.30 $
# NetHack 3.6 macosx10.5 $NHDT-Date: 1566346606 2019/08/21 00:16:46 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.32 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2009.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.5.3 (Darwin 9.3). If this doesn't work for some
# This is for Mac OS X 10.5 (Darwin 9.3) and also 10.6.
# If this doesn't work for some
# other version of either Darwin or Mac OS X, make a new file for that OS,
# don't change this one. And let us know about it.
# Useful info: http://www.opensource.apple.com/darwinsource/index.html
@@ -78,7 +79,7 @@ endif # !WANT_WIN_TTY
ifdef WANT_WIN_X11
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
CFLAGS += -DX11_GRAPHICS
ifdef USE_XPM
CFLAGS += -DUSE_XPM
@@ -176,7 +177,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -1,11 +1,12 @@
#
# NetHack 3.6 macosx10.7 $NHDT-Date: 1546082882 2018/12/29 11:28:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.34 $
# NetHack 3.6 macosx10.7 $NHDT-Date: 1566346606 2019/08/21 00:16:46 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.36 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2009.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.7.2. If this doesn't work for some other version
# This is for Mac OS X 10.7.
# If this doesn't work for some other version
# of Mac OS X, make a new file for that OS, don't change this one. And
# let us know about it.
# Useful info: http://www.opensource.apple.com/darwinsource/index.html
@@ -95,7 +96,7 @@ endif # !WANT_WIN_TTY
ifdef WANT_WIN_X11
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
CFLAGS += -DX11_GRAPHICS
ifdef USE_XPM
CFLAGS += -DUSE_XPM
@@ -194,7 +195,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -1,11 +1,11 @@
#
# NetHack 3.6 macosx10.8 $NHDT-Date: 1546220385 2018/12/31 01:39:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.36 $
# NetHack 3.6 macosx10.8 $NHDT-Date: 1566346607 2019/08/21 00:16:47 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.38 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2009.
# NetHack may be freely redistributed. See license for details.
#
#-PRE
# Mac OS X (Darwin) hints file
# This is for Mac OS X 10.8, Mountain Lion.
# This is for Mac OS X 10.8, Mountain Lion, and also 10.9.
#
# X11 is no longer included with OSX.
# To regain X11, download and install XQuartz. (Attempting to run X11.app
@@ -103,7 +103,7 @@ endif # !WANT_WIN_TTY
ifdef WANT_WIN_X11
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; ( cd $(INSTDIR); mkfontdir -x .lev );
# separate from CFLAGS so that we don't pass it to every file
X11CFLAGS = -I/opt/X11/include
CFLAGS += -DX11_GRAPHICS
@@ -206,7 +206,7 @@ VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef WANT_WIN_X11
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
endif # WANT_WIN_X11
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE

View File

@@ -61,6 +61,11 @@ MAXPLAYERS=10
# incubi to use nymphs' charm behavior rather than their own seduce behavior.
#SEDUCE=0
# Uncomment the next line to enable some accessibility features such
# as S_player_override and S_pet_override symbols for screen readers
# in the user config file.
#ACCESSIBILITY=1
# Uncomment to disable savefile UID checking.
#CHECK_SAVE_UID=0

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 unixmain.c $NHDT-Date: 1432512788 2015/05/25 00:13:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.52 $ */
/* NetHack 3.6 unixmain.c $NHDT-Date: 1570408210 2019/10/07 00:30:10 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.70 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -50,7 +50,6 @@ main(argc, argv)
int argc;
char *argv[];
{
register int fd;
#ifdef CHDIR
register char *dir;
#endif
@@ -118,7 +117,7 @@ char *argv[];
if (argcheck(argc, argv, ARG_DEBUG) == 1) {
argc--;
argv++;
}
}
if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
/* avoid matching "-dec" for DECgraphics; since the man page
@@ -263,7 +262,7 @@ char *argv[];
* First, try to find and restore a save file for specified character.
* We'll return here if new game player_selection() renames the hero.
*/
attempt_restore:
attempt_restore:
/*
* getlock() complains and quits if there is already a game
@@ -532,8 +531,8 @@ whoami()
{
/*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS
* 2. Use $USER or $LOGNAME (if 1. fails)
* 3. Use getlogin() (if 2. fails)
* 2. Use $USER or $LOGNAME (if 1. fails)
* 3. Use getlogin() (if 2. fails)
* The resulting name is overridden by command line options.
* If everything fails, or if the resulting name is some generic
* account like "games", "play", "player", "hack" then eventually
@@ -652,20 +651,20 @@ boolean
check_user_string(optstr)
char *optstr;
{
struct passwd *pw = get_unix_pw();
struct passwd *pw;
int pwlen;
char *eop, *w;
char *pwname;
char *pwname = 0;
if (optstr[0] == '*')
return TRUE; /* allow any user */
if (!pw)
return FALSE;
if (sysopt.check_plname)
pwname = g.plname;
else
else if ((pw = get_unix_pw()) != 0)
pwname = pw->pw_name;
pwlen = strlen(pwname);
if (!pwname || !*pwname)
return FALSE;
pwlen = (int) strlen(pwname);
eop = eos(optstr);
w = optstr;
while (w + pwlen <= eop) {
@@ -723,7 +722,6 @@ get_login_name()
struct passwd *pw = get_unix_pw();
buf[0] = '\0';
if (pw)
(void)strcpy(buf, pw->pw_name);
@@ -740,31 +738,33 @@ char *buf;
/* This should be replaced when there is a Cocoa port. */
const char *errfmt;
size_t len;
FILE *PB = popen("/usr/bin/pbcopy","w");
if(!PB){
errfmt = "Unable to start pbcopy (%d)\n";
goto error;
FILE *PB = popen("/usr/bin/pbcopy", "w");
if (!PB) {
errfmt = "Unable to start pbcopy (%d)\n";
goto error;
}
len = strlen(buf);
/* Remove the trailing \n, carefully. */
if(buf[len-1] == '\n') len--;
if (buf[len - 1] == '\n')
len--;
/* XXX Sorry, I'm too lazy to write a loop for output this short. */
if(len!=fwrite(buf,1,len,PB)){
errfmt = "Error sending data to pbcopy (%d)\n";
goto error;
if (len != fwrite(buf, 1, len, PB)) {
errfmt = "Error sending data to pbcopy (%d)\n";
goto error;
}
if(pclose(PB)!=-1){
return;
if (pclose(PB) != -1) {
return;
}
errfmt = "Error finishing pbcopy (%d)\n";
error:
raw_printf(errfmt,strerror(errno));
error:
raw_printf(errfmt, strerror(errno));
}
#endif
#endif /* __APPLE__ */
unsigned long
sys_random_seed()

View File

@@ -104,7 +104,8 @@ OPTIONS=suppress_alert:3.3.1
# Map window settings
# possible map_mode options include: tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|
# ascii7x12|ascii8x12|ascii16x12|ascii12x16|
# ascii10x18|fit_to_screen
# ascii10x18|fit_to_screen|ascii_fit_to_screen|
# tiles_fit_to_screen
OPTIONS=map_mode:tiles,scroll_margin:10
# Message window settings

View File

@@ -3,7 +3,7 @@
==============================================================
Instructions for compiling and installing
NetHack 3.6 on a Windows system
(Windows 7/8.x/10 or later only. XP may work but is untested)
(Windows 7/8.x/10 or later only)
==============================================================
Last revision: $NHDT-Date: 1554784481 2019/04/09 04:34:41 $

View File

@@ -99,8 +99,8 @@ TARGET_CPU=x86
# of your PDCurses C files which must already be resident on
# your machine.
#
#ADD_CURSES=Y
#PDCURSES_TOP=../../pdcurses
# ADD_CURSES=Y
# PDCURSES_TOP=../../pdcurses
#4b Qt
#
@@ -209,7 +209,7 @@ RANDOM = $(OBJ)/random.o
#RANDOM =
BCRYPT=-lbcrypt
WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501
WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0601 -DWINVER=0x0601
ifeq "$(WANT_WIN_QT4)" "Y"
WINPFLAG += -DQT_GRAPHICS -DPIXMAPDIR='"."'
endif
@@ -454,12 +454,11 @@ PDCSRC = $(PDCURSES_TOP)/pdcurses
PDCWINCON = $(PDCURSES_TOP)/wincon
PDCLIBOBJS = $(O)addch.o $(O)addchstr.o $(O)addstr.o $(O)attr.o $(O)beep.o \
$(O)bkgd.o $(O)border.o $(O)clear.o $(O)color.o $(O)delch.o $(O)deleteln.o \
$(O)deprec.o $(O)getch.o $(O)getstr.o $(O)getyx.o $(O)inch.o $(O)inchstr.o \
$(O)getch.o $(O)getstr.o $(O)getyx.o $(O)inch.o $(O)inchstr.o \
$(O)initscr.o $(O)inopts.o $(O)insch.o $(O)insstr.o $(O)instr.o $(O)kernel.o \
$(O)keyname.o $(O)mouse.o $(O)move.o $(O)outopts.o $(O)overlay.o $(O)pad.o \
$(O)panel.o $(O)printw.o $(O)refresh.o $(O)scanw.o $(O)scr_dump.o $(O)scroll.o \
$(O)slk.o $(O)termattr.o $(O)terminfo.o $(O)touch.o $(O)util.o $(O)window.o \
$(O)debug.o
$(O)slk.o $(O)termattr.o $(O)touch.o $(O)util.o $(O)window.o $(O)debug.o
PDCOBJS = $(O)pdcclip.o $(O)pdcdisp.o $(O)pdcgetsc.o $(O)pdckbd.o $(O)pdcscrn.o \
$(O)pdcsetsc.o $(O)pdcutil.o
@@ -556,9 +555,9 @@ endif
CFLAGSBASE = -c $(cflags) $(WINPINC) $(cdebug) $(CURSESDEF)
#LFLAGSBASEC = $(linkdebug)
#LFLAGSBASEG = $(linkdebug) -mwindows
conlibs = -lgdi32 -lwinmm $(BCRYPT)
guilibs = -lcomctl32 -lwinmm
baselibs = -lwinmm -lshell32 -lole32 -luuid
conlibs = -lgdi32 $(baselibs) $(BCRYPT)
guilibs = -lcomctl32 $(baselibs)
ifeq "$(WANT_WIN_QT4)" "Y"
# Might be either Qt 4 or Qt 5
ifeq "$(HAVE_QT5)" "Y"
@@ -772,11 +771,11 @@ else
# $(subst /,\,copy $(DAT)/*.lua $(GAMEDIR))
$(subst /,\,if exist $(GAMEDIR)/makefile del $(GAMEDIR)/makefile)
endif
$(subst /,\,if not exist $(GAMEDIR)/sysconf copy $(MSWSYS)/sysconf $(GAMEDIR))
$(subst /,\,if exist $(DAT)/symbols copy $(DAT)/symbols $(GAMEDIR))
$(subst /,\,if exist $(MSWSYS)/sysconf.template copy $(MSWSYS)/sysconf.template $(GAMEDIR))
$(subst /,\,if exist $(DAT)/symbols copy $(DAT)/symbols $(GAMEDIR)/symbols.template)
$(subst /,\,if exist $(DOC)/guidebook.txt copy $(DOC)/guidebook.txt $(GAMEDIR)/Guidebook.txt)
$(subst /,\,if exist $(DOC)/nethack.txt copy $(DOC)/nethack.txt $(GAMEDIR)/NetHack.txt)
$(subst /,\,if not exist $(GAMEDIR)/defaults.nh copy $(MSWSYS)/defaults.nh $(GAMEDIR)/defaults.nh)
$(subst /,\,if exist $(MSWSYS)/.nethackrc.template copy $(MSWSYS)/.nethackrc.template $(GAMEDIR))
$(subst /,\,-if not exist $(GAMEDIR)/record. echo.>$(GAMEDIR)/record.)
#
#

View File

@@ -1,4 +1,4 @@
# NetHack 3.7 Makefile.msc $NHDT-Date: 1554784482 2019/04/09 04:34:42 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.153 $ */
# NetHack 3.6 Makefile.msc $NHDT-Date: 1572748386 2019/11/03 02:33:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.167 $ */
# Copyright (c) NetHack PC Development Team 1993-2019
#
#==============================================================================
@@ -593,7 +593,8 @@ guilflags = $(lflags) -subsystem:windows,$(EXEVER)
dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
# basic subsystem specific libraries, less the C Run-Time
baselibs = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib gdi32.lib
baselibs = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib gdi32.lib \
ole32.lib Shell32.lib
winlibs = $(baselibs) user32.lib comdlg32.lib winspool.lib
# for Windows applications that use the C Run-Time libraries
@@ -902,13 +903,13 @@ $(O)install.tag: $(DAT)\data $(DAT)\rumors $(DAT)\dungeon \
copy $(DAT)\*.dat $(GAMEDIR)
if exist $(GAMEDIR)\makefile del $(GAMEDIR)\makefile
! ENDIF
if not exist $(GAMEDIR)\sysconf copy $(MSWSYS)\sysconf $(GAMEDIR)
if exist $(DAT)\symbols copy $(DAT)\symbols $(GAMEDIR)
if exist $(MSWSYS)\sysconf.template copy $(MSWSYS)\sysconf.temnplate $(GAMEDIR)
if exist $(DAT)\symbols copy $(DAT)\symbols $(GAMEDIR)\symbols.template
if exist $(DOC)\guidebook.txt copy $(DOC)\guidebook.txt $(GAMEDIR)\Guidebook.txt
if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)\NetHack.txt
@if exist $(GAMEDIR)\NetHack.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHack.PDB to conserve space
@if exist $(GAMEDIR)\NetHackW.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHackW.PDB to conserve space
-if not exist $(GAMEDIR)\defaults.nh copy $(MSWSYS)\defaults.nh $(GAMEDIR)\defaults.nh
-if exist $(MSWSYS)\.nethackrc.template copy $(MSWSYS)\.nethackrc.template $(GAMEDIR)
-if not exist $(GAMEDIR)\record. goto>$(GAMEDIR)\record.
echo install done > $@

View File

@@ -465,8 +465,15 @@ int *x, *y, *mod;
coord cc;
DWORD count;
really_move_cursor();
if (iflags.debug_fuzzer)
return randomkey();
if (iflags.debug_fuzzer) {
int poskey = randomkey();
if (poskey == 0) {
*x = rn2(console.width);
*y = rn2(console.height);
}
return poskey;
}
ch = (g.program_state.done_hup)
? '\033'
: keyboard_handler.pCheckInput(
@@ -530,12 +537,14 @@ int x, y;
set_console_cursor(x, y);
}
void
/* same signature as 'putchar()' with potential failure result ignored */
int
xputc(ch)
char ch;
int ch;
{
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
xputc_core(ch);
xputc_core((char) ch);
return 0;
}
void
@@ -543,7 +552,7 @@ xputs(s)
const char *s;
{
int k;
int slen = strlen(s);
int slen = (int) strlen(s);
if (ttyDisplay)
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
@@ -1597,8 +1606,8 @@ check_font_widths()
boolean used[256];
memset(used, 0, sizeof(used));
for (int i = 0; i < SYM_MAX; i++) {
used[g.l_syms[i]] = TRUE;
used[g.r_syms[i]] = TRUE;
used[g.primary_syms[i]] = TRUE;
used[g.rogue_syms[i]] = TRUE;
}
int wcUsedCount = 0;

View File

@@ -82,11 +82,11 @@ int mode;
return;
}
void
int
xputc(ch)
char ch;
int ch;
{
return;
return 0;
}
void

View File

@@ -52,6 +52,11 @@ WIZARDS=*
# Uncomment the next line to disable the SEDUCE option.
#SEDUCE=0
# Uncomment the next line to enable some accessibility features such
# as S_player_override and S_pet_override symbols for screen readers
# in the user config file.
#ACCESSIBILITY=1
# Record (high score) file options.
# CAUTION: changing these after people have started playing games can
# lead to lost high scores!

View File

@@ -9,6 +9,21 @@
#include "hack.h"
typedef DPI_AWARENESS_CONTEXT(WINAPI *GetThreadDpiAwarenessContextProc)(VOID);
typedef BOOL(WINAPI *AreDpiAwarenessContextsEqualProc)(
DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
typedef UINT(WINAPI *GetDpiForWindowProc)(HWND hwnd);
typedef LONG (WINAPI *GetCurrentPackageFullNameProc)(UINT32 *packageFullNameLength,
PWSTR packageFullName);
typedef struct {
BOOL Valid;
GetThreadDpiAwarenessContextProc GetThreadDpiAwarenessContext;
AreDpiAwarenessContextsEqualProc AreDpiAwarenessContextsEqual;
GetDpiForWindowProc GetDpiForWindow;
GetCurrentPackageFullNameProc GetCurrentPackageFullName;
} Win10;
Win10 gWin10 = { 0 };
void win10_init()
@@ -34,6 +49,17 @@ void win10_init()
FreeLibrary(hUser32);
HINSTANCE hKernel32 = LoadLibraryA("kernel32.dll");
if (hKernel32 == NULL)
panic("Unable to load kernel32.dll");
gWin10.GetCurrentPackageFullName = (GetCurrentPackageFullNameProc) GetProcAddress(hKernel32, "GetCurrentPackageFullName");
if (gWin10.GetCurrentPackageFullName == NULL)
panic("Unable to get address of GetCurrentPackageFullName");
FreeLibrary(hKernel32);
gWin10.Valid = TRUE;
}
@@ -80,4 +106,19 @@ void win10_monitor_info(HWND hWnd, MonitorInfo * monitorInfo)
monitorInfo->left = info.rcMonitor.left;
monitorInfo->top = info.rcMonitor.top;
}
BOOL
win10_is_desktop_bridge_application()
{
if (gWin10.Valid) {
UINT32 length = 0;
LONG rc = gWin10.GetCurrentPackageFullName(&length, NULL);
return (rc == ERROR_INSUFFICIENT_BUFFER);
}
return FALSE;
}
#endif /* _MSC_VER */

View File

@@ -7,18 +7,6 @@
#include "win32api.h"
typedef DPI_AWARENESS_CONTEXT(WINAPI *GetThreadDpiAwarenessContextProc)(VOID);
typedef BOOL(WINAPI *AreDpiAwarenessContextsEqualProc)(
DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
typedef UINT(WINAPI *GetDpiForWindowProc)(HWND hwnd);
typedef struct {
BOOL Valid;
GetThreadDpiAwarenessContextProc GetThreadDpiAwarenessContext;
AreDpiAwarenessContextsEqualProc AreDpiAwarenessContextsEqual;
GetDpiForWindowProc GetDpiForWindow;
} Win10;
typedef struct {
double scale; // dpi of monitor / 96
int width; // in pixels
@@ -27,13 +15,10 @@ typedef struct {
int left; // in desktop coordinate pixel space
} MonitorInfo;
extern Win10 gWin10;
void win10_init();
int win10_monitor_dpi(HWND hWnd);
double win10_monitor_scale(HWND hWnd);
void win10_monitor_size(HWND hWnd, int * width, int * height);
void win10_monitor_info(HWND hWnd, MonitorInfo * monitorInfo);
BOOL win10_is_desktop_bridge_application(void);
#endif // WIN10_H

View File

@@ -8,12 +8,10 @@
#include "hack.h"
#include "dlb.h"
#include <ctype.h>
#include <stdlib.h>
#include <sys\stat.h>
#include <errno.h>
#if 0
#include "wintty.h"
#endif
#include <ShlObj.h>
#if !defined(SAFEPROCS)
#error You must #define SAFEPROCS to build windmain.c
@@ -22,7 +20,7 @@
#define E extern
static void FDECL(process_options, (int argc, char **argv));
static void NDECL(nhusage);
static char *FDECL(exepath, (char *));
static char *NDECL(get_executable_path);
char *NDECL(exename);
boolean NDECL(fakeconsole);
void NDECL(freefakeconsole);
@@ -49,7 +47,6 @@ extern int NDECL(windows_console_custom_nhgetch);
void NDECL(safe_routines);
char orgdir[PATHLEN];
char *dir;
boolean getreturn_enabled;
extern int redirect_stdout; /* from sys/share/pcsys.c */
extern int GUILaunched;
@@ -66,6 +63,281 @@ static struct stat hbuf;
extern char orgdir[];
void
get_known_folder_path(
const KNOWNFOLDERID * folder_id,
char * path
, size_t path_size)
{
PWSTR wide_path;
if (FAILED(SHGetKnownFolderPath(folder_id, 0, NULL, &wide_path)))
error("Unable to get known folder path");
size_t converted;
errno_t err;
err = wcstombs_s(&converted, path, path_size, wide_path, path_size - 1);
CoTaskMemFree(wide_path);
if (err != 0) error("Failed folder path string conversion");
}
void
create_directory(const char * path)
{
HRESULT hr = CreateDirectoryA(path, NULL);
if (FAILED(hr) && hr != ERROR_ALREADY_EXISTS)
error("Unable to create directory '%s'", path);
}
void
build_known_folder_path(
const KNOWNFOLDERID * folder_id,
char * path,
size_t path_size)
{
get_known_folder_path(folder_id, path, path_size);
strcat(path, "\\NetHack\\");
create_directory(path);
strcat(path, "3.6\\");
create_directory(path);
}
void
build_environment_path(
const char * env_str,
const char * folder,
char * path,
size_t path_size)
{
path[0] = '\0';
const char * root_path = nh_getenv(env_str);
if (root_path == NULL) return;
strcpy_s(path, path_size, root_path);
char * colon = index(path, ';');
if (colon != NULL) path[0] = '\0';
if (strlen(path) == 0) return;
append_slash(path);
if (folder != NULL) {
strcat_s(path, path_size, folder);
strcat_s(path, path_size, "\\");
}
}
boolean
folder_file_exists(const char * folder, const char * file_name)
{
char path[MAX_PATH];
if (folder[0] == '\0') return FALSE;
strcpy(path, folder);
strcat(path, file_name);
return file_exists(path);
}
/*
* Rules for setting prefix locations
*
* COMMON_NETHACK_PATH = %COMMONPROGRAMFILES%\NetHack\3.6\
* PROFILE_PATH = %SystemDrive%\Users\%USERNAME%\
*
* NETHACK_PROFILE_PATH = PROFILE_PATH\NetHack\3.6\
* NETHACK_PER_USER_DATA_PATH = PROFILE_PATH\AppData\Local\NetHack\3.6\
* NETHACK_GLOBAL_DATA_PATH = %SystemDrive%\ProgramData\NetHack\3.6\
* EXECUTABLE_PATH = path to where .exe lives
*
* HACKPREFIX:
* - use environment variable NETHACKDIR if variable is defined
* - otherwise use environment variable HACKDIR if variable is defined
* - otherwise if store install use NETHACK_PROFILE_PATH
* - otherwise if manual install use EXECUTABLE_PATH
*
* LEVELPREFIX, SAVEPREFIX:
* - if store install use NETHACK_PER_USER_DATA_PATH
* - if manual install use HACKPREFIX
*
* BONESPREFIX, SCOREPREFIX, LOCKPREFIX:
* - if store install use NETHACK_GLOBAL_DATA_PATH
* - if manual install use HACKPREFIX
*
* DATAPREFIX
* - if store install use EXECUTABLE_PATH
* - if manual install use HACKPREFIX
*
* SYSCONFPREFIX
* - use COMMON_NETHACK_PATH if sysconf present
* - otherwise use HACKPREFIX
*
* CONFIGPREFIX
* - if manual install use PROFILE_PATH
* - if store install use NETHACK_PROFILE_PATH
*/
void
set_default_prefix_locations(const char *programPath)
{
char *envp = NULL;
char *sptr = NULL;
static char hack_path[MAX_PATH];
static char executable_path[MAX_PATH];
static char nethack_profile_path[MAX_PATH];
static char nethack_per_user_data_path[MAX_PATH];
static char nethack_global_data_path[MAX_PATH];
static char sysconf_path[MAX_PATH];
strcpy(executable_path, get_executable_path());
append_slash(executable_path);
build_environment_path("NETHACKDIR", NULL, hack_path, sizeof(hack_path));
if (hack_path[0] == '\0')
build_environment_path("HACKDIR", NULL, hack_path, sizeof(hack_path));
build_known_folder_path(&FOLDERID_Profile, nethack_profile_path,
sizeof(nethack_profile_path));
build_known_folder_path(&FOLDERID_LocalAppData,
nethack_per_user_data_path, sizeof(nethack_per_user_data_path));
build_known_folder_path(&FOLDERID_ProgramData,
nethack_global_data_path, sizeof(nethack_global_data_path));
if (hack_path[0] == '\0')
strcpy(hack_path, nethack_profile_path);
g.fqn_prefix[LEVELPREFIX] = nethack_per_user_data_path;
g.fqn_prefix[SAVEPREFIX] = nethack_per_user_data_path;
g.fqn_prefix[BONESPREFIX] = nethack_global_data_path;
g.fqn_prefix[DATAPREFIX] = executable_path;
g.fqn_prefix[SCOREPREFIX] = nethack_global_data_path;
g.fqn_prefix[LOCKPREFIX] = nethack_global_data_path;
g.fqn_prefix[CONFIGPREFIX] = nethack_profile_path;
g.fqn_prefix[HACKPREFIX] = hack_path;
g.fqn_prefix[TROUBLEPREFIX] = hack_path;
build_environment_path("COMMONPROGRAMFILES", "NetHack\\3.6", sysconf_path,
sizeof(sysconf_path));
if(!folder_file_exists(sysconf_path, SYSCF_FILE))
strcpy(sysconf_path, hack_path);
g.fqn_prefix[SYSCONFPREFIX] = sysconf_path;
}
/* copy file if destination does not exist */
void
copy_file(
const char * dst_folder,
const char * dst_name,
const char * src_folder,
const char * src_name)
{
char dst_path[MAX_PATH];
strcpy(dst_path, dst_folder);
strcat(dst_path, dst_name);
char src_path[MAX_PATH];
strcpy(src_path, src_folder);
strcat(src_path, src_name);
if(!file_exists(src_path))
error("Unable to copy file '%s' as it does not exist", src_path);
if(file_exists(dst_path))
return;
BOOL success = CopyFileA(src_path, dst_path, TRUE);
if(!success) error("Failed to copy '%s' to '%s'", src_path, dst_path);
}
/* update file copying if it does not exist or src is newer then dst */
void
update_file(
const char * dst_folder,
const char * dst_name,
const char * src_folder,
const char * src_name,
BOOL save_copy)
{
char dst_path[MAX_PATH];
strcpy(dst_path, dst_folder);
strcat(dst_path, dst_name);
char src_path[MAX_PATH];
strcpy(src_path, src_folder);
strcat(src_path, src_name);
char save_path[MAX_PATH];
strcpy(save_path, dst_folder);
strcat(save_path, dst_name);
strcat(save_path, ".save");
if(!file_exists(src_path))
error("Unable to copy file '%s' as it does not exist", src_path);
if (!file_newer(src_path, dst_path))
return;
if (file_exists(dst_path) && save_copy)
CopyFileA(dst_path, save_path, FALSE);
BOOL success = CopyFileA(src_path, dst_path, FALSE);
if(!success) error("Failed to update '%s' to '%s'", src_path, dst_path);
}
void copy_config_content()
{
/* Keep templates up to date */
/* TODO: Update the package to store config file as .nethackrc */
update_file(g.fqn_prefix[CONFIGPREFIX], CONFIG_TEMPLATE,
g.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE, FALSE);
update_file(g.fqn_prefix[SYSCONFPREFIX], SYSCF_TEMPLATE,
g.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE, FALSE);
/* If the required early game file does not exist, copy it */
/* NOTE: We never replace .nethackrc or sysconf */
copy_file(g.fqn_prefix[CONFIGPREFIX], CONFIG_FILE,
g.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE);
copy_file(g.fqn_prefix[SYSCONFPREFIX], SYSCF_FILE,
g.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE);
/* Update symbols and save a copy if we are replacing */
/* TODO: Can't HACKDIR be changed during option parsing
causing us to perhaps be checking options against the wrong
symbols file? */
update_file(g.fqn_prefix[HACKPREFIX], SYMBOLS,
g.fqn_prefix[DATAPREFIX], SYMBOLS_TEMPLATE, TRUE);
}
void
copy_hack_content()
{
/* Keep Guidebook and opthelp up to date */
update_file(g.fqn_prefix[HACKPREFIX], GUIDEBOOK_FILE,
g.fqn_prefix[DATAPREFIX], GUIDEBOOK_FILE, FALSE);
update_file(g.fqn_prefix[HACKPREFIX], OPTIONFILE,
g.fqn_prefix[DATAPREFIX], OPTIONFILE, FALSE);
/* Keep templates up to date */
update_file(g.fqn_prefix[HACKPREFIX], SYMBOLS_TEMPLATE,
g.fqn_prefix[DATAPREFIX], SYMBOLS_TEMPLATE, FALSE);
}
/*
* __MINGW32__ Note
* If the graphics version is built, we don't need a main; it is skipped
@@ -119,110 +391,25 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
#endif
g.hname = "NetHack"; /* used for syntax messages */
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
/* Save current directory and make sure it gets restored when
* the game is exited.
*/
if (getcwd(orgdir, sizeof orgdir) == (char *) 0)
error("NetHack: current directory path too long");
dir = nh_getenv("NETHACKDIR");
if (dir == (char *) 0)
dir = nh_getenv("HACKDIR");
if (dir == (char *) 0)
dir = exepath(argv[0]);
#ifdef _MSC_VER
if (IsDebuggerPresent()) {
static char exepath[_MAX_PATH];
/* check if we're running under the debugger so we can get to the right folder anyway */
if (dir != (char *)0) {
char *top = (char *)0;
if (strlen(dir) < (_MAX_PATH - 1))
strcpy(exepath, dir);
top = strstr(exepath, "\\build\\.\\Debug");
if (!top) top = strstr(exepath, "\\build\\.\\Release");
if (top) {
*top = '\0';
if (strlen(exepath) < (_MAX_PATH - (strlen("\\binary\\") + 1))) {
Strcat(exepath, "\\binary\\");
if (strlen(exepath) < (PATHLEN - 1)) {
dir = exepath;
}
}
}
}
}
#endif
if (dir != (char *)0) {
int prefcnt;
int fd;
boolean have_syscf = FALSE;
(void) strncpy(g.hackdir, dir, PATHLEN - 1);
g.hackdir[PATHLEN - 1] = '\0';
g.fqn_prefix[0] = (char *) alloc(strlen(g.hackdir) + 2);
Strcpy(g.fqn_prefix[0], g.hackdir);
append_slash(g.fqn_prefix[0]);
for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++)
g.fqn_prefix[prefcnt] = g.fqn_prefix[0];
/* sysconf should be searched for in this location */
envp = nh_getenv("COMMONPROGRAMFILES");
if (envp) {
if ((sptr = index(envp, ';')) != 0)
*sptr = '\0';
if (strlen(envp) > 0) {
g.fqn_prefix[SYSCONFPREFIX] =
(char *) alloc(strlen(envp) + 10);
Strcpy(g.fqn_prefix[SYSCONFPREFIX], envp);
append_slash(g.fqn_prefix[SYSCONFPREFIX]);
Strcat(g.fqn_prefix[SYSCONFPREFIX], "NetHack\\");
}
}
set_default_prefix_locations(argv[0]);
/* okay so we have the overriding and definitive locaton
for sysconf, but only in the event that there is not a
sysconf file there (for whatever reason), check a secondary
location rather than abort. */
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdir(fqn_prefix[HACKPREFIX]);
#endif
/* Is there a SYSCF_FILE there? */
fd = open(fqname(SYSCF_FILE, SYSCONFPREFIX, 0), O_RDONLY);
if (fd >= 0) {
/* readable */
close(fd);
have_syscf = TRUE;
}
copy_config_content();
if (!have_syscf) {
/* No SYSCF_FILE where there should be one, and
without an installer, a user may not be able
to place one there. So, let's try somewhere else... */
g.fqn_prefix[SYSCONFPREFIX] = g.fqn_prefix[0];
/* Is there a SYSCF_FILE there? */
fd = open(fqname(SYSCF_FILE, SYSCONFPREFIX, 0), O_RDONLY);
if (fd >= 0) {
/* readable */
close(fd);
have_syscf = TRUE;
}
}
/* user's home directory should default to this - unless
* overridden */
envp = nh_getenv("USERPROFILE");
if (envp) {
if ((sptr = index(envp, ';')) != 0)
*sptr = '\0';
if (strlen(envp) > 0) {
g.fqn_prefix[CONFIGPREFIX] =
(char *) alloc(strlen(envp) + 2);
Strcpy(g.fqn_prefix[CONFIGPREFIX], envp);
append_slash(g.fqn_prefix[CONFIGPREFIX]);
}
}
}
if (GUILaunched || IsDebuggerPresent()) {
if (GUILaunched || IsDebuggerPresent())
getreturn_enabled = TRUE;
}
check_recordfile((char *) 0);
iflags.windowtype_deferred = TRUE;
@@ -232,10 +419,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
failbuf);
nethack_exit(EXIT_FAILURE);
}
if (!g.hackdir[0])
Strcpy(g.hackdir, orgdir);
process_options(argc, argv);
copy_hack_content();
/*
* It seems you really want to play.
*/
@@ -291,10 +479,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
setting of renameallowed; when False, player_selection()
won't resent renaming as an option */
iflags.renameallowed = FALSE;
#if 0
/* Obtain the name of the logged on user and incorporate
* it into the name. */
#endif
Sprintf(fnamebuf, "%s", g.plname);
(void) fname_encode(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%',
@@ -374,7 +560,7 @@ attempt_restore:
return 0;
}
STATIC_OVL void
static void
process_options(argc, argv)
int argc;
char *argv[];
@@ -402,7 +588,7 @@ char *argv[];
*/
argc--;
argv++;
dir = argv[0] + 2;
const char * dir = argv[0] + 2;
if (*dir == '=' || *dir == ':')
dir++;
if (!*dir && argc > 1) {
@@ -533,7 +719,7 @@ char *argv[];
}
}
STATIC_OVL void
static void
nhusage()
{
char buf1[BUFSZ], buf2[BUFSZ], *bufptr;
@@ -665,33 +851,28 @@ void freefakeconsole()
}
#endif
#define EXEPATHBUFSZ 256
char exepathbuf[EXEPATHBUFSZ];
char *
exepath(str)
char *str;
get_executable_path()
{
char *tmp, *tmp2;
int bsize;
static char path_buffer[MAX_PATH];
if (!str)
return (char *) 0;
bsize = EXEPATHBUFSZ;
tmp = exepathbuf;
#ifdef UNICODE
{
TCHAR wbuf[BUFSZ];
GetModuleFileName((HANDLE) 0, wbuf, BUFSZ);
WideCharToMultiByte(CP_ACP, 0, wbuf, -1, tmp, bsize, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, wbuf, -1, path_buffer, sizeof(path_buffer), NULL, NULL);
}
#else
*(tmp + GetModuleFileName((HANDLE) 0, tmp, bsize)) = '\0';
DWORD length = GetModuleFileName((HANDLE) 0, path_buffer, MAX_PATH);
if (length == ERROR_INSUFFICIENT_BUFFER) error("Unable to get module name");
path_buffer[length] = '\0';
#endif
tmp2 = strrchr(tmp, PATH_SEPARATOR);
if (tmp2)
*tmp2 = '\0';
return tmp;
char * seperator = strrchr(path_buffer, PATH_SEPARATOR);
if (seperator)
*seperator = '\0';
return path_buffer;
}
/*ARGSUSED*/
@@ -783,7 +964,9 @@ getlock()
{
register int fd, c, ci, ct, ern;
int fcmask = FCMASK;
#ifndef SELF_RECOVER
char tbuf[BUFSZ];
#endif
const char *fq_lock;
#define OOPS_BUFSZ 512
char oops[OOPS_BUFSZ];
@@ -930,4 +1113,28 @@ const char *path;
return TRUE;
}
/*
file_newer returns TRUE if the file at a_path is newer then the file
at b_path. If a_path does not exist, it returns FALSE. If b_path
does not exist, it returns TRUE.
*/
boolean
file_newer(a_path, b_path)
const char * a_path;
const char * b_path;
{
struct stat a_sb;
struct stat b_sb;
if (stat(a_path, &a_sb))
return FALSE;
if (stat(b_path, &b_sb))
return TRUE;
if(difftime(a_sb.st_mtime, b_sb.st_mtime) < 0)
return TRUE;
return FALSE;
}
/*windmain.c*/

View File

@@ -11,6 +11,7 @@
*
*/
#include "win10.h"
#include "winos.h"
#define NEED_VARARGS
@@ -188,15 +189,26 @@ get_username(lan_username_size)
int *lan_username_size;
{
static TCHAR username_buffer[BUFSZ];
unsigned int status;
DWORD i = BUFSZ - 1;
BOOL allowUserName = TRUE;
Strcpy(username_buffer, "NetHack");
#ifndef WIN32CON
/* Our privacy policy for the windows store version of nethack makes
* a promise about not collecting any personally identifiable information.
* Do not allow getting user name if we being run from windows store
* version of nethack. In 3.7, we should remove use of username.
*/
allowUserName = !win10_is_desktop_bridge_application();
#endif
if (allowUserName) {
/* i gets updated with actual size */
if (GetUserName(username_buffer, &i))
username_buffer[i] = '\0';
}
/* i gets updated with actual size */
status = GetUserName(username_buffer, &i);
if (status)
username_buffer[i] = '\0';
else
Strcpy(username_buffer, "NetHack");
if (lan_username_size)
*lan_username_size = strlen(username_buffer);
return username_buffer;