From: Eric S. Raymond Date: Wed, 24 May 2017 12:30:06 +0000 (-0400) Subject: Implement stub handler for SEED command. Not hooked up to PRNG yet. X-Git-Tag: seed~63 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=65c081a0acc24707915a2abf80ef64ed70e50f45;p=open-adventure.git Implement stub handler for SEED command. Not hooked up to PRNG yet. --- diff --git a/actions1.c b/actions1.c index 79c0ea7..b8fac67 100644 --- a/actions1.c +++ b/actions1.c @@ -65,6 +65,7 @@ L4000: VERB=K; case 31: goto L8320; /* FLY */ case 32: goto L8330; /* LISTEN */ case 33: goto L8340; /* ZZZZ */ + case 34: goto L8350; /* SEED */ } BUG(23); @@ -105,6 +106,7 @@ L4090: switch (VERB-1) { case 31: goto L9320; /* FLY */ case 32: return(2011); /* LISTEN */ case 33: goto L8340; /* ZZZZ */ + case 34: goto L8350; /* SEED */ } BUG(24); @@ -623,4 +625,6 @@ L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011); RSPEAK(241); return(2); +L8350: printf("I see a SEED command. %s\n", raw_input); + return(2); } diff --git a/adventure.text b/adventure.text index 5ec4034..732be25 100644 --- a/adventure.text +++ b/adventure.text @@ -1358,6 +1358,7 @@ 2032 FLY 2033 LISTE 2034 Z'ZZZ (GETS REPLACED) +2035 SEED (USED IN REPLAY LOGS, NOT INTENDED FOR PLAYER) 3001 FEE 3002 FIE 3003 FOE diff --git a/main.c b/main.c index 4854b69..d93c967 100644 --- a/main.c +++ b/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "main.h" #include "misc.h" @@ -17,6 +18,7 @@ long ABB[186], ATAB[331], ATLOC[186], BLKLIN = true, DFLAG, PARMS[26], PLACE[101], PTEXT[101], RTEXT[278], SETUP = 0, TABSIZ = 330; signed char INLINE[LINESIZE+1], MAP1[129], MAP2[129]; +signed char raw_input[LINESIZE+1]; long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, @@ -448,8 +450,19 @@ L2800: WD1=WD2; /* Gee, I don't understand. */ L3000: SETPRM(1,WD1,WD1X); - RSPEAK(254); - goto L2600; + /* This is a kludge. The command parser we inherited from the base 2.5 + * barfs on numeric tokens. It will fall through to here when it sees + * seed NNNN. Instead of barfing, go straight to the action processor + * where it will examine the raw input. This will fo away when we get + * rid of the obfuscated FORTRANoid input processing. + */ + if (strncmp(raw_input, "seed", 4) == 0) { + I=4090; K=34; + goto Laction; + } else { + RSPEAK(254); + goto L2600; + } /* Verb and object analysis moved to separate module. */ diff --git a/main.h b/main.h index a71b9e3..f4fcf00 100644 --- a/main.h +++ b/main.h @@ -11,6 +11,7 @@ extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG, KTAB[], *LINES, LINK[], LNLENG, LNPOSN, PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ; extern signed char INLINE[LINESIZE+1], MAP1[], MAP2[]; +extern signed char raw_input[LINESIZE+1]; extern FILE *logfp; extern bool oldstyle; extern lcg_state lcgstate; diff --git a/misc.c b/misc.c index b87c769..2e68901 100644 --- a/misc.c +++ b/misc.c @@ -855,8 +855,8 @@ void fBUG(long NUM) { #define BUG(NUM) fBUG(NUM) #undef MAPLIN void fMAPLIN(FILE *OPENED) { -long I, VAL; - + signed char *cp; + /* Read a line of input, from the specified input source, * translate the chars to integers in the range 0-126 and store * them in the common array "INLINE". Integer values are as follows: @@ -886,21 +886,18 @@ long I, VAL; if (!oldstyle && SETUP) fputs("> ", stdout); - IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED)); + IGNORE(fgets(raw_input,sizeof(INLINE)-1,OPENED)); if (feof(OPENED)) { if (logfp) fclose(logfp); } else { if (logfp) - IGNORE(fputs(INLINE+1, logfp)); + IGNORE(fputs(raw_input, logfp)); else if (!isatty(0)) - IGNORE(fputs(INLINE+1, stdout)); - LNLENG=0; - for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) { - VAL=INLINE[I]+1; - INLINE[I]=MAP1[VAL]; - if(INLINE[I] != 0)LNLENG=I; - } /* end loop */ + IGNORE(fputs(raw_input, stdout)); + for (cp = raw_input; *cp; cp++) + INLINE[cp - raw_input + 1]=MAP1[*cp + 1]; + LNLENG = (cp - raw_input); LNPOSN=1; } }