Implement stub handler for SEED command. Not hooked up to PRNG yet.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 24 May 2017 12:30:06 +0000 (08:30 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 24 May 2017 12:30:06 +0000 (08:30 -0400)
actions1.c
adventure.text
main.c
main.h
misc.c

index 79c0ea719c497ac138efb711af7b5c68beab3243..b8fac67a3a162a94bbb2c6df66c339f8fedf2d8c 100644 (file)
@@ -65,6 +65,7 @@ L4000:        VERB=K;
                case 31: goto L8320;    /* FLY */
                case 32: goto L8330;    /* LISTEN */
                case 33: goto L8340;    /* ZZZZ */
                case 31: goto L8320;    /* FLY */
                case 32: goto L8330;    /* LISTEN */
                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 32: return(2011);  /* LISTEN */
                case 33: goto L8340;    /* ZZZZ */
                case 31: goto L9320;    /* FLY */
                case 32: return(2011);  /* LISTEN */
                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);
         return(2);
 
        RSPEAK(241);
         return(2);
 
+L8350: printf("I see a SEED command. %s\n", raw_input);
+        return(2);
 }
 }
index 5ec4034e22935c6cac8c229b1506d9c6757951d8..732be253476c47d849dff8867e9f215ba20cef87 100644 (file)
 2032   FLY
 2033   LISTE
 2034   Z'ZZZ   (GETS REPLACED)
 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
 3001   FEE
 3002   FIE
 3003   FOE
diff --git a/main.c b/main.c
index 4854b695f187bb55545f8b5adc0c40f49a5ba56e..d93c9671f518d1451b1fe55e962bcc2b554562e6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <getopt.h>
+#include <string.h>
 #include "main.h"
 
 #include "misc.h"
 #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];
                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,
 
 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);
 /*  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. */
 
 
 /* Verb and object analysis moved to separate module. */
 
diff --git a/main.h b/main.h
index a71b9e3ff113bce06f1915f1d36daf7e4a5acec3..f4fcf00423595ffd5226e54525368219bccc655f 100644 (file)
--- 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[];
                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;
 extern FILE *logfp;
 extern bool oldstyle;
 extern lcg_state lcgstate;
diff --git a/misc.c b/misc.c
index b87c76913f6aab68b500979b20adce84fb05d443..2e68901161d0316bf18dae8ac795b5649b55e061 100644 (file)
--- 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) {
 #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:
 /*  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);
 
        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)
        if (feof(OPENED)) {
                if (logfp)
                        fclose(logfp);
        } else {
                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));
-               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;
        }
 }
                LNPOSN=1;
        }
 }