save/restore changes - part 3
This is the third of a series of savefile-related changes.
This adds early-days experimental support for a completely optional
'sfctool' utility (savefile conversion tool), to be able to export
a savefile's contents into a more portable format. There are likely
to be bugs at this stage. In this initial first-attempt, the export
format is a very simple ascii output.
NetHack can be built entirely, without also building this tool.
NetHack has no dependencies on the tool.
Attempts were made to minimize duplication of existing NetHack code.
To achieve that, unfortunately, #ifdef SFCTOOL and #ifndef SFCTOOL
had to be sprinkled around through some of the existing NetHack
source code, so that it could be re-used for building the utility.
The process for building the sfctool typically recompiles the source
files with #define SFCTOOL and a distinct object file with SF- is
produced.
sfctool notes:
Universal ctags is used and required to produce the sfctool utility.
Some targets were added to the Unix and Windows Makefiles to
facilitate the build process.
make sfctool
That should build a copy in util.
Note: At present, the Unix Makefiles do not copy sfctool over to the
NetHack playground during 'make install' or 'make update'.
Until that gets resolved by someone, The tool will
have to be manually copied there by the builder/admin if
desired.
cp util/sfctool ~/nh/install/games/lib/nethackdir/sfctool
Also, a separate Visual Studio sfctool.sln solution was written and
placed in sys/windows/vs. That has has only very limited testing.
Usage:
i) To convert an existing savefile to an exportascii format
that co-resides with the savefile:
sfctool -c savefile
That *must* be executed on the same platform / architecture /
data model that produced the save file in the first place.
ii) To unconvert an existing exportascii format export file to a
historical format savefile that can then be used by NetHack:
sfctool -u savefile
That must be executed on the same target platform / architecture /
data model that was used to build the NetHack that will
utilize the save file that results.
A Windows example:
sfctool -c Fred.NetHack-saved-game
That should result in creation of Fred.NetHack-saved-game.exportascii
from existing savefile:
%USERPROFILE%\AppData\Local\NetHack\3.7\Fred.NetHack-saved-game
A Unix example:
sfctool -c 1000wizard
That should result in creation of 1000wizard.exportascii.gz
from existing savefile in the playground save directory:
1000wizard.gz
Current Mechanics:
1. Makefile recipe, or script uses universal ctags to produce
util/sf.tags.
2. util/sftags is built and executed to read util/sf.tags and
generate: include/sfproto.h and src/sfdata.c.
3. util/sfctool is built from the following:
generated file compiled with -DSFCTOOL:
src/sfdata.c -> sfdata.o
existing files compiled with -DSFCTOOL:
util/sfctool.c -> sfctool.o
util/sfexpasc.c -> sfexpasc.o
src/alloc.c -> sf-alloc.o
src/monst.c -> sf-monst.o
src/objects.c -> sf-objects.o
src/sfbase.c -> sfbase.o
src/sfstruct.c -> sfstruct.o
src/nhlua.c -> sf-nhlua.o
util/panic.c -> panic.o
src/date.c -> sf-date.o
src/decl.c -> sf-decl.o
src/artifact.c -> sf-artifact.o
src/dungeon.c -> sf-dungeon.o
src/end.c -> sf-end.o
src/engrave.c -> sf-engrave.o
src/cfgfiles.c -> sf-cfgfiles.o
src/files.c -> sf-files.o
src/light.c -> sf-light.o
src/mdlib.c -> sf-mdlib.o
src/mkmaze.c -> sf-mkmaze.o
src/mkroom.c -> sf-mkroom.o
src/o_init.c -> sf-o_init.o
src/region.c -> sf-region.o
src/restore.c -> sf-restore.o
src/rumors.c -> sf-rumors.o
src/sys.c -> sf-sys.o
src/timeout.c -> sf-timeout.o
src/track.c -> sf-track.o
src/version.c -> sf-version.o
src/worm.c -> sf-worm.o
src/strutil.c -> strutil.o
This commit is contained in:
@@ -1068,6 +1068,10 @@ extern char **get_saved_games(void);
|
||||
extern void free_saved_games(char **);
|
||||
extern void nh_compress(const char *);
|
||||
extern void nh_uncompress(const char *);
|
||||
extern void nh_sfconvert(const char *);
|
||||
extern void nh_sfunconvert(const char *);
|
||||
extern int delete_convertedfile(const char *);
|
||||
extern void free_convert_filenames(void);
|
||||
extern boolean lock_file(const char *, int, int) NONNULLARG1;
|
||||
extern void unlock_file(const char *) NONNULLARG1;
|
||||
extern void check_recordfile(const char *);
|
||||
@@ -1093,6 +1097,7 @@ extern boolean read_tribute(const char *, const char *, int, char *, int,
|
||||
extern boolean Death_quote(char *, int) NONNULLARG1;
|
||||
extern void livelog_add(long ll_type, const char *) NONNULLARG2;
|
||||
ATTRNORETURN extern void do_deferred_showpaths(int) NORETURN;
|
||||
extern boolean contains_directory(const char *);
|
||||
|
||||
/* ### fountain.c ### */
|
||||
|
||||
@@ -1969,7 +1974,7 @@ extern int dosuspend(void);
|
||||
extern void nt_regularize(char *);
|
||||
extern int(*nt_kbhit)(void);
|
||||
extern void Delay(int);
|
||||
extern boolean contains_directory(const char *);
|
||||
boolean get_user_home_folder(char *, size_t);
|
||||
# ifdef CRASHREPORT
|
||||
struct CRctxt;
|
||||
extern struct CRctxt *ctxp;
|
||||
@@ -2678,6 +2683,12 @@ extern boolean lookup_id_mapping(unsigned, unsigned *) NONNULLARG2;
|
||||
/* extern void reset_restpref(void); */
|
||||
/* extern void set_restpref(const char *); */
|
||||
/* extern void set_savepref(const char *); */
|
||||
#ifdef SFCTOOL
|
||||
void rest_bubbles(NHFILE *);
|
||||
void restore_gamelog(NHFILE *);
|
||||
boolean restgamestate(NHFILE *);
|
||||
void restore_msghistory(NHFILE *);
|
||||
#endif
|
||||
|
||||
/* ### rip.c ### */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user