Skip to content

Commit

Permalink
Stop trying to use compress to shrink save files
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbressers committed Nov 10, 2006
1 parent 5f4f3d7 commit 0d6ef02
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 172 deletions.
57 changes: 0 additions & 57 deletions Configure
Expand Up @@ -97,8 +97,6 @@ mailx=''
mail=''
cpp=''
perl=''
compress=''
uncompress=''
imake=''
xmkmf=''
bindir=''
Expand All @@ -111,8 +109,6 @@ d_random=''
defcomp=''
imaketmpl=''
libdir=''
mycompress=''
myuncompress=''
CONFIG=''
: set package name
package=Ularn
Expand Down Expand Up @@ -331,8 +327,6 @@ grep
trylist="
xmkmf
imake
compress
uncompress
test
Mcc
cpp
Expand Down Expand Up @@ -1202,40 +1196,6 @@ else
d_voidsig="$undef"
fi

:
if $test $cygwin = "define" ; then
echo "cygwin doesn't get to compress savegame files."
compress=''
defcomp="$undef"
else
case "$compress" in
'xxx') compress=''
;;
*)

echo " "
echo "I see you have the 'compress' program."

dflt="y"
rp="Would you like to have save files compressed by default? [$dflt]"
$echo $n "$rp $c"
. myread

case "$ans" in
n*) defcomp="$undef"
echo " "
echo "Compression of save files can be enabled by placing"
echo "the keyword \"compress\" in your .${package}opts file."
echo " "
;;
*) defcomp="$define"
;;
esac
;;
esac

fi

: determine where public executables go
case "$bindir" in
'')
Expand Down Expand Up @@ -1294,19 +1254,6 @@ while $test "$cont" ; do
cont=''
done
:
case "$compress" in
'') mycompress="/usr/ucb/compress -c"
;;
*) mycompress="$compress -c"
;;
esac
:
case "$uncompress" in
'') myuncompress="/usr/ucb/uncompress -c"
;;
*) myuncompress="$uncompress -c"
;;
esac
: where do we get termlib routines from
echo " "
ans=`loc libcurses.a x $libpth`
Expand Down Expand Up @@ -1459,8 +1406,6 @@ mailx='$mailx'
mail='$mail'
cpp='$cpp'
perl='$perl'
compress='$compress'
uncompress='$uncompress'
imake='$imake'
xmkmf='$xmkmf'
bindir='$bindir'
Expand All @@ -1473,8 +1418,6 @@ d_random='$d_random'
defcomp='$defcomp'
imaketmpl='$imaketmpl'
libdir='$libdir'
mycompress='$mycompress'
myuncompress='$myuncompress'
CONFIG=true
EOT

Expand Down
4 changes: 1 addition & 3 deletions README
Expand Up @@ -11,9 +11,7 @@ with their compiler anyway. You're probably better off with gcc. I may work
on this in the future, if people ask, but I probably won't bother.

Anyway, mail me patches and things if you have them. Fix things in the TODO
and I'll be really happy. There are no major problems right now, except that
using compressed savefiles might not work everywhere. Try it out _before_
you get to 35th level and have to reboot or go to bed or something...
and I'll be really happy.

Ularn is distributed under the Gnu Public License. This is because the
original author included Gnu getopt in main.c. I have included a copy of the
Expand Down
2 changes: 1 addition & 1 deletion TODO
Expand Up @@ -7,7 +7,7 @@ BUGS:

- "press return to continue" when at home doesn't do anything

- compressing saved-game files seems not to work. [This now sort of works]
- Use zlib to compress save files

- configure script thinks all sorts of things are ksh

Expand Down
2 changes: 0 additions & 2 deletions Uhelp
Expand Up @@ -72,12 +72,10 @@ encountered and identified so far.
The file ".Ularnopts", if used, should be in your home directory (see -o).
A sequence of words terminated by whitespace is used to specify options.
Word Meaning
compress compress save files (usually on by default)
enable-checkpointing turn on periodic checkpointing
no-introduction do not display intro message
no-beep disable beeping of the terminal
no-bold turn off highliting
no-compress don't compress save files
no-nap eliminate all delays when playing game
no-mail don't send mail after winning game
male choose your sex to be a man
Expand Down
1 change: 0 additions & 1 deletion Ularnopts
Expand Up @@ -5,7 +5,6 @@ enable-checkpointing
#male
female
#character: klingon
compress
name: Satyr
monster: "Aardvark"
monster: "Bitch"
Expand Down
18 changes: 0 additions & 18 deletions config.h.SH
Expand Up @@ -125,29 +125,11 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#undef!'
*/
#$d_random RANDOM /**/
/* DEF_COMPRESS:
* This symbol,if defined, indicates that the save files should
* be compressed by default.
*/
#$defcomp DEF_COMPRESS /**/
/* LIBDIR:
* This symbol indicates where the data files will reside.
*/
#define LIBDIR "$libdir" /**/
/* COMPRESS
* This symbol contains the command to do compression from stdin
* to stdout.
*/
#define COMPRESS "$mycompress"
/* UNCOMPRESS
* This symbol contains the command to do uncompression from stdin
* to stdout.
*/
#define UNCOMPRESS "$myuncompress"
/* LINUX
* we're compiling on linux.
*/
Expand Down
6 changes: 0 additions & 6 deletions data.c
Expand Up @@ -121,12 +121,6 @@ short iarg[MAXX][MAXY]; /* arg for the item array */
short lastnum=0; /* the number of the monster last hitting player, or */
/* reason why dead */

