games@tekred.CNA.TEK.COM (03/22/89)
Submitted-by: ching@pepsi.AMD.COM (Mike Ching) Posting-number: Volume 6, Issue 33 Archive-name: sokoban2/Patch1 [From the author...] [[This is a set of diffs for version 2 of sokoban to run under MSDOS using the Turbo C compiler. I'm contemplating doing graphics similar to EGA-wanderer if I can stop playing the game long enough.]] [I applied Mike's diffs and recreated a set of context diffs from the original source. The MSDOS stuff is #ifdef'd. -br] #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: Patches01 # Wrapped by billr@saab on Tue Mar 21 13:38:17 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Patches01' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Patches01'\" else echo shar: Extracting \"'Patches01'\" \(9992 characters\) sed "s/^X//" >'Patches01' <<'END_OF_FILE' X*** sokoban.h.orig Wed Mar 15 14:44:26 1989 X--- sokoban.h Tue Mar 21 11:55:14 1989 X*************** X*** 66,72 **** X packet = { '$', '$', 0 }, X save = { '*', '$', 1 }, X ground = { ' ', ' ', 0 }, X! wall = { '#', ' ', 1 }; X X /************************************************************************* X ********************** DO NOT CHANGE BELOW THIS LINE ********************* X--- 66,72 ---- X packet = { '$', '$', 0 }, X save = { '*', '$', 1 }, X ground = { ' ', ' ', 0 }, X! wall = { '#', '#', 1 }; X X /************************************************************************* X ********************** DO NOT CHANGE BELOW THIS LINE ********************* X*** readscreen.c.orig Wed Mar 15 14:43:56 1989 X--- readscreen.c Tue Mar 21 11:54:43 1989 X*************** X*** 14,20 **** X char *fnam; X short j, c, ret = 0; X X! fnam = malloc( strlen( SCREENPATH) + 11); X sprintf( fnam, "%s/screen.%d", SCREENPATH, level); X if( (screen = fopen( fnam, "r")) == NULL) X ret = E_FOPENSCREEN; X--- 14,20 ---- X char *fnam; X short j, c, ret = 0; X X! fnam = malloc( strlen( SCREENPATH) + 12); X sprintf( fnam, "%s/screen.%d", SCREENPATH, level); X if( (screen = fopen( fnam, "r")) == NULL) X ret = E_FOPENSCREEN; X*** save.c.orig Wed Mar 15 14:43:57 1989 X--- save.c Tue Mar 21 11:54:52 1989 X*************** X*** 23,30 **** X short ret = 0; X X signal( SIGINT, SIG_IGN); X! sfname = malloc( strlen( SAVEPATH) + strlen( username) + 5); X sprintf( sfname, "%s/%s.sav", SAVEPATH, username); X if( (savefile = fopen( sfname, "w")) == NULL) X ret = E_FOPENSAVE; X else { X--- 23,54 ---- X short ret = 0; X X signal( SIGINT, SIG_IGN); X! sfname = malloc( strlen( SAVEPATH) + strlen( username) + 6); X sprintf( sfname, "%s/%s.sav", SAVEPATH, username); X+ #ifdef __MSDOS__ X+ if( (savefile = fopen( sfname, "wb")) == NULL) X+ ret = E_FOPENSAVE; X+ else { X+ if( fwrite( map, 1, MAXROW*MAXCOL, savefile) != MAXROW*MAXCOL) X+ ret = E_WRITESAVE; X+ else if( fwrite( &ppos, 1, sizeof( POS), savefile) != sizeof( POS)) X+ ret = E_WRITESAVE; X+ else if( fwrite( &level, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &moves, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &pushes, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &packets, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &savepack, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &rows, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else if( fwrite( &cols, 1, 2, savefile) != 2) ret = E_WRITESAVE; X+ else { X+ fclose( savefile); X+ if( stat( sfname, &sfstat) != 0) ret = E_STATSAVE; X+ else if( (savefile = fopen( sfname, "ab")) == NULL) X+ ret = E_FOPENSAVE; X+ else { X+ if( fwrite( &sfstat, 1, sizeof( sfstat), savefile) != sizeof( sfstat)) X+ ret = E_WRITESAVE; X+ #else X if( (savefile = fopen( sfname, "w")) == NULL) X ret = E_FOPENSAVE; X else { X*************** X*** 33,39 **** X ret = E_WRITESAVE; X else if( write( savedbn, &ppos, sizeof( POS)) != sizeof( POS)) X ret = E_WRITESAVE; X- else if( write( savedbn, &scoring, 2) != 2) ret = E_WRITESAVE; X else if( write( savedbn, &level, 2) != 2) ret = E_WRITESAVE; X else if( write( savedbn, &moves, 2) != 2) ret = E_WRITESAVE; X else if( write( savedbn, &pushes, 2) != 2) ret = E_WRITESAVE; X--- 57,62 ---- X*************** X*** 49,54 **** X--- 72,78 ---- X else { X if( write( savedbn, &sfstat, sizeof( sfstat)) != sizeof( sfstat)) X ret = E_WRITESAVE; X+ #endif X fclose( savefile); X } X } X*************** X*** 65,75 **** X struct stat oldsfstat; X X signal( SIGINT, SIG_IGN); X! sfname = malloc( strlen( SAVEPATH) + strlen( username) + 5); X sprintf( sfname, "%s/%s.sav", SAVEPATH, username); X if( stat( sfname, &oldsfstat) < -1) X ret = E_NOSAVEFILE; X else { X if( (savefile = fopen( sfname, "r")) == NULL) X ret = E_FOPENSAVE; X else { X--- 89,119 ---- X struct stat oldsfstat; X X signal( SIGINT, SIG_IGN); X! sfname = malloc( strlen( SAVEPATH) + strlen( username) + 6); X sprintf( sfname, "%s/%s.sav", SAVEPATH, username); X+ #ifdef __MSDOS__ X if( stat( sfname, &oldsfstat) < -1) X ret = E_NOSAVEFILE; X else { X+ if( (savefile = fopen( sfname, "rb")) == NULL) X+ ret = E_FOPENSAVE; X+ else { X+ if( fread( map, 1, MAXROW*MAXCOL, savefile) != MAXROW*MAXCOL) X+ ret = E_READSAVE; X+ else if( fread( &ppos, 1, sizeof( POS), savefile) != sizeof( POS)) X+ ret = E_READSAVE; X+ else if( fread( &level, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &moves, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &pushes, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &packets, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &savepack, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &rows, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &cols, 1, 2, savefile) != 2) ret = E_READSAVE; X+ else if( fread( &sfstat, 1, sizeof( sfstat), savefile) != sizeof( sfstat)) X+ #else X+ if( stat( sfname, &oldsfstat) < -1) X+ ret = E_NOSAVEFILE; X+ else { X if( (savefile = fopen( sfname, "r")) == NULL) X ret = E_FOPENSAVE; X else { X*************** X*** 78,84 **** X ret = E_READSAVE; X else if( read( savedbn, &ppos, sizeof( POS)) != sizeof( POS)) X ret = E_READSAVE; X- else if( read( savedbn, &scoring, 2) != 2) ret = E_READSAVE; X else if( read( savedbn, &level, 2) != 2) ret = E_READSAVE; X else if( read( savedbn, &moves, 2) != 2) ret = E_READSAVE; X else if( read( savedbn, &pushes, 2) != 2) ret = E_READSAVE; X--- 122,127 ---- X*************** X*** 87,92 **** X--- 130,136 ---- X else if( read( savedbn, &rows, 2) != 2) ret = E_READSAVE; X else if( read( savedbn, &cols, 2) != 2) ret = E_READSAVE; X else if( read( savedbn, &sfstat, sizeof( sfstat)) != sizeof( sfstat)) X+ #endif X ret = E_READSAVE; X else if( (sfstat.st_dev != oldsfstat.st_dev) || X (sfstat.st_ino != oldsfstat.st_ino) || X*************** X*** 101,103 **** X--- 145,148 ---- X signal( SIGINT, SIG_DFL); X return( ret); X } X+ X*** score.c.orig Wed Mar 15 14:43:58 1989 X--- score.c Tue Mar 21 11:54:58 1989 X*************** X*** 33,43 **** X--- 33,51 ---- X X while( creat( LOCKFILE, 0666) < 0) ; X scoreentries = 0; X+ #ifdef __MSDOS__ X+ if( (scorefile = fopen( SCOREFILE, "wb")) == NULL) X+ ret = E_FOPENSCORE; X+ else { X+ if (fwrite (&scoreentries, 1, sizeof( scoreentries), scorefile) != sizeof(scoreentries)) X+ ret = E_WRITESCORE; X+ #else X if( (scorefile = fopen( SCOREFILE, "w")) == NULL) X ret = E_FOPENSCORE; X else { X sfdbn = fileno( scorefile); X if( write( sfdbn, &scoreentries, 2) != 2) ret = E_WRITESCORE; X+ #endif X fclose( scorefile); X } X unlink( LOCKFILE); X*************** X*** 50,56 **** X--- 58,68 ---- X short ret = 0, pos; X X while( creat( LOCKFILE, 0666) < 0); X+ #ifdef __MSDOS__ X+ if( (scorefile = fopen( SCOREFILE, "rb")) == NULL) X+ #else X if( (scorefile = fopen( SCOREFILE, "r")) == NULL) X+ #endif X ret = E_FOPENSCORE; X else { X if( (ret = readscore()) == 0) X*************** X*** 78,83 **** X--- 90,106 ---- X short ret = 0; X long tmp; X X+ #ifdef __MSDOS__ X+ if( (scorefile = fopen( SCOREFILE, "rb")) == NULL) X+ ret = E_FOPENSCORE; X+ else { X+ tmp = sizeof( scoreentries); X+ if( fread( &scoreentries, 1, tmp, scorefile) != tmp) ret = E_READSCORE; X+ else { X+ tmp = scoreentries * sizeof( scoretable[0]); X+ if( fread( scoretable, 1, tmp, scorefile) != tmp) ret = E_READSCORE; X+ } X+ #else X if( (scorefile = fopen( SCOREFILE, "r")) == NULL) X ret = E_FOPENSCORE; X else { X*************** X*** 87,92 **** X--- 110,116 ---- X tmp = scoreentries * sizeof( scoretable[0]); X if( read( sfdbn, &(scoretable[0]), tmp) != tmp) ret = E_READSCORE; X } X+ #endif X fclose( scorefile); X } X return( ret); X*************** X*** 161,166 **** X--- 185,201 ---- X short ret = 0; X long tmp; X X+ #ifdef __MSDOS__ X+ if( (scorefile = fopen( SCOREFILE, "wb")) == NULL) X+ ret = E_FOPENSCORE; X+ else { X+ tmp = sizeof( scoreentries); X+ if( fwrite( &scoreentries, 1, tmp, scorefile) != tmp) ret = E_WRITESCORE; X+ else { X+ tmp = scoreentries * sizeof( scoretable[0]); X+ if( fwrite( scoretable, 1, tmp, scorefile) != tmp) ret = E_WRITESCORE; X+ } X+ #else X if( (scorefile = fopen( SCOREFILE, "w")) == NULL) X ret = E_FOPENSCORE; X else { X*************** X*** 170,175 **** X--- 205,211 ---- X tmp = scoreentries * sizeof( scoretable[0]); X if( write( sfdbn, &(scoretable[0]), tmp) != tmp) ret = E_WRITESCORE; X } X+ #endif X fclose( scorefile); X } X return( ret); X*** showscreen.c.orig Wed Mar 15 14:44:25 1989 X--- showscreen.c Tue Mar 21 11:55:05 1989 X*************** X*** 1,3 **** X--- 1,4 ---- X+ #include <stdio.h> X #include <curses.h> X #include "sokoban.h" X X*** sok.c.orig Wed Mar 15 14:44:26 1989 X--- sok.c Tue Mar 21 11:55:09 1989 X*************** X*** 1,5 **** X--- 1,15 ---- X+ #include <stdio.h> X #include <curses.h> X #include "sokoban.h" X+ #ifdef __MSDOS__ X+ char * getlogin() /* interactive login name */ X+ { static char loginname[MAXUSERNAME]; X+ fputs("\nName? ", stdout); X+ fgets(loginname, MAXUSERNAME, stdin); X+ loginname[strlen(loginname)-1] = 0; X+ return(loginname); X+ } X+ #endif X X extern char *strrchr(), *getlogin(), *getpass(); X extern short readscreen(), play(), outputscore(), getuserlevel(), END_OF_FILE if test 9992 -ne `wc -c <'Patches01'`; then echo shar: \"'Patches01'\" unpacked with wrong size! fi # end of 'Patches01' fi echo shar: End of shell archive. exit 0