X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=f1bd954c7932cdf9c463c072c2f1a970b166e340;hb=cf219e920bb038c9ac2c879adcfd048dc13bf3bc;hp=b87c76913f6aab68b500979b20adce84fb05d443;hpb=627144354c9d16d1d6d6ea0fb2d5925ab16fffcb;p=open-adventure.git diff --git a/misc.c b/misc.c index b87c769..f1bd954 100644 --- a/misc.c +++ b/misc.c @@ -723,7 +723,7 @@ 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) { @@ -758,11 +758,10 @@ 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; + srand(seedval); + lcgstate.x = (unsigned long) rand() % lcgstate.m; } unsigned long get_next_lcg_value(void) @@ -855,8 +854,8 @@ void fBUG(long NUM) { #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: @@ -886,21 +885,18 @@ long I, VAL; 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) - IGNORE(fputs(INLINE+1, logfp)); + IGNORE(fputs(raw_input, logfp)); 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; } }