Implement stub handler for SEED command. Not hooked up to PRNG yet.

This commit is contained in:
Eric S. Raymond 2017-05-24 08:30:06 -04:00
parent 627144354c
commit 65c081a0ac
5 changed files with 29 additions and 13 deletions

View file

@ -65,6 +65,7 @@ L4000: VERB=K;
case 31: goto L8320; /* FLY */ case 31: goto L8320; /* FLY */
case 32: goto L8330; /* LISTEN */ case 32: goto L8330; /* LISTEN */
case 33: goto L8340; /* ZZZZ */ case 33: goto L8340; /* ZZZZ */
case 34: goto L8350; /* SEED */
} }
BUG(23); BUG(23);
@ -105,6 +106,7 @@ L4090: switch (VERB-1) {
case 31: goto L9320; /* FLY */ case 31: goto L9320; /* FLY */
case 32: return(2011); /* LISTEN */ case 32: return(2011); /* LISTEN */
case 33: goto L8340; /* ZZZZ */ case 33: goto L8340; /* ZZZZ */
case 34: goto L8350; /* SEED */
} }
BUG(24); BUG(24);
@ -623,4 +625,6 @@ L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011);
RSPEAK(241); RSPEAK(241);
return(2); return(2);
L8350: printf("I see a SEED command. %s\n", raw_input);
return(2);
} }

View file

@ -1358,6 +1358,7 @@
2032 FLY 2032 FLY
2033 LISTE 2033 LISTE
2034 Z'ZZZ (GETS REPLACED) 2034 Z'ZZZ (GETS REPLACED)
2035 SEED (USED IN REPLAY LOGS, NOT INTENDED FOR PLAYER)
3001 FEE 3001 FEE
3002 FIE 3002 FIE
3003 FOE 3003 FOE

13
main.c
View file

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <getopt.h> #include <getopt.h>
#include <string.h>
#include "main.h" #include "main.h"
#include "misc.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], PARMS[26], PLACE[101], PTEXT[101], RTEXT[278],
SETUP = 0, TABSIZ = 330; SETUP = 0, TABSIZ = 330;
signed char INLINE[LINESIZE+1], MAP1[129], MAP2[129]; 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, long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
@ -448,8 +450,19 @@ L2800: WD1=WD2;
/* Gee, I don't understand. */ /* Gee, I don't understand. */
L3000: SETPRM(1,WD1,WD1X); L3000: SETPRM(1,WD1,WD1X);
/* 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); RSPEAK(254);
goto L2600; goto L2600;
}
/* Verb and object analysis moved to separate module. */ /* Verb and object analysis moved to separate module. */

1
main.h
View file

@ -11,6 +11,7 @@ extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
KTAB[], *LINES, LINK[], LNLENG, LNPOSN, KTAB[], *LINES, LINK[], LNLENG, LNPOSN,
PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ; PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ;
extern signed char INLINE[LINESIZE+1], MAP1[], MAP2[]; extern signed char INLINE[LINESIZE+1], MAP1[], MAP2[];
extern signed char raw_input[LINESIZE+1];
extern FILE *logfp; extern FILE *logfp;
extern bool oldstyle; extern bool oldstyle;
extern lcg_state lcgstate; extern lcg_state lcgstate;

17
misc.c
View file

@ -855,7 +855,7 @@ void fBUG(long NUM) {
#define BUG(NUM) fBUG(NUM) #define BUG(NUM) fBUG(NUM)
#undef MAPLIN #undef MAPLIN
void fMAPLIN(FILE *OPENED) { void fMAPLIN(FILE *OPENED) {
long I, VAL; signed char *cp;
/* Read a line of input, from the specified input source, /* Read a line of input, from the specified input source,
* translate the chars to integers in the range 0-126 and store * translate the chars to integers in the range 0-126 and store
@ -886,21 +886,18 @@ long I, VAL;
if (!oldstyle && SETUP) if (!oldstyle && SETUP)
fputs("> ", stdout); fputs("> ", stdout);
IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED)); IGNORE(fgets(raw_input,sizeof(INLINE)-1,OPENED));
if (feof(OPENED)) { if (feof(OPENED)) {
if (logfp) if (logfp)
fclose(logfp); fclose(logfp);
} else { } else {
if (logfp) if (logfp)
IGNORE(fputs(INLINE+1, logfp)); IGNORE(fputs(raw_input, logfp));
else if (!isatty(0)) else if (!isatty(0))
IGNORE(fputs(INLINE+1, stdout)); IGNORE(fputs(raw_input, stdout));
LNLENG=0; for (cp = raw_input; *cp; cp++)
for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) { INLINE[cp - raw_input + 1]=MAP1[*cp + 1];
VAL=INLINE[I]+1; LNLENG = (cp - raw_input);
INLINE[I]=MAP1[VAL];
if(INLINE[I] != 0)LNLENG=I;
} /* end loop */
LNPOSN=1; LNPOSN=1;
} }
} }