NetHack minor release checklist items - savefiles

Make some progress on a couple of next minor release checklist
items, hopefully without introducing too many new bugs. This
is just the initial commit, and work continues.

Checklist items:

Savefiles compatible between Windows versions, whether 64-bit
or 32-bit in little-endian field format.

Selection of file formats:
 historical (structlevel saves),
 lendian (little-endian, fieldlevel saves),
 and just for proof-of-concept, ascii fieldlevel saves
 (the ascii is huge! 10x bigger than little-endian).

For the fieldlevel save, all complex data structures recursively
get broken down until until it is one of the simple types that
can't be broken down any further, and that gets when it gets
written to the output file.

New files needed for this build:

hand-coded:
include/sfprocs.h
src/sfbase.c      - really a dispatcher to one of the
                    output/input format routines.
src/sflendian.c   - little-endian output writer/reader.
src/sfascii.c     - ascii text output writer/reader.

auto-coded (generated):
include/sfproto.h
src/sfdata.c

This is just one approach. I'm sure there are countless others
and they have different pros and cons.

For producing the auto-coded files a utility called
universal-ctags, that is actively maintained and evolving,
was used to do all the heavy-lifting of parsing the
NetHack C sources to tabulate the data fields, and store
them in an intermediate file called util/nethack.tags
(not required for building NetHack if you already have a
generated include/sfproto.h and src/sfdata.c)

util/readtags (also not required for building NetHack
itself) will decipher the nethack.tags file and produce
the functions that can deal with the NetHack struct data
fields.

You can obtain the source for universal-ctags by cloning it
from here:
https://github.com/universal-ctags/ctags.git

The combination universal-ctags + util/readtags has been
tried and tested under both Windows and Linux, so it is
not tied to a particular platform.

Note: util/readtags will work only with universal-ctags
output, so other ctags are unlikely to work as-is.
Universal-ctags can be build from source very easily
under Linux, or under Windows using visual studio.
This commit is contained in:
nhmall
2019-06-23 00:11:46 -04:00
parent c9e8ae6323
commit 7054e06e42
45 changed files with 14114 additions and 1280 deletions

View File

