X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=main.c;h=6c5512721c9daddaae1079ad9259ee2bb17a8946;hb=0f126b0cb5f8539f456f2d7f2c06d8f32c2491c2;hp=a72d3b55d88211a314a8253212628b42ed950887;hpb=df46df697917304a78ae9d3392ffff9b535ae5a5;p=open-adventure.git diff --git a/main.c b/main.c index a72d3b5..6c55127 100644 --- a/main.c +++ b/main.c @@ -8,16 +8,16 @@ #include #include #include -#include "main.h" +#include +#include "advent.h" #include "database.h" -#include "misc.h" long ABB[186], ATLOC[186], BLKLIN = true, DFLAG, DLOC[7], FIXED[101], HOLDNG, LINK[201], LNLENG, LNPOSN, PARMS[26], PLACE[101], SETUP = 0; -signed char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; +char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, @@ -26,10 +26,10 @@ long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, DKILL, DOOR, DPRSSN, DRAGON, DSEEN[7], DTOTAL, DWARF, EGGS, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD, GRATE, HINT, HINTED[21], HINTLC[21], - HNTSIZ = 20, I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK, + I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK, KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LL, LMWARN, LOC, LOCK, LOOK, - MAGZIN, MAXDIE, MAXTRS, MESH = 123456789, + MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ, ODLOC[7], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER, @@ -38,7 +38,7 @@ long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK, STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT, TRNDEX, TRNLUZ, TROLL, TROLL2, - TRVSIZ = 885, TURNS, URN, V1, V2, VASE, VEND, VERB, + TURNS, URN, V1, V2, VASE, VEND, VERB, VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X, WZDARK = false, ZZWORD; FILE *logfp; @@ -109,7 +109,8 @@ int main(int argc, char *argv[]) { lcgstate.a = 1093; lcgstate.c = 221587; lcgstate.m = 1048576; - long seedval = (long)time(NULL); + srand(time(NULL)); + long seedval = (long)rand(); set_seed(seedval); /* Read the database if we have not yet done so */ @@ -130,7 +131,7 @@ int main(int argc, char *argv[]) { L1: SETUP= -1; I=0; - ZZWORD=RNDVOC(3,0)+MESH*2; + ZZWORD=RNDVOC(3,0); NOVICE=YES(stdin, 65,1,0); NEWLOC=1; LOC=1; @@ -139,7 +140,7 @@ L1: SETUP= -1; if (logfp) fprintf(logfp, "seed %ld\n", seedval); - + for (;;) { if (!do_command(stdin)) break; @@ -147,15 +148,17 @@ L1: SETUP= -1; score(1); } -static bool fallback_handler(signed char *buf) +static bool fallback_handler(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); + // autogenerated, so don't charge user time for it. + --TURNS; // here we reconfigure any global game state that uses random numbers - ZZWORD=RNDVOC(3,0)+MESH*2; + ZZWORD=RNDVOC(3,0); return true; } return false; @@ -399,8 +402,7 @@ L2600: if(COND[LOC] < CONDS) goto L2603; L2602: /*etc*/ ; } /* end loop */ -/* Kick the random number generator just to add variety to the chase. Also, - * if closing time, check for any objects being toted with PROP < 0 and set +/* If closing time, check for any objects being toted with PROP < 0 and set * the prop to -1-PROP. This way objects won't be described until they've * been picked up and put down separate from their respective piles. Don't * tick CLOCK1 unless well into cave (and not at Y2). */ @@ -920,4 +922,5 @@ L12400: LIMIT= -1; L18999: RSPEAK(SPK); L19000: RSPEAK(136); score(0); + return true; }