followup to compression changes
This commit is contained in:
@@ -2087,8 +2087,8 @@ value is examined; `r' is an exception with ``Rogue'', ``Ranger'',
|
|||||||
and ``random'' values. If you prefix a `!' or ``no'' to the value, you can
|
and ``random'' values. If you prefix a `!' or ``no'' to the value, you can
|
||||||
exclude that role from being picked randomly.
|
exclude that role from being picked randomly.
|
||||||
.lp rlecomp
|
.lp rlecomp
|
||||||
When writing out a save file, perform run length compression of level
|
When writing out a save file, perform run length compression of the map.
|
||||||
structures. Not all ports support run length compression. It has no
|
Not all ports support run length compression. It has no
|
||||||
effect on reading an existing save file.
|
effect on reading an existing save file.
|
||||||
.lp runmode
|
.lp runmode
|
||||||
Controls the amount of screen updating for the map window when engaged
|
Controls the amount of screen updating for the map window when engaged
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
\begin{document}
|
\begin{document}
|
||||||
%
|
%
|
||||||
% input file: guidebook.mn
|
% input file: guidebook.mn
|
||||||
% $Revision: 1.90 $ $Date: 2005/01/16 03:57:39 $
|
% $Revision: 1.91 $ $Date: 2005/01/22 15:27:20 $
|
||||||
%
|
%
|
||||||
%.ds h0 "
|
%.ds h0 "
|
||||||
%.ds h1 %.ds h2 \%
|
%.ds h1 %.ds h2 \%
|
||||||
@@ -2555,8 +2555,8 @@ and ``{\tt random}'' values. If you prefix `{\tt !}' or ``{\tt no}'' to the
|
|||||||
value, you can exclude that role from being picked randomly.
|
value, you can exclude that role from being picked randomly.
|
||||||
%.lp
|
%.lp
|
||||||
\item[\ib{rlecomp}]
|
\item[\ib{rlecomp}]
|
||||||
When writing out a save file, perform run length compression of level
|
When writing out a save file, perform run length compression of the map.
|
||||||
structures. Not all ports support run length compression. It has no
|
Not all ports support run length compression. It has no
|
||||||
effect on reading an existing save file.
|
effect on reading an existing save file.
|
||||||
%.lp
|
%.lp
|
||||||
\item[\ib{runmode}]
|
\item[\ib{runmode}]
|
||||||
|
|||||||
@@ -168,7 +168,8 @@
|
|||||||
* la unixmain.c if so inclined.
|
* la unixmain.c if so inclined.
|
||||||
*
|
*
|
||||||
* Defining ZLIB_COMP builds in support for zlib compression. If you
|
* Defining ZLIB_COMP builds in support for zlib compression. If you
|
||||||
* define ZLIB_COMP, you must link with a zlib library.
|
* define ZLIB_COMP, you must link with a zlib library. Not all ports
|
||||||
|
* support ZLIB_COMP.
|
||||||
*
|
*
|
||||||
* COMPRESS and ZLIB_COMP are mutually exclusive.
|
* COMPRESS and ZLIB_COMP are mutually exclusive.
|
||||||
*
|
*
|
||||||
|
|||||||
81
src/files.c
81
src/files.c
@@ -97,6 +97,15 @@ char lock[PL_NSIZ+25]; /* long enough for username+-+name+.99 */
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(SAVE_EXTENSION)
|
||||||
|
# ifdef MICRO
|
||||||
|
#define SAVE_EXTENSION ".sav"
|
||||||
|
# endif
|
||||||
|
# ifdef WIN32
|
||||||
|
#define SAVE_EXTENSION ".NetHack-saved-game"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
char SAVEF[SAVESIZE]; /* holds relative path of save file from playground */
|
char SAVEF[SAVESIZE]; /* holds relative path of save file from playground */
|
||||||
#ifdef MICRO
|
#ifdef MICRO
|
||||||
char SAVEP[SAVESIZE]; /* holds path of directory for save file */
|
char SAVEP[SAVESIZE]; /* holds path of directory for save file */
|
||||||
@@ -169,6 +178,9 @@ STATIC_DCL void FDECL(redirect, (const char *,const char *,FILE *,BOOLEAN_P));
|
|||||||
#if defined(COMPRESS) || defined(ZLIB_COMP)
|
#if defined(COMPRESS) || defined(ZLIB_COMP)
|
||||||
STATIC_DCL void FDECL(docompress_file, (const char *,BOOLEAN_P));
|
STATIC_DCL void FDECL(docompress_file, (const char *,BOOLEAN_P));
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(ZLIB_COMP)
|
||||||
|
STATIC_DCL boolean FDECL(make_compressed_name, (const char *, char *));
|
||||||
|
#endif
|
||||||
STATIC_DCL char *FDECL(make_lockname, (const char *,char *));
|
STATIC_DCL char *FDECL(make_lockname, (const char *,char *));
|
||||||
STATIC_DCL FILE *FDECL(fopen_config_file, (const char *));
|
STATIC_DCL FILE *FDECL(fopen_config_file, (const char *));
|
||||||
STATIC_DCL int FDECL(get_uchars, (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *));
|
STATIC_DCL int FDECL(get_uchars, (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *));
|
||||||
@@ -839,7 +851,7 @@ set_savefile_name()
|
|||||||
# endif
|
# endif
|
||||||
regularize(SAVEF+i);
|
regularize(SAVEF+i);
|
||||||
}
|
}
|
||||||
Strcat(SAVEF, ".sav");
|
Strcat(SAVEF, SAVE_EXTENSION);
|
||||||
# else
|
# else
|
||||||
# if defined(WIN32)
|
# if defined(WIN32)
|
||||||
/* Obtain the name of the logged on user and incorporate
|
/* Obtain the name of the logged on user and incorporate
|
||||||
@@ -847,7 +859,7 @@ set_savefile_name()
|
|||||||
Sprintf(fnamebuf, "%s-%s", get_username(0), plname);
|
Sprintf(fnamebuf, "%s-%s", get_username(0), plname);
|
||||||
(void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.",
|
(void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.",
|
||||||
'%', fnamebuf, encodedfnamebuf, BUFSZ);
|
'%', fnamebuf, encodedfnamebuf, BUFSZ);
|
||||||
Sprintf(SAVEF, "%s.NetHack-saved-game", encodedfnamebuf);
|
Sprintf(SAVEF, "%s%s", encodedfnamebuf,SAVE_EXTENSION);
|
||||||
# else
|
# else
|
||||||
Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname);
|
Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname);
|
||||||
regularize(SAVEF+5); /* avoid . or / in name */
|
regularize(SAVEF+5); /* avoid . or / in name */
|
||||||
@@ -1042,7 +1054,7 @@ get_saved_games()
|
|||||||
Sprintf(fnamebuf, "%s-", get_username(0));
|
Sprintf(fnamebuf, "%s-", get_username(0));
|
||||||
(void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.",
|
(void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.",
|
||||||
'%', fnamebuf, encodedfnamebuf, BUFSZ);
|
'%', fnamebuf, encodedfnamebuf, BUFSZ);
|
||||||
Sprintf(SAVEF, "%s*.NetHack-saved-game", encodedfnamebuf);
|
Sprintf(SAVEF, "%s*%s", encodedfnamebuf, SAVE_EXTENSION);
|
||||||
#if defined(ZLIB_COMP)
|
#if defined(ZLIB_COMP)
|
||||||
Strcat(SAVEF, COMPRESS_EXTENSION);
|
Strcat(SAVEF, COMPRESS_EXTENSION);
|
||||||
#endif
|
#endif
|
||||||
@@ -1319,45 +1331,36 @@ const char *filename;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZLIB_COMP /* RLC 09 Mar 1999: Support internal ZLIB */
|
#ifdef ZLIB_COMP /* RLC 09 Mar 1999: Support internal ZLIB */
|
||||||
static int
|
STATIC_OVL boolean
|
||||||
make_compressed_name(filename,cfn)
|
make_compressed_name(filename,cfn)
|
||||||
const char *filename;
|
const char *filename;
|
||||||
char *cfn;
|
char *cfn;
|
||||||
{
|
{
|
||||||
#ifndef SHORT_FILENAMES
|
#ifndef SHORT_FILENAMES
|
||||||
/* Assume free-form filename */
|
/* Assume free-form filename with no 8.3 restrictions */
|
||||||
|
|
||||||
strcpy(cfn, filename);
|
strcpy(cfn, filename);
|
||||||
strcat(cfn, COMPRESS_EXTENSION);
|
strcat(cfn, COMPRESS_EXTENSION);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
/* Accomodates 8.3 restriction, but otherwise assumes free-form filenames.
|
# ifdef SAVE_EXTENSION
|
||||||
This may need to be revised for some systems. If a name cannot be
|
char *bp = (char *)0;
|
||||||
generated, this function may return FALSE and the file will then remain
|
|
||||||
uncompressed. */
|
|
||||||
unsigned len;
|
|
||||||
|
|
||||||
/* Assume DOS style filename */
|
|
||||||
|
|
||||||
strcpy(cfn, filename);
|
strcpy(cfn, filename);
|
||||||
len = strlen(cfn);
|
if ((bp = strstri(cfn, SAVE_EXTENSION))) {
|
||||||
if (len>4 && stricmp(cfn+len-4,".sav")==0) {
|
strsubst(bp, SAVE_EXTENSION, ".saz");
|
||||||
/* Save file; change .SAV extension to .SAZ */
|
|
||||||
/* EMX/GCC (for OS/2) seems to miscompile cfn[len-1] */
|
|
||||||
|
|
||||||
cfn[strlen(cfn)-1]='z';
|
|
||||||
return TRUE;
|
|
||||||
} else if (strnicmp(cfn,"bones",5)==0) {
|
|
||||||
/* Bones file; change BONES prefix to BONEZ */
|
|
||||||
|
|
||||||
cfn[4]='z';
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* Don't know how to convert this filename */
|
/* find last occurrence of bon */
|
||||||
|
bp = eos(cfn);
|
||||||
return FALSE;
|
while (bp-- > cfn) {
|
||||||
|
if (strstri(bp,"bon")) {
|
||||||
|
strsubst(bp, "bon", "boz");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* !MSDOS */
|
# endif /* SAVE_EXTENSION */
|
||||||
|
return FALSE;
|
||||||
|
#endif /* SHORT_FILENAMES */
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
@@ -1371,11 +1374,8 @@ boolean uncomp;
|
|||||||
char buf[1024];
|
char buf[1024];
|
||||||
unsigned len, len2;
|
unsigned len, len2;
|
||||||
|
|
||||||
if (!make_compressed_name(filename, cfn)) {
|
if (!make_compressed_name(filename, cfn))
|
||||||
/* Can't generate a name for the compressed file
|
|
||||||
due to 8.3 restriction */
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!uncomp) {
|
if (!uncomp) {
|
||||||
/* Open the input and output files */
|
/* Open the input and output files */
|
||||||
@@ -1383,8 +1383,8 @@ boolean uncomp;
|
|||||||
fopen takes "r" and "w" */
|
fopen takes "r" and "w" */
|
||||||
|
|
||||||
uncompressedfile = fopen(filename, RDBMODE);
|
uncompressedfile = fopen(filename, RDBMODE);
|
||||||
if (uncompressedfile == NULL) {
|
if (!uncompressedfile) {
|
||||||
perror(filename);
|
pline("Error in zlib docompress_file %s", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
compressedfile = gzopen(cfn, "wb");
|
compressedfile = gzopen(cfn, "wb");
|
||||||
@@ -1392,7 +1392,8 @@ boolean uncomp;
|
|||||||
if (errno == 0) {
|
if (errno == 0) {
|
||||||
pline("zlib failed to allocate memory");
|
pline("zlib failed to allocate memory");
|
||||||
} else {
|
} else {
|
||||||
perror(filename);
|
panic("Error in docompress_file %d",
|
||||||
|
errno);
|
||||||
}
|
}
|
||||||
fclose(uncompressedfile);
|
fclose(uncompressedfile);
|
||||||
return;
|
return;
|
||||||
@@ -1441,13 +1442,15 @@ boolean uncomp;
|
|||||||
if (errno == 0) {
|
if (errno == 0) {
|
||||||
pline("zlib failed to allocate memory");
|
pline("zlib failed to allocate memory");
|
||||||
} else if (errno != ENOENT) {
|
} else if (errno != ENOENT) {
|
||||||
perror(filename);
|
panic("Error in zlib docompress_file %s, %d",
|
||||||
|
filename, errno);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uncompressedfile = fopen(filename, WRBMODE);
|
uncompressedfile = fopen(filename, WRBMODE);
|
||||||
if (uncompressedfile == NULL) {
|
if (!uncompressedfile) {
|
||||||
perror(filename);
|
pline("Error in zlib docompress file uncompress %s",
|
||||||
|
filename);
|
||||||
gzclose(compressedfile);
|
gzclose(compressedfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -803,7 +803,7 @@ static const char *build_opts[] = {
|
|||||||
"zero-compressed save files",
|
"zero-compressed save files",
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLECOMP
|
#ifdef RLECOMP
|
||||||
"run-length compression of levl array in save files",
|
"run-length compression of map in save files",
|
||||||
#endif
|
#endif
|
||||||
save_bones_compat_buf,
|
save_bones_compat_buf,
|
||||||
"basic NetHack features"
|
"basic NetHack features"
|
||||||
|
|||||||
Reference in New Issue
Block a user