@@ -90,7 +90,7 @@ pcmain(argc, argv)
int argc;
char *argv[];
{
register int fd;
NHFILE *nhfp;
register char *dir;
#if defined(MSDOS)
char *envp = NULL;
@@ -444,13 +444,16 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/* Set up level 0 file to keep the game state.
*/
fd = create_levelfile(0, (char *) 0);
if (fd < 0) {
nhfp = create_levelfile(0, (char *) 0);
if (!nhfp) {
raw_print("Cannot create lock file");
} else {
g.hackpid = 1;
write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid));
nhclose(fd);
if (nhfp->structlevel)
write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid));
if (nhfp->fieldlevel)
sfi_int(nhfp, &g.hackpid, "locking", "g.hackpid", 1);
close_nhfile(nhfp);
}
#ifdef MFLOPPY
level_info[0].where = ACTIVE;
@@ -468,7 +471,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
* We'll return here if new game player_selection() renames the hero.
*/
attempt_restore:
if ((fd = restore_saved_game()) >= 0) {
if ((nhfp = restore_saved_game()) > 0) {
#ifndef NO_SIGNAL
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
#endif
@@ -481,7 +484,7 @@ attempt_restore:
pline("Restoring save file...");
mark_synch(); /* flush output */
if (dorecover(fd)) {
if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */
if (discover)
You("are in non-scoring discovery mode.");

View File

@@ -448,7 +448,9 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.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 \
priest.c quest.c questpgr.c read.c rect.c region.c restore.c \
rip.c rnd.c role.c rumors.c save.c shk.c shknam.c sit.c sounds.c \
rip.c rnd.c role.c rumors.c save.c \
sfbase.c sfdata.c sfascii.c sflendian.c \
shk.c shknam.c sit.c sounds.c \
sp_lev.c spell.c steal.c steed.c sys.c teleport.c timeout.c \
topten.c track.c trap.c u_init.c \
uhitm.c vault.c version.c vision.c weapon.c were.c wield.c \
@@ -464,7 +466,7 @@ SYSCSRC = ../sys/atari/tos.c ../sys/share/pcmain.c ../sys/share/pcsys.c \
SYSCXXSRC = ../sys/share/cppregex.cpp
# generated source files (tile.c is handled separately via WINxxxSRC)
GENCSRC = vis_tab.c #tile.c
GENCSRC = vis_tab.c sfdata.c #tile.c
# all windowing-system-dependent .c (for dependencies and such)
WINCSRC = $(WINTTYSRC) $(WINCURSESSRC) $(WINX11SRC) $(WINGNOMESRC) $(WINGEMSRC)
@@ -515,8 +517,9 @@ HOBJ = $(FIRSTOBJ) allmain.o alloc.o apply.o artifact.o attrib.o ball.o \
mplayer.o mthrowu.o muse.o music.o o_init.o objnam.o options.o \
pager.o pickup.o pline.o polyself.o potion.o pray.o priest.o \
quest.o questpgr.o read.o rect.o region.o restore.o rip.o rnd.o \
role.o rumors.o save.o shk.o shknam.o sit.o sounds.o sp_lev.o spell.o \
sys.o \
role.o rumors.o save.o \
sfbase.o sfdata.o sfascii.o sflendian.o \
shk.o shknam.o sit.o sounds.o sp_lev.o spell.o sys.o \
steal.o steed.o teleport.o timeout.o topten.o track.o trap.o u_init.o \
uhitm.o vault.o vision.o vis_tab.o weapon.o were.o wield.o windows.o \
wizard.o worm.o worn.o write.o zap.o \
@@ -658,6 +661,26 @@ tile.c: ../win/share/tilemap.c $(HACK_H)
../win/gnome/gn_rip.h: ../win/X11/rip.xpm
cp ../win/X11/rip.xpm ../win/gnome/gn_rip.h
# readtags dependencies
#
#
../util/readtags:
@( cd ../util ; $(MAKE) readtags )
../util/nethack.tags:
@( cd ../util ; $(MAKE) nethack.tags )
sfbase.o: sfbase.c $(HACK_H) ../include/sfproto.h ../include/sfprocs.h
sfascii.o: sfascii.c $(HACK_H) ../include/sfprocs.h
sflendian.o: sflendian.c $(HACK_H) ../include/sfprocs.h
sfdata.o: sfdata.c $(HACK_H) ../include/sfprocs.h
sfdata.c: ../util/readtags ../util/nethack.tags
@( cd ../util ; ./readtags )
../include/sfproto.h: ../util/readtags ../util/nethack.tags
@( cd ../util ; ./readtags )
# date.h should be remade any time any of the source or include code
# is modified. Unfortunately, this would make the contents of this
# file far more complex. Since "hack.h" depends on most of the include
@@ -672,7 +695,6 @@ tile.c: ../win/share/tilemap.c $(HACK_H)
-$(SHELL) ../sys/unix/gitinfo.sh $(GITINFO) #before 'makedefs -v'
../util/makedefs -v
lint:
# lint cannot have -p here because (i) capitals are meaningful:
# [Ww]izard, (ii) identifiers may coincide in the first six places:

View File

@@ -126,6 +126,10 @@ LEXYYC = lex.yy.c
# YTABH = y_tab.h
# LEXYYC = lexyy.c
# This is the universal ctags utility which produces the tags in the
# format that util/readtags requires.
# https://github.com/universal-ctags/ctags.git
CTAGSCMD = universal-ctags
# if you change this to 1, feedback while building will omit -Dthis -Wthat
# -Isomewhere so that each file being compiled is listed on one short line;
@@ -184,6 +188,7 @@ DGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c
RECOVSRC = recover.c
DLBSRC = dlb_main.c
UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC)
READTAGSSRC = readtags.c
# files that define all monsters and objects
CMONOBJ = ../src/monst.c ../src/objects.c
@@ -210,6 +215,9 @@ RECOVOBJS = recover.o
# object files for the data librarian
DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC)
# object files for readtags
READTAGSOBJS = readtags.o
# flags for creating distribution versions of sys/share/*_lex.c, using
# a more portable flex skeleton, which is not included in the distribution.
# hopefully keeping this out of the section to be edited will keep too
@@ -441,6 +449,73 @@ tileedit: tileedit.cpp $(TEXT_IO)
$(CC) -o tileedit -I../include -I$(QTDIR)/include -L$(QTDIR)/lib \
tileedit.cpp $(TEXT_IO) -lqt
# dependencies for readtags
#
CTAGDEP = ../include/align.h ../include/artifact.h ../src/artifact.c \
../include/artilist.h ../include/attrib.h ../src/bones.c \
../include/context.h ../include/coord.h ../include/decl.h \
../src/decl.c ../include/dungeon.h ../include/engrave.h \
../src/engrave.c ../include/flag.h ../include/func_tab.h \
../include/global.h ../include/hack.h ../include/lev.h \
../include/mextra.h ../include/mkroom.h ../include/monst.h \
../include/monsym.h ../include/obj.h ../include/objclass.h \
../include/prop.h ../include/quest.h ../include/rect.h \
../include/region.h ../include/rm.h ../include/skills.h \
../include/spell.h ../include/sys.h ../include/timeout.h \
../include/trap.h ../include/you.h ../include/onames.h \
../include/wintype.h
# ../include/permonst.h
CTAGSOPT = --language-force=c --sort=no -D"Bitfield(x,n)=unsigned x : n" --excmd=pattern
readtags: $(READTAGSOBJS)
$(CC) $(LFLAGS) -o readtags $(READTAGSOBJS) $(LIBS)
readtags.o: readtags.c $(HACK_H)
$(CC) $(CFLAGS) -c readtags.c
nethack.tags: $(CTAGDEP)
#
# tested with universal ctags from https://github.com/universal-ctags/ctags.git
#
$(CTAGSCMD) $(CTAGSOPT) -f nethack.tags ../include/align.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/artifact.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../src/artifact.c
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/artilist.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/attrib.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../src/bones.c
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/context.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/coord.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/decl.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../src/decl.c
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/dungeon.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/engrave.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../src/engrave.c
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/flag.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/func_tab.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/global.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/hack.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/lev.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/mextra.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/mkroom.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/monst.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/monsym.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/obj.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/objclass.h
# $(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/permonst.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/prop.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/quest.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/rect.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/region.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/rm.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/skills.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/spell.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/sys.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/timeout.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/trap.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/you.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/onames.h
$(CTAGSCMD) $(CTAGSOPT) -a -f nethack.tags ../include/wintype.h
# using dependencies like
# ../src/foo::
# @( cd ../src ; $(MAKE) foo )

View File

@@ -54,6 +54,7 @@ char *argv[];
#ifdef CHDIR
register char *dir;
#endif
NHFILE *nhfp;
boolean exact_username;
boolean resuming = FALSE; /* assume new game */
boolean plsel_once = FALSE;
@@ -280,7 +281,7 @@ attempt_restore:
g.program_state.preserve_locks = 0; /* after getlock() */
}
if (*g.plname && (fd = restore_saved_game()) >= 0) {
if (*g.plname && (nhfp = restore_saved_game()) != 0) {
const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */
@@ -295,7 +296,7 @@ attempt_restore:
#endif
pline("Restoring save file...");
mark_synch(); /* flush output */
if (dorecover(fd)) {
if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */
wd_message();
if (discover || wizard) {

View File

@@ -236,7 +236,8 @@ VOBJ24 = $(O)track.o $(O)trap.o $(O)u_init.o $(O)uhitm.o
VOBJ25 = $(O)vault.o $(O)vis_tab.o $(O)vision.o $(O)weapon.o
VOBJ26 = $(O)were.o $(O)wield.o $(O)windows.o $(O)wizard.o
VOBJ27 = $(O)worm.o $(O)worn.o $(O)write.o $(O)zap.o
VOBJ28 =
VOBJ28 = $(O)sfbase.o $(O)sfdata.o $(O)sfascii.o $(O)sflendian.o
#VOBJ29 =
DLBOBJ = $(O)dlb.o
@@ -259,8 +260,8 @@ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
$(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(REGEX) \
$(CURSESOBJ)
$(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(VOBJ30) \
$(REGEX) $(CURSESOBJ)
GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \
$(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \
@@ -364,6 +365,19 @@ DATABASE = $(DAT)\data.base
#==========================================
#==========================================
#
# ctags options
#
#CTAGSCMD=ctags-orig.exe
CTAGSCMD=..\..\..\ctags\ctags.exe
CTAGSOPT =--language-force=c --sort=no -D"Bitfield(x,n)=unsigned x : n" --excmd=pattern
#
# ctags wants unix-style pathnames
#
TINC = $(INCL:\=/)
TSRC = $(SRC:\=/)
cc=cl
link=link
rc=Rc
@@ -1066,6 +1080,7 @@ $(U)dgncomp.exe: $(DGNCOMPOBJS)
)
<<
#=================================================
# Create directory for holding object files
#=================================================
@@ -1477,6 +1492,93 @@ $(O)NetHackW.o: $(HACK_H) $(MSWIN)\NetHackW.c
$(O)ttystub.o: $(HACK_H) $(MSWSYS)\stubs.c
@$(cc) $(cflagsBuild) -DTTYSTUB -Fo$@ $(MSWSYS)\stubs.c
#
#============================================
# fieldlevel save dependencies
#============================================
$(O)sfbase.o: $(HACK_H) $(INCL)\sfproto.h $(INCL)\sfprocs.h \
$(SRC)\sfbase.c
@$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfbase.c
$(O)sfdata.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sfdata.c
@$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfdata.c
$(O)sfascii.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sfascii.c
@$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfascii.c
$(O)sflendian.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sflendian.c
@$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sflendian.c
$(SRC)\sfdata.c: $(U)readtags.exe $(U)nethack.tags
$(U)readtags.exe
$(INCL)\sfproto.h: $(U)readtags.exe $(U)nethack.tags
$(U)readtags.exe
$(U)readtags.exe: $(O)readtags.o
@$(link) $(lflagsBuild) -out:$@ $(O)readtags.o
$(O)readtags.o: $(U)readtags.c $(U)nethack.tags $(CONFIG_H) $(PATCHLEVEL_H)
@$(cc) $(cflagsBuild) $(TEMPL) -Fo$@ $(U)readtags.c
#
#tested only with exuberant ctags from http://ctags.sourceforge.net
#
CTAGDEP = $(TINC)/align.h $(TINC)/artifact.h $(TSRC)/artifact.c \
$(TINC)/artilist.h $(TINC)/attrib.h $(TSRC)/bones.c \
$(TINC)/context.h $(TINC)/coord.h $(TINC)/decl.h \
$(TSRC)/decl.c $(TINC)/dungeon.h $(TINC)/engrave.h \
$(TSRC)/engrave.c $(TINC)/flag.h $(TINC)/func_tab.h \
$(TINC)/global.h $(TINC)/hack.h $(TINC)/lev.h \
$(TINC)/mextra.h $(TINC)/mkroom.h $(TINC)/monst.h \
$(TINC)/monsym.h $(TINC)/obj.h $(TINC)/objclass.h \
$(TINC)/permonst.h $(TINC)/prop.h $(TINC)/quest.h \
$(TINC)/rect.h $(TINC)/region.h $(TINC)/rm.h \
$(TINC)/skills.h $(TINC)/spell.h $(TINC)/sys.h \
$(TINC)/timeout.h $(TINC)/trap.h $(TINC)/you.h \
$(TINC)/onames.h $(TINC)/wintype.h
$(U)nethack.tags: $(CTAGDEP)
$(CTAGSCMD) $(CTAGSOPT) -f $(U)nethack.tags $(TINC)/align.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/artifact.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TSRC)/artifact.c
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/artilist.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/attrib.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TSRC)/bones.c
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/context.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/coord.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/decl.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TSRC)/decl.c
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/dungeon.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/engrave.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TSRC)/engrave.c
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/flag.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/func_tab.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/global.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/hack.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/lev.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/mextra.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/mkroom.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/monst.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/monsym.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/obj.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/objclass.h
# $(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/permonst.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/prop.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/quest.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/rect.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/region.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/rm.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/skills.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/spell.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/sys.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/timeout.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/trap.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/you.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/onames.h
$(CTAGSCMD) $(CTAGSOPT) -a -f $(U)nethack.tags $(TINC)/wintype.h
#
# util dependencies
#

View File

@@ -82,7 +82,7 @@ int argc;
char *argv[];
{
boolean resuming = FALSE; /* assume new game */
int fd;
NHFILE *nhfp;
char *windowtype = NULL;
char *envp = NULL;
char *sptr = NULL;
@@ -291,9 +291,11 @@ _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. */
Sprintf(fnamebuf, "%s-%s", get_username(0), g.plname);
#endif
Sprintf(fnamebuf, "%s", g.plname);
(void) fname_encode(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%',
fnamebuf, encodedfnamebuf, BUFSZ);
@@ -303,13 +305,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/* Set up level 0 file to keep the game state.
*/
fd = create_levelfile(0, (char *) 0);
if (fd < 0) {
nhfp = create_levelfile(0, (char *) 0);
if (!nhfp) {
raw_print("Cannot create lock file");
} else {
g.hackpid = GetCurrentProcessId();
write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid));
nhclose(fd);
write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid));
close_nhfile(nhfp);
}
/*
* Initialize the vision system. This must be before mklev() on a
@@ -322,7 +324,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
* We'll return here if new game player_selection() renames the hero.
*/
attempt_restore:
if ((fd = restore_saved_game()) >= 0) {
if ((nhfp = restore_saved_game()) != 0) {
#ifdef NEWS
if (iflags.news) {
display_file(NEWS, FALSE);
@@ -331,7 +333,7 @@ attempt_restore:
#endif
pline("Restoring save file...");
mark_synch(); /* flush output */
if (dorecover(fd)) {
if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */
if (discover)
You("are in non-scoring discovery mode.");