zlib support; also internal compression changes
o Add support for zlib compression via ZLIB_COMP in config.h (ZLIB_COMP and COMPRESS are mutually exclusive). o rlecomp and zerocomp are run time options available if RLECOMP and ZEROCOMP are defined, but not turned on by default if either COMPRESS or ZLIB_COMP are defined. o Add information to the save file about internal compression options used when writing the save file, particularly rlecomp and zerocomp support. o Automatically adjust rlecomp and zerocomp (if support compiled in) when reading in an existing savefile that was saved with those options turned on. Still allows writing out of savefile in preferred format. o In order to support zlib and not conflict with compress and uncompress routines there, the NetHack internal functions were changed to nh_uncompress and nh_compress as done in the zlib contribution received in 1999 from <Someone>. I tagged the sources NETHACK_3_5_0_PREZLIB prior to applying these changes.
This commit is contained in:
@@ -159,18 +159,22 @@
|
||||
|
||||
/*
|
||||
* If COMPRESS is defined, it should contain the full path name of your
|
||||
* 'compress' program. Defining INTERNAL_COMP causes NetHack to do
|
||||
* simpler byte-stream compression internally. Both COMPRESS and
|
||||
* INTERNAL_COMP create smaller bones/level/save files, but require
|
||||
* additional code and time. Currently, only UNIX fully implements
|
||||
* COMPRESS; other ports should be able to uncompress save files a
|
||||
* la unixmain.c if so inclined.
|
||||
* 'compress' program.
|
||||
*
|
||||
* If you define COMPRESS, you must also define COMPRESS_EXTENSION
|
||||
* as the extension your compressor appends to filenames after
|
||||
* compression.
|
||||
* compression. Currently, only UNIX fully implements
|
||||
* COMPRESS; other ports should be able to uncompress save files a
|
||||
* la unixmain.c if so inclined.
|
||||
*
|
||||
* Defining ZLIB_COMP builds in support for zlib compression. If you
|
||||
* define ZLIB_COMP, you must link with a zlib library.
|
||||
*
|
||||
* COMPRESS and ZLIB_COMP are mutually exclusive.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef UNIX
|
||||
|
||||
#if defined(UNIX) && !defined(ZLIB_COMP) && !defined(COMPRESS)
|
||||
/* path and file name extension for compression program */
|
||||
#define COMPRESS "/usr/bin/compress" /* Lempel-Ziv compression */
|
||||
#define COMPRESS_EXTENSION ".Z" /* compress's extension */
|
||||
@@ -180,9 +184,41 @@
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS
|
||||
# define INTERNAL_COMP /* control use of NetHack's compression routines */
|
||||
# define ZLIB_COMP /* ZLIB for compression */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal Compression Options
|
||||
*
|
||||
* Internal compression options RLECOMP and ZEROCOMP alter the data
|
||||
* that gets written to the save file by NetHack, in contrast
|
||||
* to COMPRESS or ZLIB_COMP which compress the entire file after
|
||||
* the NetHack data is written out.
|
||||
*
|
||||
* Defining RLECOMP builds in support for internal run-length
|
||||
* compression of level structures. If RLECOMP support is included
|
||||
* it can be toggled on/off at runtime via the config file option
|
||||
* rlecomp.
|
||||
*
|
||||
* Defining ZEROCOMP builds in support for internal zero-comp
|
||||
* compression of data. If ZEROCOMP support is included it can still
|
||||
* be toggled on/off at runtime via the config file option zerocomp.
|
||||
*
|
||||
* RLECOMP and ZEROCOMP support can be included even if
|
||||
* COMPRESS or ZLIB_COMP support is included. One reason for doing
|
||||
* so would be to provide savefile read compatibility with a savefile
|
||||
* where those options were in effect. With RLECOMP and/or ZEROCOMP
|
||||
* defined, NetHack can read an rlecomp or zerocomp savefile in, yet
|
||||
* re-save without them.
|
||||
*
|
||||
* Using any compression option will create smaller bones/level/save
|
||||
* files at the cost of additional code and time.
|
||||
*/
|
||||
|
||||
/* # define INTERNAL_COMP */ /* Forces both ZEROCOMP and RLECOMP */
|
||||
/* # define ZEROCOMP */ /* Support ZEROCOMP compression */
|
||||
/* # define RLECOMP */ /* Support RLECOMP compression */
|
||||
|
||||
/*
|
||||
* Data librarian. Defining DLB places most of the support files into
|
||||
* a tar-like file, thus making a neater installation. See *conf.h
|
||||
|
||||
@@ -381,6 +381,8 @@ E char *fqn_prefix[PREFIX_COUNT];
|
||||
E char *fqn_prefix_names[PREFIX_COUNT];
|
||||
#endif
|
||||
|
||||
E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
|
||||
|
||||
#ifdef AUTOPICKUP_EXCEPTIONS
|
||||
struct autopickup_exception {
|
||||
char *pattern;
|
||||
|
||||
@@ -673,8 +673,8 @@ E int NDECL(create_savefile);
|
||||
E int NDECL(open_savefile);
|
||||
E int NDECL(delete_savefile);
|
||||
E int NDECL(restore_saved_game);
|
||||
E void FDECL(compress, (const char *));
|
||||
E void FDECL(uncompress, (const char *));
|
||||
E void FDECL(nh_compress, (const char *));
|
||||
E void FDECL(nh_uncompress, (const char *));
|
||||
E boolean FDECL(lock_file, (const char *,int,int));
|
||||
E void FDECL(unlock_file, (const char *));
|
||||
#ifdef USER_SOUNDS
|
||||
@@ -1751,14 +1751,14 @@ E void FDECL(getlev, (int,int,XCHAR_P,BOOLEAN_P));
|
||||
E void FDECL(get_plname_from_file, (int, char *));
|
||||
E void NDECL(minit);
|
||||
E boolean FDECL(lookup_id_mapping, (unsigned, unsigned *));
|
||||
#ifdef ZEROCOMP
|
||||
E int FDECL(mread, (int,genericptr_t,unsigned int));
|
||||
#else
|
||||
E void FDECL(mread, (int,genericptr_t,unsigned int));
|
||||
#endif
|
||||
#ifndef GOLDOBJ
|
||||
E void FDECL(put_gold_back, (struct obj **,long *));
|
||||
#endif
|
||||
E int FDECL(validate, (int,const char *));
|
||||
E void NDECL(reset_restpref);
|
||||
E void FDECL(set_restpref, (const char *));
|
||||
E void FDECL(set_savepref, (const char *));
|
||||
|
||||
/* ### rip.c ### */
|
||||
|
||||
@@ -1835,10 +1835,15 @@ E void FDECL(bufoff, (int));
|
||||
E void FDECL(bflush, (int));
|
||||
E void FDECL(bwrite, (int,genericptr_t,unsigned int));
|
||||
E void FDECL(bclose, (int));
|
||||
E void FDECL(def_bclose, (int));
|
||||
#if defined(ZEROCOMP)
|
||||
E void FDECL(zerocomp_bclose, (int));
|
||||
#endif
|
||||
E void FDECL(savefruitchn, (int,int));
|
||||
E void FDECL(store_plname_in_file, (int));
|
||||
E void NDECL(free_dungeons);
|
||||
E void NDECL(freedynamicdata);
|
||||
E void FDECL(store_savefileinfo, (int));
|
||||
|
||||
/* ### shk.c ### */
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@ struct instance_flags {
|
||||
boolean menu_tab_sep; /* Use tabs to separate option menu fields */
|
||||
boolean menu_requested; /* Flag for overloaded use of 'm' prefix
|
||||
* on some non-move commands */
|
||||
boolean zerocomp; /* write zero-compressed save files */
|
||||
boolean rlecomp; /* run-length comp of levels when writing savefile */
|
||||
uchar num_pad_mode;
|
||||
int menu_headings; /* ATR for menu headings */
|
||||
int purge_monsters; /* # of dead monsters still on fmon list */
|
||||
|
||||
@@ -305,6 +305,20 @@ struct version_info {
|
||||
unsigned long struct_sizes2; /* size of more key structs */
|
||||
};
|
||||
|
||||
struct savefile_info {
|
||||
unsigned long sfi1; /* compression etc. */
|
||||
unsigned long sfi2; /* miscellaneous */
|
||||
unsigned long sfi3; /* thirdparty */
|
||||
};
|
||||
#ifdef NHSTDC
|
||||
#define SFI1_EXTERNALCOMP (1UL)
|
||||
#define SFI1_RLECOMP (1UL << 1)
|
||||
#define SFI1_ZEROCOMP (1UL << 2)
|
||||
#else
|
||||
#define SFI1_EXTERNALCOMP (1L)
|
||||
#define SFI1_RLECOMP (1L << 1)
|
||||
#define SFI1_ZEROCOMP (1L << 2)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configurable internal parameters.
|
||||
|
||||
Reference in New Issue
Block a user