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
+16 -2
View File
@@ -21,10 +21,10 @@
.ds h0 "NetHack Guidebook .ds h0 "NetHack Guidebook
.ds h1 .ds h1
.ds h2 % .ds h2 %
.ds vr "NetHack 3.6 .ds vr "NetHack 3.7
.ds f0 "\*(vr .ds f0 "\*(vr
.ds f1 .ds f1
.ds f2 "May 7, 2019 .ds f2 "June 20, 2019
. .
.\" A note on some special characters: .\" A note on some special characters:
.\" \(lq = left double quote .\" \(lq = left double quote
@@ -4650,6 +4650,20 @@ The syntax is the same as WIZARDS.
MAXPLAYERS\ =\ Limit the maximum number of games that can be running MAXPLAYERS\ =\ Limit the maximum number of games that can be running
at the same time. at the same time.
.lp .lp
SAVEFORMAT\ =\ A list of up to two save file formats separated by space.
The first format in the list will written as well as read. The second format
will be read only if no save file in the first format exists.
Valid choices are \(lqhistorical\(rq for binary writing of entire structs,
\(lqlendian\(rq for binary writing of each field in little-endian order,
\(lqascii\(rq for writing the save file content in ascii text.
.lp
BONESFORMAT\ =\ A list of up to two bones file formats separated by space.
The first format in the list will written as well as read. The second format
will be read only if no bones files in the first format exist.
Valid choices are \(lqhistorical\(rq for binary writing of entire structs,
\(lqlendian\(rq for binary writing of each field in little-endian order,
\(lqascii\(rq for writing the bones file content in ascii text.
.lp
SUPPORT\ =\ A string explaining how to get local support (no default value). SUPPORT\ =\ A string explaining how to get local support (no default value).
.lp .lp
RECOVER\ =\ A string explaining how to recover a game on this system RECOVER\ =\ A string explaining how to recover a game on this system
+17 -1
View File
@@ -45,7 +45,7 @@
%.au %.au
\author{Original version - Eric S. Raymond\\ \author{Original version - Eric S. Raymond\\
(Edited and expanded for 3.6 by Mike Stephenson and others)} (Edited and expanded for 3.6 by Mike Stephenson and others)}
\date{May 7, 2019} \date{June 20, 2019}
\maketitle \maketitle
@@ -5161,6 +5161,22 @@ The syntax is the same as WIZARDS.
\item[\ib{MAXPLAYERS}] \item[\ib{MAXPLAYERS}]
Limit the maximum number of games that can be running at the same time. Limit the maximum number of games that can be running at the same time.
%.lp %.lp
\item[\ib{SAVEFORMAT}]
A list of up to two save file formats separated by space.
The first format in the list will written as well as read. The second format
will be read only if no save file in the first format exists.
Valid choices are ``{\tt historical}'' for binary writing of entire structs,
``{\tt lendian}'' for binary writing of each field in little-endian order,
``{\tt ascii}'' for writing the save file content in ascii text.
%.lp
\item[\ib{BONESFORMAT}]
A list of up to two bones file formats separated by space.
The first format in the list will written as well as read. The second
format will be read only if no bones files in the first format exist.
Valid choices are ``{\tt historical}'' for binary writing of entire structs,
``{\tt lendian}'' for binary writing of each field in little-endian order,
``{\tt ascii}'' for writing the bones file content in ascii text.
%.lp
\item[\ib{SUPPORT}] \item[\ib{SUPPORT}]
A string explainign how to get local support (no default value). A string explainign how to get local support (no default value).
%.lp %.lp
+60 -10
View File
@@ -8,7 +8,7 @@
#define E extern #define E extern
#if !defined(MFLOPPY) && !defined(VMS) && !defined(WIN32) #if !defined(MFLOPPY) && !defined(VMS)
#define LOCKNAMESIZE (PL_NSIZ + 14) /* long enough for uid+name+.99 */ #define LOCKNAMESIZE (PL_NSIZ + 14) /* long enough for uid+name+.99 */
#define LOCKNAMEINIT "1lock" #define LOCKNAMEINIT "1lock"
#define BONESINIT "bonesnn.xxx" #define BONESINIT "bonesnn.xxx"
@@ -26,22 +26,18 @@
#define BONESINIT "bonesnn.xxx;1" #define BONESINIT "bonesnn.xxx;1"
#define BONESSIZE sizeof(BONESINIT) #define BONESSIZE sizeof(BONESINIT)
#endif #endif
#if defined(WIN32)
#define LOCKNAMESIZE (PL_NSIZ + 25) /* long enough for username+-+name+.99 */
#define LOCKNAMEINIT ""
#define BONESINIT "bonesnn.xxx"
#define BONESSIZE sizeof(BONESINIT)
#endif
#endif #endif
/* This is written to a savefile by a defined size on some platforms,
so let's not create an automatic and unnecessary incompatibility */
#if defined(UNIX) || defined(__BEOS__) #if defined(UNIX) || defined(__BEOS__)
#define SAVESIZE (PL_NSIZ + 13) /* save/99999player.e */ #define SAVESIZE (PL_NSIZ + 50) /* save/99999player.e */
#else #else
#ifdef VMS #ifdef VMS
#define SAVESIZE (PL_NSIZ + 22) /* [.save]<uid>player.e;1 */ #define SAVESIZE (PL_NSIZ + 50) /* [.save]<uid>player.e;1 */
#else #else
#if defined(WIN32) #if defined(WIN32)
#define SAVESIZE (PL_NSIZ + 40) /* username-player.NetHack-saved-game */ #define SAVESIZE (PL_NSIZ + 50) /* username-player.NetHack-saved-game */
#else #else
#define SAVESIZE FILENAME /* from macconf.h or pcconf.h */ #define SAVESIZE FILENAME /* from macconf.h or pcconf.h */
#endif #endif
@@ -162,6 +158,52 @@ struct sinfo {
int wizkit_wishing; int wizkit_wishing;
}; };
/* Flags for controlling uptodate */
#define UTD_CHECKSIZES 0x01
#define UTD_CHECKFIELDCOUNTS 0x02
#define UTD_SKIP_SANITY1 0x04
#define UTD_SKIP_SAVEFILEINFO 0x08
/* NetHack ftypes */
#define NHF_LEVELFILE 1
#define NHF_SAVEFILE 2
#define NHF_BONESFILE 3
/* modes */
#define READING 0x0
#define COUNTING 0x1
#define WRITING 0x2
#define FREEING 0x4
#define MAX_BMASK 4
/* operations of the various saveXXXchn & co. routines */
#define perform_bwrite(nhfp) ((nhfp)->mode & (COUNTING | WRITING))
#define release_data(nhfp) ((nhfp)->mode & FREEING)
/* Content types for fieldlevel files */
struct fieldlevel_content {
boolean deflt; /* individual fields */
boolean binary; /* binary rather than text */
boolean json; /* JSON */
};
typedef struct {
int fd; /* for traditional structlevel binary writes */
int mode; /* holds READING, WRITING, or FREEING modes */
int ftype; /* NHF_LEVELFILE, NHF_SAVEFILE, or NHF_BONESFILE */
int fnidx; /* index of procs for fieldlevel saves */
long count; /* holds current line count for default style file,
field count for binary style */
boolean structlevel; /* traditional structure binary saves */
boolean fieldlevel; /* fieldlevel saves saves each field individually */
boolean addinfo; /* if set, some additional context info from core */
boolean eof; /* place to mark eof reached */
boolean bendian; /* set to true if executing on a big-endian machine */
FILE *fpdef; /* file pointer for fieldlevel default style */
FILE *fpdefmap; /* file pointer mapfile for def format */
FILE *fplog; /* file pointer logfile */
FILE *fpdebug; /* file pointer debug info */
struct fieldlevel_content style;
} NHFILE;
E const char quitchars[]; E const char quitchars[];
E const char vowels[]; E const char vowels[];
E const char ynchars[]; E const char ynchars[];
@@ -349,6 +391,14 @@ E const char *const monexplain[], invisexplain[], *const oclass_names[];
E const char *fqn_prefix_names[PREFIX_COUNT]; E const char *fqn_prefix_names[PREFIX_COUNT];
#endif #endif
struct restore_procs {
const char *name;
int mread_flags;
void NDECL((*restore_minit));
void FDECL((*restore_mread), (int,genericptr_t,unsigned int));
void FDECL((*restore_bclose), (int));
};
E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
struct opvar { struct opvar {
+58 -47
View File
@@ -56,8 +56,8 @@ E int FDECL(unfixable_trouble_count, (BOOLEAN_P));
/* ### artifact.c ### */ /* ### artifact.c ### */
E void NDECL(init_artifacts); E void NDECL(init_artifacts);
E void FDECL(save_artifacts, (int)); E void FDECL(save_artifacts, (NHFILE *));
E void FDECL(restore_artifacts, (int)); E void FDECL(restore_artifacts, (NHFILE *));
E const char *FDECL(artiname, (int)); E const char *FDECL(artiname, (int));
E struct obj *FDECL(mk_artifact, (struct obj *, ALIGNTYP_P)); E struct obj *FDECL(mk_artifact, (struct obj *, ALIGNTYP_P));
E const char *FDECL(artifact_name, (const char *, short *)); E const char *FDECL(artifact_name, (const char *, short *));
@@ -596,8 +596,8 @@ E boolean FDECL(cursed_object_at, (int, int));
/* ### dungeon.c ### */ /* ### dungeon.c ### */
E void FDECL(save_dungeon, (int, BOOLEAN_P, BOOLEAN_P)); E void FDECL(save_dungeon, (NHFILE *, BOOLEAN_P, BOOLEAN_P));
E void FDECL(restore_dungeon, (int)); E void FDECL(restore_dungeon, (NHFILE *));
E void FDECL(insert_branch, (branch *, BOOLEAN_P)); E void FDECL(insert_branch, (branch *, BOOLEAN_P));
E void NDECL(init_dungeons); E void NDECL(init_dungeons);
E s_level *FDECL(find_level, (const char *)); E s_level *FDECL(find_level, (const char *));
@@ -716,8 +716,8 @@ E int NDECL(num_genocides);
E void FDECL(delayed_killer, (int, int, const char *)); E void FDECL(delayed_killer, (int, int, const char *));
E struct kinfo *FDECL(find_delayed_killer, (int)); E struct kinfo *FDECL(find_delayed_killer, (int));
E void FDECL(dealloc_killer, (struct kinfo *)); E void FDECL(dealloc_killer, (struct kinfo *));
E void FDECL(save_killers, (int, int)); E void FDECL(save_killers, (NHFILE *));
E void FDECL(restore_killers, (int)); E void FDECL(restore_killers, (NHFILE *));
E char *FDECL(build_english_list, (char *)); E char *FDECL(build_english_list, (char *));
#if defined(PANICTRACE) && !defined(NO_SIGNAL) #if defined(PANICTRACE) && !defined(NO_SIGNAL)
E void FDECL(panictrace_setsignals, (BOOLEAN_P)); E void FDECL(panictrace_setsignals, (BOOLEAN_P));
@@ -741,8 +741,8 @@ E void FDECL(del_engr_at, (int, int));
E int NDECL(freehand); E int NDECL(freehand);
E int NDECL(doengrave); E int NDECL(doengrave);
E void NDECL(sanitize_engravings); E void NDECL(sanitize_engravings);
E void FDECL(save_engravings, (int, int)); E void FDECL(save_engravings, (NHFILE *));
E void FDECL(rest_engravings, (int)); E void FDECL(rest_engravings, (NHFILE *));
E void FDECL(engr_stats, (const char *, char *, long *, long *)); E void FDECL(engr_stats, (const char *, char *, long *, long *));
E void FDECL(del_engr, (struct engr *)); E void FDECL(del_engr, (struct engr *));
E void FDECL(rloc_engr, (struct engr *)); E void FDECL(rloc_engr, (struct engr *));
@@ -781,30 +781,33 @@ E FILE *FDECL(fopen_datafile, (const char *, const char *, int));
#ifdef MFLOPPY #ifdef MFLOPPY
E void NDECL(set_lock_and_bones); E void NDECL(set_lock_and_bones);
#endif #endif
E void FDECL(zero_nhfile, (NHFILE *));
E void FDECL(close_nhfile, (NHFILE *));
E void FDECL(rewind_nhfile, (NHFILE *));
E void FDECL(set_levelfile_name, (char *, int)); E void FDECL(set_levelfile_name, (char *, int));
E int FDECL(create_levelfile, (int, char *)); E NHFILE *FDECL(create_levelfile, (int, char *));
E int FDECL(open_levelfile, (int, char *)); E NHFILE *FDECL(open_levelfile, (int, char *));
E void FDECL(delete_levelfile, (int)); E void FDECL(delete_levelfile, (int));
E void NDECL(clearlocks); E void NDECL(clearlocks);
E int FDECL(create_bonesfile, (d_level *, char **, char *)); E NHFILE *FDECL(create_bonesfile, (d_level *, char **, char *));
#ifdef MFLOPPY #ifdef MFLOPPY
E void NDECL(cancel_bonesfile); E void NDECL(cancel_bonesfile);
#endif #endif
E void FDECL(commit_bonesfile, (d_level *)); E void FDECL(commit_bonesfile, (d_level *));
E int FDECL(open_bonesfile, (d_level *, char **)); E NHFILE *FDECL(open_bonesfile, (d_level *, char **));
E int FDECL(delete_bonesfile, (d_level *)); E int FDECL(delete_bonesfile, (d_level *));
E void NDECL(compress_bonesfile); E void NDECL(compress_bonesfile);
E void FDECL(set_savefile_name, (BOOLEAN_P)); E void FDECL(set_savefile_name, (BOOLEAN_P));
#ifdef INSURANCE #ifdef INSURANCE
E void FDECL(save_savefile_name, (int)); E void FDECL(save_savefile_name, (NHFILE *));
#endif #endif
#ifndef MICRO #ifndef MICRO
E void NDECL(set_error_savefile); E void NDECL(set_error_savefile);
#endif #endif
E int NDECL(create_savefile); E NHFILE *NDECL(create_savefile);
E int NDECL(open_savefile); E NHFILE *NDECL(open_savefile);
E int NDECL(delete_savefile); E int NDECL(delete_savefile);
E int NDECL(restore_saved_game); E NHFILE *NDECL(restore_saved_game);
E void FDECL(nh_compress, (const char *)); E void FDECL(nh_compress, (const char *));
E void FDECL(nh_uncompress, (const char *)); E void FDECL(nh_uncompress, (const char *));
E boolean FDECL(lock_file, (const char *, int, int)); E boolean FDECL(lock_file, (const char *, int, int));
@@ -1070,8 +1073,8 @@ E void FDECL(do_light_sources, (char **));
E void FDECL(show_transient_light, (struct obj *, int, int)); E void FDECL(show_transient_light, (struct obj *, int, int));
E void NDECL(transient_light_cleanup); E void NDECL(transient_light_cleanup);
E struct monst *FDECL(find_mid, (unsigned, unsigned)); E struct monst *FDECL(find_mid, (unsigned, unsigned));
E void FDECL(save_light_sources, (int, int, int)); E void FDECL(save_light_sources, (NHFILE *, int));
E void FDECL(restore_light_sources, (int)); E void FDECL(restore_light_sources, (NHFILE *));
E void FDECL(light_stats, (const char *, char *, long *, long *)); E void FDECL(light_stats, (const char *, char *, long *, long *));
E void FDECL(relink_light_sources, (BOOLEAN_P)); E void FDECL(relink_light_sources, (BOOLEAN_P));
E void NDECL(light_sources_sanity_check); E void NDECL(light_sources_sanity_check);
@@ -1300,8 +1303,8 @@ E void NDECL(fixup_special);
E void NDECL(fumaroles); E void NDECL(fumaroles);
E void NDECL(movebubbles); E void NDECL(movebubbles);
E void NDECL(water_friction); E void NDECL(water_friction);
E void FDECL(save_waterlevel, (int, int)); E void FDECL(save_waterlevel, (NHFILE *));
E void FDECL(restore_waterlevel, (int)); E void FDECL(restore_waterlevel, (NHFILE *));
E const char *FDECL(waterbody_name, (XCHAR_P, XCHAR_P)); E const char *FDECL(waterbody_name, (XCHAR_P, XCHAR_P));
/* ### mkobj.c ### */ /* ### mkobj.c ### */
@@ -1388,8 +1391,8 @@ E boolean FDECL(inside_room, (struct mkroom *, XCHAR_P, XCHAR_P));
E boolean FDECL(somexy, (struct mkroom *, coord *)); E boolean FDECL(somexy, (struct mkroom *, coord *));
E void FDECL(mkundead, (coord *, BOOLEAN_P, int)); E void FDECL(mkundead, (coord *, BOOLEAN_P, int));
E struct permonst *NDECL(courtmon); E struct permonst *NDECL(courtmon);
E void FDECL(save_rooms, (int)); E void FDECL(save_rooms, (NHFILE *));
E void FDECL(rest_rooms, (int)); E void FDECL(rest_rooms, (NHFILE *));
E struct mkroom *FDECL(search_special, (SCHAR_P)); E struct mkroom *FDECL(search_special, (SCHAR_P));
E int FDECL(cmap_to_type, (int)); E int FDECL(cmap_to_type, (int));
@@ -1674,8 +1677,8 @@ E void NDECL(init_objects);
E void FDECL(obj_shuffle_range, (int, int *, int *)); E void FDECL(obj_shuffle_range, (int, int *, int *));
E int NDECL(find_skates); E int NDECL(find_skates);
E void NDECL(oinit); E void NDECL(oinit);
E void FDECL(savenames, (int, int)); E void FDECL(savenames, (NHFILE *));
E void FDECL(restnames, (int)); E void FDECL(restnames, (NHFILE *));
E void FDECL(discover_object, (int, BOOLEAN_P, BOOLEAN_P)); E void FDECL(discover_object, (int, BOOLEAN_P, BOOLEAN_P));
E void FDECL(undiscover_object, (int)); E void FDECL(undiscover_object, (int));
E int NDECL(dodiscovered); E int NDECL(dodiscovered);
@@ -2098,8 +2101,8 @@ E void NDECL(update_player_regions);
E void FDECL(update_monster_region, (struct monst *)); E void FDECL(update_monster_region, (struct monst *));
E NhRegion *FDECL(visible_region_at, (XCHAR_P, XCHAR_P)); E NhRegion *FDECL(visible_region_at, (XCHAR_P, XCHAR_P));
E void FDECL(show_region, (NhRegion *, XCHAR_P, XCHAR_P)); E void FDECL(show_region, (NhRegion *, XCHAR_P, XCHAR_P));
E void FDECL(save_regions, (int, int)); E void FDECL(save_regions, (NHFILE *));
E void FDECL(rest_regions, (int, BOOLEAN_P)); E void FDECL(rest_regions, (NHFILE *, BOOLEAN_P));
E void FDECL(region_stats, (const char *, char *, long *, long *)); E void FDECL(region_stats, (const char *, char *, long *, long *));
E NhRegion *FDECL(create_gas_cloud, (XCHAR_P, XCHAR_P, int, int)); E NhRegion *FDECL(create_gas_cloud, (XCHAR_P, XCHAR_P, int, int));
E boolean NDECL(region_danger); E boolean NDECL(region_danger);
@@ -2108,18 +2111,19 @@ E void NDECL(region_safety);
/* ### restore.c ### */ /* ### restore.c ### */
E void FDECL(inven_inuse, (BOOLEAN_P)); E void FDECL(inven_inuse, (BOOLEAN_P));
E int FDECL(dorecover, (int)); E int FDECL(dorecover, (NHFILE *));
E void FDECL(restcemetery, (int, struct cemetery **)); E void FDECL(restcemetery, (NHFILE *, struct cemetery **));
E void FDECL(trickery, (char *)); E void FDECL(trickery, (char *));
E void FDECL(getlev, (int, int, XCHAR_P, BOOLEAN_P)); E void FDECL(getlev, (NHFILE *, int, XCHAR_P, BOOLEAN_P));
E void FDECL(get_plname_from_file, (int, char *)); E void FDECL(get_plname_from_file, (NHFILE *, char *));
#ifdef SELECTSAVED #ifdef SELECTSAVED
E int FDECL(restore_menu, (winid)); E int FDECL(restore_menu, (winid));
#endif #endif
E void NDECL(minit); E void NDECL(minit);
E boolean FDECL(lookup_id_mapping, (unsigned, unsigned *)); E boolean FDECL(lookup_id_mapping, (unsigned, unsigned *));
E void FDECL(mread, (int, genericptr_t, unsigned int)); E void FDECL(mread, (int, genericptr_t, unsigned int));
E int FDECL(validate, (int, const char *)); E void FDECL(newread, (NHFILE *, int, int, genericptr_t, unsigned int));
E int FDECL(validate, (NHFILE *, const char *));
E void NDECL(reset_restpref); E void NDECL(reset_restpref);
E void FDECL(set_restpref, (const char *)); E void FDECL(set_restpref, (const char *));
E void FDECL(set_savepref, (const char *)); E void FDECL(set_savepref, (const char *));
@@ -2183,8 +2187,8 @@ E char *FDECL(getrumor, (int, char *, BOOLEAN_P));
E char *FDECL(get_rnd_text, (const char *, char *, int FDECL((*), (int)))); E char *FDECL(get_rnd_text, (const char *, char *, int FDECL((*), (int))));
E void FDECL(outrumor, (int, int)); E void FDECL(outrumor, (int, int));
E void FDECL(outoracle, (BOOLEAN_P, BOOLEAN_P)); E void FDECL(outoracle, (BOOLEAN_P, BOOLEAN_P));
E void FDECL(save_oracles, (int, int)); E void FDECL(save_oracles, (NHFILE *));
E void FDECL(restore_oracles, (int)); E void FDECL(restore_oracles, (NHFILE *));
E int FDECL(doconsult, (struct monst *)); E int FDECL(doconsult, (struct monst *));
E void NDECL(rumor_check); E void NDECL(rumor_check);
@@ -2192,16 +2196,16 @@ E void NDECL(rumor_check);
E int NDECL(dosave); E int NDECL(dosave);
E int NDECL(dosave0); E int NDECL(dosave0);
E boolean FDECL(tricked_fileremoved, (int, char *)); E boolean FDECL(tricked_fileremoved, (NHFILE *, char *));
#ifdef INSURANCE #ifdef INSURANCE
E void NDECL(savestateinlock); E void NDECL(savestateinlock);
#endif #endif
#ifdef MFLOPPY #ifdef MFLOPPY
E boolean FDECL(savelev, (int, XCHAR_P, int)); E boolean FDECL(savelev, (NHFILE *, XCHAR_P));
E boolean FDECL(swapin_file, (int)); E boolean FDECL(swapin_file, (int));
E void NDECL(co_false); E void NDECL(co_false);
#else #else
E void FDECL(savelev, (int, XCHAR_P, int)); E void FDECL(savelev, (NHFILE *, XCHAR_P));
#endif #endif
E genericptr_t FDECL(mon_to_buffer, (struct monst *, int *)); E genericptr_t FDECL(mon_to_buffer, (struct monst *, int *));
E void FDECL(bufon, (int)); E void FDECL(bufon, (int));
@@ -2210,15 +2214,22 @@ E void FDECL(bflush, (int));
E void FDECL(bwrite, (int, genericptr_t, unsigned int)); E void FDECL(bwrite, (int, genericptr_t, unsigned int));
E void FDECL(bclose, (int)); E void FDECL(bclose, (int));
E void FDECL(def_bclose, (int)); E void FDECL(def_bclose, (int));
E void FDECL(newwrite, (NHFILE *, int, int, genericptr_t, unsigned int));
E void FDECL(newclose, (NHFILE *));
#if defined(ZEROCOMP) #if defined(ZEROCOMP)
E void FDECL(zerocomp_bclose, (int)); E void FDECL(zerocomp_bclose, (int));
#endif #endif
E void FDECL(savecemetery, (int, int, struct cemetery **)); E void FDECL(savecemetery, (NHFILE *, struct cemetery **));
E void FDECL(savefruitchn, (int, int)); E void FDECL(savefruitchn, (NHFILE *));
E void FDECL(store_plname_in_file, (int)); E void FDECL(store_plname_in_file, (NHFILE *));
E void NDECL(free_dungeons); E void NDECL(free_dungeons);
E void NDECL(freedynamicdata); E void NDECL(freedynamicdata);
E void FDECL(store_savefileinfo, (int)); E void FDECL(store_savefileinfo, (NHFILE *));
E void FDECL(store_savefileinfo, (NHFILE *));
E int NDECL(nhdatatypes_size);
E void FDECL(assignlog, (char *, char*, int));
E FILE *FDECL(getlog, (NHFILE *));
E void FDECL(closelog, (NHFILE *));
/* ### shk.c ### */ /* ### shk.c ### */
@@ -2455,8 +2466,8 @@ E void FDECL(spot_stop_timers, (XCHAR_P, XCHAR_P, SHORT_P));
E long FDECL(spot_time_expires, (XCHAR_P, XCHAR_P, SHORT_P)); E long FDECL(spot_time_expires, (XCHAR_P, XCHAR_P, SHORT_P));
E long FDECL(spot_time_left, (XCHAR_P, XCHAR_P, SHORT_P)); E long FDECL(spot_time_left, (XCHAR_P, XCHAR_P, SHORT_P));
E boolean FDECL(obj_is_local, (struct obj *)); E boolean FDECL(obj_is_local, (struct obj *));
E void FDECL(save_timers, (int, int, int)); E void FDECL(save_timers, (NHFILE *, int));
E void FDECL(restore_timers, (int, int, BOOLEAN_P, long)); E void FDECL(restore_timers, (NHFILE *, int, BOOLEAN_P, long));
E void FDECL(timer_stats, (const char *, char *, long *, long *)); E void FDECL(timer_stats, (const char *, char *, long *, long *));
E void FDECL(relink_timers, (BOOLEAN_P)); E void FDECL(relink_timers, (BOOLEAN_P));
E int NDECL(wiz_timeout_queue); E int NDECL(wiz_timeout_queue);
@@ -2630,9 +2641,9 @@ E int NDECL(doextversion);
E boolean FDECL(comp_times, (long)); E boolean FDECL(comp_times, (long));
#endif #endif
E boolean E boolean
FDECL(check_version, (struct version_info *, const char *, BOOLEAN_P)); FDECL(check_version, (struct version_info *, const char *, BOOLEAN_P, unsigned long));
E boolean FDECL(uptodate, (int, const char *)); E boolean FDECL(uptodate, (NHFILE *, const char *, unsigned long));
E void FDECL(store_version, (int)); E void FDECL(store_version, (NHFILE *));
E unsigned long FDECL(get_feature_notice_ver, (char *)); E unsigned long FDECL(get_feature_notice_ver, (char *));
E unsigned long NDECL(get_current_feature_ver); E unsigned long NDECL(get_current_feature_ver);
E const char *FDECL(copyright_banner_line, (int)); E const char *FDECL(copyright_banner_line, (int));
@@ -2882,8 +2893,8 @@ E void FDECL(wormhitu, (struct monst *));
E void FDECL(cutworm, (struct monst *, XCHAR_P, XCHAR_P, BOOLEAN_P)); E void FDECL(cutworm, (struct monst *, XCHAR_P, XCHAR_P, BOOLEAN_P));
E void FDECL(see_wsegs, (struct monst *)); E void FDECL(see_wsegs, (struct monst *));
E void FDECL(detect_wsegs, (struct monst *, BOOLEAN_P)); E void FDECL(detect_wsegs, (struct monst *, BOOLEAN_P));
E void FDECL(save_worm, (int, int)); E void FDECL(save_worm, (NHFILE *));
E void FDECL(rest_worm, (int)); E void FDECL(rest_worm, (NHFILE *));
E void FDECL(place_wsegs, (struct monst *, struct monst *)); E void FDECL(place_wsegs, (struct monst *, struct monst *));
E void FDECL(sanity_check_worm, (struct monst *)); E void FDECL(sanity_check_worm, (struct monst *));
E void FDECL(remove_worm, (struct monst *)); E void FDECL(remove_worm, (struct monst *));
+7
View File
@@ -232,6 +232,13 @@ enum hmon_atkmode_types {
HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */ HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */
}; };
enum saveformats {
invalid = 0,
historical = 1, /* entire struct, binary, as-is */
lendian = 2, /* each field, binary, little-endian */
ascii = 3 /* each field, ascii text (just proof of concept) */
};
/* sortloot() return type; needed before extern.h */ /* sortloot() return type; needed before extern.h */
struct sortloot_item { struct sortloot_item {
struct obj *obj; struct obj *obj;
-7
View File
@@ -8,12 +8,5 @@
#ifndef LEV_H #ifndef LEV_H
#define LEV_H #define LEV_H
#define COUNT_SAVE 0x1
#define WRITE_SAVE 0x2
#define FREE_SAVE 0x4
/* operations of the various saveXXXchn & co. routines */
#define perform_bwrite(mode) ((mode) & (COUNT_SAVE | WRITE_SAVE))
#define release_data(mode) ((mode) &FREE_SAVE)
#endif /* LEV_H */ #endif /* LEV_H */
+2
View File
@@ -80,6 +80,7 @@
* objects being thrown when the hangup occurs. \ * objects being thrown when the hangup occurs. \
*/ */
#define MAIL
/* Stuff to help the user with some common, yet significant errors */ /* Stuff to help the user with some common, yet significant errors */
#define INTERJECT_PANIC 0 #define INTERJECT_PANIC 0
#define INTERJECTION_TYPES (INTERJECT_PANIC + 1) #define INTERJECTION_TYPES (INTERJECT_PANIC + 1)
@@ -104,6 +105,7 @@ extern void NDECL(getlock);
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#define HAS_STDINT
#if (_MSC_VER > 1000) #if (_MSC_VER > 1000)
/* Visual C 8 warning elimination */ /* Visual C 8 warning elimination */
#ifndef _CRT_SECURE_NO_DEPRECATE #ifndef _CRT_SECURE_NO_DEPRECATE
+192
View File
@@ -0,0 +1,192 @@
/* NetHack 3.6 sfprocs.h Tue Nov 6 19:38:48 2018 */
/* Copyright (c) NetHack Development Team 2018. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef SFPROCS_H
#define SFPROCS_H
#include "hack.h"
#include "integer.h"
#include "wintype.h"
#define E extern
/* output routines */
E void FDECL(ascii_sfo_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(ascii_sfo_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(ascii_sfo_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(ascii_sfo_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(ascii_sfo_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(ascii_sfo_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(ascii_sfo_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(ascii_sfo_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(ascii_sfo_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(ascii_sfo_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(ascii_sfo_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(ascii_sfo_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(ascii_sfo_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(ascii_sfo_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(ascii_sfo_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(ascii_sfo_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(ascii_sfo_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(ascii_sfo_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(ascii_sfo_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(ascii_sfo_addinfo, (NHFILE *, const char *, const char *, const char *, int));
/* input routines */
E void FDECL(ascii_sfi_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(ascii_sfi_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(ascii_sfi_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(ascii_sfi_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(ascii_sfi_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(ascii_sfi_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(ascii_sfi_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(ascii_sfi_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(ascii_sfi_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(ascii_sfi_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(ascii_sfi_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(ascii_sfi_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(ascii_sfi_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(ascii_sfi_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(ascii_sfi_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(ascii_sfi_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(ascii_sfi_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(ascii_sfi_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(ascii_sfi_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(ascii_sfi_addinfo, (NHFILE *, const char *, const char *, const char *, int));
/* output routines */
E void FDECL(lendian_sfo_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(lendian_sfo_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(lendian_sfo_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(lendian_sfo_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(lendian_sfo_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(lendian_sfo_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(lendian_sfo_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(lendian_sfo_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(lendian_sfo_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(lendian_sfo_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(lendian_sfo_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(lendian_sfo_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(lendian_sfo_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(lendian_sfo_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(lendian_sfo_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(lendian_sfo_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(lendian_sfo_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(lendian_sfo_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(lendian_sfo_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(lendian_sfo_addinfo, (NHFILE *, const char *, const char *, const char *, int));
/* input routines */
E void FDECL(lendian_sfi_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(lendian_sfi_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(lendian_sfi_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(lendian_sfi_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(lendian_sfi_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(lendian_sfi_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(lendian_sfi_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(lendian_sfi_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(lendian_sfi_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(lendian_sfi_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(lendian_sfi_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(lendian_sfi_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(lendian_sfi_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(lendian_sfi_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(lendian_sfi_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(lendian_sfi_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(lendian_sfi_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(lendian_sfi_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(lendian_sfi_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(lendian_sfi_addinfo, (NHFILE *, const char *, const char *, const char *, int));
#ifdef JSON_SUPPORT
/* output routines */
E void FDECL(json_sfo_aligntyp, (NHFILE *, aligntype *, const char *, const char *, int));
E void FDECL(json_sfo_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(json_sfo_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(json_sfo_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(json_sfo_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(json_sfo_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(json_sfo_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(json_sfo_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(json_sfo_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(json_sfo_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(json_sfo_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(json_sfo_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(json_sfo_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(json_sfo_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(json_sfo_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(json_sfo_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(json_sfo_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(json_sfo_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(json_sfo_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(json_sfo_addinfo), (NHFILE *, const char *, const char *, const char *, int));
/* input routines */
E void FDECL(json_sfi_aligntyp, (NHFILE *, aligntype *, const char *, const char *, int));
E void FDECL(json_sfi_any, (NHFILE *, union any *d_any, const char *, const char *, int));
E void FDECL(json_sfi_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(json_sfi_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(json_sfi_char, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(json_sfi_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(json_sfi_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(json_sfi_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(json_sfi_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(json_sfi_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(json_sfi_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(json_sfi_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(json_sfi_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(json_sfi_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(json_sfi_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(json_sfi_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(json_sfi_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(json_sfi_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(json_sfi_str, (NHFILE *, char *, const char *, const char *, int));
E void FDECL(json_sfi_addinfo), (NHFILE *, const char *, const char *, const char *, int));
#endif /* JSON_SUPPORT */
struct fieldlevel_procs {
void FDECL((*sf_aligntyp), (NHFILE *, aligntyp *, const char *, const char *, int));
void FDECL((*sf_any), (NHFILE *, union any *d_any, const char *, const char *, int));
void FDECL((*sf_bitfield), (NHFILE *, uint8_t *, const char *, const char *, int));
void FDECL((*sf_boolean), (NHFILE *, boolean *, const char *, const char *, int));
void FDECL((*sf_char), (NHFILE *, char *, const char *, const char *, int));
void FDECL((*sf_genericptr), (NHFILE *, genericptr_t *, const char *, const char *, int));
void FDECL((*sf_int), (NHFILE *, int *, const char *, const char *, int));
void FDECL((*sf_long), (NHFILE *, long *, const char *, const char *, int));
void FDECL((*sf_schar), (NHFILE *, schar *, const char *, const char *, int));
void FDECL((*sf_short), (NHFILE *, short *, const char *, const char *, int));
void FDECL((*sf_size_t), (NHFILE *, size_t *, const char *, const char *, int));
void FDECL((*sf_time_t), (NHFILE *, time_t *, const char *, const char *, int));
void FDECL((*sf_unsigned), (NHFILE *, unsigned *, const char *, const char *, int));
void FDECL((*sf_uchar), (NHFILE *, unsigned char *, const char *, const char *, int));
void FDECL((*sf_uint), (NHFILE *, unsigned int *, const char *, const char *, int));
void FDECL((*sf_ulong), (NHFILE *, unsigned long *, const char *, const char *, int));
void FDECL((*sf_ushort), (NHFILE *, unsigned short *, const char *, const char *, int));
void FDECL((*sf_xchar), (NHFILE *, xchar *, const char *, const char *, int));
void FDECL((*sf_str), (NHFILE *, char *, const char *, const char *, int));
void FDECL((*sf_addinfo), (NHFILE *, const char *, const char *, const char *, int));
};
struct sf_procs {
const char *ext;
struct fieldlevel_procs fn;
};
E void NDECL(sf_init);
E struct sf_procs sfoprocs[4], sfiprocs[4];
E struct sf_procs ascii_sfo_procs;
E struct sf_procs ascii_sfi_procs;
E struct sf_procs lendian_sfo_procs;
E struct sf_procs lendian_sfi_procs;
E struct sf_procs stub_sfo_procs;
E struct sf_procs stub_sfi_procs;
#ifdef JSON_SUPPORT
E struct sf_procs json_sfo_procs;
E struct sf_procs json_sfi_procs;
#endif
#undef E
#endif /* SFPROCS_H */
+201
View File
@@ -0,0 +1,201 @@
/* NetHack 3.7 sfproto.h Sat Jun 22 23:55:47 2019 */
/* Copyright (c) NetHack Development Team 2018. */
/* NetHack may be freely redistributed. See license for details. */
/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE! */
#ifndef SFPROTO_H
#define SFPROTO_H
#include "hack.h"
#include "integer.h"
#include "wintype.h"
#define E extern
E int NDECL(critical_members_count);
/* sfbase.c output functions */
E void FDECL(sfo_addinfo, (NHFILE *, const char *, const char *, const char *, int));
E void FDECL(sfo_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(sfo_any, (NHFILE *, anything *, const char *, const char *, int));
E void FDECL(sfo_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(sfo_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(sfo_char, (NHFILE *, const char *, const char *, const char *, int));
E void FDECL(sfo_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(sfo_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(sfo_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(sfo_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(sfo_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(sfo_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(sfo_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(sfo_uchar, (NHFILE *, uchar *, const char *, const char *, int));
E void FDECL(sfo_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(sfo_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(sfo_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(sfo_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(sfo_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(sfo_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(sfo_str, (NHFILE *, const char *, const char *, const char *, int));
/* sfbase.c input functions */
E void FDECL(sfi_addinfo, (NHFILE *, const char *, const char *, const char *, int));
E void FDECL(sfi_aligntyp, (NHFILE *, aligntyp *, const char *, const char *, int));
E void FDECL(sfi_any, (NHFILE *, anything *, const char *, const char *, int));
E void FDECL(sfi_bitfield, (NHFILE *, uint8_t *, const char *, const char *, int));
E void FDECL(sfi_boolean, (NHFILE *, boolean *, const char *, const char *, int));
E void FDECL(sfi_char, (NHFILE *, const char *, const char *, const char *, int));
E void FDECL(sfi_genericptr, (NHFILE *, genericptr_t *, const char *, const char *, int));
E void FDECL(sfi_int, (NHFILE *, int *, const char *, const char *, int));
E void FDECL(sfi_long, (NHFILE *, long *, const char *, const char *, int));
E void FDECL(sfi_schar, (NHFILE *, schar *, const char *, const char *, int));
E void FDECL(sfi_short, (NHFILE *, short *, const char *, const char *, int));
E void FDECL(sfi_size_t, (NHFILE *, size_t *, const char *, const char *, int));
E void FDECL(sfi_time_t, (NHFILE *, time_t *, const char *, const char *, int));
E void FDECL(sfi_uchar, (NHFILE *, uchar *, const char *, const char *, int));
E void FDECL(sfi_unsigned, (NHFILE *, unsigned *, const char *, const char *, int));
E void FDECL(sfi_uchar, (NHFILE *, unsigned char *, const char *, const char *, int));
E void FDECL(sfi_uint, (NHFILE *, unsigned int *, const char *, const char *, int));
E void FDECL(sfi_ulong, (NHFILE *, unsigned long *, const char *, const char *, int));
E void FDECL(sfi_ushort, (NHFILE *, unsigned short *, const char *, const char *, int));
E void FDECL(sfi_xchar, (NHFILE *, xchar *, const char *, const char *, int));
E void FDECL(sfi_str, (NHFILE *, const char *, const char *, const char *, int));
/* generated output functions */
E void FDECL(sfo_align, (NHFILE *, struct align *, const char *, const char *, int));
E void FDECL(sfo_attribs, (NHFILE *, struct attribs *, const char *, const char *, int));
E void FDECL(sfo_bill_x, (NHFILE *, struct bill_x *, const char *, const char *, int));
E void FDECL(sfo_book_info, (NHFILE *, struct book_info *, const char *, const char *, int));
E void FDECL(sfo_branch, (NHFILE *, struct branch *, const char *, const char *, int));
E void FDECL(sfo_bubble, (NHFILE *, struct bubble *, const char *, const char *, int));
E void FDECL(sfo_cemetery, (NHFILE *, struct cemetery *, const char *, const char *, int));
E void FDECL(sfo_context_info, (NHFILE *, struct context_info *, const char *, const char *, int));
E void FDECL(sfo_d_flags, (NHFILE *, struct d_flags *, const char *, const char *, int));
E void FDECL(sfo_d_level, (NHFILE *, struct d_level *, const char *, const char *, int));
E void FDECL(sfo_damage, (NHFILE *, struct damage *, const char *, const char *, int));
E void FDECL(sfo_dest_area, (NHFILE *, struct dest_area *, const char *, const char *, int));
E void FDECL(sfo_dgn_topology, (NHFILE *, struct dgn_topology *, const char *, const char *, int));
E void FDECL(sfo_dig_info, (NHFILE *, struct dig_info *, const char *, const char *, int));
E void FDECL(sfo_dungeon, (NHFILE *, struct dungeon *, const char *, const char *, int));
E void FDECL(sfo_edog, (NHFILE *, struct edog *, const char *, const char *, int));
E void FDECL(sfo_egd, (NHFILE *, struct egd *, const char *, const char *, int));
E void FDECL(sfo_emin, (NHFILE *, struct emin *, const char *, const char *, int));
E void FDECL(sfo_engr, (NHFILE *, struct engr *, const char *, const char *, int));
E void FDECL(sfo_epri, (NHFILE *, struct epri *, const char *, const char *, int));
E void FDECL(sfo_eshk, (NHFILE *, struct eshk *, const char *, const char *, int));
E void FDECL(sfo_fakecorridor, (NHFILE *, struct fakecorridor *, const char *, const char *, int));
E void FDECL(sfo_fe, (NHFILE *, struct fe *, const char *, const char *, int));
E void FDECL(sfo_flag, (NHFILE *, struct flag *, const char *, const char *, int));
E void FDECL(sfo_fruit, (NHFILE *, struct fruit *, const char *, const char *, int));
E void FDECL(sfo_kinfo, (NHFILE *, struct kinfo *, const char *, const char *, int));
E void FDECL(sfo_levelflags, (NHFILE *, struct levelflags *, const char *, const char *, int));
E void FDECL(sfo_linfo, (NHFILE *, struct linfo *, const char *, const char *, int));
E void FDECL(sfo_ls_t, (NHFILE *, struct ls_t *, const char *, const char *, int));
E void FDECL(sfo_mapseen_feat, (NHFILE *, struct mapseen_feat *, const char *, const char *, int));
E void FDECL(sfo_mapseen_flags, (NHFILE *, struct mapseen_flags *, const char *, const char *, int));
E void FDECL(sfo_mapseen_rooms, (NHFILE *, struct mapseen_rooms *, const char *, const char *, int));
E void FDECL(sfo_mapseen, (NHFILE *, struct mapseen *, const char *, const char *, int));
E void FDECL(sfo_mextra, (NHFILE *, struct mextra *, const char *, const char *, int));
E void FDECL(sfo_mkroom, (NHFILE *, struct mkroom *, const char *, const char *, int));
E void FDECL(sfo_monst, (NHFILE *, struct monst *, const char *, const char *, int));
E void FDECL(sfo_mvitals, (NHFILE *, struct mvitals *, const char *, const char *, int));
E void FDECL(sfo_nhcoord, (NHFILE *, struct nhcoord *, const char *, const char *, int));
E void FDECL(sfo_nhrect, (NHFILE *, struct nhrect *, const char *, const char *, int));
E void FDECL(sfo_novel_tracking, (NHFILE *, struct novel_tracking *, const char *, const char *, int));
E void FDECL(sfo_obj, (NHFILE *, struct obj *, const char *, const char *, int));
E void FDECL(sfo_objclass, (NHFILE *, struct objclass *, const char *, const char *, int));
E void FDECL(sfo_obj_split, (NHFILE *, struct obj_split *, const char *, const char *, int));
E void FDECL(sfo_oextra, (NHFILE *, struct oextra *, const char *, const char *, int));
E void FDECL(sfo_polearm_info, (NHFILE *, struct polearm_info *, const char *, const char *, int));
E void FDECL(sfo_prop, (NHFILE *, struct prop *, const char *, const char *, int));
E void FDECL(sfo_q_score, (NHFILE *, struct q_score *, const char *, const char *, int));
E void FDECL(sfo_rm, (NHFILE *, struct rm *, const char *, const char *, int));
E void FDECL(sfo_s_level, (NHFILE *, struct s_level *, const char *, const char *, int));
E void FDECL(sfo_savefile_info, (NHFILE *, struct savefile_info *, const char *, const char *, int));
E void FDECL(sfo_skills, (NHFILE *, struct skills *, const char *, const char *, int));
E void FDECL(sfo_spell, (NHFILE *, struct spell *, const char *, const char *, int));
E void FDECL(sfo_stairway, (NHFILE *, struct stairway *, const char *, const char *, int));
E void FDECL(sfo_takeoff_info, (NHFILE *, struct takeoff_info *, const char *, const char *, int));
E void FDECL(sfo_tin_info, (NHFILE *, struct tin_info *, const char *, const char *, int));
E void FDECL(sfo_trap, (NHFILE *, struct trap *, const char *, const char *, int));
E void FDECL(sfo_tribute_info, (NHFILE *, struct tribute_info *, const char *, const char *, int));
E void FDECL(sfo_u_achieve, (NHFILE *, struct u_achieve *, const char *, const char *, int));
E void FDECL(sfo_u_conduct, (NHFILE *, struct u_conduct *, const char *, const char *, int));
E void FDECL(sfo_u_event, (NHFILE *, struct u_event *, const char *, const char *, int));
E void FDECL(sfo_u_have, (NHFILE *, struct u_have *, const char *, const char *, int));
E void FDECL(sfo_u_realtime, (NHFILE *, struct u_realtime *, const char *, const char *, int));
E void FDECL(sfo_u_roleplay, (NHFILE *, struct u_roleplay *, const char *, const char *, int));
E void FDECL(sfo_version_info, (NHFILE *, struct version_info *, const char *, const char *, int));
E void FDECL(sfo_victual_info, (NHFILE *, struct victual_info *, const char *, const char *, int));
E void FDECL(sfo_vlaunchinfo, (NHFILE *, union vlaunchinfo *, const char *, const char *, int));
E void FDECL(sfo_vptrs, (NHFILE *, union vptrs *, const char *, const char *, int));
E void FDECL(sfo_warntype_info, (NHFILE *, struct warntype_info *, const char *, const char *, int));
E void FDECL(sfo_you, (NHFILE *, struct you *, const char *, const char *, int));
/* generated input functions */
E void FDECL(sfi_align, (NHFILE *, struct align *, const char *, const char *, int));
E void FDECL(sfi_attribs, (NHFILE *, struct attribs *, const char *, const char *, int));
E void FDECL(sfi_bill_x, (NHFILE *, struct bill_x *, const char *, const char *, int));
E void FDECL(sfi_book_info, (NHFILE *, struct book_info *, const char *, const char *, int));
E void FDECL(sfi_branch, (NHFILE *, struct branch *, const char *, const char *, int));
E void FDECL(sfi_bubble, (NHFILE *, struct bubble *, const char *, const char *, int));
E void FDECL(sfi_cemetery, (NHFILE *, struct cemetery *, const char *, const char *, int));
E void FDECL(sfi_context_info, (NHFILE *, struct context_info *, const char *, const char *, int));
E void FDECL(sfi_d_flags, (NHFILE *, struct d_flags *, const char *, const char *, int));
E void FDECL(sfi_d_level, (NHFILE *, struct d_level *, const char *, const char *, int));
E void FDECL(sfi_damage, (NHFILE *, struct damage *, const char *, const char *, int));
E void FDECL(sfi_dest_area, (NHFILE *, struct dest_area *, const char *, const char *, int));
E void FDECL(sfi_dgn_topology, (NHFILE *, struct dgn_topology *, const char *, const char *, int));
E void FDECL(sfi_dig_info, (NHFILE *, struct dig_info *, const char *, const char *, int));
E void FDECL(sfi_dungeon, (NHFILE *, struct dungeon *, const char *, const char *, int));
E void FDECL(sfi_edog, (NHFILE *, struct edog *, const char *, const char *, int));
E void FDECL(sfi_egd, (NHFILE *, struct egd *, const char *, const char *, int));
E void FDECL(sfi_emin, (NHFILE *, struct emin *, const char *, const char *, int));
E void FDECL(sfi_engr, (NHFILE *, struct engr *, const char *, const char *, int));
E void FDECL(sfi_epri, (NHFILE *, struct epri *, const char *, const char *, int));
E void FDECL(sfi_eshk, (NHFILE *, struct eshk *, const char *, const char *, int));
E void FDECL(sfi_fakecorridor, (NHFILE *, struct fakecorridor *, const char *, const char *, int));
E void FDECL(sfi_fe, (NHFILE *, struct fe *, const char *, const char *, int));
E void FDECL(sfi_flag, (NHFILE *, struct flag *, const char *, const char *, int));
E void FDECL(sfi_fruit, (NHFILE *, struct fruit *, const char *, const char *, int));
E void FDECL(sfi_kinfo, (NHFILE *, struct kinfo *, const char *, const char *, int));
E void FDECL(sfi_levelflags, (NHFILE *, struct levelflags *, const char *, const char *, int));
E void FDECL(sfi_linfo, (NHFILE *, struct linfo *, const char *, const char *, int));
E void FDECL(sfi_ls_t, (NHFILE *, struct ls_t *, const char *, const char *, int));
E void FDECL(sfi_mapseen_feat, (NHFILE *, struct mapseen_feat *, const char *, const char *, int));
E void FDECL(sfi_mapseen_flags, (NHFILE *, struct mapseen_flags *, const char *, const char *, int));
E void FDECL(sfi_mapseen_rooms, (NHFILE *, struct mapseen_rooms *, const char *, const char *, int));
E void FDECL(sfi_mapseen, (NHFILE *, struct mapseen *, const char *, const char *, int));
E void FDECL(sfi_mextra, (NHFILE *, struct mextra *, const char *, const char *, int));
E void FDECL(sfi_mkroom, (NHFILE *, struct mkroom *, const char *, const char *, int));
E void FDECL(sfi_monst, (NHFILE *, struct monst *, const char *, const char *, int));
E void FDECL(sfi_mvitals, (NHFILE *, struct mvitals *, const char *, const char *, int));
E void FDECL(sfi_nhcoord, (NHFILE *, struct nhcoord *, const char *, const char *, int));
E void FDECL(sfi_nhrect, (NHFILE *, struct nhrect *, const char *, const char *, int));
E void FDECL(sfi_novel_tracking, (NHFILE *, struct novel_tracking *, const char *, const char *, int));
E void FDECL(sfi_obj, (NHFILE *, struct obj *, const char *, const char *, int));
E void FDECL(sfi_objclass, (NHFILE *, struct objclass *, const char *, const char *, int));
E void FDECL(sfi_obj_split, (NHFILE *, struct obj_split *, const char *, const char *, int));
E void FDECL(sfi_oextra, (NHFILE *, struct oextra *, const char *, const char *, int));
E void FDECL(sfi_polearm_info, (NHFILE *, struct polearm_info *, const char *, const char *, int));
E void FDECL(sfi_prop, (NHFILE *, struct prop *, const char *, const char *, int));
E void FDECL(sfi_q_score, (NHFILE *, struct q_score *, const char *, const char *, int));
E void FDECL(sfi_rm, (NHFILE *, struct rm *, const char *, const char *, int));
E void FDECL(sfi_s_level, (NHFILE *, struct s_level *, const char *, const char *, int));
E void FDECL(sfi_savefile_info, (NHFILE *, struct savefile_info *, const char *, const char *, int));
E void FDECL(sfi_skills, (NHFILE *, struct skills *, const char *, const char *, int));
E void FDECL(sfi_spell, (NHFILE *, struct spell *, const char *, const char *, int));
E void FDECL(sfi_stairway, (NHFILE *, struct stairway *, const char *, const char *, int));
E void FDECL(sfi_takeoff_info, (NHFILE *, struct takeoff_info *, const char *, const char *, int));
E void FDECL(sfi_tin_info, (NHFILE *, struct tin_info *, const char *, const char *, int));
E void FDECL(sfi_trap, (NHFILE *, struct trap *, const char *, const char *, int));
E void FDECL(sfi_tribute_info, (NHFILE *, struct tribute_info *, const char *, const char *, int));
E void FDECL(sfi_u_achieve, (NHFILE *, struct u_achieve *, const char *, const char *, int));
E void FDECL(sfi_u_conduct, (NHFILE *, struct u_conduct *, const char *, const char *, int));
E void FDECL(sfi_u_event, (NHFILE *, struct u_event *, const char *, const char *, int));
E void FDECL(sfi_u_have, (NHFILE *, struct u_have *, const char *, const char *, int));
E void FDECL(sfi_u_realtime, (NHFILE *, struct u_realtime *, const char *, const char *, int));
E void FDECL(sfi_u_roleplay, (NHFILE *, struct u_roleplay *, const char *, const char *, int));
E void FDECL(sfi_version_info, (NHFILE *, struct version_info *, const char *, const char *, int));
E void FDECL(sfi_victual_info, (NHFILE *, struct victual_info *, const char *, const char *, int));
E void FDECL(sfi_vlaunchinfo, (NHFILE *, union vlaunchinfo *, const char *, const char *, int));
E void FDECL(sfi_vptrs, (NHFILE *, union vptrs *, const char *, const char *, int));
E void FDECL(sfi_warntype_info, (NHFILE *, struct warntype_info *, const char *, const char *, int));
E void FDECL(sfi_you, (NHFILE *, struct you *, const char *, const char *, int));
#endif /* SFPROTO_H */
+4
View File
@@ -41,6 +41,10 @@ struct sysopt {
char *greppath; char *greppath;
int panictrace_gdb; int panictrace_gdb;
int panictrace_libc; int panictrace_libc;
/* save and bones format */
int saveformat[2]; /* primary and onetime conversion */
int bonesformat[2]; /* primary and onetime conversion */
}; };
extern struct sysopt sysopt; extern struct sysopt sysopt;
+1 -2
View File
@@ -59,8 +59,7 @@ struct u_achieve {
Bitfield(bell, 1); /* touched Bell */ Bitfield(bell, 1); /* touched Bell */
Bitfield(book, 1); /* touched Book */ Bitfield(book, 1); /* touched Book */
Bitfield(menorah, 1); /* touched Candelabrum */ Bitfield(menorah, 1); /* touched Candelabrum */
Bitfield(enter_gehennom, Bitfield(enter_gehennom,1); /* entered Gehennom (or Valley) by any means */
1); /* entered Gehennom (or Valley) by any means */
Bitfield(ascended, 1); /* not quite the same as u.uevent.ascended */ Bitfield(ascended, 1); /* not quite the same as u.uevent.ascended */
Bitfield(mines_luckstone, 1); /* got a luckstone at end of mines */ Bitfield(mines_luckstone, 1); /* got a luckstone at end of mines */
Bitfield(finish_sokoban, 1); /* obtained the sokoban prize */ Bitfield(finish_sokoban, 1); /* obtained the sokoban prize */
+33 -9
View File
@@ -6,6 +6,8 @@
#include "hack.h" #include "hack.h"
#include "artifact.h" #include "artifact.h"
#include "artilist.h" #include "artilist.h"
#include "sfproto.h"
/* /*
* Note: both artilist[] and artiexist[] have a dummy element #0, * Note: both artilist[] and artiexist[] have a dummy element #0,
@@ -76,20 +78,42 @@ init_artifacts()
} }
void void
save_artifacts(fd) save_artifacts(nhfp)
int fd; NHFILE *nhfp;
{ {
bwrite(fd, (genericptr_t) g.artiexist, sizeof g.artiexist); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) g.artidisco, sizeof g.artidisco); bwrite(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
bwrite(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
}
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < (1 + NROFARTIFACTS + 1); ++i)
sfo_boolean(nhfp, &g.artiexist[i], "artifacts", "g.artiexist", 1);
for (i = 0; i < NROFARTIFACTS; ++i)
sfo_xchar(nhfp, &g.artidisco[i], "artifacts", "g.artidisco", 1);
}
} }
void void
restore_artifacts(fd) restore_artifacts(nhfp)
int fd; NHFILE *nhfp;
{ {
mread(fd, (genericptr_t) g.artiexist, sizeof g.artiexist); if (nhfp->structlevel) {
mread(fd, (genericptr_t) g.artidisco, sizeof g.artidisco); mread(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
hack_artifacts(); /* redo non-saved special cases */ mread(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
}
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < (1 + NROFARTIFACTS + 1); ++i)
sfi_boolean(nhfp, &g.artiexist[i], "artifacts", "g.artiexist", 1);
for (i = 0; i < NROFARTIFACTS; ++i)
sfi_xchar(nhfp, &g.artidisco[i], "artifacts", "g.artidisco", 1);
}
hack_artifacts(); /* redo non-saved special cases */
} }
const char * const char *
+68 -32
View File
@@ -5,6 +5,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" #include "lev.h"
#include "sfproto.h"
#ifdef MFLOPPY #ifdef MFLOPPY
extern long bytes_counted; extern long bytes_counted;
@@ -338,7 +340,7 @@ int how;
time_t when; time_t when;
struct obj *corpse; struct obj *corpse;
{ {
int fd, x, y; int x, y;
struct trap *ttmp; struct trap *ttmp;
struct monst *mtmp; struct monst *mtmp;
struct permonst *mptr; struct permonst *mptr;
@@ -346,13 +348,14 @@ struct obj *corpse;
struct cemetery *newbones; struct cemetery *newbones;
char c, *bonesid; char c, *bonesid;
char whynot[BUFSZ]; char whynot[BUFSZ];
NHFILE *nhfp;
/* caller has already checked `can_make_bones()' */ /* caller has already checked `can_make_bones()' */
clear_bypasses(); clear_bypasses();
fd = open_bonesfile(&u.uz, &bonesid); nhfp = open_bonesfile(&u.uz, &bonesid);
if (fd >= 0) { if (nhfp) {
(void) nhclose(fd); close_nhfile(nhfp);
if (wizard) { if (wizard) {
if (yn("Bones file already exists. Replace it?") == 'y') { if (yn("Bones file already exists. Replace it?") == 'y') {
if (delete_bonesfile(&u.uz)) if (delete_bonesfile(&u.uz))
@@ -500,8 +503,8 @@ struct obj *corpse;
if (wizard) if (wizard)
g.level.flags.wizard_bones = 1; g.level.flags.wizard_bones = 1;
fd = create_bonesfile(&u.uz, &bonesid, whynot); nhfp = create_bonesfile(&u.uz, &bonesid, whynot);
if (fd < 0) { if (!nhfp) {
if (wizard) if (wizard)
pline1(whynot); pline1(whynot);
/* bones file creation problems are silent to the player. /* bones file creation problems are silent to the player.
@@ -514,7 +517,10 @@ struct obj *corpse;
#ifdef MFLOPPY /* check whether there is room */ #ifdef MFLOPPY /* check whether there is room */
if (iflags.checkspace) { if (iflags.checkspace) {
savelev(fd, ledger_no(&u.uz), COUNT_SAVE); int savemode = nhfp->mode;
nhfp->mode = COUNTING;
savelev(nhfp, ledger_no(&u.uz));
/* savelev() initializes bytes_counted to 0, so it must come /* savelev() initializes bytes_counted to 0, so it must come
* first here even though it does not in the real save. the * first here even though it does not in the real save. the
* resulting extra bflush() at the end of savelev() may increase * resulting extra bflush() at the end of savelev() may increase
@@ -525,31 +531,47 @@ struct obj *corpse;
* this code would have to know the size of the version * this code would have to know the size of the version
* information itself. * information itself.
*/ */
store_version(fd); store_version(nhfp);
store_savefileinfo(fd); store_savefileinfo(nhfp);
bwrite(fd, (genericptr_t) &c, sizeof c); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */ bwrite(nhfp->fd, (genericptr_t) &c, sizeof c);
savefruitchn(fd, COUNT_SAVE); bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */
bflush(fd); }
if (nhfp->fieldlevel) {
sfo_char(nhfp, &c, "bones", "bones_count", 1);
sfo_char(nhfp, bonesid, "bones", "bonesid", (int) c);
}
savefruitchn(nhfp);
if (nhfp->structlevel)
bflush(nhfp->fd);
if (bytes_counted > freediskspace(bones)) { /* not enough room */ if (bytes_counted > freediskspace(bones)) { /* not enough room */
if (wizard) if (wizard)
pline("Insufficient space to create bones file."); pline("Insufficient space to create bones file.");
(void) nhclose(fd); close_nhfile(nhfp);
cancel_bonesfile(); cancel_bonesfile();
return; return;
} }
co_false(); /* make sure stuff before savelev() gets written */ co_false(); /* make sure stuff before savelev() gets written */
nhfp->mode = savemode;
} }
#endif /* MFLOPPY */ #endif /* MFLOPPY */
store_version(fd); nhfp->mode = WRITING | FREEING;
store_savefileinfo(fd); store_version(nhfp);
bwrite(fd, (genericptr_t) &c, sizeof c); store_savefileinfo(nhfp);
bwrite(fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */ if (nhfp->structlevel) {
savefruitchn(fd, WRITE_SAVE | FREE_SAVE); bwrite(nhfp->fd, (genericptr_t) &c, sizeof c);
bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */
savefruitchn(nhfp);
}
if (nhfp->fieldlevel) {
sfo_char(nhfp, &c, "bones", "bones_count", 1);
sfo_char(nhfp, bonesid, "bones", "bonesid", (int) c); /* DD.nnn */
savefruitchn(nhfp);
}
update_mlstmv(); /* update monsters for eventual restoration */ update_mlstmv(); /* update monsters for eventual restoration */
savelev(fd, ledger_no(&u.uz), WRITE_SAVE | FREE_SAVE); savelev(nhfp, ledger_no(&u.uz));
bclose(fd); close_nhfile(nhfp);
commit_bonesfile(&u.uz); commit_bonesfile(&u.uz);
compress_bonesfile(); compress_bonesfile();
} }
@@ -557,8 +579,8 @@ struct obj *corpse;
int int
getbones() getbones()
{ {
register int fd; int ok, i;
register int ok; NHFILE *nhfp = (NHFILE *) 0;
char c, *bonesid, oldbonesid[40]; /* was [10]; more should be safer */ char c, *bonesid, oldbonesid[40]; /* was [10]; more should be safer */
if (discover) /* save bones files for real games */ if (discover) /* save bones files for real games */
@@ -572,11 +594,18 @@ getbones()
return 0; return 0;
if (no_bones_level(&u.uz)) if (no_bones_level(&u.uz))
return 0; return 0;
fd = open_bonesfile(&u.uz, &bonesid);
if (fd < 0)
return 0;
if (validate(fd, g.bones) != 0) { nhfp = open_bonesfile(&u.uz, &bonesid);
if (!nhfp)
return 0;
if (nhfp && nhfp->structlevel && nhfp->fd < 0)
return 0;
if (nhfp && nhfp->fieldlevel) {
if (nhfp->style.deflt && !nhfp->fpdef)
return 0;
}
if (validate(nhfp, g.bones) != 0) {
if (!wizard) if (!wizard)
pline("Discarding unuseable bones; no need to panic..."); pline("Discarding unuseable bones; no need to panic...");
ok = FALSE; ok = FALSE;
@@ -584,13 +613,20 @@ getbones()
ok = TRUE; ok = TRUE;
if (wizard) { if (wizard) {
if (yn("Get bones?") == 'n') { if (yn("Get bones?") == 'n') {
(void) nhclose(fd); close_nhfile(nhfp);
compress_bonesfile(); compress_bonesfile();
return 0; return 0;
} }
} }
mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */ if (nhfp->structlevel) {
mread(fd, (genericptr_t) oldbonesid, (unsigned) c); /* DD.nnn */ mread(nhfp->fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */
mread(nhfp->fd, (genericptr_t) oldbonesid, (unsigned) c); /* DD.nnn */
}
if (nhfp->fieldlevel) {
sfi_char(nhfp, &c, "bones", "bones_count", 1); /* length incl. '\0' */
for (i = 0; i < (int) c; ++i)
sfi_char(nhfp, &oldbonesid[i], "bones", "bonesid", 1);
}
if (strcmp(bonesid, oldbonesid) != 0 if (strcmp(bonesid, oldbonesid) != 0
/* from 3.3.0 through 3.6.0, bones in the quest branch stored /* from 3.3.0 through 3.6.0, bones in the quest branch stored
a bogus bonesid in the file; 3.6.1 fixed that, but for a bogus bonesid in the file; 3.6.1 fixed that, but for
@@ -612,7 +648,7 @@ getbones()
} else { } else {
register struct monst *mtmp; register struct monst *mtmp;
getlev(fd, 0, 0, TRUE); getlev(nhfp, 0, 0, TRUE);
/* Note that getlev() now keeps tabs on unique /* Note that getlev() now keeps tabs on unique
* monsters such as demon lords, and tracks the * monsters such as demon lords, and tracks the
@@ -638,7 +674,7 @@ getbones()
resetobjs(g.level.buriedobjlist, TRUE); resetobjs(g.level.buriedobjlist, TRUE);
} }
} }
(void) nhclose(fd); close_nhfile(nhfp);
sanitize_engravings(); sanitize_engravings();
u.uroleplay.numbones++; u.uroleplay.numbones++;
+5 -1
View File
@@ -789,6 +789,8 @@ wiz_identify(VOID_ARGS)
STATIC_PTR int STATIC_PTR int
wiz_makemap(VOID_ARGS) wiz_makemap(VOID_ARGS)
{ {
NHFILE tmpnhfp;
if (wizard) { if (wizard) {
struct monst *mtmp; struct monst *mtmp;
boolean was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz); boolean was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz);
@@ -835,7 +837,9 @@ wiz_makemap(VOID_ARGS)
keepdogs(TRUE); /* (pets-only; normally we'd be using 'FALSE' here) */ keepdogs(TRUE); /* (pets-only; normally we'd be using 'FALSE' here) */
/* discard current level; "saving" is used to release dynamic data */ /* discard current level; "saving" is used to release dynamic data */
savelev(-1, ledger_no(&u.uz), FREE_SAVE); zero_nhfile(&tmpnhfp); /* also sets fd to -1 as desired */
tmpnhfp.mode = FREEING;
savelev(&tmpnhfp, ledger_no(&u.uz));
/* create a new level; various things like bestowing a guardian /* create a new level; various things like bestowing a guardian
angel on Astral or setting off alarm on Ft.Ludios are handled angel on Astral or setting off alarm on Ft.Ludios are handled
by goto_level(do.c) so won't occur for replacement levels */ by goto_level(do.c) so won't occur for replacement levels */
+51 -30
View File
@@ -15,7 +15,7 @@ STATIC_DCL void FDECL(dosinkring, (struct obj *));
STATIC_PTR int FDECL(drop, (struct obj *)); STATIC_PTR int FDECL(drop, (struct obj *));
STATIC_PTR int NDECL(wipeoff); STATIC_PTR int NDECL(wipeoff);
STATIC_DCL int FDECL(menu_drop, (int)); STATIC_DCL int FDECL(menu_drop, (int));
STATIC_DCL int NDECL(currentlevel_rewrite); STATIC_DCL NHFILE *NDECL(currentlevel_rewrite);
STATIC_DCL void NDECL(final_level); STATIC_DCL void NDECL(final_level);
/* static boolean FDECL(badspot, (XCHAR_P,XCHAR_P)); */ /* static boolean FDECL(badspot, (XCHAR_P,XCHAR_P)); */
@@ -1114,18 +1114,21 @@ doup()
} }
/* check that we can write out the current level */ /* check that we can write out the current level */
STATIC_OVL int STATIC_OVL NHFILE *
currentlevel_rewrite() currentlevel_rewrite()
{ {
register int fd; NHFILE *nhfp;
char whynot[BUFSZ]; char whynot[BUFSZ];
#ifdef MFLOPPY
int savemode;
#endif
/* since level change might be a bit slow, flush any buffered screen /* since level change might be a bit slow, flush any buffered screen
* output (like "you fall through a trap door") */ * output (like "you fall through a trap door") */
mark_synch(); mark_synch();
fd = create_levelfile(ledger_no(&u.uz), whynot); nhfp = create_levelfile(ledger_no(&u.uz), whynot);
if (fd < 0) { if (!nhfp) {
/* /*
* This is not quite impossible: e.g., we may have * This is not quite impossible: e.g., we may have
* exceeded our quota. If that is the case then we * exceeded our quota. If that is the case then we
@@ -1134,35 +1137,39 @@ currentlevel_rewrite()
* writable. * writable.
*/ */
pline1(whynot); pline1(whynot);
return -1; return (NHFILE *) 0;
} }
#ifdef MFLOPPY #ifdef MFLOPPY
if (!savelev(fd, ledger_no(&u.uz), COUNT_SAVE)) { savemode = nhfp->mode;
(void) nhclose(fd); nhfp->mode = COUNTING;
if (!savelev(nhfp, ledger_no(&u.uz))) {
close_nhfile(nhfp);
delete_levelfile(ledger_no(&u.uz)); delete_levelfile(ledger_no(&u.uz));
pline("NetHack is out of disk space for making levels!"); pline("NetHack is out of disk space for making levels!");
You("can save, quit, or continue playing."); You("can save, quit, or continue playing.");
return -1; return -1;
} }
nhfp->mode = savemode;
#endif #endif
return fd; return nhfp;
} }
#ifdef INSURANCE #ifdef INSURANCE
void void
save_currentstate() save_currentstate()
{ {
int fd; NHFILE *nhfp;
if (flags.ins_chkpt) { if (flags.ins_chkpt) {
/* write out just-attained level, with pets and everything */ /* write out just-attained level, with pets and everything */
fd = currentlevel_rewrite(); nhfp = currentlevel_rewrite();
if (fd < 0) if (!nhfp)
return; return;
bufon(fd); bufon(nhfp->fd);
savelev(fd, ledger_no(&u.uz), WRITE_SAVE); nhfp->mode = WRITING;
bclose(fd); savelev(nhfp,ledger_no(&u.uz));
close_nhfile(nhfp);
} }
/* write out non-level state */ /* write out non-level state */
@@ -1226,7 +1233,8 @@ goto_level(newlevel, at_stairs, falling, portal)
d_level *newlevel; d_level *newlevel;
boolean at_stairs, falling, portal; boolean at_stairs, falling, portal;
{ {
int fd, l_idx; int l_idx, save_mode;
NHFILE *nhfp;
xchar new_ledger; xchar new_ledger;
boolean cant_go_back, great_effort, boolean cant_go_back, great_effort,
up = (depth(newlevel) < depth(&u.uz)), up = (depth(newlevel) < depth(&u.uz)),
@@ -1307,8 +1315,8 @@ boolean at_stairs, falling, portal;
if (u.utrap && u.utraptype == TT_BURIEDBALL) if (u.utrap && u.utraptype == TT_BURIEDBALL)
buried_ball_to_punishment(); /* (before we save/leave old level) */ buried_ball_to_punishment(); /* (before we save/leave old level) */
fd = currentlevel_rewrite(); nhfp = currentlevel_rewrite();
if (fd < 0) if (!nhfp)
return; return;
/* discard context which applies to the level we're leaving; /* discard context which applies to the level we're leaving;
@@ -1354,10 +1362,12 @@ boolean at_stairs, falling, portal;
cant_go_back = (newdungeon && In_endgame(newlevel)); cant_go_back = (newdungeon && In_endgame(newlevel));
if (!cant_go_back) { if (!cant_go_back) {
update_mlstmv(); /* current monsters are becoming inactive */ update_mlstmv(); /* current monsters are becoming inactive */
bufon(fd); /* use buffered output */ bufon(nhfp->fd); /* use buffered output */
} }
savelev(fd, ledger_no(&u.uz), save_mode = nhfp->mode;
cant_go_back ? FREE_SAVE : (WRITE_SAVE | FREE_SAVE)); nhfp->mode = cant_go_back ? FREEING : (WRITING | FREEING);
savelev(nhfp, ledger_no(&u.uz));
nhfp->mode = save_mode;
/* air bubbles and clouds are saved in game-state rather than with the /* air bubbles and clouds are saved in game-state rather than with the
level they're used on; in normal play, you can't leave and return level they're used on; in normal play, you can't leave and return
to any endgame level--bubbles aren't needed once you move to the to any endgame level--bubbles aren't needed once you move to the
@@ -1366,9 +1376,15 @@ boolean at_stairs, falling, portal;
aren't saved with the level and restored upon return (new ones are aren't saved with the level and restored upon return (new ones are
created instead), we need to discard them to avoid a memory leak; created instead), we need to discard them to avoid a memory leak;
so bubbles are now discarded as we leave the level they're used on */ so bubbles are now discarded as we leave the level they're used on */
if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) {
save_waterlevel(-1, FREE_SAVE); NHFILE tmpnhfp;
bclose(fd);
zero_nhfile(&tmpnhfp);
tmpnhfp.fd = -1;
tmpnhfp.mode = FREEING;
save_waterlevel(&tmpnhfp);
}
close_nhfile(nhfp);
if (cant_go_back) { if (cant_go_back) {
/* discard unreachable levels; keep #0 */ /* discard unreachable levels; keep #0 */
for (l_idx = maxledgerno(); l_idx > 0; --l_idx) for (l_idx = maxledgerno(); l_idx > 0; --l_idx)
@@ -1418,21 +1434,26 @@ boolean at_stairs, falling, portal;
new = TRUE; /* made the level */ new = TRUE; /* made the level */
} else { } else {
/* returning to previously visited level; reload it */ /* returning to previously visited level; reload it */
fd = open_levelfile(new_ledger, whynot); nhfp = open_levelfile(new_ledger, whynot);
if (tricked_fileremoved(fd, whynot)) { if (tricked_fileremoved(nhfp, whynot)) {
/* we'll reach here if running in wizard mode */ /* we'll reach here if running in wizard mode */
error("Cannot continue this game."); error("Cannot continue this game.");
} }
reseed_random(rn2); reseed_random(rn2);
reseed_random(rn2_on_display_rng); reseed_random(rn2_on_display_rng);
minit(); /* ZEROCOMP */ minit(); /* ZEROCOMP */
getlev(fd, g.hackpid, new_ledger, FALSE); getlev(nhfp, g.hackpid, new_ledger, FALSE);
/* when in wizard mode, it is possible to leave from and return to /* when in wizard mode, it is possible to leave from and return to
any level in the endgame; above, we discarded bubble/cloud info any level in the endgame; above, we discarded bubble/cloud info
when leaving Plane of Water or Air so recreate some now */ when leaving Plane of Water or Air so recreate some now */
if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) {
restore_waterlevel(-1); NHFILE tmpnhfp;
(void) nhclose(fd);
zero_nhfile(&tmpnhfp);
tmpnhfp.fd = -1;
restore_waterlevel(&tmpnhfp);
}
close_nhfile(nhfp);
oinit(); /* reassign level dependent obj probabilities */ oinit(); /* reassign level dependent obj probabilities */
} }
reglyph_darkroom(); reglyph_darkroom();
+173 -64
View File
@@ -7,6 +7,8 @@
#include "dgn_file.h" #include "dgn_file.h"
#include "dlb.h" #include "dlb.h"
#include "lev.h" #include "lev.h"
#include "sfproto.h"
#define DUNGEON_FILE "dungeon" #define DUNGEON_FILE "dungeon"
@@ -56,8 +58,9 @@ STATIC_DCL const char *FDECL(br_string, (int));
STATIC_DCL char FDECL(chr_u_on_lvl, (d_level *)); STATIC_DCL char FDECL(chr_u_on_lvl, (d_level *));
STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P, STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P,
struct lchoice *)); struct lchoice *));
STATIC_DCL mapseen *FDECL(load_mapseen, (int)); /* SAVE2018 */
STATIC_DCL void FDECL(save_mapseen, (int, mapseen *)); STATIC_DCL mapseen *FDECL(load_mapseen, (NHFILE *));
STATIC_DCL void FDECL(save_mapseen, (NHFILE *, mapseen *));
STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *)); STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *));
STATIC_DCL mapseen *FDECL(find_mapseen_by_str, (const char *)); STATIC_DCL mapseen *FDECL(find_mapseen_by_str, (const char *));
STATIC_DCL void FDECL(print_mapseen, (winid, mapseen *, int, int, BOOLEAN_P)); STATIC_DCL void FDECL(print_mapseen, (winid, mapseen *, int, int, BOOLEAN_P));
@@ -129,41 +132,68 @@ dumpit()
/* Save the dungeon structures. */ /* Save the dungeon structures. */
void void
save_dungeon(fd, perform_write, free_data) save_dungeon(nhfp, perform_write, free_data)
int fd; NHFILE *nhfp;
boolean perform_write, free_data; boolean perform_write, free_data;
{ {
int i, count;
branch *curr, *next; branch *curr, *next;
mapseen *curr_ms, *next_ms; mapseen *curr_ms, *next_ms;
int count;
if (perform_write) { if (perform_write) {
bwrite(fd, (genericptr_t) &g.n_dgns, sizeof g.n_dgns); if(nhfp->structlevel) {
bwrite(fd, (genericptr_t) g.dungeons, bwrite(nhfp->fd, (genericptr_t) &g.n_dgns, sizeof g.n_dgns);
sizeof(dungeon) * (unsigned) g.n_dgns); bwrite(nhfp->fd, (genericptr_t) g.dungeons,
bwrite(fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology); sizeof(dungeon) * (unsigned) g.n_dgns);
bwrite(fd, (genericptr_t) g.tune, sizeof tune); bwrite(nhfp->fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology);
bwrite(nhfp->fd, (genericptr_t) g.tune, sizeof tune);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &g.n_dgns, "dungeon", "dungeon_count", 1);
for (i = 0; i < g.n_dgns; ++i)
sfo_dungeon(nhfp, &g.dungeons[i], "dungeon", "dungeon", 1);
sfo_dgn_topology(nhfp, &g.dungeon_topology, "dungeon", "g.dungeon_topology", 1);
for (i = 0; i < sizeof tune; ++i)
sfo_char(nhfp, &g.tune[i], "dungeon", "tune", 1);
}
for (count = 0, curr = g.branches; curr; curr = curr->next) for (count = 0, curr = g.branches; curr; curr = curr->next)
count++; count++;
bwrite(fd, (genericptr_t) &count, sizeof(count)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof(count));
for (curr = g.branches; curr; curr = curr->next) if (nhfp->fieldlevel)
bwrite(fd, (genericptr_t) curr, sizeof(branch)); sfo_int(nhfp, &count, "dungeon", "branch_count", 1);
for (curr = g.branches; curr; curr = curr->next) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) curr, sizeof(branch));
if (nhfp->fieldlevel)
sfo_branch(nhfp, curr, "dungeon", "branch", 1);
}
count = maxledgerno(); count = maxledgerno();
bwrite(fd, (genericptr_t) &count, sizeof count); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) g.level_info, bwrite(nhfp->fd, (genericptr_t) &count, sizeof count);
(unsigned) count * sizeof(struct linfo)); bwrite(nhfp->fd, (genericptr_t) g.level_info,
bwrite(fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); (unsigned) count * sizeof(struct linfo));
bwrite(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &count, "dungeon", "level_info_count", 1);
for (i = 0; i < count; ++i)
sfo_linfo(nhfp, &g.level_info[i], "dungeon", "g.level_info", 1);
sfo_nhcoord(nhfp, &g.inv_pos, "dungeon", "g.inv_pos", 1);
}
for (count = 0, curr_ms = g.mapseenchn; curr_ms; for (count = 0, curr_ms = g.mapseenchn; curr_ms;
curr_ms = curr_ms->next) curr_ms = curr_ms->next)
count++; count++;
bwrite(fd, (genericptr_t) &count, sizeof(count));
for (curr_ms = g.mapseenchn; curr_ms; curr_ms = curr_ms->next) if (nhfp->structlevel)
save_mapseen(fd, curr_ms); bwrite(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "dungeon", "mapseen_count", 1);
for (curr_ms = g.mapseenchn; curr_ms; curr_ms = curr_ms->next) {
save_mapseen(nhfp, curr_ms);
}
} }
if (free_data) { if (free_data) {
@@ -177,7 +207,7 @@ boolean perform_write, free_data;
if (curr_ms->custom) if (curr_ms->custom)
free((genericptr_t) curr_ms->custom); free((genericptr_t) curr_ms->custom);
if (curr_ms->final_resting_place) if (curr_ms->final_resting_place)
savecemetery(fd, FREE_SAVE, &curr_ms->final_resting_place); savecemetery(nhfp, &curr_ms->final_resting_place);
free((genericptr_t) curr_ms); free((genericptr_t) curr_ms);
} }
g.mapseenchn = 0; g.mapseenchn = 0;
@@ -186,24 +216,40 @@ boolean perform_write, free_data;
/* Restore the dungeon structures. */ /* Restore the dungeon structures. */
void void
restore_dungeon(fd) restore_dungeon(nhfp)
int fd; NHFILE *nhfp;
{ {
branch *curr, *last; branch *curr, *last;
int count, i; int count, i;
mapseen *curr_ms, *last_ms; mapseen *curr_ms, *last_ms;
mread(fd, (genericptr_t) &g.n_dgns, sizeof(g.n_dgns)); if (nhfp->structlevel) {
mread(fd, (genericptr_t) g.dungeons, sizeof(dungeon) * (unsigned) g.n_dgns); mread(nhfp->fd, (genericptr_t) &g.n_dgns, sizeof(g.n_dgns));
mread(fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology); mread(nhfp->fd, (genericptr_t) g.dungeons, sizeof(dungeon) * (unsigned) g.n_dgns);
mread(fd, (genericptr_t) g.tune, sizeof tune); mread(nhfp->fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology);
mread(nhfp->fd, (genericptr_t) g.tune, sizeof tune);
}
if (nhfp->fieldlevel) {
sfi_int(nhfp, &g.n_dgns, "dungeon", "dungeon_count", 1);
for (i = 0; i < g.n_dgns; ++i)
sfi_dungeon(nhfp, &g.dungeons[i], "dungeon", "dungeon", 1);
sfi_dgn_topology(nhfp, &g.dungeon_topology, "dungeon", "g.dungeon_topology", 1);
for (i = 0; i < sizeof tune; ++i)
sfi_char(nhfp, &g.tune[i], "dungeon", "tune", 1);
}
last = g.branches = (branch *) 0; last = g.branches = (branch *) 0;
mread(fd, (genericptr_t) &count, sizeof(count)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "dungeon", "branch_count", 1);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
curr = (branch *) alloc(sizeof(branch)); curr = (branch *) alloc(sizeof(branch));
mread(fd, (genericptr_t) curr, sizeof(branch)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) curr, sizeof(branch));
if (nhfp->fieldlevel)
sfi_branch(nhfp, curr, "dungeon", "branch", 1);
curr->next = (branch *) 0; curr->next = (branch *) 0;
if (last) if (last)
last->next = curr; last->next = curr;
@@ -212,18 +258,33 @@ int fd;
last = curr; last = curr;
} }
mread(fd, (genericptr_t) &count, sizeof(count)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "dungeon", "level_info_count", 1);
if (count >= MAXLINFO) if (count >= MAXLINFO)
panic("level information count larger (%d) than allocated size", panic("level information count larger (%d) than allocated size",
count); count);
mread(fd, (genericptr_t) g.level_info, if (nhfp->structlevel)
(unsigned) count * sizeof(struct linfo)); mread(nhfp->fd, (genericptr_t) g.level_info,
mread(fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); (unsigned) count * sizeof(struct linfo));
if (nhfp->fieldlevel)
for (i = 0; i < count; ++i)
sfi_linfo(nhfp, &g.level_info[i], "dungeon", "g.level_info", 1);
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos);
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
}
if (nhfp->fieldlevel) {
sfi_nhcoord(nhfp, &g.inv_pos, "dungeon", "inv_pos", 1);
sfi_int(nhfp, &count, "dungeon", "mapseen_count", 1);
}
mread(fd, (genericptr_t) &count, sizeof(count));
last_ms = (mapseen *) 0; last_ms = (mapseen *) 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
curr_ms = load_mapseen(fd); curr_ms = load_mapseen(nhfp);
curr_ms->next = (mapseen *) 0; curr_ms->next = (mapseen *) 0;
if (last_ms) if (last_ms)
last_ms->next = curr_ms; last_ms->next = curr_ms;
@@ -752,7 +813,7 @@ init_dungeons()
*/ */
if (iflags.window_inited) if (iflags.window_inited)
clear_nhwindow(WIN_MAP); clear_nhwindow(WIN_MAP);
if (!check_version(&vers_info, DUNGEON_FILE, TRUE)) if (!check_version(&vers_info, DUNGEON_FILE, TRUE, UTD_CHECKSIZES))
panic("Dungeon description not valid."); panic("Dungeon description not valid.");
/* /*
@@ -2187,58 +2248,106 @@ int ledger_num;
} }
STATIC_OVL void STATIC_OVL void
save_mapseen(fd, mptr) save_mapseen(nhfp, mptr)
int fd; NHFILE *nhfp;
mapseen *mptr; mapseen *mptr;
{ {
branch *curr; branch *curr;
int brindx; int i, brindx;
for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx) for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx)
if (curr == mptr->br) if (curr == mptr->br)
break; break;
bwrite(fd, (genericptr_t) &brindx, sizeof brindx); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &brindx, sizeof brindx);
if (nhfp->fieldlevel)
sfo_int(nhfp, &brindx, "mapseen", "branch_index", 1);
bwrite(fd, (genericptr_t) &mptr->lev, sizeof mptr->lev); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) &mptr->feat, sizeof mptr->feat); bwrite(nhfp->fd, (genericptr_t) &mptr->lev, sizeof mptr->lev);
bwrite(fd, (genericptr_t) &mptr->flags, sizeof mptr->flags); bwrite(nhfp->fd, (genericptr_t) &mptr->feat, sizeof mptr->feat);
bwrite(fd, (genericptr_t) &mptr->custom_lth, sizeof mptr->custom_lth); bwrite(nhfp->fd, (genericptr_t) &mptr->flags, sizeof mptr->flags);
if (mptr->custom_lth) bwrite(nhfp->fd, (genericptr_t) &mptr->custom_lth, sizeof mptr->custom_lth);
bwrite(fd, (genericptr_t) mptr->custom, mptr->custom_lth); }
bwrite(fd, (genericptr_t) mptr->msrooms, sizeof mptr->msrooms); if (nhfp->fieldlevel) {
savecemetery(fd, WRITE_SAVE, &mptr->final_resting_place); sfo_d_level(nhfp, &mptr->lev, "mapseen", "d_level", 1);
sfo_mapseen_feat(nhfp, &mptr->feat, "mapseen", "feat", 1);
sfo_mapseen_flags(nhfp, &mptr->flags, "mapseen", "flags", 1);
sfo_unsigned(nhfp, &mptr->custom_lth, "mapseen", "custom_lth", 1);
}
if (mptr->custom_lth) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) mptr->custom, mptr->custom_lth);
}
if (nhfp->fieldlevel) {
for (i = 0; i < (int) mptr->custom_lth; ++i)
sfo_char(nhfp, &mptr->custom[i], "mapseen", "custom", 1);
}
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &mptr->msrooms, sizeof mptr->msrooms);
}
if (nhfp->fieldlevel) {
for (i = 0; i < ((MAXNROFROOMS + 1) * 2); ++i)
sfo_mapseen_rooms(nhfp, &mptr->msrooms[i], "mapseen", "msrooms", 1);
}
savecemetery(nhfp, &mptr->final_resting_place);
} }
STATIC_OVL mapseen * STATIC_OVL mapseen *
load_mapseen(fd) load_mapseen(nhfp)
int fd; NHFILE *nhfp;
{ {
int branchnum, brindx; int i, branchnum, brindx;
mapseen *load; mapseen *load;
branch *curr; branch *curr;
load = (mapseen *) alloc(sizeof *load); load = (mapseen *) alloc(sizeof *load);
mread(fd, (genericptr_t) &branchnum, sizeof branchnum); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &branchnum, sizeof branchnum);
if (nhfp->fieldlevel)
sfi_int(nhfp, &branchnum, "mapseen", "branch_index", 1);
for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx) for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx)
if (brindx == branchnum) if (brindx == branchnum)
break; break;
load->br = curr; load->br = curr;
mread(fd, (genericptr_t) &load->lev, sizeof load->lev); if (nhfp->structlevel) {
mread(fd, (genericptr_t) &load->feat, sizeof load->feat); mread(nhfp->fd, (genericptr_t) &load->lev, sizeof load->lev);
mread(fd, (genericptr_t) &load->flags, sizeof load->flags); mread(nhfp->fd, (genericptr_t) &load->feat, sizeof load->feat);
mread(fd, (genericptr_t) &load->custom_lth, sizeof load->custom_lth); mread(nhfp->fd, (genericptr_t) &load->flags, sizeof load->flags);
mread(nhfp->fd, (genericptr_t) &load->custom_lth, sizeof load->custom_lth);
}
if (nhfp->fieldlevel) {
sfi_d_level(nhfp, &load->lev, "mapseen", "d_level", 1);
sfi_mapseen_feat(nhfp, &load->feat, "mapseen", "feat", 1);
sfi_mapseen_flags(nhfp, &load->flags, "mapseen", "flags", 1);
sfi_unsigned(nhfp, &load->custom_lth, "mapseen", "custom_lth", 1);
}
if (load->custom_lth) { if (load->custom_lth) {
/* length doesn't include terminator (which isn't saved & restored) */ /* length doesn't include terminator (which isn't saved & restored) */
load->custom = (char *) alloc(load->custom_lth + 1); load->custom = (char *) alloc(load->custom_lth + 1);
mread(fd, (genericptr_t) load->custom, load->custom_lth); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) load->custom, load->custom_lth);
}
if (nhfp->fieldlevel) {
for (i = 0; i < (int) load->custom_lth; ++i)
sfi_char(nhfp, &load->custom[i], "mapseen", "custom", 1);
}
load->custom[load->custom_lth] = '\0'; load->custom[load->custom_lth] = '\0';
} else } else
load->custom = 0; load->custom = 0;
mread(fd, (genericptr_t) load->msrooms, sizeof load->msrooms); if (nhfp->structlevel) {
restcemetery(fd, &load->final_resting_place); mread(nhfp->fd, (genericptr_t) &load->msrooms, sizeof load->msrooms);
}
if (nhfp->fieldlevel) {
for (i = 0; i < ((MAXNROFROOMS + 1) * 2); ++i)
sfi_mapseen_rooms(nhfp, &load->msrooms[i], "mapseen", "msrooms", 1);
}
restcemetery(nhfp, &load->final_resting_place);
return load; return load;
} }
+16 -9
View File
@@ -15,6 +15,8 @@
#include <limits.h> #include <limits.h>
#endif #endif
#include "dlb.h" #include "dlb.h"
#include "sfproto.h"
/* add b to long a, convert wraparound to max value */ /* add b to long a, convert wraparound to max value */
#define nowrap_add(a, b) (a = ((a + b) < 0 ? LONG_MAX : (a + b))) #define nowrap_add(a, b) (a = ((a + b) < 0 ? LONG_MAX : (a + b)))
@@ -2131,18 +2133,20 @@ struct kinfo *kptr;
} }
void void
save_killers(fd, mode) save_killers(nhfp)
int fd; NHFILE *nhfp;
int mode;
{ {
struct kinfo *kptr; struct kinfo *kptr;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) {
bwrite(fd, (genericptr_t) kptr, sizeof (struct kinfo)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo));
if (nhfp->fieldlevel)
sfo_kinfo(nhfp, kptr, "killers", "kinfo", 1);
} }
} }
if (release_data(mode)) { if (release_data(nhfp)) {
while (g.killer.next) { while (g.killer.next) {
kptr = g.killer.next->next; kptr = g.killer.next->next;
free((genericptr_t) g.killer.next); free((genericptr_t) g.killer.next);
@@ -2152,13 +2156,16 @@ int mode;
} }
void void
restore_killers(fd) restore_killers(nhfp)
int fd; NHFILE *nhfp;
{ {
struct kinfo *kptr; struct kinfo *kptr;
for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) {
mread(fd, (genericptr_t) kptr, sizeof (struct kinfo)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo));
if (nhfp->fieldlevel)
sfi_kinfo(nhfp, kptr, "killers", "kinfo", 1);
if (kptr->next) { if (kptr->next) {
kptr->next = (struct kinfo *) alloc(sizeof (struct kinfo)); kptr->next = (struct kinfo *) alloc(sizeof (struct kinfo));
} }
+40 -17
View File
@@ -5,6 +5,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" #include "lev.h"
#include "sfproto.h"
STATIC_VAR NEARDATA struct engr *head_engr; STATIC_VAR NEARDATA struct engr *head_engr;
STATIC_DCL const char *NDECL(blengr); STATIC_DCL const char *NDECL(blengr);
@@ -1173,48 +1175,69 @@ sanitize_engravings()
} }
void void
save_engravings(fd, mode) save_engravings(nhfp)
int fd, mode; NHFILE *nhfp;
{ {
struct engr *ep, *ep2; struct engr *ep, *ep2;
unsigned no_more_engr = 0; unsigned no_more_engr = 0;
for (ep = head_engr; ep; ep = ep2) { for (ep = head_engr; ep; ep = ep2) {
ep2 = ep->nxt_engr; ep2 = ep->nxt_engr;
if (ep->engr_lth && ep->engr_txt[0] && perform_bwrite(mode)) { if (ep->engr_lth && ep->engr_txt[0] && perform_bwrite(nhfp)) {
bwrite(fd, (genericptr_t) &ep->engr_lth, sizeof ep->engr_lth); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) ep, sizeof (struct engr) + ep->engr_lth); bwrite(nhfp->fd, (genericptr_t)&(ep->engr_lth), sizeof(ep->engr_lth));
bwrite(nhfp->fd, (genericptr_t)ep, sizeof(struct engr) + ep->engr_lth);
}
if (nhfp->fieldlevel) {
sfo_unsigned(nhfp, &(ep->engr_lth), "engravings", "engr_lth", 1);
sfo_engr(nhfp, ep, "engravings", "engr", 1);
sfo_str(nhfp, ep->engr_txt, "engravings", "engr_txt", ep->engr_lth);
}
} }
if (release_data(mode)) if (release_data(nhfp))
dealloc_engr(ep); dealloc_engr(ep);
} }
if (perform_bwrite(mode)) if (perform_bwrite(nhfp)) {
bwrite(fd, (genericptr_t) &no_more_engr, sizeof no_more_engr); if (nhfp->structlevel)
if (release_data(mode)) bwrite(nhfp->fd, (genericptr_t)&no_more_engr, sizeof no_more_engr);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &no_more_engr, "engravings", "engr_lth", 1);
}
if (release_data(nhfp))
head_engr = 0; head_engr = 0;
} }
void void
rest_engravings(fd) rest_engravings(nhfp)
int fd; NHFILE *nhfp;
{ {
struct engr *ep; struct engr *ep;
unsigned lth; unsigned lth;
head_engr = 0; head_engr = 0;
while (1) { while (1) {
mread(fd, (genericptr_t) &lth, sizeof lth); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &lth, sizeof(unsigned));
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &lth, "engravings", "engr_lth", 1);
if (lth == 0) if (lth == 0)
return; return;
ep = newengr(lth); ep = newengr(lth);
mread(fd, (genericptr_t) ep, sizeof (struct engr) + lth); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) ep, sizeof(struct engr) + lth);
}
if (nhfp->fieldlevel) {
sfi_engr(nhfp, ep, "engravings", "engr", 1);
ep->engr_txt = (char *) (ep + 1);
sfi_str(nhfp, ep->engr_txt, "engravings", "engr_txt", lth);
}
ep->nxt_engr = head_engr; ep->nxt_engr = head_engr;
head_engr = ep; head_engr = ep;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */ ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
/* Mark as finished for bones levels -- no problem for /* mark as finished for bones levels -- no problem for
* normal levels as the player must have finished engraving * normal levels as the player must have finished engraving
* to be able to move again. * to be able to move again */
*/
ep->engr_time = g.moves; ep->engr_time = g.moves;
} }
} }
+538 -148
View File
File diff suppressed because it is too large Load Diff
+58 -25
View File
@@ -4,6 +4,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" /* for checking save modes */ #include "lev.h" /* for checking save modes */
#include "sfproto.h"
/* /*
* Mobile light sources. * Mobile light sources.
@@ -42,25 +44,27 @@
#define LSF_SHOW 0x1 /* display the light source */ #define LSF_SHOW 0x1 /* display the light source */
#define LSF_NEEDS_FIXUP 0x2 /* need oid fixup */ #define LSF_NEEDS_FIXUP 0x2 /* need oid fixup */
STATIC_DCL void FDECL(write_ls, (int, light_source *)); /* SAVE2018 */
STATIC_DCL int FDECL(maybe_write_ls, (int, int, BOOLEAN_P)); STATIC_DCL void FDECL(write_ls, (NHFILE *, light_source *));
STATIC_DCL int FDECL(maybe_write_ls, (NHFILE *, int, BOOLEAN_P));
/* imported from vision.c, for small circles */ /* imported from vision.c, for small circles */
extern char circle_data[]; extern char circle_data[];
extern char circle_start[]; extern char circle_start[];
/* Create a new light source. */ /* Create a new light source. */
void void
new_light_source(x, y, range, type, id) new_light_source(x, y, range, type, id)
xchar x, y; xchar x, y;
int range, type; int range, type;
anything *id; anything *id;
{ {
light_source *ls; light_source *ls;
if (range > MAX_RADIUS || range < 1) { if (range > MAX_RADIUS || range < 1) {
impossible("new_light_source: illegal range %d", range); impossible("new_light_source: illegal range %d", range);
return; return;
} }
ls = (light_source *) alloc(sizeof *ls); ls = (light_source *) alloc(sizeof *ls);
@@ -311,22 +315,28 @@ unsigned fmflags;
/* Save all light sources of the given range. */ /* Save all light sources of the given range. */
void void
save_light_sources(fd, mode, range) save_light_sources(nhfp, range)
int fd, mode, range; NHFILE *nhfp;
int range;
{ {
int count, actual, is_global; int count, actual, is_global;
light_source **prev, *curr; light_source **prev, *curr;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
count = maybe_write_ls(fd, range, FALSE); count = maybe_write_ls(nhfp, range, FALSE);
bwrite(fd, (genericptr_t) &count, sizeof count); if (nhfp->structlevel) {
actual = maybe_write_ls(fd, range, TRUE); bwrite(nhfp->fd, (genericptr_t) &count, sizeof count);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &count, "lightsources", "lightsource_count", 1);
}
actual = maybe_write_ls(nhfp, range, TRUE);
if (actual != count) if (actual != count)
panic("counted %d light sources, wrote %d! [range=%d]", count, panic("counted %d light sources, wrote %d! [range=%d]", count,
actual, range); actual, range);
} }
if (release_data(mode)) { if (release_data(nhfp)) {
for (prev = &g.light_base; (curr = *prev) != 0;) { for (prev = &g.light_base; (curr = *prev) != 0;) {
if (!curr->id.a_monst) { if (!curr->id.a_monst) {
impossible("save_light_sources: no id! [range=%d]", range); impossible("save_light_sources: no id! [range=%d]", range);
@@ -361,18 +371,24 @@ int fd, mode, range;
* pointers. * pointers.
*/ */
void void
restore_light_sources(fd) restore_light_sources(nhfp)
int fd; NHFILE *nhfp;
{ {
int count; int count;
light_source *ls; light_source *ls;
/* restore elements */ /* restore elements */
mread(fd, (genericptr_t) &count, sizeof count); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "lightsources", "lightsource_count", 1);
while (count-- > 0) { while (count-- > 0) {
ls = (light_source *) alloc(sizeof(light_source)); ls = (light_source *) alloc(sizeof(light_source));
mread(fd, (genericptr_t) ls, sizeof(light_source)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfi_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
ls->next = g.light_base; ls->next = g.light_base;
g.light_base = ls; g.light_base = ls;
} }
@@ -430,14 +446,17 @@ boolean ghostly;
} }
} }
/* SAVE2018 */
/* /*
* Part of the light source save routine. Count up the number of light * Part of the light source save routine. Count up the number of light
* sources that would be written. If write_it is true, actually write * sources that would be written. If write_it is true, actually write
* the light source out. * the light source out.
*/ */
STATIC_OVL int STATIC_OVL int
maybe_write_ls(fd, range, write_it) maybe_write_ls(nhfp, range, write_it)
int fd, range; NHFILE *nhfp;
int range;
boolean write_it; boolean write_it;
{ {
int count = 0, is_global; int count = 0, is_global;
@@ -465,7 +484,7 @@ boolean write_it;
if (is_global ^ (range == RANGE_LEVEL)) { if (is_global ^ (range == RANGE_LEVEL)) {
count++; count++;
if (write_it) if (write_it)
write_ls(fd, ls); write_ls(nhfp, ls);
} }
} }
@@ -499,11 +518,19 @@ light_sources_sanity_check()
} }
} }
/* Write a light source structure to disk. */ /* SAVE2018 */
#if 0
STATIC_OVL void STATIC_OVL void
write_ls(fd, ls) write_ls(fd, ls)
int fd; int fd;
light_source *ls; light_source *ls;
#endif /* 0 */
/* Write a light source structure to disk. */
STATIC_OVL void
write_ls(nhfp, ls)
NHFILE *nhfp;
light_source *ls;
{ {
anything arg_save; anything arg_save;
struct obj *otmp; struct obj *otmp;
@@ -511,7 +538,10 @@ light_source *ls;
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) { if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
if (ls->flags & LSF_NEEDS_FIXUP) { if (ls->flags & LSF_NEEDS_FIXUP) {
bwrite(fd, (genericptr_t) ls, sizeof(light_source)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfo_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
} else { } else {
/* replace object pointer with id for write, then put back */ /* replace object pointer with id for write, then put back */
arg_save = ls->id; arg_save = ls->id;
@@ -531,7 +561,10 @@ light_source *ls;
ls->id.a_uint); ls->id.a_uint);
} }
ls->flags |= LSF_NEEDS_FIXUP; ls->flags |= LSF_NEEDS_FIXUP;
bwrite(fd, (genericptr_t) ls, sizeof(light_source)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfo_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
ls->id = arg_save; ls->id = arg_save;
ls->flags &= ~LSF_NEEDS_FIXUP; ls->flags &= ~LSF_NEEDS_FIXUP;
} }
+56 -29
View File
@@ -6,6 +6,8 @@
#include "hack.h" #include "hack.h"
#include "sp_lev.h" #include "sp_lev.h"
#include "lev.h" /* save & restore info */ #include "lev.h" /* save & restore info */
#include "sfproto.h"
STATIC_DCL int FDECL(iswall, (int, int)); STATIC_DCL int FDECL(iswall, (int, int));
STATIC_DCL int FDECL(iswall_or_stone, (int, int)); STATIC_DCL int FDECL(iswall_or_stone, (int, int));
@@ -1558,33 +1560,46 @@ water_friction()
} }
void void
save_waterlevel(fd, mode) save_waterlevel(nhfp)
int fd, mode; NHFILE *nhfp;
{ {
struct bubble *b; struct bubble *b;
if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz)) if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz))
return; return;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
int n = 0; int n = 0;
for (b = g.bbubbles; b; b = b->next) for (b = g.bbubbles; b; b = b->next)
++n; ++n;
bwrite(fd, (genericptr_t) &n, sizeof n); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) &g.xmin, sizeof g.xmin); bwrite(nhfp->fd, (genericptr_t) &n, sizeof(int));
bwrite(fd, (genericptr_t) &g.ymin, sizeof g.ymin); bwrite(nhfp->fd, (genericptr_t) &g.xmin, sizeof(int));
bwrite(fd, (genericptr_t) &g.xmax, sizeof g.xmax); bwrite(nhfp->fd, (genericptr_t) &g.ymin, sizeof(int));
bwrite(fd, (genericptr_t) &g.ymax, sizeof g.ymax); bwrite(nhfp->fd, (genericptr_t) &g.xmax, sizeof(int));
for (b = g.bbubbles; b; b = b->next) bwrite(nhfp->fd, (genericptr_t) &g.ymax, sizeof(int));
bwrite(fd, (genericptr_t) b, sizeof *b); }
if (nhfp->fieldlevel) {
sfo_int(nhfp, &n, "waterlevel", "bubble_count", 1);
sfo_int(nhfp, &g.xmin, "waterlevel", "g.xmin", 1);
sfo_int(nhfp, &g.ymin, "waterlevel", "g.ymin", 1);
sfo_int(nhfp, &g.xmax, "waterlevel", "g.xmax", 1);
sfo_int(nhfp, &g.ymax, "waterlevel", "g.ymax", 1);
}
for (b = g.bbubbles; b; b = b->next) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) b, sizeof(struct bubble));
if (nhfp->fieldlevel)
sfo_bubble(nhfp, b, "waterlevel", "bubble", 1);
}
} }
if (release_data(mode)) if (release_data(nhfp))
unsetup_waterlevel(); unsetup_waterlevel();
} }
void void
restore_waterlevel(fd) restore_waterlevel(nhfp)
int fd; NHFILE *nhfp;
{ {
struct bubble *b = (struct bubble *) 0, *btmp; struct bubble *b = (struct bubble *) 0, *btmp;
int i, n; int i, n;
@@ -1592,7 +1607,7 @@ int fd;
if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz)) if (!Is_waterlevel(&u.uz) && !Is_airlevel(&u.uz))
return; return;
if (fd == -1) { /* special handling for restore in goto_level() */ if (nhfp->fd == -1) { /* special handling for restore in goto_level() */
if (!wizard) if (!wizard)
impossible("restore_waterlevel: returning to %s?", impossible("restore_waterlevel: returning to %s?",
Is_waterlevel(&u.uz) ? "Water" : "Air"); Is_waterlevel(&u.uz) ? "Water" : "Air");
@@ -1601,23 +1616,35 @@ int fd;
} }
set_wportal(); set_wportal();
mread(fd, (genericptr_t) &n, sizeof n); if (nhfp->structlevel) {
mread(fd, (genericptr_t) &g.xmin, sizeof g.xmin); mread(nhfp->fd,(genericptr_t)&n,sizeof(int));
mread(fd, (genericptr_t) &g.ymin, sizeof g.ymin); mread(nhfp->fd,(genericptr_t)&g.xmin,sizeof(int));
mread(fd, (genericptr_t) &g.xmax, sizeof g.xmax); mread(nhfp->fd,(genericptr_t)&g.ymin,sizeof(int));
mread(fd, (genericptr_t) &g.ymax, sizeof g.ymax); mread(nhfp->fd,(genericptr_t)&g.xmax,sizeof(int));
mread(nhfp->fd,(genericptr_t)&g.ymax,sizeof(int));
}
if (nhfp->fieldlevel) {
sfi_int(nhfp, &n, "waterlevel", "bubble_count", 1);
sfi_int(nhfp, &g.xmin, "waterlevel", "g.xmin", 1);
sfi_int(nhfp, &g.ymin, "waterlevel", "g.ymin", 1);
sfi_int(nhfp, &g.xmax, "waterlevel", "g.xmax", 1);
sfi_int(nhfp, &g.ymax, "waterlevel", "g.ymax", 1);
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
btmp = b; btmp = b;
b = (struct bubble *) alloc(sizeof *b); b = (struct bubble *) alloc(sizeof(struct bubble));
mread(fd, (genericptr_t) b, sizeof *b); if (nhfp->structlevel)
if (g.bbubbles) { mread(nhfp->fd,(genericptr_t) b, sizeof(struct bubble));
btmp->next = b; if (nhfp->fieldlevel)
b->prev = btmp; sfi_bubble(nhfp, b, "waterlevel", "bubble", 1);
} else { if (g.bbubbles) {
g.bbubbles = b; btmp->next = b;
b->prev = (struct bubble *) 0; b->prev = btmp;
} } else {
mv_bubble(b, 0, 0, TRUE); g.bbubbles = b;
b->prev = (struct bubble *) 0;
}
mv_bubble(b, 0, 0, TRUE);
} }
g.ebubbles = b; g.ebubbles = b;
b->next = (struct bubble *) 0; b->next = (struct bubble *) 0;
+39 -19
View File
@@ -16,6 +16,8 @@
*/ */
#include "hack.h" #include "hack.h"
#include "sfproto.h"
STATIC_DCL boolean FDECL(isbig, (struct mkroom *)); STATIC_DCL boolean FDECL(isbig, (struct mkroom *));
STATIC_DCL struct mkroom *FDECL(pick_room, (BOOLEAN_P)); STATIC_DCL struct mkroom *FDECL(pick_room, (BOOLEAN_P));
@@ -24,8 +26,11 @@ STATIC_DCL void NDECL(mktemple);
STATIC_DCL coord *FDECL(shrine_pos, (int)); STATIC_DCL coord *FDECL(shrine_pos, (int));
STATIC_DCL struct permonst *NDECL(morguemon); STATIC_DCL struct permonst *NDECL(morguemon);
STATIC_DCL struct permonst *NDECL(squadmon); STATIC_DCL struct permonst *NDECL(squadmon);
STATIC_DCL void FDECL(save_room, (int, struct mkroom *)); /* SAVE2018 */
STATIC_DCL void FDECL(rest_room, (int, struct mkroom *)); /* STATIC_DCL void FDECL(save_room, (int,struct mkroom *)); */
/* STATIC_DCL void FDECL(rest_room, (int,struct mkroom *)); */
STATIC_DCL void FDECL(save_room, (NHFILE *, struct mkroom *));
STATIC_DCL void FDECL(rest_room, (NHFILE *, struct mkroom *));
#define sq(x) ((x) * (x)) #define sq(x) ((x) * (x))
@@ -796,8 +801,8 @@ gotone:
* (if any). * (if any).
*/ */
STATIC_OVL void STATIC_OVL void
save_room(fd, r) save_room(nhfp, r)
int fd; NHFILE *nhfp;
struct mkroom *r; struct mkroom *r;
{ {
short i; short i;
@@ -807,37 +812,48 @@ struct mkroom *r;
* of writing the whole structure. That is I should not write * of writing the whole structure. That is I should not write
* the g.subrooms pointers, but who cares ? * the g.subrooms pointers, but who cares ?
*/ */
bwrite(fd, (genericptr_t) r, sizeof (struct mkroom)); if (nhfp->structlevel)
for (i = 0; i < r->nsubrooms; i++) bwrite(nhfp->fd, (genericptr_t) r, sizeof (struct mkroom));
save_room(fd, r->sbrooms[i]); if (nhfp->fieldlevel)
sfo_mkroom(nhfp, r, "room", "mkroom", 1);
for (i = 0; i < r->nsubrooms; i++) {
save_room(nhfp, r->sbrooms[i]);
}
} }
/* /*
* save_rooms : Save all the rooms on disk! * save_rooms : Save all the rooms on disk!
*/ */
void void
save_rooms(fd) save_rooms(nhfp)
int fd; NHFILE *nhfp;
{ {
short i; short i;
/* First, write the number of rooms */ /* First, write the number of rooms */
bwrite(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom));
if (nhfp->fieldlevel)
sfo_int(nhfp, &g.nroom, "room", "g.nroom", 1);
for (i = 0; i < g.nroom; i++) for (i = 0; i < g.nroom; i++)
save_room(fd, &g.rooms[i]); save_room(nhfp, &g.rooms[i]);
} }
STATIC_OVL void STATIC_OVL void
rest_room(fd, r) rest_room(nhfp, r)
int fd; NHFILE *nhfp;
struct mkroom *r; struct mkroom *r;
{ {
short i; short i;
mread(fd, (genericptr_t) r, sizeof(struct mkroom)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) r, sizeof(struct mkroom));
if (nhfp->fieldlevel)
sfi_mkroom(nhfp, r, "room", "mkroom", 1);
for (i = 0; i < r->nsubrooms; i++) { for (i = 0; i < r->nsubrooms; i++) {
r->sbrooms[i] = &g.subrooms[g.nsubroom]; r->sbrooms[i] = &g.subrooms[g.nsubroom];
rest_room(fd, &g.subrooms[g.nsubroom]); rest_room(nhfp, &g.subrooms[g.nsubroom]);
g.subrooms[g.nsubroom++].resident = (struct monst *) 0; g.subrooms[g.nsubroom++].resident = (struct monst *) 0;
} }
} }
@@ -847,15 +863,19 @@ struct mkroom *r;
* the disk. * the disk.
*/ */
void void
rest_rooms(fd) rest_rooms(nhfp)
int fd; NHFILE *nhfp;
{ {
short i; short i;
mread(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom));
if (nhfp->fieldlevel)
sfi_int(nhfp, &g.nroom, "room", "g.nroom", 1);
g.nsubroom = 0; g.nsubroom = 0;
for (i = 0; i < g.nroom; i++) { for (i = 0; i < g.nroom; i++) {
rest_room(fd, &g.rooms[i]); rest_room(nhfp, &g.rooms[i]);
g.rooms[i].resident = (struct monst *) 0; g.rooms[i].resident = (struct monst *) 0;
} }
g.rooms[g.nroom].hx = -1; /* restore ending flags */ g.rooms[g.nroom].hx = -1; /* restore ending flags */
+65 -22
View File
@@ -5,6 +5,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" /* save & restore info */ #include "lev.h" /* save & restore info */
#include "sfproto.h"
STATIC_DCL void FDECL(setgemprobs, (d_level *)); STATIC_DCL void FDECL(setgemprobs, (d_level *));
STATIC_DCL void FDECL(shuffle, (int, int, BOOLEAN_P)); STATIC_DCL void FDECL(shuffle, (int, int, BOOLEAN_P));
@@ -286,29 +288,46 @@ oinit()
} }
void void
savenames(fd, mode) savenames(nhfp)
int fd, mode; NHFILE *nhfp;
{ {
register int i; int i, j;
unsigned int len; unsigned int len;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
bwrite(fd, (genericptr_t) g.bases, sizeof g.bases); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) g.disco, sizeof g.disco); bwrite(nhfp->fd, (genericptr_t)g.bases, sizeof g.bases);
bwrite(fd, (genericptr_t) objects, bwrite(nhfp->fd, (genericptr_t)g.disco, sizeof g.disco);
sizeof(struct objclass) * NUM_OBJECTS); bwrite(nhfp->fd, (genericptr_t)objects,
sizeof(struct objclass) * NUM_OBJECTS);
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAXOCLASSES; ++i)
sfo_int(nhfp, &g.bases[i], "names", "g.bases", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfo_short(nhfp, &g.disco[i], "names", "g.disco", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfo_objclass(nhfp, &objects[i], "names", "objclass", 1);
}
} }
/* as long as we use only one version of Hack we /* as long as we use only one version of Hack we
need not save oc_name and oc_descr, but we must save need not save oc_name and oc_descr, but we must save
oc_uname for all objects */ oc_uname for all objects */
for (i = 0; i < NUM_OBJECTS; i++) for (i = 0; i < NUM_OBJECTS; i++)
if (objects[i].oc_uname) { if (objects[i].oc_uname) {
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
len = strlen(objects[i].oc_uname) + 1; len = strlen(objects[i].oc_uname) + 1;
bwrite(fd, (genericptr_t) &len, sizeof len); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) objects[i].oc_uname, len); bwrite(nhfp->fd, (genericptr_t)&len, sizeof len);
bwrite(nhfp->fd, (genericptr_t)objects[i].oc_uname, len);
}
if (nhfp->fieldlevel) {
sfo_unsigned(nhfp, &len, "names", "len", 1);
for (j = 0; (unsigned) j < len; ++j)
sfo_char(nhfp, &objects[i].oc_uname[j], "names", "oc_uname", 1);
}
} }
if (release_data(mode)) { if (release_data(nhfp)) {
free((genericptr_t) objects[i].oc_uname); free((genericptr_t) objects[i].oc_uname);
objects[i].oc_uname = 0; objects[i].oc_uname = 0;
} }
@@ -316,21 +335,45 @@ int fd, mode;
} }
void void
restnames(fd) restnames(nhfp)
register int fd; NHFILE *nhfp;
{ {
register int i; int i, j;
unsigned int len; unsigned int len;
mread(fd, (genericptr_t)g.bases, sizeof g.bases); if (nhfp->structlevel) {
mread(fd, (genericptr_t) g.disco, sizeof g.disco); mread(nhfp->fd, (genericptr_t) g.bases, sizeof g.bases);
mread(fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS); mread(nhfp->fd, (genericptr_t) g.disco, sizeof g.disco);
for (i = 0; i < NUM_OBJECTS; i++) mread(nhfp->fd, (genericptr_t) objects,
sizeof(struct objclass) * NUM_OBJECTS);
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAXOCLASSES; ++i)
sfi_int(nhfp, &g.bases[i], "names", "g.bases", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfi_short(nhfp, &g.disco[i], "names", "g.disco", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfi_objclass(nhfp, &objects[i], "names", "objclass", 1);
}
for (i = 0; i < NUM_OBJECTS; i++) {
if (objects[i].oc_uname) { if (objects[i].oc_uname) {
mread(fd, (genericptr_t) &len, sizeof len); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &len, sizeof len);
}
if (nhfp->fieldlevel) {
sfi_unsigned(nhfp, &len, "names", "len", 1);
}
objects[i].oc_uname = (char *) alloc(len); objects[i].oc_uname = (char *) alloc(len);
mread(fd, (genericptr_t) objects[i].oc_uname, len); if (nhfp->structlevel) {
} mread(nhfp->fd, (genericptr_t)objects[i].oc_uname, len);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < len; ++j)
sfi_char(nhfp, &objects[i].oc_uname[j],
"names", "oc_uname", 1);
}
}
}
#ifdef USE_TILES #ifdef USE_TILES
shuffle_tiles(); shuffle_tiles();
#endif #endif
+4
View File
@@ -18,6 +18,7 @@ NEARDATA struct instance_flags iflags; /* provide linkage */
#include "tcap.h" #include "tcap.h"
#include <ctype.h> #include <ctype.h>
#endif #endif
#include "sfprocs.h"
#define BACKWARD_COMPAT #define BACKWARD_COMPAT
@@ -698,6 +699,9 @@ initoptions_init()
if (boolopt[i].addr) if (boolopt[i].addr)
*(boolopt[i].addr) = boolopt[i].initvalue; *(boolopt[i].addr) = boolopt[i].initvalue;
} }
/* initialize the function pointers for fieldlevel saves */
sf_init();
#if defined(COMPRESS) || defined(ZLIB_COMP) #if defined(COMPRESS) || defined(ZLIB_COMP)
set_savepref("externalcomp"); set_savepref("externalcomp");
set_restpref("externalcomp"); set_restpref("externalcomp");
+227 -88
View File
@@ -4,6 +4,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" #include "lev.h"
#include "sfproto.h"
/* /*
* This should really go into the level structure, but * This should really go into the level structure, but
@@ -613,64 +615,126 @@ xchar x, y;
* save_regions : * save_regions :
*/ */
void void
save_regions(fd, mode) save_regions(nhfp)
int fd; NHFILE *nhfp;
int mode;
{ {
int i, j; int i, j;
unsigned n; unsigned n;
if (!perform_bwrite(mode)) if (!perform_bwrite(nhfp))
goto skip_lots; goto skip_lots;
if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) &g.moves, sizeof(g.moves)); /* timestamp */ bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof (g.moves)); /* timestamp */
bwrite(fd, (genericptr_t) &g.n_regions, sizeof(g.n_regions)); bwrite(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
for (i = 0; i < g.n_regions; i++) {
bwrite(fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof(NhRect));
bwrite(fd, (genericptr_t) &g.regions[i]->nrects, sizeof(short));
for (j = 0; j < g.regions[i]->nrects; j++)
bwrite(fd, (genericptr_t) &g.regions[i]->rects[j], sizeof(NhRect));
bwrite(fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof(boolean));
n = 0;
bwrite(fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof(unsigned));
n = g.regions[i]->enter_msg != (const char *) 0
? strlen(g.regions[i]->enter_msg)
: 0;
bwrite(fd, (genericptr_t) &n, sizeof n);
if (n > 0)
bwrite(fd, (genericptr_t) g.regions[i]->enter_msg, n);
n = g.regions[i]->leave_msg != (const char *) 0
? strlen(g.regions[i]->leave_msg)
: 0;
bwrite(fd, (genericptr_t) &n, sizeof n);
if (n > 0)
bwrite(fd, (genericptr_t) g.regions[i]->leave_msg, n);
bwrite(fd, (genericptr_t) &g.regions[i]->ttl, sizeof(long));
bwrite(fd, (genericptr_t) &g.regions[i]->expire_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->can_enter_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->enter_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->can_leave_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->leave_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->inside_f, sizeof(short));
bwrite(fd, (genericptr_t) &g.regions[i]->player_flags,
sizeof(unsigned int));
bwrite(fd, (genericptr_t) &g.regions[i]->n_monst, sizeof(short));
for (j = 0; j < g.regions[i]->n_monst; j++)
bwrite(fd, (genericptr_t) &g.regions[i]->monsters[j],
sizeof(unsigned));
bwrite(fd, (genericptr_t) &g.regions[i]->visible, sizeof(boolean));
bwrite(fd, (genericptr_t) &g.regions[i]->glyph, sizeof(int));
bwrite(fd, (genericptr_t) &g.regions[i]->arg, sizeof(anything));
} }
if (nhfp->fieldlevel) {
sfo_long(nhfp, &g.moves, "regions", "tmstamp", 1);
sfo_int(nhfp, &g.n_regions, "regions", "region_count", 1);
}
for (i = 0; i < g.n_regions; i++) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
}
if (nhfp->fieldlevel) {
sfo_nhrect(nhfp, &g.regions[i]->bounding_box, "g.regions", "bounding_box", 1);
sfo_short(nhfp, &g.regions[i]->nrects, "g.regions", "nrects", 1);
}
for (j = 0; j < g.regions[i]->nrects; j++) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
if (nhfp->fieldlevel)
sfo_nhrect(nhfp, &g.regions[i]->rects[j], "g.regions", "rect", 1);
}
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
if (nhfp->fieldlevel)
sfo_boolean(nhfp, &g.regions[i]->attach_2_u, "g.regions", "attach_2_u", 1);
n = 0;
skip_lots: if (nhfp->structlevel)
if (release_data(mode)) bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.regions[i]->attach_2_m, "g.regions", "attach_2_m", 1);
n = g.regions[i]->enter_msg != (const char *)0 ?
strlen(g.regions[i]->enter_msg) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &n, "g.regions", "enter_msg_length", 1);
if (n > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->enter_msg, n);
if (nhfp->fieldlevel)
sfo_char(nhfp, g.regions[i]->enter_msg, "g.regions", "enter_msg", 1);
}
n = g.regions[i]->leave_msg != (const char *)0 ?
strlen(g.regions[i]->leave_msg) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &n, "g.regions", "leave_msg_length", 1);
if (n > 0) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->leave_msg, n);
}
if (nhfp->fieldlevel) {
for (j = 0; j < (int) n; ++j)
sfo_char(nhfp, &g.regions[i]->leave_msg[j], "g.regions", "leave_msg", 1);
}
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_enter_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->enter_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_leave_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->leave_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->inside_f, sizeof (short));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags, sizeof (unsigned int));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
}
if (nhfp->fieldlevel) {
sfo_long(nhfp, &g.regions[i]->ttl, "g.regions", "ttl", 1);
sfo_short(nhfp, &g.regions[i]->expire_f, "g.regions", "expire_f", 1);
sfo_short(nhfp, &g.regions[i]->can_enter_f, "g.regions", "can_enter_f", 1);
sfo_short(nhfp, &g.regions[i]->enter_f, "g.regions", "enter_f", 1);
sfo_short(nhfp, &g.regions[i]->can_leave_f, "g.regions", "can_leave_f", 1);
sfo_short(nhfp, &g.regions[i]->leave_f, "g.regions", "leave_f", 1);
sfo_short(nhfp, &g.regions[i]->inside_f, "g.regions", "inside_f", 1);
sfo_unsigned(nhfp, &g.regions[i]->player_flags, "g.regions", "player_flags", 1);
sfo_short(nhfp, &g.regions[i]->n_monst, "g.regions", "monster_count", 1);
}
for (j = 0; j < g.regions[i]->n_monst; j++) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->monsters[j],
sizeof (unsigned));
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.regions[i]->monsters[j], "g.regions", "monster", 1);
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
}
if (nhfp->fieldlevel) {
sfo_boolean(nhfp, &g.regions[i]->visible, "g.regions", "visible", 1);
sfo_int(nhfp, &g.regions[i]->glyph, "g.regions", "glyph", 1);
sfo_any(nhfp, &g.regions[i]->arg, "g.regions", "arg", 1);
}
}
skip_lots:
if (release_data(nhfp))
clear_regions(); clear_regions();
} }
void void
rest_regions(fd, ghostly) rest_regions(nhfp, ghostly)
int fd; NHFILE *nhfp;
boolean ghostly; /* If a bones file restore */ boolean ghostly; /* If a bones file restore */
{ {
int i, j; int i, j;
@@ -678,77 +742,152 @@ boolean ghostly; /* If a bones file restore */
long tmstamp; long tmstamp;
char *msg_buf; char *msg_buf;
clear_regions(); /* Just for security */ clear_regions(); /* Just for security */
mread(fd, (genericptr_t) &tmstamp, sizeof(tmstamp)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &tmstamp, sizeof (tmstamp));
if (nhfp->fieldlevel)
sfi_long(nhfp, &tmstamp, "regions", "tmstamp", 1);
if (ghostly) if (ghostly)
tmstamp = 0; tmstamp = 0;
else else
tmstamp = (g.moves - tmstamp); tmstamp = (g.moves - tmstamp);
mread(fd, (genericptr_t) &g.n_regions, sizeof(g.n_regions));
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
if (nhfp->fieldlevel)
sfi_int(nhfp, &g.n_regions, "regions", "region_count", 1);
g.max_regions = g.n_regions; g.max_regions = g.n_regions;
if (g.n_regions > 0) if (g.n_regions > 0)
g.regions = (NhRegion **) alloc(sizeof(NhRegion *) * g.n_regions); g.regions = (NhRegion **) alloc(sizeof (NhRegion *) * g.n_regions);
for (i = 0; i < g.n_regions; i++) { for (i = 0; i < g.n_regions; i++) {
g.regions[i] = (NhRegion *) alloc(sizeof(NhRegion)); g.regions[i] = (NhRegion *) alloc(sizeof (NhRegion));
mread(fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof(NhRect)); if (nhfp->structlevel) {
mread(fd, (genericptr_t) &g.regions[i]->nrects, sizeof(short)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
}
if (nhfp->fieldlevel) {
sfi_nhrect(nhfp, &g.regions[i]->bounding_box, "g.regions", "bounding box", 1);
sfi_short(nhfp, &g.regions[i]->nrects, "g.regions", "nrects", 1);
}
if (g.regions[i]->nrects > 0) if (g.regions[i]->nrects > 0)
g.regions[i]->rects = g.regions[i]->rects = (NhRect *)
(NhRect *) alloc(sizeof(NhRect) * g.regions[i]->nrects); alloc(sizeof (NhRect) * g.regions[i]->nrects);
for (j = 0; j < g.regions[i]->nrects; j++) for (j = 0; j < g.regions[i]->nrects; j++) {
mread(fd, (genericptr_t) &g.regions[i]->rects[j], sizeof(NhRect)); if (nhfp->structlevel)
mread(fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof(boolean)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
mread(fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof(unsigned)); if (nhfp->fieldlevel)
sfi_nhrect(nhfp, &g.regions[i]->rects[j], "g.regions", "rect", 1);
}
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
}
if (nhfp->fieldlevel) {
sfi_boolean(nhfp, &g.regions[i]->attach_2_u, "g.regions", "attach_2_u", 1);
sfi_unsigned(nhfp, &g.regions[i]->attach_2_m, "g.regions", "attach_2_m", 1);
}
mread(fd, (genericptr_t) &n, sizeof n); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &n, "g.regions", "enter_msg_length", 1);
if (n > 0) { if (n > 0) {
msg_buf = (char *) alloc(n + 1); msg_buf = (char *) alloc(n + 1);
mread(fd, (genericptr_t) msg_buf, n); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) msg_buf, n);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < n; ++j)
sfi_char(nhfp, &msg_buf[j], "g.regions", "enter_msg", 1);
}
msg_buf[n] = '\0'; msg_buf[n] = '\0';
g.regions[i]->enter_msg = (const char *) msg_buf; g.regions[i]->enter_msg = (const char *) msg_buf;
} else } else
g.regions[i]->enter_msg = (const char *) 0; g.regions[i]->enter_msg = (const char *)0;
mread(fd, (genericptr_t) &n, sizeof n); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &n, "g.regions", "leave_msg_length", 1);
if (n > 0) { if (n > 0) {
msg_buf = (char *) alloc(n + 1); msg_buf = (char *) alloc(n + 1);
mread(fd, (genericptr_t) msg_buf, n); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) msg_buf, n);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < n; ++j)
sfi_char(nhfp, &msg_buf[j], "g.regions", "leave_msg", 1);
}
msg_buf[n] = '\0'; msg_buf[n] = '\0';
g.regions[i]->leave_msg = (const char *) msg_buf; g.regions[i]->leave_msg = (const char *) msg_buf;
} else } else
g.regions[i]->leave_msg = (const char *) 0; g.regions[i]->leave_msg = (const char *)0;
mread(fd, (genericptr_t) &g.regions[i]->ttl, sizeof(long)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
if (nhfp->fieldlevel)
sfi_long(nhfp, &g.regions[i]->ttl, "g.regions", "ttl", 1);
/* check for expired region */ /* check for expired region */
if (g.regions[i]->ttl >= 0L) if (g.regions[i]->ttl >= 0L)
g.regions[i]->ttl = g.regions[i]->ttl =
(g.regions[i]->ttl > tmstamp) ? g.regions[i]->ttl - tmstamp : 0L; (g.regions[i]->ttl > tmstamp) ? g.regions[i]->ttl - tmstamp : 0L;
mread(fd, (genericptr_t) &g.regions[i]->expire_f, sizeof(short)); if (nhfp->structlevel) {
mread(fd, (genericptr_t) &g.regions[i]->can_enter_f, sizeof(short)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f,
mread(fd, (genericptr_t) &g.regions[i]->enter_f, sizeof(short)); sizeof (short));
mread(fd, (genericptr_t) &g.regions[i]->can_leave_f, sizeof(short)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->can_enter_f,
mread(fd, (genericptr_t) &g.regions[i]->leave_f, sizeof(short)); sizeof (short));
mread(fd, (genericptr_t) &g.regions[i]->inside_f, sizeof(short)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->enter_f,
mread(fd, (genericptr_t) &g.regions[i]->player_flags, sizeof (short));
sizeof(unsigned int)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->can_leave_f,
if (ghostly) { /* settings pertained to old player */ sizeof (short));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->leave_f,
sizeof (short));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->inside_f,
sizeof (short));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags,
sizeof (unsigned int));
}
if (nhfp->fieldlevel) {
sfi_short(nhfp, &g.regions[i]->expire_f, "g.regions", "expire_f", 1);
sfi_short(nhfp, &g.regions[i]->can_enter_f, "g.regions", "can_enter_f", 1);
sfi_short(nhfp, &g.regions[i]->enter_f, "g.regions", "enter_f", 1);
sfi_short(nhfp, &g.regions[i]->can_leave_f, "g.regions", "can_leave_f", 1);
sfi_short(nhfp, &g.regions[i]->leave_f, "g.regions", "leave_f", 1);
sfi_short(nhfp, &g.regions[i]->inside_f, "g.regions", "inside_f", 1);
sfi_unsigned(nhfp, &g.regions[i]->player_flags, "g.regions", "player_flags", 1);
}
if (ghostly) { /* settings pertained to old player */
clear_hero_inside(g.regions[i]); clear_hero_inside(g.regions[i]);
clear_heros_fault(g.regions[i]); clear_heros_fault(g.regions[i]);
} }
mread(fd, (genericptr_t) &g.regions[i]->n_monst, sizeof(short)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
if (nhfp->fieldlevel)
sfi_short(nhfp, &g.regions[i]->n_monst, "g.regions", "monster_count", 1);
if (g.regions[i]->n_monst > 0) if (g.regions[i]->n_monst > 0)
g.regions[i]->monsters = g.regions[i]->monsters =
(unsigned *) alloc(sizeof(unsigned) * g.regions[i]->n_monst); (unsigned *) alloc(sizeof (unsigned) * g.regions[i]->n_monst);
else else
g.regions[i]->monsters = (unsigned int *) 0; g.regions[i]->monsters = (unsigned int *)0;
g.regions[i]->max_monst = g.regions[i]->n_monst; g.regions[i]->max_monst = g.regions[i]->n_monst;
for (j = 0; j < g.regions[i]->n_monst; j++) for (j = 0; j < g.regions[i]->n_monst; j++) {
mread(fd, (genericptr_t) &g.regions[i]->monsters[j], if (nhfp->structlevel)
sizeof(unsigned)); mread(nhfp->fd, (genericptr_t) &g.regions[i]->monsters[j],
mread(fd, (genericptr_t) &g.regions[i]->visible, sizeof(boolean)); sizeof (unsigned));
mread(fd, (genericptr_t) &g.regions[i]->glyph, sizeof(int)); if (nhfp->fieldlevel)
mread(fd, (genericptr_t) &g.regions[i]->arg, sizeof(anything)); sfi_unsigned(nhfp, &g.regions[i]->monsters[j], "g.regions", "monster", 1);
}
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
}
if (nhfp->fieldlevel) {
sfi_boolean(nhfp, &g.regions[i]->visible, "g.regions", "visible", 1);
sfi_int(nhfp, &g.regions[i]->glyph, "g.regions", "glyph", 1);
sfi_any(nhfp, &g.regions[i]->arg, "g.regions", "arg", 1);
}
} }
/* remove expired regions, do not trigger the expire_f callback (yet!); /* remove expired regions, do not trigger the expire_f callback (yet!);
also update monster lists if this data is coming from a bones file */ also update monster lists if this data is coming from a bones file */
+649 -309
View File
File diff suppressed because it is too large Load Diff
+36 -11
View File
@@ -6,6 +6,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" #include "lev.h"
#include "dlb.h" #include "dlb.h"
#include "sfproto.h"
/* [note: this comment is fairly old, but still accurate for 3.1] /* [note: this comment is fairly old, but still accurate for 3.1]
* Rumors have been entirely rewritten to speed up the access. This is * Rumors have been entirely rewritten to speed up the access. This is
@@ -383,15 +385,27 @@ dlb *fp;
} }
void void
save_oracles(fd, mode) save_oracles(nhfp)
int fd, mode; NHFILE *nhfp;
{ {
if (perform_bwrite(mode)) { int i;
bwrite(fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (g.oracle_cnt) if (perform_bwrite(nhfp)) {
bwrite(fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof(long)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.oracle_cnt, "oracles", "g.oracle_cnt", 1);
if (g.oracle_cnt) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t)g.oracle_loc, g.oracle_cnt * sizeof (long));
}
if (nhfp->fieldlevel) {
for (i = 0; (unsigned) i < g.oracle_cnt; ++i)
sfo_ulong(nhfp, &g.oracle_loc[i], "oracles", "oracle loc", 1);
}
}
} }
if (release_data(mode)) { if (release_data(nhfp)) {
if (g.oracle_cnt) { if (g.oracle_cnt) {
free((genericptr_t) g.oracle_loc); free((genericptr_t) g.oracle_loc);
g.oracle_loc = 0, g.oracle_cnt = 0, g.oracle_flg = 0; g.oracle_loc = 0, g.oracle_cnt = 0, g.oracle_flg = 0;
@@ -400,13 +414,24 @@ int fd, mode;
} }
void void
restore_oracles(fd) restore_oracles(nhfp)
int fd; NHFILE *nhfp;
{ {
mread(fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt); int i;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &g.oracle_cnt, "oracles", "g.oracle_cnt", 1);
if (g.oracle_cnt) { if (g.oracle_cnt) {
g.oracle_loc = (unsigned long *) alloc(g.oracle_cnt * sizeof(long)); g.oracle_loc = (unsigned long *) alloc(g.oracle_cnt * sizeof(long));
mread(fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof(long)); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof (long));
}
if (nhfp->fieldlevel) {
for (i = 0; (unsigned) i < g.oracle_cnt; ++i)
sfi_ulong(nhfp, &g.oracle_loc[i], "oracles", "g.oracle_loc", 1);
}
g.oracle_flg = 1; /* no need to call init_oracles() */ g.oracle_flg = 1; /* no need to call init_oracles() */
} }
} }
+616 -294
View File
File diff suppressed because it is too large Load Diff
+1112
View File
File diff suppressed because it is too large Load Diff
+640
View File
@@ -0,0 +1,640 @@
/* NetHack 3.6 sf_base.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* Copyright (c) Michael Allison, 2019. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "integer.h"
#include "sfprocs.h"
struct sf_procs sfoprocs[4], sfiprocs[4],
zerosfoprocs = {0}, zerosfiprocs = {0};
void FDECL(sfi_log, (NHFILE *, const char *, const char *, const char *, int));
/*
*----------------------------------------------------------------------------
* initialize the function pointers. These are called from initoptions_init().
*----------------------------------------------------------------------------
*/
void
sf_init()
{
sfoprocs[invalid] = zerosfoprocs;
sfiprocs[invalid] = zerosfiprocs;
sfoprocs[historical] = zerosfoprocs;
sfiprocs[historical] = zerosfiprocs;
sfoprocs[lendian] = lendian_sfo_procs;
sfiprocs[lendian] = lendian_sfi_procs;
sfoprocs[ascii] = ascii_sfo_procs;
sfiprocs[ascii] = ascii_sfi_procs;
}
/*
*----------------------------------------
* routines called from engine core and
* from functions in generated sfdata.c
*----------------------------------------
*/
void
sfo_any(nhfp, d_any, myparent, myname, cnt)
NHFILE *nhfp;
union any *d_any;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_any)(nhfp, d_any, myparent, myname, cnt);
}
void
sfo_aligntyp(nhfp, d_aligntyp, myparent, myname, cnt)
NHFILE *nhfp;
aligntyp *d_aligntyp;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_aligntyp)(nhfp, d_aligntyp, myparent, myname, cnt);
}
void
sfo_bitfield(nhfp, d_bitfield, myparent, myname, cnt)
NHFILE *nhfp;
uint8_t *d_bitfield;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_bitfield)(nhfp, d_bitfield, myparent, myname, cnt);
}
void
sfo_boolean(nhfp, d_boolean, myparent, myname, cnt)
NHFILE *nhfp;
boolean *d_boolean;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_boolean)(nhfp, d_boolean, myparent, myname, cnt);
}
void
sfo_char(nhfp, d_char, myparent, myname, cnt)
NHFILE *nhfp;
char *d_char;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_char)(nhfp, d_char, myparent, myname, cnt);
}
void
sfo_genericptr(nhfp, d_genericptr, myparent, myname, cnt)
NHFILE *nhfp;
genericptr_t d_genericptr;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_genericptr)(nhfp, d_genericptr, myparent, myname, cnt);
}
void
sfo_int(nhfp, d_int, myparent, myname, cnt)
NHFILE *nhfp;
int *d_int;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_int)(nhfp, d_int, myparent, myname, cnt);
}
void
sfo_long(nhfp, d_long, myparent, myname, cnt)
NHFILE *nhfp;
long *d_long;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_long)(nhfp, d_long, myparent, myname, cnt);
}
void
sfo_schar(nhfp, d_schar, myparent, myname, cnt)
NHFILE *nhfp;
schar *d_schar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_schar)(nhfp, d_schar, myparent, myname, cnt);
}
void
sfo_short(nhfp, d_short, myparent, myname, cnt)
NHFILE *nhfp;
short *d_short;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_short)(nhfp, d_short, myparent, myname, cnt);
}
void
sfo_size_t(nhfp, d_size_t, myparent, myname, cnt)
NHFILE *nhfp;
size_t *d_size_t;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_size_t)(nhfp, d_size_t, myparent, myname, cnt);
}
void
sfo_time_t(nhfp, d_time_t, myparent, myname, cnt)
NHFILE *nhfp;
time_t *d_time_t;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_time_t)(nhfp, d_time_t, myparent, myname, cnt);
}
void
sfo_unsigned(nhfp, d_unsigned, myparent, myname, cnt)
NHFILE *nhfp;
unsigned *d_unsigned;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_unsigned)(nhfp, d_unsigned, myparent, myname, cnt);
}
void
sfo_uchar(nhfp, d_uchar, myparent, myname, cnt)
NHFILE *nhfp;
unsigned char *d_uchar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_uchar)(nhfp, d_uchar, myparent, myname, cnt);
}
void
sfo_uint(nhfp, d_uint, myparent, myname, cnt)
NHFILE *nhfp;
unsigned int *d_uint;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_uint)(nhfp, d_uint, myparent, myname, cnt);
}
void
sfo_ulong(nhfp, d_ulong, myparent, myname, cnt)
NHFILE *nhfp;
unsigned long *d_ulong;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_ulong)(nhfp, d_ulong, myparent, myname, cnt);
}
void
sfo_ushort(nhfp, d_ushort, myparent, myname, cnt)
NHFILE *nhfp;
unsigned short *d_ushort;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_ushort)(nhfp, d_ushort, myparent, myname, cnt);
}
void
sfo_xchar(nhfp, d_xchar, myparent, myname, cnt)
NHFILE *nhfp;
xchar *d_xchar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_xchar)(nhfp, d_xchar, myparent, myname, cnt);
}
void
sfo_str(nhfp, d_str, myparent, myname, cnt)
NHFILE *nhfp;
char *d_str;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_str)(nhfp, d_str, myparent, myname, cnt);
}
void
sfo_addinfo(nhfp, parent, action, myname, index)
NHFILE *nhfp;
const char *parent, *action, *myname;
int index;
{
(*sfoprocs[nhfp->fnidx].fn.sf_addinfo)(nhfp, parent, action, myname, index);
}
/*
*----------------------------------------------------------------------------
* routines called from core and from functions in generated sfi_data.c
*----------------------------------------------------------------------------
*/
void
sfi_any(nhfp, d_any, myparent, myname, cnt)
NHFILE *nhfp;
union any *d_any;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "any";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_any)(nhfp, d_any, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%ld)\n", d_any->a_long);
#endif
}
void
sfi_aligntyp(nhfp, d_aligntyp, myparent, myname, cnt)
NHFILE *nhfp;
aligntyp *d_aligntyp;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "aligntyp";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_aligntyp)(nhfp, d_aligntyp, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%d)\n", *d_aligntyp);
#endif
}
void
sfi_bitfield(nhfp, d_bitfield, myparent, myname, cnt)
NHFILE *nhfp;
uint8_t *d_bitfield;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "bitfield";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_bitfield)(nhfp, d_bitfield, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", *d_bitfield);
#endif
}
void
sfi_boolean(nhfp, d_boolean, myparent, myname, cnt)
NHFILE *nhfp;
boolean *d_boolean;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "boolean";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_boolean)(nhfp, d_boolean, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", (*d_boolean) ? "true" : "false");
#endif
}
void
sfi_char(nhfp, d_char, myparent, myname, cnt)
NHFILE *nhfp;
char *d_char;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "char";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_char)(nhfp, d_char, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", d_char ? d_char : "");
#endif
}
void
sfi_genericptr(nhfp, d_genericptr, myparent, myname, cnt)
NHFILE *nhfp;
genericptr_t d_genericptr;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "genericptr";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_genericptr)(nhfp, d_genericptr, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", (d_genericptr) ? "set" : "null");
#endif
}
void
sfi_int(nhfp, d_int, myparent, myname, cnt)
NHFILE *nhfp;
int *d_int;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "int";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_int)(nhfp, d_int, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%d)\n", *d_int);
#endif
}
void
sfi_long(nhfp, d_long, myparent, myname, cnt)
NHFILE *nhfp;
long *d_long;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "long";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_long)(nhfp, d_long, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%ld)\n", *d_long);
#endif
}
void
sfi_schar(nhfp, d_schar, myparent, myname, cnt)
NHFILE *nhfp;
schar *d_schar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "schar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_schar)(nhfp, d_schar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", (short) *d_schar);
#endif
}
void
sfi_short(nhfp, d_short, myparent, myname, cnt)
NHFILE *nhfp;
short *d_short;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "short";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_short)(nhfp, d_short, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", *d_short);
#endif
}
void
sfi_size_t(nhfp, d_size_t, myparent, myname, cnt)
NHFILE *nhfp;
size_t *d_size_t;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "size_t";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_size_t)(nhfp, d_size_t, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%lu)\n", (unsigned long) *d_size_t);
#endif
}
void
sfi_time_t(nhfp, d_time_t, myparent, myname, cnt)
NHFILE *nhfp;
time_t *d_time_t;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "time_t";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_time_t)(nhfp, d_time_t, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", yyyymmddhhmmss(*d_time_t));
#endif
}
void
sfi_unsigned(nhfp, d_unsigned, myparent, myname, cnt)
NHFILE *nhfp;
unsigned *d_unsigned;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "unsigned";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_unsigned)(nhfp, d_unsigned, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%u)\n", *d_unsigned);
#endif
}
void
sfi_uchar(nhfp, d_uchar, myparent, myname, cnt)
NHFILE *nhfp;
unsigned char *d_uchar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "uchar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_uchar)(nhfp, d_uchar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hu)\n", (unsigned short) *d_uchar);
#endif
}
void
sfi_uint(nhfp, d_uint, myparent, myname, cnt)
NHFILE *nhfp;
unsigned int *d_uint;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "uint";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_uint)(nhfp, d_uint, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%u)\n", *d_uint);
#endif
}
void
sfi_ulong(nhfp, d_ulong, myparent, myname, cnt)
NHFILE *nhfp;
unsigned long *d_ulong;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "ulong";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_ulong)(nhfp, d_ulong, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%lu)\n", *d_ulong);
#endif
}
void
sfi_ushort(nhfp, d_ushort, myparent, myname, cnt)
NHFILE *nhfp;
unsigned short *d_ushort;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "ushort";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_ushort)(nhfp, d_ushort, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hu)\n", *d_ushort);
#endif
}
void
sfi_xchar(nhfp, d_xchar, myparent, myname, cnt)
NHFILE *nhfp;
xchar *d_xchar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "xchar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_xchar)(nhfp, d_xchar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", (short) *d_xchar);
#endif
}
void
sfi_str(nhfp, d_str, myparent, myname, cnt)
NHFILE *nhfp;
char *d_str;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "str";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_str)(nhfp, d_str, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(\"%s\")\n", d_str);
#endif
}
void
sfi_addinfo(nhfp, myparent, action, myname, index)
NHFILE *nhfp;
const char *myparent, *action, *myname;
int index;
{
if (nhfp) {
if (nhfp->fplog)
(void) fprintf(nhfp->fplog, "# %s %s %s %d\n", myparent, action, myname, index);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
(void) fprintf(nhfp->fpdebug, "# %s %s %s %d\n", myparent, action, myname, index);
#endif
}
(*sfiprocs[nhfp->fnidx].fn.sf_addinfo)(nhfp, myparent, action, myname, index);
}
void
sfi_log(nhfp, t1, t2, t3, cnt)
NHFILE *nhfp;
const char *t1, *t2, *t3;
int cnt;
{
#ifdef DO_DEBUG
#ifdef SAVEFILE_DEBUGGING
if (nhfp) {
if (nhfp->fplog)
(void) fprintf(nhfp->fplog, "%s %s %s cnt=%d\n", t1, t2, t3, cnt);
if (nhfp->fpdebug)
(void) fprintf(nhfp->fpdebug, "%s %s %s cnt=%d ", t1, t2, t3, cnt);
}
#endif
#endif
}
+5776
View File
File diff suppressed because it is too large Load Diff
+1313
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -6032,7 +6032,7 @@ const char *name;
if (!fd) if (!fd)
return FALSE; return FALSE;
Fread((genericptr_t) &vers_info, sizeof vers_info, 1, fd); Fread((genericptr_t) &vers_info, sizeof vers_info, 1, fd);
if (!check_version(&vers_info, name, TRUE)) { if (!check_version(&vers_info, name, TRUE, UTD_CHECKSIZES)) {
(void) dlb_fclose(fd); (void) dlb_fclose(fd);
goto give_up; goto give_up;
} }
+73 -38
View File
@@ -5,6 +5,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" /* for checking save modes */ #include "lev.h" /* for checking save modes */
#include "sfproto.h"
STATIC_DCL void NDECL(stoned_dialogue); STATIC_DCL void NDECL(stoned_dialogue);
STATIC_DCL void NDECL(vomiting_dialogue); STATIC_DCL void NDECL(vomiting_dialogue);
@@ -1631,13 +1633,13 @@ do_storms()
* Call timers that have timed out. * Call timers that have timed out.
* *
* Save/Restore: * Save/Restore:
* void save_timers(int fd, int mode, int range) * void save_timers(NHFILE *, int range)
* Save all timers of range 'range'. Range is either global * Save all timers of range 'range'. Range is either global
* or local. Global timers follow game play, local timers * or local. Global timers follow game play, local timers
* are saved with a level. Object and monster timers are * are saved with a level. Object and monster timers are
* saved using their respective id's instead of pointers. * saved using their respective id's instead of pointers.
* *
* void restore_timers(int fd, int range, boolean ghostly, long adjust) * void restore_timers(NHFILE *, int range, boolean ghostly, long adjust)
* Restore timers of range 'range'. If from a ghost pile, * Restore timers of range 'range'. If from a ghost pile,
* adjust the timeout by 'adjust'. The object and monster * adjust the timeout by 'adjust'. The object and monster
* ids are not restored until later. * ids are not restored until later.
@@ -1665,10 +1667,10 @@ STATIC_DCL void FDECL(print_queue, (winid, timer_element *));
STATIC_DCL void FDECL(insert_timer, (timer_element *)); STATIC_DCL void FDECL(insert_timer, (timer_element *));
STATIC_DCL timer_element *FDECL(remove_timer, STATIC_DCL timer_element *FDECL(remove_timer,
(timer_element **, SHORT_P, ANY_P *)); (timer_element **, SHORT_P, ANY_P *));
STATIC_DCL void FDECL(write_timer, (int, timer_element *)); STATIC_DCL void FDECL(write_timer, (NHFILE *, timer_element *));
STATIC_DCL boolean FDECL(mon_is_local, (struct monst *)); STATIC_DCL boolean FDECL(mon_is_local, (struct monst *));
STATIC_DCL boolean FDECL(timer_is_local, (timer_element *)); STATIC_DCL boolean FDECL(timer_is_local, (timer_element *));
STATIC_DCL int FDECL(maybe_write_timer, (int, int, BOOLEAN_P)); STATIC_DCL int FDECL(maybe_write_timer, (NHFILE *, int, BOOLEAN_P));
/* If defined, then include names when printing out the timer queue */ /* If defined, then include names when printing out the timer queue */
#define VERBOSE_TIMER #define VERBOSE_TIMER
@@ -2110,8 +2112,8 @@ anything *arg;
} }
STATIC_OVL void STATIC_OVL void
write_timer(fd, timer) write_timer(nhfp, timer)
int fd; NHFILE *nhfp;
timer_element *timer; timer_element *timer;
{ {
anything arg_save; anything arg_save;
@@ -2121,34 +2123,49 @@ timer_element *timer;
case TIMER_GLOBAL: case TIMER_GLOBAL:
case TIMER_LEVEL: case TIMER_LEVEL:
/* assume no pointers in arg */ /* assume no pointers in arg */
bwrite(fd, (genericptr_t) timer, sizeof(timer_element)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
break; break;
case TIMER_OBJECT: case TIMER_OBJECT:
if (timer->needs_fixup) if (timer->needs_fixup) {
bwrite(fd, (genericptr_t) timer, sizeof(timer_element)); if (nhfp->structlevel)
else { bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
} else {
/* replace object pointer with id */ /* replace object pointer with id */
arg_save.a_obj = timer->arg.a_obj; arg_save.a_obj = timer->arg.a_obj;
timer->arg = cg.zeroany; timer->arg = cg.zeroany;
timer->arg.a_uint = (arg_save.a_obj)->o_id; timer->arg.a_uint = (arg_save.a_obj)->o_id;
timer->needs_fixup = 1; timer->needs_fixup = 1;
bwrite(fd, (genericptr_t) timer, sizeof(timer_element)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
timer->arg.a_obj = arg_save.a_obj; timer->arg.a_obj = arg_save.a_obj;
timer->needs_fixup = 0; timer->needs_fixup = 0;
} }
break; break;
case TIMER_MONSTER: case TIMER_MONSTER:
if (timer->needs_fixup) if (timer->needs_fixup) {
bwrite(fd, (genericptr_t) timer, sizeof(timer_element)); if (nhfp->structlevel)
else { bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
} else {
/* replace monster pointer with id */ /* replace monster pointer with id */
arg_save.a_monst = timer->arg.a_monst; arg_save.a_monst = timer->arg.a_monst;
timer->arg = cg.zeroany; timer->arg = cg.zeroany;
timer->arg.a_uint = (arg_save.a_monst)->m_id; timer->arg.a_uint = (arg_save.a_monst)->m_id;
timer->needs_fixup = 1; timer->needs_fixup = 1;
bwrite(fd, (genericptr_t) timer, sizeof(timer_element)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
timer->arg.a_monst = arg_save.a_monst; timer->arg.a_monst = arg_save.a_monst;
timer->needs_fixup = 0; timer->needs_fixup = 0;
} }
@@ -2231,8 +2248,9 @@ timer_element *timer;
* be written. If write_it is true, actually write the timer. * be written. If write_it is true, actually write the timer.
*/ */
STATIC_OVL int STATIC_OVL int
maybe_write_timer(fd, range, write_it) maybe_write_timer(nhfp, range, write_it)
int fd, range; NHFILE *nhfp;
int range;
boolean write_it; boolean write_it;
{ {
int count = 0; int count = 0;
@@ -2244,17 +2262,14 @@ boolean write_it;
if (!timer_is_local(curr)) { if (!timer_is_local(curr)) {
count++; count++;
if (write_it) if (write_it) write_timer(nhfp, curr);
write_timer(fd, curr);
} }
} else { } else {
/* local timers */ /* local timers */
if (timer_is_local(curr)) { if (timer_is_local(curr)) {
count++; count++;
if (write_it) if (write_it) write_timer(nhfp, curr);
write_timer(fd, curr);
} }
} }
} }
@@ -2262,6 +2277,7 @@ boolean write_it;
return count; return count;
} }
/* /*
* Save part of the timer list. The parameter 'range' specifies either * Save part of the timer list. The parameter 'range' specifies either
* global or level timers to save. The timer ID is saved with the global * global or level timers to save. The timer ID is saved with the global
@@ -2276,22 +2292,29 @@ boolean write_it;
* + timeouts that stay with the level (obj & monst) * + timeouts that stay with the level (obj & monst)
*/ */
void void
save_timers(fd, mode, range) save_timers(nhfp, range)
int fd, mode, range; NHFILE *nhfp;
int range;
{ {
timer_element *curr, *prev, *next_timer = 0; timer_element *curr, *prev, *next_timer = 0;
int count; int count;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
if (range == RANGE_GLOBAL) if (range == RANGE_GLOBAL) {
bwrite(fd, (genericptr_t) &g.timer_id, sizeof(g.timer_id)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.timer_id, sizeof(g.timer_id));
count = maybe_write_timer(fd, range, FALSE); if (nhfp->fieldlevel)
bwrite(fd, (genericptr_t) &count, sizeof count); sfo_ulong(nhfp, &g.timer_id, "timers", "g.timer_id", 1);
(void) maybe_write_timer(fd, range, TRUE); }
count = maybe_write_timer(nhfp, range, FALSE);
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "timers", "timer_count", 1);
(void) maybe_write_timer(nhfp, range, TRUE);
} }
if (release_data(mode)) { if (release_data(nhfp)) {
for (prev = 0, curr = g.timer_base; curr; curr = next_timer) { for (prev = 0, curr = g.timer_base; curr; curr = next_timer) {
next_timer = curr->next; /* in case curr is removed */ next_timer = curr->next; /* in case curr is removed */
@@ -2314,22 +2337,34 @@ int fd, mode, range;
* monster pointers. * monster pointers.
*/ */
void void
restore_timers(fd, range, ghostly, adjust) restore_timers(nhfp, range, ghostly, adjust)
int fd, range; NHFILE *nhfp;
int range;
boolean ghostly; /* restoring from a ghost level */ boolean ghostly; /* restoring from a ghost level */
long adjust; /* how much to adjust timeout */ long adjust; /* how much to adjust timeout */
{ {
int count; int count;
timer_element *curr; timer_element *curr;
if (range == RANGE_GLOBAL) if (range == RANGE_GLOBAL) {
mread(fd, (genericptr_t) &g.timer_id, sizeof g.timer_id); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.timer_id, sizeof g.timer_id);
if (nhfp->fieldlevel)
sfi_ulong(nhfp, &g.timer_id, "timers", "g.timer_id", 1);
}
/* restore elements */ /* restore elements */
mread(fd, (genericptr_t) &count, sizeof count); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "timers", "timer_count", 1);
while (count-- > 0) { while (count-- > 0) {
curr = (timer_element *) alloc(sizeof(timer_element)); curr = (timer_element *) alloc(sizeof(timer_element));
mread(fd, (genericptr_t) curr, sizeof(timer_element)); if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) curr, sizeof(timer_element));
if (nhfp->fieldlevel)
sfi_fe(nhfp, curr, "timers", "timer", 1);
if (ghostly) if (ghostly)
curr->timeout += adjust; curr->timeout += adjust;
insert_timer(curr); insert_timer(curr);
+60 -23
View File
@@ -6,6 +6,10 @@
#include "hack.h" #include "hack.h"
#include "dlb.h" #include "dlb.h"
#include "date.h" #include "date.h"
#include "lev.h"
#include "sfproto.h"
/* /*
* All the references to the contents of patchlevel.h have been moved * All the references to the contents of patchlevel.h have been moved
* into makedefs.... * into makedefs....
@@ -250,10 +254,11 @@ long filetime;
#endif #endif
boolean boolean
check_version(version_data, filename, complain) check_version(version_data, filename, complain, utdflags)
struct version_info *version_data; struct version_info *version_data;
const char *filename; const char *filename;
boolean complain; boolean complain;
unsigned long utdflags;
{ {
if ( if (
#ifdef VERSION_COMPATIBILITY #ifdef VERSION_COMPATIBILITY
@@ -273,9 +278,12 @@ boolean complain;
(version_data->feature_set & ~IGNORED_FEATURES) (version_data->feature_set & ~IGNORED_FEATURES)
!= (VERSION_FEATURES & ~IGNORED_FEATURES) != (VERSION_FEATURES & ~IGNORED_FEATURES)
#endif #endif
|| version_data->entity_count != VERSION_SANITY1 || ((utdflags & UTD_SKIP_SANITY1) == 0
|| version_data->struct_sizes1 != VERSION_SANITY2 && version_data->entity_count != VERSION_SANITY1)
|| version_data->struct_sizes2 != VERSION_SANITY3) { || ((utdflags & UTD_CHECKSIZES) &&
(version_data->struct_sizes1 != VERSION_SANITY2))
|| ((utdflags & UTD_CHECKSIZES) &&
(version_data->struct_sizes2 != VERSION_SANITY3))) {
if (complain) if (complain)
pline("Configuration incompatibility for file \"%s\".", filename); pline("Configuration incompatibility for file \"%s\".", filename);
return FALSE; return FALSE;
@@ -286,24 +294,47 @@ boolean complain;
/* this used to be based on file date and somewhat OS-dependant, /* this used to be based on file date and somewhat OS-dependant,
but now examines the initial part of the file's contents */ but now examines the initial part of the file's contents */
boolean boolean
uptodate(fd, name) uptodate(nhfp, name, utdflags)
int fd; NHFILE *nhfp;
const char *name; const char *name;
unsigned long utdflags;
{ {
int rlen; int rlen, cmc = 0, filecmc = 0;
struct version_info vers_info; struct version_info vers_info;
boolean verbose = name ? TRUE : FALSE; boolean verbose = name ? TRUE : FALSE;
char indicator;
rlen = read(fd, (genericptr_t) &vers_info, sizeof vers_info); if (nhfp->structlevel) {
minit(); /* ZEROCOMP */ rlen = read(nhfp->fd, (genericptr_t) &indicator, sizeof indicator);
if (rlen == 0) { rlen = read(nhfp->fd, (genericptr_t) &filecmc, sizeof filecmc);
if (verbose) { if (rlen == 0)
pline("File \"%s\" is empty?", name); return FALSE;
wait_synch();
}
return FALSE;
} }
if (!check_version(&vers_info, name, verbose)) { if (nhfp->fieldlevel) {
sfi_char(nhfp, &indicator, "indicate", "format", 1);
sfi_int(nhfp, &filecmc, "validate", "critical_members_count", 1);
cmc = critical_members_count();
}
if (cmc != filecmc)
return FALSE;
if (nhfp->fieldlevel && (nhfp->fnidx > historical)) {
sfi_version_info(nhfp, &vers_info, "version", "version_info", 1);
} else {
int rlen;
rlen = read(nhfp->fd, (genericptr_t) &vers_info, sizeof vers_info);
minit(); /* ZEROCOMP */
if (rlen == 0) {
if (verbose) {
pline("File \"%s\" is empty?", name);
wait_synch();
}
return FALSE;
}
}
if (!check_version(&vers_info, name, verbose, utdflags)) {
if (verbose) if (verbose)
wait_synch(); wait_synch();
return FALSE; return FALSE;
@@ -312,19 +343,25 @@ const char *name;
} }
void void
store_version(fd) store_version(nhfp)
int fd; NHFILE *nhfp;
{ {
static const struct version_info version_data = { static const struct version_info version_data = {
VERSION_NUMBER, VERSION_FEATURES, VERSION_NUMBER, VERSION_FEATURES,
VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3 VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3
}; };
bufoff(fd); if (nhfp->structlevel) {
/* bwrite() before bufon() uses plain write() */ bufoff(nhfp->fd);
bwrite(fd, (genericptr_t) &version_data, /* bwrite() before bufon() uses plain write() */
(unsigned) (sizeof version_data)); bwrite(nhfp->fd,(genericptr_t) &version_data,
bufon(fd); (unsigned) (sizeof version_data));
bufon(nhfp->fd);
}
if (nhfp->fieldlevel) {
sfo_version_info(nhfp, (struct version_info *) &version_data,
"version", "version_info", 1);
}
return; return;
} }
+48 -16
View File
@@ -5,6 +5,8 @@
#include "hack.h" #include "hack.h"
#include "lev.h" #include "lev.h"
#include "sfproto.h"
#define newseg() (struct wseg *) alloc(sizeof (struct wseg)) #define newseg() (struct wseg *) alloc(sizeof (struct wseg))
#define dealloc_seg(wseg) free((genericptr_t) (wseg)) #define dealloc_seg(wseg) free((genericptr_t) (wseg))
@@ -477,31 +479,46 @@ boolean use_detection_glyph;
* of segments, including the dummy. Called from save.c. * of segments, including the dummy. Called from save.c.
*/ */
void void
save_worm(fd, mode) save_worm(nhfp)
int fd, mode; NHFILE *nhfp;
{ {
int i; int i;
int count; int count;
struct wseg *curr, *temp; struct wseg *curr, *temp;
if (perform_bwrite(mode)) { if (perform_bwrite(nhfp)) {
for (i = 1; i < MAX_NUM_WORMS; i++) { for (i = 1; i < MAX_NUM_WORMS; i++) {
for (count = 0, curr = wtails[i]; curr; curr = curr->nseg) for (count = 0, curr = wtails[i]; curr; curr = curr->nseg)
count++; count++;
/* Save number of segments */ /* Save number of segments */
bwrite(fd, (genericptr_t) &count, sizeof(int)); if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof(int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "worm", "segment_count", 1);
/* Save segment locations of the monster. */ /* Save segment locations of the monster. */
if (count) { if (count) {
for (curr = wtails[i]; curr; curr = curr->nseg) { for (curr = wtails[i]; curr; curr = curr->nseg) {
bwrite(fd, (genericptr_t) & (curr->wx), sizeof(xchar)); if (nhfp->structlevel) {
bwrite(fd, (genericptr_t) & (curr->wy), sizeof(xchar)); bwrite(nhfp->fd, (genericptr_t) &(curr->wx), sizeof(xchar));
bwrite(nhfp->fd, (genericptr_t) &(curr->wy), sizeof(xchar));
}
if (nhfp->fieldlevel) {
sfo_xchar(nhfp, &(curr->wx), "worm", "wx", 1);
sfo_xchar(nhfp, &(curr->wy), "worm", "wy", 1);
}
} }
} }
} }
bwrite(fd, (genericptr_t) wgrowtime, sizeof(wgrowtime)); if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAX_NUM_WORMS; ++i)
sfo_long(nhfp, &wgrowtime[i], "worm", "wgrowtime", 1);
}
} }
if (release_data(mode)) { if (release_data(nhfp)) {
/* Free the segments only. savemonchn() will take care of the /* Free the segments only. savemonchn() will take care of the
* monsters. */ * monsters. */
for (i = 1; i < MAX_NUM_WORMS; i++) { for (i = 1; i < MAX_NUM_WORMS; i++) {
@@ -518,29 +535,38 @@ int fd, mode;
} }
} }
/* SAVE2018 */
/* /*
* rest_worm() * rest_worm()
* *
* Restore the worm information from the save file. Called from restore.c * Restore the worm information from the save file. Called from restore.c
*/ */
void void
rest_worm(fd) rest_worm(nhfp)
int fd; NHFILE *nhfp;
{ {
int i, j, count; int i, j, count;
struct wseg *curr, *temp; struct wseg *curr, *temp;
for (i = 1; i < MAX_NUM_WORMS; i++) { for (i = 1; i < MAX_NUM_WORMS; i++) {
mread(fd, (genericptr_t) &count, sizeof(int)); if (nhfp->structlevel)
if (!count) mread(nhfp->fd, (genericptr_t) &count, sizeof(int));
continue; /* none */ if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "worm", "segment_count", 1);
/* Get the segments. */ /* Get the segments. */
for (curr = (struct wseg *) 0, j = 0; j < count; j++) { for (curr = (struct wseg *) 0, j = 0; j < count; j++) {
temp = newseg(); temp = newseg();
temp->nseg = (struct wseg *) 0; temp->nseg = (struct wseg *) 0;
mread(fd, (genericptr_t) & (temp->wx), sizeof(xchar)); if (nhfp->structlevel) {
mread(fd, (genericptr_t) & (temp->wy), sizeof(xchar)); mread(nhfp->fd, (genericptr_t) &(temp->wx), sizeof(xchar));
mread(nhfp->fd, (genericptr_t) &(temp->wy), sizeof(xchar));
}
if (nhfp->fieldlevel) {
sfi_xchar(nhfp, &(temp->wx), "worm", "wx", 1);
sfi_xchar(nhfp, &(temp->wy), "worm", "wy", 1);
}
if (curr) if (curr)
curr->nseg = temp; curr->nseg = temp;
else else
@@ -549,7 +575,13 @@ int fd;
} }
wheads[i] = curr; wheads[i] = curr;
} }
mread(fd, (genericptr_t) wgrowtime, sizeof(wgrowtime)); if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAX_NUM_WORMS; ++i)
sfi_long(nhfp, &wgrowtime[i], "worm", "wgrowtime", 1);
}
} }
/* /*
+10 -7
View File
@@ -90,7 +90,7 @@ pcmain(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
register int fd; NHFILE *nhfp;
register char *dir; register char *dir;
#if defined(MSDOS) #if defined(MSDOS)
char *envp = NULL; char *envp = NULL;
@@ -444,13 +444,16 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/* Set up level 0 file to keep the game state. /* Set up level 0 file to keep the game state.
*/ */
fd = create_levelfile(0, (char *) 0); nhfp = create_levelfile(0, (char *) 0);
if (fd < 0) { if (!nhfp) {
raw_print("Cannot create lock file"); raw_print("Cannot create lock file");
} else { } else {
g.hackpid = 1; g.hackpid = 1;
write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); if (nhfp->structlevel)
nhclose(fd); 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 #ifdef MFLOPPY
level_info[0].where = ACTIVE; 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. * We'll return here if new game player_selection() renames the hero.
*/ */
attempt_restore: attempt_restore:
if ((fd = restore_saved_game()) >= 0) { if ((nhfp = restore_saved_game()) > 0) {
#ifndef NO_SIGNAL #ifndef NO_SIGNAL
(void) signal(SIGINT, (SIG_RET_TYPE) done1); (void) signal(SIGINT, (SIG_RET_TYPE) done1);
#endif #endif
@@ -481,7 +484,7 @@ attempt_restore:
pline("Restoring save file..."); pline("Restoring save file...");
mark_synch(); /* flush output */ mark_synch(); /* flush output */
if (dorecover(fd)) { if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */ resuming = TRUE; /* not starting new game */
if (discover) if (discover)
You("are in non-scoring discovery mode."); You("are in non-scoring discovery mode.");
+27 -5
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 \ 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 \ 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 \ 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 \ sp_lev.c spell.c steal.c steed.c sys.c teleport.c timeout.c \
topten.c track.c trap.c u_init.c \ topten.c track.c trap.c u_init.c \
uhitm.c vault.c version.c vision.c weapon.c were.c wield.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 SYSCXXSRC = ../sys/share/cppregex.cpp
# generated source files (tile.c is handled separately via WINxxxSRC) # 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) # all windowing-system-dependent .c (for dependencies and such)
WINCSRC = $(WINTTYSRC) $(WINCURSESSRC) $(WINX11SRC) $(WINGNOMESRC) $(WINGEMSRC) 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 \ 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 \ 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 \ 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 \ role.o rumors.o save.o \
sys.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 \ 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 \ 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 \ 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 ../win/gnome/gn_rip.h: ../win/X11/rip.xpm
cp ../win/X11/rip.xpm ../win/gnome/gn_rip.h 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 # date.h should be remade any time any of the source or include code
# is modified. Unfortunately, this would make the contents of this # is modified. Unfortunately, this would make the contents of this
# file far more complex. Since "hack.h" depends on most of the include # 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' -$(SHELL) ../sys/unix/gitinfo.sh $(GITINFO) #before 'makedefs -v'
../util/makedefs -v ../util/makedefs -v
lint: lint:
# lint cannot have -p here because (i) capitals are meaningful: # lint cannot have -p here because (i) capitals are meaningful:
# [Ww]izard, (ii) identifiers may coincide in the first six places: # [Ww]izard, (ii) identifiers may coincide in the first six places:
+75
View File
@@ -126,6 +126,10 @@ LEXYYC = lex.yy.c
# YTABH = y_tab.h # YTABH = y_tab.h
# LEXYYC = lexyy.c # 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 # 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; # -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 RECOVSRC = recover.c
DLBSRC = dlb_main.c DLBSRC = dlb_main.c
UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC) UTILSRCS = $(MAKESRC) panic.c $(SPLEVSRC) $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC)
READTAGSSRC = readtags.c
# files that define all monsters and objects # files that define all monsters and objects
CMONOBJ = ../src/monst.c ../src/objects.c CMONOBJ = ../src/monst.c ../src/objects.c
@@ -210,6 +215,9 @@ RECOVOBJS = recover.o
# object files for the data librarian # object files for the data librarian
DLBOBJS = dlb_main.o $(OBJDIR)/dlb.o $(OALLOC) 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 # flags for creating distribution versions of sys/share/*_lex.c, using
# a more portable flex skeleton, which is not included in the distribution. # 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 # 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 \ $(CC) -o tileedit -I../include -I$(QTDIR)/include -L$(QTDIR)/lib \
tileedit.cpp $(TEXT_IO) -lqt 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 # using dependencies like
# ../src/foo:: # ../src/foo::
# @( cd ../src ; $(MAKE) foo ) # @( cd ../src ; $(MAKE) foo )
+3 -2
View File
@@ -54,6 +54,7 @@ char *argv[];
#ifdef CHDIR #ifdef CHDIR
register char *dir; register char *dir;
#endif #endif
NHFILE *nhfp;
boolean exact_username; boolean exact_username;
boolean resuming = FALSE; /* assume new game */ boolean resuming = FALSE; /* assume new game */
boolean plsel_once = FALSE; boolean plsel_once = FALSE;
@@ -280,7 +281,7 @@ attempt_restore:
g.program_state.preserve_locks = 0; /* after getlock() */ 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); const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */ (void) chmod(fq_save, 0); /* disallow parallel restores */
@@ -295,7 +296,7 @@ attempt_restore:
#endif #endif
pline("Restoring save file..."); pline("Restoring save file...");
mark_synch(); /* flush output */ mark_synch(); /* flush output */
if (dorecover(fd)) { if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */ resuming = TRUE; /* not starting new game */
wd_message(); wd_message();
if (discover || wizard) { if (discover || wizard) {
+105 -3
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 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 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 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 DLBOBJ = $(O)dlb.o
@@ -259,8 +260,8 @@ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \ $(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \ $(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \ $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
$(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(REGEX) \ $(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(VOBJ30) \
$(CURSESOBJ) $(REGEX) $(CURSESOBJ)
GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \ GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \
$(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.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 cc=cl
link=link link=link
rc=Rc rc=Rc
@@ -1066,6 +1080,7 @@ $(U)dgncomp.exe: $(DGNCOMPOBJS)
) )
<< <<
#================================================= #=================================================
# Create directory for holding object files # 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 $(O)ttystub.o: $(HACK_H) $(MSWSYS)\stubs.c
@$(cc) $(cflagsBuild) -DTTYSTUB -Fo$@ $(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 # util dependencies
# #
+10 -8
View File
@@ -82,7 +82,7 @@ int argc;
char *argv[]; char *argv[];
{ {
boolean resuming = FALSE; /* assume new game */ boolean resuming = FALSE; /* assume new game */
int fd; NHFILE *nhfp;
char *windowtype = NULL; char *windowtype = NULL;
char *envp = NULL; char *envp = NULL;
char *sptr = NULL; char *sptr = NULL;
@@ -291,9 +291,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
setting of renameallowed; when False, player_selection() setting of renameallowed; when False, player_selection()
won't resent renaming as an option */ won't resent renaming as an option */
iflags.renameallowed = FALSE; iflags.renameallowed = FALSE;
#if 0
/* Obtain the name of the logged on user and incorporate /* Obtain the name of the logged on user and incorporate
* it into the name. */ * it into the name. */
Sprintf(fnamebuf, "%s-%s", get_username(0), g.plname); #endif
Sprintf(fnamebuf, "%s", g.plname);
(void) fname_encode( (void) fname_encode(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%', "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%',
fnamebuf, encodedfnamebuf, BUFSZ); fnamebuf, encodedfnamebuf, BUFSZ);
@@ -303,13 +305,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
/* Set up level 0 file to keep the game state. /* Set up level 0 file to keep the game state.
*/ */
fd = create_levelfile(0, (char *) 0); nhfp = create_levelfile(0, (char *) 0);
if (fd < 0) { if (!nhfp) {
raw_print("Cannot create lock file"); raw_print("Cannot create lock file");
} else { } else {
g.hackpid = GetCurrentProcessId(); g.hackpid = GetCurrentProcessId();
write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid));
nhclose(fd); close_nhfile(nhfp);
} }
/* /*
* Initialize the vision system. This must be before mklev() on a * 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. * We'll return here if new game player_selection() renames the hero.
*/ */
attempt_restore: attempt_restore:
if ((fd = restore_saved_game()) >= 0) { if ((nhfp = restore_saved_game()) != 0) {
#ifdef NEWS #ifdef NEWS
if (iflags.news) { if (iflags.news) {
display_file(NEWS, FALSE); display_file(NEWS, FALSE);
@@ -331,7 +333,7 @@ attempt_restore:
#endif #endif
pline("Restoring save file..."); pline("Restoring save file...");
mark_synch(); /* flush output */ mark_synch(); /* flush output */
if (dorecover(fd)) { if (dorecover(nhfp)) {
resuming = TRUE; /* not starting new game */ resuming = TRUE; /* not starting new game */
if (discover) if (discover)
You("are in non-scoring discovery mode."); You("are in non-scoring discovery mode.");
+1618
View File
File diff suppressed because it is too large Load Diff
+6 -1
View File
@@ -133,6 +133,11 @@
<ClCompile Include="$(SrcDir)role.c" /> <ClCompile Include="$(SrcDir)role.c" />
<ClCompile Include="$(SrcDir)rumors.c" /> <ClCompile Include="$(SrcDir)rumors.c" />
<ClCompile Include="$(SrcDir)save.c" /> <ClCompile Include="$(SrcDir)save.c" />
<ClCompile Include="$(SrcDir)sfstruct.c" />
<ClCompile Include="$(SrcDir)sfbase.c" />
<ClCompile Include="$(SrcDir)sflendian.c" />
<ClCompile Include="$(SrcDir)sfascii.c" />
<ClCompile Include="$(SrcDir)sfdata.c" />
<ClCompile Include="$(SrcDir)shk.c" /> <ClCompile Include="$(SrcDir)shk.c" />
<ClCompile Include="$(SrcDir)shknam.c" /> <ClCompile Include="$(SrcDir)shknam.c" />
<ClCompile Include="$(SrcDir)sit.c" /> <ClCompile Include="$(SrcDir)sit.c" />
@@ -267,4 +272,4 @@
<Target Name="AfterRebuild"> <Target Name="AfterRebuild">
<MSBuild Projects="afternethack.proj" Targets="Build" Properties="Configuration=$(Configuration)" /> <MSBuild Projects="afternethack.proj" Targets="Build" Properties="Configuration=$(Configuration)" />
</Target> </Target>
</Project> </Project>
+5
View File
@@ -127,6 +127,11 @@
<ClCompile Include="$(SrcDir)role.c" /> <ClCompile Include="$(SrcDir)role.c" />
<ClCompile Include="$(SrcDir)rumors.c" /> <ClCompile Include="$(SrcDir)rumors.c" />
<ClCompile Include="$(SrcDir)save.c" /> <ClCompile Include="$(SrcDir)save.c" />
<ClCompile Include="$(SrcDir)sfstruct.c" />
<ClCompile Include="$(SrcDir)sfbase.c" />
<ClCompile Include="$(SrcDir)sflendian.c" />
<ClCompile Include="$(SrcDir)sfascii.c" />
<ClCompile Include="$(SrcDir)sfdata.c" />
<ClCompile Include="$(SrcDir)shk.c" /> <ClCompile Include="$(SrcDir)shk.c" />
<ClCompile Include="$(SrcDir)shknam.c" /> <ClCompile Include="$(SrcDir)shknam.c" />
<ClCompile Include="$(SrcDir)sit.c" /> <ClCompile Include="$(SrcDir)sit.c" />