From 0d6ef02abe9a48b933eb3af7c3c84969194b3f95 Mon Sep 17 00:00:00 2001 From: Josh Bressers Date: Fri, 10 Nov 2006 14:42:31 +0000 Subject: [PATCH] Stop trying to use compress to shrink save files --- Configure | 57 ------------------------------------ README | 4 +-- TODO | 2 +- Uhelp | 2 -- Ularnopts | 1 - config.h.SH | 18 ------------ data.c | 6 ---- extern.h | 2 +- main.c | 9 +----- savelev.c | 84 +++++++++-------------------------------------------- tok.c | 5 +--- 11 files changed, 18 insertions(+), 172 deletions(-) diff --git a/Configure b/Configure index 91922d7..b47f3a4 100755 --- a/Configure +++ b/Configure @@ -97,8 +97,6 @@ mailx='' mail='' cpp='' perl='' -compress='' -uncompress='' imake='' xmkmf='' bindir='' @@ -111,8 +109,6 @@ d_random='' defcomp='' imaketmpl='' libdir='' -mycompress='' -myuncompress='' CONFIG='' : set package name package=Ularn @@ -331,8 +327,6 @@ grep trylist=" xmkmf imake -compress -uncompress test Mcc cpp @@ -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 '') @@ -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` @@ -1459,8 +1406,6 @@ mailx='$mailx' mail='$mail' cpp='$cpp' perl='$perl' -compress='$compress' -uncompress='$uncompress' imake='$imake' xmkmf='$xmkmf' bindir='$bindir' @@ -1473,8 +1418,6 @@ d_random='$d_random' defcomp='$defcomp' imaketmpl='$imaketmpl' libdir='$libdir' -mycompress='$mycompress' -myuncompress='$myuncompress' CONFIG=true EOT diff --git a/README b/README index 5571793..b549ce7 100644 --- a/README +++ b/README @@ -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 diff --git a/TODO b/TODO index 0f6593f..8ed6b2a 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/Uhelp b/Uhelp index ce175d6..30c130b 100644 --- a/Uhelp +++ b/Uhelp @@ -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 diff --git a/Ularnopts b/Ularnopts index 368bee8..a446a9b 100644 --- a/Ularnopts +++ b/Ularnopts @@ -5,7 +5,6 @@ enable-checkpointing #male female #character: klingon -compress name: Satyr monster: "Aardvark" monster: "Bitch" diff --git a/config.h.SH b/config.h.SH index 50623b9..98e4566 100644 --- a/config.h.SH +++ b/config.h.SH @@ -125,29 +125,11 @@ sed <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. */ diff --git a/data.c b/data.c index a9b7a46..1f8914a 100644 --- a/data.c +++ b/data.c @@ -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 */ diff --git a/extern.h b/extern.h index 708b1cb..be57c38 100644 --- a/extern.h +++ b/extern.h @@ -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 */ diff --git a/main.c b/main.c index 43f0e49..cca8e07 100644 --- a/main.c +++ b/main.c @@ -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 */ diff --git a/savelev.c b/savelev.c index 485cfac..e2cd13c 100644 --- a/savelev.c +++ b/savelev.c @@ -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(); @@ -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); @@ -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(); @@ -329,9 +274,6 @@ char *fname; fsorry(); close(fd); - if (compress) - if (unlink(tempfilename) == -1) - fcheat(); oldx = oldy = 0; if (strcmp(fname, ckpfile) == 0) { diff --git a/tok.c b/tok.c index c818eb3..2c6ceb2 100644 --- a/tok.c +++ b/tok.c @@ -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': @@ -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':