X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=main.c;h=881578def7c757011166db7608f75a7735a41e50;hb=f5cd343fc6cf580f8e723c30e8bdfd2ddd735e84;hp=ba7df1aee1c7bc01283c09ad21f2cc0d00f0b044;hpb=6ba9a7de7fe7c829a2215f254bfbbbd2a5686584;p=open-adventure.git diff --git a/main.c b/main.c index ba7df1a..881578d 100644 --- a/main.c +++ b/main.c @@ -16,7 +16,7 @@ long ABB[186], ATAB[331], ATLOC[186], BLKLIN = true, DFLAG, KTAB[331], *LINES, LINK[201], LNLENG, LNPOSN, PARMS[26], PLACE[101], PTEXT[101], RTEXT[278], SETUP = 0, TABSIZ = 330; -signed char INLINE[LINESIZE+1], MAP1[129], MAP2[129]; +signed char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, @@ -99,7 +99,8 @@ int main(int argc, char *argv[]) { lcgstate.a = 1093; lcgstate.c = 221587; lcgstate.m = 1048576; - set_seed((long)time(NULL)); + long seedval = (long)time(NULL); + set_seed(seedval); /* Read the database if we have not yet done so */ @@ -132,6 +133,9 @@ L1: SETUP= -1; LIMIT=330; if(NOVICE)LIMIT=1000; + if (logfp) + fprintf(logfp, "seed %ld\n", seedval); + for (;;) { if (!do_command(stdin)) break; @@ -139,6 +143,18 @@ L1: SETUP= -1; score(1); } +static bool fallback_handler(signed char *buf) +/* fallback handler for commands not handled by FORTRANish parser */ +{ + long sv; + if (sscanf(buf, "seed %ld", &sv) == 1) { + set_seed(sv); + printf("Seed set to %ld\n", sv); + return true; + } + return false; +} + static bool do_command(FILE *cmdin) { /* Can't leave cave once it's closing (except by main office). */ @@ -451,6 +467,8 @@ L2800: WD1=WD2; /* Gee, I don't understand. */ L3000: SETPRM(1,WD1,WD1X); + if (fallback_handler(rawbuf)) + return true; RSPEAK(254); goto L2600;