char compress
#ifdef DEF_COMPRESS
= 1;
#else
= 0;
#endif
char item[MAXX][MAXY]; /* objects in maze if any */
char know[MAXX][MAXY]; /* 1 or 0 if here before */
/*char mitem[MAXX][MAXY]; /* monster item array */
Expand Down
2 changes: 1 addition & 1 deletion extern.h
Expand Up @@ -733,7 +733,7 @@ extern char potprob[], predostuff, scprob[], spelknow[], do_fork, sex;
extern char spelweird[MAXMONST+8][SPNUM], wizard;
extern char diroffx[],diroffy[],hitflag,hit2flag,hit3flag;
extern char rmst, lasthx,lasthy,lastpx,lastpy;
extern char ramboflag, compress;
extern char ramboflag;

extern short hitp[MAXX][MAXY], ivenarg[], screen[MAXX][MAXY];
extern short iarg[MAXX][MAXY], lastnum; /* must be short for gold piles */
Expand Down
9 changes: 1 addition & 8 deletions main.c
Expand Up @@ -402,14 +402,7 @@ parse ()
case 'S': clear();
lprcat("Saving . . .");
lflush();
if (savegame(savefilename) == -1 && compress) {
lprcat("\nCompression of your savefile failed.\n");
lprcat("Do you want to try to save without compression? ");
if ((i = getyn()) == 'y' || i == 'Y') {
compress=0;
savegame(savefilename);
}
}
savegame(savefilename);
wizard=1; /* so not show scores */
died(-257);
/* NOTREACHED */
Expand Down
84 changes: 13 additions & 71 deletions savelev.c
Expand Up @@ -103,24 +103,12 @@ char *fname;
savelevel();
ointerest();

if (compress) {
sprintf(buf, "%s > %s 2>/dev/null", COMPRESS, fname);
if ((fp = popen(buf, "w")) == (FILE *)NULL) {
fprintf(stderr,"Can't open pipe to <%s> to save game\n",
COMPRESS);
perror("popen");
nosignal = 0;
if (do_fork) exit(1); else return(-1);
}
fd = fileno(fp);
} else {
if ((fd = creat(fname, 0600)) < 0) {
fprintf(stderr,"Can't open file <%s> to save game\n",
fname);
perror("open of savefile");
nosignal = 0;
if (do_fork) exit(1); else return(-1);
}
if ((fd = creat(fname, 0600)) < 0) {
fprintf(stderr,"Can't open file <%s> to save game\n",
fname);
perror("open of savefile");
nosignal = 0;
if (do_fork) exit(1); else return(-1);
}

set_score_output();
Expand Down Expand Up @@ -183,16 +171,6 @@ char *fname;
bwrite(fd,(char *)&FileSum, sizeof(FileSum));
close(fd);

if (compress) {
if (pclose(fp) != 0) { /* if compress failed */
unlink(fname);
nosignal = 0;
if (do_fork)
exit(1);
else
return (-1);
}
}
nosignal = 0;
if (do_fork)
exit(0);
Expand All @@ -212,46 +190,13 @@ char *fname;
char buf[1024], *tmp="/tmp/UtmpXXXXXX";
int fd;

if (compress) {
if (mkstemp(tmp) == -1) {
fprintf(stderr,"Can't create temp file to restore game\n");
perror("mkstemp");
nosignal=0;
sleep(4);
c[GOLD] = c[BANKACCOUNT] = 0;
died(-265);
return;
}
tempfilename = tmp;
sprintf(buf, "%s < %s > %s 2>/dev/null",
UNCOMPRESS, fname, tempfilename);
printf(" Uncompressing...");fflush(stdout);
if (system(buf) != 0) {
fprintf(stderr,"\"%s\" failed\n",buf);
perror("system");
sleep(4);
c[GOLD] = c[BANKACCOUNT] = 0;
died(-265);
unlink(tempfilename);
return;
}
if ((fd = open(tempfilename, O_RDONLY)) < 0) {
fprintf(stderr,"Can't open temp file to restore game\n");
perror("open");
sleep(4);
c[GOLD] = c[BANKACCOUNT] = 0;
died(-265);
return;
}
} else {
if ((fd = open(fname, O_RDONLY)) <= 0) {
fprintf(stderr,"Can't open file <%s> to restore game\n",
fname);
sleep(4);
c[GOLD] = c[BANKACCOUNT] = 0;
died(-265);
return;
}
if ((fd = open(fname, O_RDONLY)) <= 0) {
fprintf(stderr,"Can't open file <%s> to restore game\n",
fname);
sleep(4);
c[GOLD] = c[BANKACCOUNT] = 0;
died(-265);
return;
}
printf(" Reading data...");fflush(stdout);
init_cells();
Expand Down Expand Up @@ -329,9 +274,6 @@ char *fname;
fsorry();

close(fd);
if (compress)
if (unlink(tempfilename) == -1)
fcheat();

oldx = oldy = 0;
if (strcmp(fname, ckpfile) == 0) {
Expand Down
5 changes: 1 addition & 4 deletions tok.c
Expand Up @@ -262,8 +262,6 @@ readopts ()
mail=0;
else if (strcmp(str,"no-nap") == 0)
nonap=1;
else if (strcmp(str,"no-compress") == 0)
compress=0;
break;

case 'c':
Expand Down Expand Up @@ -293,8 +291,7 @@ readopts ()
char_picked = 'g';
else if (!strcmp(char_class, "rambo"))
char_picked = 'h';
} else if(!strcmp(str, "compress"))
compress = 1;
}
break;

case 's':
Expand Down

0 comments on commit 0d6ef02

Please sign in to comment.