X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=a656cbc24e22823699ec9c2a132942f9a0a03626;hb=f5cd343fc6cf580f8e723c30e8bdfd2ddd735e84;hp=3e0bb4145adcc2182c4c32e1cdd4f3d294c3eab9;hpb=3a2c0ca199cba2efbce5849285c910f02b961441;p=open-adventure.git diff --git a/misc.c b/misc.c index 3e0bb41..a656cbc 100644 --- a/misc.c +++ b/misc.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "main.h" #include "share.h" /* for SETUP */ #include "misc.h" @@ -724,7 +725,8 @@ L2: ATDWRF=I; -/* Utility routines (SETBIT, TSTBIT, set_seed_from_time, get_next_lcg_value, randrange, RNDVOC, BUG) */ +/* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value, + * randrange, RNDVOC, BUG) */ #undef SETBIT long fSETBIT(long BIT) { @@ -759,11 +761,9 @@ long TSTBIT; #define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT) -void set_seed_from_time(void) +void set_seed(long seedval) { - /* Use the current system time to get seed the ISO rand() function, from which we get a seed for the LCG. */ - srand(time(NULL)); - lcgstate.x = (unsigned long) rand() % lcgstate.m; + lcgstate.x = (unsigned long) seedval % lcgstate.m; } unsigned long get_next_lcg_value(void) @@ -886,16 +886,20 @@ long I, VAL; if(MAP2[1] == 0)MPINIT(); if (!oldstyle && SETUP && OPENED == stdin) - fputs("> ", stdout); - IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED)); + fputs("> ", stdout); + do { + IGNORE(fgets(rawbuf,sizeof(rawbuf)-1,OPENED)); + } while + (!feof(OPENED) && rawbuf[0] == '#'); if (feof(OPENED)) { if (logfp && OPENED == stdin) fclose(logfp); } else { - if (logfp) - IGNORE(fputs(INLINE+1, logfp)); + if (logfp && OPENED == stdin) + IGNORE(fputs(rawbuf, logfp)); else if (!isatty(0)) - IGNORE(fputs(INLINE+1, stdout)); + IGNORE(fputs(rawbuf, stdout)); + strcpy(INLINE+1, rawbuf); LNLENG=0; for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) { VAL=INLINE[I]+1;