Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2019-01-29 07:27:56 -05:00
50 changed files with 778 additions and 205 deletions

View File

@@ -519,4 +519,15 @@ unsigned setvalue;
return (regs.x.dx);
}
unsigned long
sys_random_seed(VOID_ARGS)
{
unsigned long ourseed = 0UL;
time_t datetime = 0;
(void) time(&datetime);
ourseed = (unsigned long) datetime;
return ourseed;
}
#endif /* MSDOS */

View File

@@ -441,9 +441,9 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \
botl.c cmd.c dbridge.c decl.c detect.c dig.c display.c dlb.c do.c \
do_name.c do_wear.c dog.c dogmove.c dokick.c dothrow.c drawing.c \
dungeon.c eat.c end.c engrave.c exper.c explode.c extralev.c \
files.c fountain.c hack.c hacklib.c invent.c light.c lock.c \
mail.c makemon.c mapglyph.c mcastu.c mhitm.c mhitu.c minion.c \
mklev.c mkmap.c \
files.c fountain.c hack.c hacklib.c invent.c isaac64.c light.c \
lock.c mail.c makemon.c mapglyph.c mcastu.c mhitm.c mhitu.c \
minion.c mklev.c mkmap.c \
mkmaze.c mkobj.c mkroom.c mon.c mondata.c monmove.c monst.c \
mplayer.c mthrowu.c muse.c music.c o_init.c objects.c objnam.c \
options.c pager.c pickup.c pline.c polyself.c potion.c pray.c \
@@ -508,8 +508,8 @@ HOBJ = $(FIRSTOBJ) allmain.o alloc.o apply.o artifact.o attrib.o ball.o \
bones.o botl.o cmd.o dbridge.o decl.o detect.o dig.o display.o dlb.o \
do.o do_name.o do_wear.o dog.o dogmove.o dokick.o dothrow.o \
drawing.o dungeon.o eat.o end.o engrave.o exper.o explode.o \
extralev.o files.o fountain.o hack.o hacklib.o invent.o light.o \
lock.o mail.o makemon.o mapglyph.o mcastu.o mhitm.o mhitu.o \
extralev.o files.o fountain.o hack.o hacklib.o invent.o isaac64.o \
light.o lock.o mail.o makemon.o mapglyph.o mcastu.o mhitm.o mhitu.o \
minion.o mklev.o mkmap.o \
mkmaze.o mkobj.o mkroom.o mon.o mondata.o monmove.o \
mplayer.o mthrowu.o muse.o music.o o_init.o objnam.o options.o \
@@ -1013,6 +1013,7 @@ fountain.o: fountain.c $(HACK_H)
hack.o: hack.c $(HACK_H)
hacklib.o: hacklib.c $(HACK_H)
invent.o: invent.c $(HACK_H)
isaac64.o: isaac64.c ../include/isaac64.h ../include/integer.h
light.o: light.c $(HACK_H) ../include/lev.h
lock.o: lock.c $(HACK_H)
mail.o: mail.c $(HACK_H) ../include/mail.h

View File

@@ -69,7 +69,7 @@ CC=gcc
#
#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic -Wno-long-long
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
#CFLAGS+=-Wunreachable-code

View File

@@ -69,7 +69,7 @@ CC=gcc
#
#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic -Wno-long-long
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
#CFLAGS+=-Wunreachable-code

View File

@@ -53,7 +53,7 @@ GAMEGRP = games
#WANT_SOURCE_INSTALL=1
#CC=gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
CC=gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
CC=gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic -Wno-long-long
#
# You shouldn't need to change anything below here.

View File

@@ -63,7 +63,7 @@ CC=gcc
#
#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic -Wno-long-long
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
#CFLAGS+=-Wunreachable-code

View File

@@ -70,7 +70,7 @@ CC=gcc
#
#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic -Wno-long-long
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
#CFLAGS+=-Wunreachable-code

View File

@@ -765,4 +765,36 @@ error:
}
#endif
unsigned long
sys_random_seed()
{
unsigned long seed;
unsigned long pid = (unsigned long) getpid();
boolean no_seed = TRUE;
#ifdef DEV_RANDOM
FILE *fptr = NULL;
fptr = fopen(DEV_RANDOM, "r");
if (fptr) {
fread(&seed, sizeof(long), 1, fptr);
has_strong_rngseed = TRUE; /* decl.c */
no_seed = FALSE;
fclose(fptr);
} else {
/* leaves clue, doesn't exit */
paniclog("sys_random_seed", "falling back to weak seed");
}
#endif
if (no_seed) {
seed = (unsigned long) getnow(); /* time((TIME_type) 0) */
/* Quick dirty band-aid to prevent PRNG prediction */
if (pid) {
if (!(pid & 3L))
pid -= 1L;
seed *= pid;
}
}
return seed;
}
/*unixmain.c*/

View File

@@ -465,4 +465,20 @@ wd_message()
You("are in non-scoring explore/discovery mode.");
}
unsigned long
sys_random_seed()
{
unsigned long seed;
unsigned long pid = (unsigned long) getpid();
seed = (unsigned long) getnow(); /* time((TIME_type) 0) */
/* Quick dirty band-aid to prevent PRNG prediction */
if (pid) {
if (!(pid & 3L))
pid -= 1L;
seed *= pid;
}
return seed;
}
/*vmsmain.c*/

