games@tekred.TEK.COM (12/15/88)
Submitted by: tale@pawl.rpi.edu (Dave Lawrence) Comp.sources.games: Volume 5, Issue 97 Archive-name: tess/Patch1 [[Note: this is the second version of these patches. If you got a copy of this set of patches before the first article was canceled, delete it and use this instead. -br]] [These patches have been approved by the original author for distribution as official patches. -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: Fixes patches01 # Wrapped by billr@saab on Wed Dec 14 13:37:47 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Fixes' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Fixes'\" else echo shar: Extracting \"'Fixes'\" \(1950 characters\) sed "s/^X//" >'Fixes' <<'END_OF_FILE' XBUGS X o ^D (EOF) on stdin causes input routines to endlessly loop. X o When the programme asks "What is the probability of getting X the improbability?" the answer is assumed to contain a X decimal point. If none is entered, a signal SEGV occurs. X XFIXES X o A routine was added to parser.c named trapEOF and the eofgets() X macro facilitates this call. ^D now terminates the programme X with exit code 1. X o The input to the question now accepts forms of 50, 50.7, 0.50 X and 1/2, all returning a value equivalent to 50%. Other input X (1/,fifty percent) will simply be interpreted as 0. X XAESTHETIC CHANGES X o A -f option was allowed. This causes the programme to start X in the researcher's office. The title and instructions are skipped. X o The prompt at the end of the title screen lets you skip the X instructions. X o srand() is now randomized by the system clock. It had been X randomized by the values returned from get_enter() at the X first two screens, but this usually resulted in sum being X always set to a value of 86 as most people don't type anything X at a prompt that says to just press <enter>. X o The code now passes the lint test. It barfed in a big way X with the original code as numerous return codes were not X checked and some return values were inconsistent. The X latter was caused by the absence of string.h; to keep X portability, I included extern definitions to the X common string functions used in the programme. I don't X know whether it will compile with Datalight (?) C X as I don't have access to that compiler. All casting X to (void) will also have to be removed on compilers X without void. X o fgets replaced all gets calls because gets is inherently X evil. X o The printing of the title screen when exiting the programme X has been removed. It just isn't in the spirit of UNIX. |:-) X X-- XDave Lawrence X tale@rpitsmts.bitnet, tale%mts@rpitsgw.rpi.edu, tale@pawl.rpi.edu END_OF_FILE if test 1950 -ne `wc -c <'Fixes'`; then echo shar: \"'Fixes'\" unpacked with wrong size! fi # end of 'Fixes' fi if test -f 'patches01' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patches01'\" else echo shar: Extracting \"'patches01'\" \(17604 characters\) sed "s/^X//" >'patches01' <<'END_OF_FILE' X*** tess2/parser.c Mon Dec 12 17:34:04 1988 X--- tess/parser.c Tue Dec 13 23:30:25 1988 X*************** X*** 33,43 **** X--- 33,76 ---- X *str = tolower (*str); X return (orig); X } X+ X+ int intlwr(c) X+ int c; X+ X+ { X+ return (c = (isupper(c)) ? tolower(c) : c); X+ } X+ X /*----------------------- END of additions for portable version. */ X X+ char *trapEOF(s,stream) X+ char *s; X+ FILE *stream; X X+ { X+ if (s == NULL) { X+ if (feof(stream)) { X+ prints("(EOF)"); X+ exit(1); X+ } else { X+ perror("fgets: "); X+ exit(1); X+ } X+ } X+ return(s); X+ } X X+ strip_nl(s) X+ char *s; X X+ { X+ auto int i; X+ i = strlen(s); X+ if (*(s+i-1)=='\n') *(s+i-1) = '\0'; /* fgets is safer, but imbeds \n */ X+ } X+ X+ #define eofgets(st, nu, fi) trapEOF(fgets(st,nu,fi), fi) X+ X #define v_sig 4 /* 1st 4 letters of vocab words significant */ X X #define max_cmd_size 64 /* at most 63 chars per command */ X*************** X*** 88,99 **** X q = strchr( cm, '\0'); /* get last char */ X X if (!p) p = q; /* if 1 word, set ptr */ X! strncat( verb, cm, min(p-cm, max_word_len) ); X X if (*p) /* if >1 word */ X { X while (*p && *p==' ') p++; /* skip lead blanks */ X! strncat( noun, p, min(q-p, max_word_len) ); X } X } X X--- 121,132 ---- X q = strchr( cm, '\0'); /* get last char */ X X if (!p) p = q; /* if 1 word, set ptr */ X! (void)strncat( verb, cm, min(p-cm, max_word_len) ); X X if (*p) /* if >1 word */ X { X while (*p && *p==' ') p++; /* skip lead blanks */ X! (void)strncat( noun, p, min(q-p, max_word_len) ); X } X } X X*************** X*** 105,112 **** X char *s; X { X int i; X! X! for ( i=strlen(s); i<v_sig; i++ ) X *(s+i) = ' '; X *(s+v_sig)='\0'; X } X--- 138,145 ---- X char *s; X { X int i; X! X! for (i = strlen(s); i<v_sig; i++ ) X *(s+i) = ' '; X *(s+v_sig)='\0'; X } X*************** X*** 118,127 **** X char *w; X vocab_type *voc; X { X! int wn,i; X v_word sh_word; X X! strcpy( sh_word, w ); X resize_word( sh_word ); X for ( wn=0; *voc->name; voc++ ) X { X--- 151,160 ---- X char *w; X vocab_type *voc; X { X! int wn; X v_word sh_word; X X! (void)strcpy( sh_word, w ); X resize_word( sh_word ); X for ( wn=0; *voc->name; voc++ ) X { X*************** X*** 159,165 **** X int nn; X X cprintf( prompt ); X! gets( noun ); X nn = GetNounNum( noun ); X resize_word( noun ); X return( nn ); X--- 192,198 ---- X int nn; X X cprintf( prompt ); X! strip_nl(eofgets(noun,max_word_size,stdin)); X nn = GetNounNum( noun ); X resize_word( noun ); X return( nn ); X*************** X*** 172,186 **** X CmdRec *cmd; X { X ParseCommand( cmd->cm, cmd->verb, cmd->noun ); X! strlwr( cmd->verb ); X! strlwr( cmd->noun ); X cmd->vn = GetVerbNum( cmd->verb ); X cmd->nn = GetNounNum( cmd->noun ); X X! strcpy( cmd->sh_verb, cmd->verb ); X! resize_word( cmd->sh_verb ); X! strcpy( cmd->sh_noun, cmd->noun ); X! resize_word( cmd->sh_noun ); X } X X X--- 205,219 ---- X CmdRec *cmd; X { X ParseCommand( cmd->cm, cmd->verb, cmd->noun ); X! (void)strlwr( cmd->verb ); X! (void)strlwr( cmd->noun ); X cmd->vn = GetVerbNum( cmd->verb ); X cmd->nn = GetNounNum( cmd->noun ); X X! (void)strcpy(cmd->sh_verb, cmd->verb); X! resize_word(cmd->sh_verb); X! (void)strcpy(cmd->sh_noun, cmd->noun); X! resize_word(cmd->sh_noun); X } X X X*** tess.1 Mon Dec 12 11:17:07 1988 X--- tess/tess.1 Mon Dec 12 11:32:34 1988 X*************** X*** 3,7 **** X tess - beyond the tesseract, an abstract adventure X .SH SYNOPSIS X! tess X .SH DESCRIPTION X .SH Scenario: X--- 3,7 ---- X tess - beyond the tesseract, an abstract adventure X .SH SYNOPSIS X! tess [-f] X .SH DESCRIPTION X .SH Scenario: X*************** X*** 23,26 **** X--- 23,28 ---- X of each word are significant. The adventure recognizes about 200 words, X so if one word doesn't work, try another. X+ .SH OPTIONS X+ -f Fast start-up; skip title, scenario and instructions. X .SH Notes: X .LP X X*** tess2/tess.c Mon Dec 12 17:34:09 1988 X--- tess/tess.c Wed Dec 14 00:14:55 1988 X*************** X*** 7,15 **** X X /* X Portable version V2.0p By Dennis Lo 10/30/88 X X This version can compile with Datalight C 2.20, Microsoft C 5.0, X! QuickC 1.0, Turbo C 1.5, Unix cc (SunOs 3.?), and GNU cc. X X - Changed ANSI-style function parameter declarations to K & R-style. X - Removed #include <string.h> and added the string routines X--- 7,18 ---- X X /* X Portable version V2.0p By Dennis Lo 10/30/88 X+ V2.1p patches by Dave Lawrence 12/14/88 X+ (fixed probability read, pass by X+ long screens, EOF endless loops) X X This version can compile with Datalight C 2.20, Microsoft C 5.0, X! QuickC 1.0, Turbo C 1.5, Unix cc (SunOs 3.?), GNU cc and *C87. X X - Changed ANSI-style function parameter declarations to K & R-style. X - Removed #include <string.h> and added the string routines X*************** X*** 31,40 **** X--- 34,48 ---- X will use Turbo-C screen manipulation library routines. ******/ X #define tty X X+ /****** quick alias for *C87 on MTS; loader only recognizes 8 chars. ****/ X+ #define goto_new_lev GoNewLev X+ #define goto_new_loc GoNewLoc X X #include <ctype.h> X /*#include <string.h>*/ X #include <stdio.h> X+ extern char *strcpy(), *strncat(), *strcat(); X+ extern int strcmp(); X X #define max(a,b) (((a) > (b)) ? (a) : (b)) X #define min(a,b) (((a) < (b)) ? (a) : (b)) X*************** X*** 46,61 **** X */ X nl() { putchar('\n'); } X X- /*----------------------------*/ X- int get_enter() X- { X- int i=0, ch; X X- while ((ch=getchar()) != '\n') X- i+=ch; X- return (i); X- } X- X /*----------------------------*/ X /* if tty-mode, then using standard library functions for I/O, and ignore the X screen I/O functions X--- 54,60 ---- X*************** X*** 62,69 **** X */ X #ifdef tty X X! # define cprintf printf X! # define cputs printf X # define prints puts X X # define clrscr() X--- 61,68 ---- X */ X #ifdef tty X X! # define cprintf (void)printf X! # define cputs (void)printf X # define prints puts X X # define clrscr() X*************** X*** 88,93 **** X--- 87,93 ---- X X #include "tess-def.c" X #include "parser.c" X+ #include <sys/time.h> X X X /*------------------------------------------------------------*/ X*************** X*** 126,131 **** X--- 126,133 ---- X InitAdv() X { X int i; X+ struct timeval tp; X+ struct timezone tzp; X X for ( i=1; i<MaxObjs; i++ ) X { X*************** X*** 141,146 **** X--- 143,153 ---- X X zap = cc = wa = ep = dr = af = gp = mi = ti = kp = 0; X X+ if (gettimeofday(&tp,&tzp)==-1) { X+ perror("gettimeofday"); X+ exit(1); X+ } X+ (void)srand ((int)tp.tv_sec); X for ( sum=0, i=0; i<3; i++ ) X sum += (dc [i] = rand() & 31); X X*************** X*** 454,461 **** X for ( i=1; i<MaxObjs; i++ ) X if ( ObjOnPlayer(i) ) X { X! strcpy( s, obj[i].name ); X! if (WearingObj(i)) strcat( s, " (wearing)" ); X len = strlen(s); X if (currx+ len + 3 > 78 ) { currx=0; nl(); } X cprintf(" %s.", s ); X--- 461,468 ---- X for ( i=1; i<MaxObjs; i++ ) X if ( ObjOnPlayer(i) ) X { X! (void)strcpy ( s, obj[i].name ); X! if (WearingObj(i)) (void)strcat( s, " (wearing)" ); X len = strlen(s); X if (currx+ len + 3 > 78 ) { currx=0; nl(); } X cprintf(" %s.", s ); X*************** X*** 472,478 **** X /*----------------------------*/ X do_get() X { X! int where, attr, i, get_flag; X char s[16], *p; X X if (ObjOnPlayer(cmd.nn)) X--- 479,485 ---- X /*----------------------------*/ X do_get() X { X! int i, get_flag; X char s[16], *p; X X if (ObjOnPlayer(cmd.nn)) X*************** X*** 529,539 **** X else if (cmd.nn==o_improb) /* improbability */ X { X cprintf("What is the probability of getting this improbability? "); X! gets( s ); X! p = strchr( s, '.' ); /* skip past decimal point */ X! if (p) p++; X! i = atoi( p ); X! if (i!=sum && i*10!=sum) X { X prints("Wrong."); X get_flag = 0; X--- 536,548 ---- X else if (cmd.nn==o_improb) /* improbability */ X { X cprintf("What is the probability of getting this improbability? "); X! strip_nl(eofgets(s,16,stdin)); X! if ((p=strchr(s,'.')) && atoi(s)==0) X! i = atoi(p + 1); X! else if (p = strchr(s,'/')) i = (i = atoi(p+1)) ? X! atoi(s)/(float)i * 100 : atoi(s); X! else i = atoi(s); X! if (i!=sum) X { X prints("Wrong."); X get_flag = 0; X*************** X*** 551,557 **** X /*----------------------------*/ X do_drop() X { X! int where, i; X X if (ObjInRoom(cmd.nn)) X prints("It's already here."); X--- 560,566 ---- X /*----------------------------*/ X do_drop() X { X! int i; X X if (ObjInRoom(cmd.nn)) X prints("It's already here."); X*************** X*** 589,596 **** X /*----------------------------*/ X do_throw() X { X- char *s; X- X if (ObjInRoom(cmd.nn)) X prints("It's already here."); X X--- 598,603 ---- X*************** X*** 1509,1533 **** X char s[80]; X X cprintf("Filename to save game to: "); X! gets( s ); X! if (!*s) return; X X f=fopen(s,"w"); X if (f) X { X for ( i=1; i<MaxObjs; i++ ) X! fprintf( f, "%d ", obj[i].loc ); X X! fprintf( f, "%d %d %d %d %d %d ", X curr_lev, curr_loc, X level_loc[1], level_loc[2], level_loc[3], sleep_lev ); X X! fprintf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ", X cc, wa, ep, dr, af, gp, mi, ti, kp, dc[0], dc[1], dc[2] ); X X putc( '\n', f ); X! fclose( f ); X! prints("Game saved."); X } X else X { X--- 1516,1541 ---- X char s[80]; X X cprintf("Filename to save game to: "); X! (void)eofgets(s,80,stdin); X! if (s[0] == '\n') return; X! else strip_nl(s); X X f=fopen(s,"w"); X if (f) X { X for ( i=1; i<MaxObjs; i++ ) X! (void)fprintf( f, "%d ", obj[i].loc ); X X! (void)fprintf( f, "%d %d %d %d %d %d ", X curr_lev, curr_loc, X level_loc[1], level_loc[2], level_loc[3], sleep_lev ); X X! (void)fprintf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ", X cc, wa, ep, dr, af, gp, mi, ti, kp, dc[0], dc[1], dc[2] ); X X putc( '\n', f ); X! if (fclose(f)) perror("Error saving game: "); X! else prints("Game saved."); X } X else X { X*************** X*** 1543,1569 **** X char s[80]; X X cprintf("Filename to load game from: "); X! gets( s ); X! if (!*s) return; X X f=fopen(s,"r"); X if (f) X { X for ( i=1; i<MaxObjs; i++ ) X! fscanf( f, "%d ", &obj[i].loc ); X X! fscanf( f, "%d %d %d %d %d %d ", X &curr_lev, &curr_loc, X! &level_loc[1], &level_loc[2], &level_loc[3], &sleep_lev ); X X! fscanf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ", X! &cc, &wa, &ep, &dr, &af, &gp, &mi, &ti, &kp, &dc[0], &dc[1], &dc[2] ); X X for ( sum=0, i=0; i<3; i++ ) X sum += dc[i]; X X! fclose( f ); X! prints("Game loaded."); X print_room = 1; X } X else X--- 1551,1579 ---- X char s[80]; X X cprintf("Filename to load game from: "); X! (void)eofgets(s,80,stdin); X! if (s[0] == '\n') return; X! else strip_nl(s); X X f=fopen(s,"r"); X if (f) X { X for ( i=1; i<MaxObjs; i++ ) X! if(fscanf( f, "%d ", &obj[i].loc ) != 1) goto erred; X X! if(fscanf( f, "%d %d %d %d %d %d ", X &curr_lev, &curr_loc, X! &level_loc[1],&level_loc[2],&level_loc[3],&sleep_lev)!=6) goto erred; X X! if(fscanf( f, "%d %d %d %d %d %d %d %d %d %d %d %d ", X! &cc, &wa, &ep, &dr, &af, &gp, &mi, &ti, &kp, &dc[0], &dc[1], &dc[2] ) X! != 12) goto erred; X X for ( sum=0, i=0; i<3; i++ ) X sum += dc[i]; X X! if (fclose(f)) perror("Error closing save file: "); X! else prints("Game loaded."); X print_room = 1; X } X else X*************** X*** 1570,1575 **** X--- 1580,1589 ---- X { X cprintf("Unable to load game from %s", s); nl(); X } X+ return; X+ erred: X+ prints("load: save file of inconsistent format"); X+ exit(1); X } X X /*----------------------------*/ X*************** X*** 1712,1723 **** X flag = stack_say("sonic harmony present."); X X if (!flag) X! stack_say("nothing special to report."); X } X X else X { X! stack_say( "" ); X switch ( cmd.nn ) X { X case o_mirror: X--- 1726,1737 ---- X flag = stack_say("sonic harmony present."); X X if (!flag) X! (void)stack_say("nothing special to report."); X } X X else X { X! (void)stack_say( "" ); X switch ( cmd.nn ) X { X case o_mirror: X*************** X*** 2069,2093 **** X else X { X prints( X! "As the complex disintegrates around you, the stack, sensing your\n"); X prints( X! "danger, overloads all it's circuits to regain a moment's control.\n"); X prints( X! "With a final burst of energy, the stack implodes, projecting a\n"); X prints( X! "stasis field around you that protects you from the destruction.\n"); X prints( X! "...\n"); X prints( X! "From the smoldering debris of the Doomsday complex you pick up the\n"); X prints( X! "pieces of the stack and reflect on how as you risked your life to\n"); X prints( X! "save Earth, the stack has given its own to save yours. As you walk\n"); X prints( X! "away, you solemnly swear to repair the stack, for the adventures\n"); X prints( X! "that lie ahead.\n" X ); X } X break; X--- 2083,2107 ---- X else X { X prints( X! "As the complex disintegrates around you, the stack, sensing your"); X prints( X! "danger, overloads all it's circuits to regain a moment's control."); X prints( X! "With a final burst of energy, the stack implodes, projecting a"); X prints( X! "stasis field around you that protects you from the destruction."); X prints( X! "..."); X prints( X! "From the smoldering debris of the Doomsday complex you pick up the"); X prints( X! "pieces of the stack and reflect on how as you risked your life to"); X prints( X! "save Earth, the stack has given its own to save yours. As you walk"); X prints( X! "away, you solemnly swear to repair the stack, for the adventures"); X prints( X! "that lie ahead." X ); X } X break; X*************** X*** 2142,2153 **** X X intro() X { X! int i,j,k; X X clrscr(); X intro1(); X! prints("Press <Enter> to continue"); X! i=get_enter(); X clrscr(); X X prints("Scenario:"); X--- 2156,2170 ---- X X intro() X { X! int ch; X X clrscr(); X intro1(); X! do { X! prints("Scenario and instructions? "); X! (void)eofgets(cmd.cm,max_cmd_size,stdin); X! if ((ch=intlwr(cmd.cm[0]))=='n' || ch == '\n') return; X! } while (ch != 'y'); X clrscr(); X X prints("Scenario:"); X*************** X*** 2182,2198 **** X prints(""); X X prints("Press <Enter> to begin"); X! j=get_enter(); X clrscr(); X- srand( i*i + j + k ); X } X X /*------------------------------------------------------------*/ X! main() X { X! int i, keep_playing; X X! intro(); X X do X { X--- 2199,2222 ---- X prints(""); X X prints("Press <Enter> to begin"); X! (void)eofgets(cmd.cm,max_cmd_size,stdin); X clrscr(); X } X X /*------------------------------------------------------------*/ X! main(argc,argv) X! int argc; X! char *argv[]; X! X { X! int l, fast = 0, keep_playing; X X! for (l=1; l < argc; l++) { X! if(fast=(strcmp(argv[l],"-f")==0)) break; X! } X! if ((argc == 2 && !fast) || argc > 2) X! prints("Only -f for fast start-up is allowed. Unknown options ignored.\n"); X! if (!fast) intro(); X X do X { X*************** X*** 2219,2230 **** X #endif X X if (InDreamWorld( curr_loc )) X! printf("(sleeping) "); X else if (InBookWorld( curr_loc )) X! printf("(reading) "); X X cprintf("Enter command: "); X! gets( cmd.cm ); X if (cmd.cm[0]) X { X AnalyseCommand( &cmd ); X--- 2243,2254 ---- X #endif X X if (InDreamWorld( curr_loc )) X! (void)printf("(sleeping) "); X else if (InBookWorld( curr_loc )) X! (void)printf("(reading) "); X X cprintf("Enter command: "); X! strip_nl(eofgets(cmd.cm,max_cmd_size,stdin)); X if (cmd.cm[0]) X { X AnalyseCommand( &cmd ); X*************** X*** 2237,2248 **** X Ending( zap ); X nl(); X cprintf("Play again (y/n)? "); X! gets( cmd.cm ); X! keep_playing = (cmd.cm[0]!='n' && cmd.cm[0] !='N'); X nl(); X } X while ( keep_playing ); X clrscr(); X- intro1(); X } X X--- 2261,2271 ---- X Ending( zap ); X nl(); X cprintf("Play again (y/n)? "); X! (void)eofgets(cmd.cm,max_cmd_size,stdin); X! keep_playing = (intlwr(cmd.cm[0])!='n'); X nl(); X } X while ( keep_playing ); X clrscr(); X } X X*** tess.doc Mon Dec 12 11:17:08 1988 X--- tess/tess.doc Mon Dec 12 11:21:41 1988 X*************** X*** 34,37 **** X--- 34,40 ---- X so if one word doesn't work, try another. X X+ The game also accepts an argument of -f at run-time for fast start-up. X+ This skips the title screen, scenario and instructions. Very useful X+ for people at lower baud rates. X X Notes: END_OF_FILE if test 17604 -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