View File

@@ -129,9 +129,13 @@ OBJ = o
# (see pcconf.h). Set to nothing if not used.
#
RANDOM = $(OBJ)\random.o
RANDOM = $(OBJ)\isaac64.o
#RANDOM = $(OBJ)\random.o
#RANDOM =
BCRYPT=
! IF ("$(RANDOM)"=="$(OBJ)\isaac64.o")
BCRYPT=bcrypt.lib
! ENDIF
WINPFLAG= -DTILES -DMSWIN_GRAPHICS -DWIN32CON
# To store all the level files,
@@ -460,7 +464,8 @@ CURSESLIB=
ccommon= -c -nologo -D"_CONSOLE" -D"_CRT_NONSTDC_NO_DEPRECATE" -D"_CRT_SECURE_NO_DEPRECATE" \
-D"_LIB" -D"_SCL_SECURE_NO_DEPRECATE" -D"_VC80_UPGRADE=0x0600" -D"DLB" -D"_MBCS" \
-DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" $(CURSESDEF) \
-DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" \
-DHAS_STDINT_H -DHAS_INLINE $(CURSESDEF) \
-EHsc -fp:precise -Gd -GF -GS -Gy \
$(CL_RECENT) -WX- -Zc:forScope -Zc:wchar_t -Zi
cdebug= -analyze- -D"_DEBUG" -Gm -MTd -RTC1 -Od
@@ -801,7 +806,7 @@ $(GAMEDIR)\NetHack.exe : $(O)gamedir.tag $(PDCLIB) $(O)tile.o $(O)nttty.o $(O)gu
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
@echo Linking $(@:\=/)
$(link) $(lflagsBuild) $(conlflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB /MAP:$(O)$(@B).MAP \
$(LIBS) $(PDCLIB) $(conlibs) -out:$@ @<<$(@B).lnk
$(LIBS) $(PDCLIB) $(conlibs) $(BCRYPT) -out:$@ @<<$(@B).lnk
$(GAMEOBJ)
$(TTYOBJ)
$(O)nttty.o
@@ -824,7 +829,7 @@ $(GAMEDIR)\NetHackW.exe : $(O)gamedir.tag $(O)tile.o $(O)ttystub.o \
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
@echo Linking $(@:\=/)
$(link) $(lflagsBuild) $(guilflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB \
/MAP:$(O)$(@B).MAP $(LIBS) $(PDCLIB) $(guilibs) $(COMCTRL) -out:$@ @<<$(@B).lnk
/MAP:$(O)$(@B).MAP $(LIBS) $(PDCLIB) $(guilibs) $(COMCTRL) $(BCRYPT) -out:$@ @<<$(@B).lnk
$(GAMEOBJ)
$(GUIOBJ)
$(O)tile.o
@@ -1514,6 +1519,8 @@ $(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c
$(O)pctty.o: ..\sys\share\pctty.c $(HACK_H)
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c
$(O)isaac64.o: ..\src\isaac64.c $(HACK_H) $(INCL)\isaac64.h $(INCL)\integer.h
@$(CC) $(cflagsBuild) -Fo$@ ..\src\isaac64.c
$(O)random.o: ..\sys\share\random.c $(HACK_H)
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\random.c
$(O)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h

View File

@@ -680,6 +680,54 @@ char *name;
}
return;
}
#include <bcrypt.h> /* Windows Crypto Next Gen (CNG) */
#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS 0
#endif
#ifndef STATUS_NOT_FOUND
#define STATUS_NOT_FOUND 0xC0000225
#endif
#ifndef STATUS_UNSUCCESSFUL
#define STATUS_UNSUCCESSFUL 0xC0000001
#endif
unsigned long
sys_random_seed(VOID_ARGS)
{
unsigned long ourseed = 0UL;
BCRYPT_ALG_HANDLE hRa = (BCRYPT_ALG_HANDLE) 0;
NTSTATUS status = STATUS_UNSUCCESSFUL;
boolean Plan_B = TRUE;
status = BCryptOpenAlgorithmProvider(&hRa, BCRYPT_RNG_ALGORITHM,
(LPCWSTR) 0, 0);
if (hRa && status == STATUS_SUCCESS) {
status = BCryptGenRandom(hRa, (PUCHAR) &ourseed,
(ULONG) sizeof ourseed, 0);
if (status == STATUS_SUCCESS) {
BCryptCloseAlgorithmProvider(hRa,0);
has_strong_rngseed = TRUE;
Plan_B = FALSE;
}
}
if (Plan_B) {
time_t datetime = 0;
const char *emsg;
if (status == STATUS_NOT_FOUND)
emsg = "BCRYPT_RNG_ALGORITHM not avail, falling back";
else
emsg = "Other failure than algorithm not avail";
paniclog("sys_random_seed", emsg); /* leaves clue, doesn't exit */
(void) time(&datetime);
ourseed = (unsigned long) datetime;
}
return ourseed;
}
#endif /* WIN32 */
/*winnt.c*/