X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=a656cbc24e22823699ec9c2a132942f9a0a03626;hb=5c4fdc35ebeb58655c8d6ae7a2f883395f49ca0c;hp=e025c78807f585d76a2db794d2c9cb79a970344e;hpb=c703bd78d9db22fbaef43efb798e2ae2e2cd0d9e;p=open-adventure.git diff --git a/misc.c b/misc.c index e025c78..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, 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) { @@ -761,8 +763,7 @@ long TSTBIT; void set_seed(long seedval) { - srand(seedval); - lcgstate.x = (unsigned long) rand() % lcgstate.m; + lcgstate.x = (unsigned long) seedval % lcgstate.m; } unsigned long get_next_lcg_value(void) @@ -855,8 +856,8 @@ void fBUG(long NUM) { #define BUG(NUM) fBUG(NUM) #undef MAPLIN void fMAPLIN(FILE *OPENED) { - signed char *cp; - +long I, VAL; + /* 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: @@ -887,21 +888,24 @@ void fMAPLIN(FILE *OPENED) { if (!oldstyle && SETUP && OPENED == stdin) fputs("> ", stdout); do { - IGNORE(fgets(raw_input,sizeof(INLINE)-1,OPENED)); + IGNORE(fgets(rawbuf,sizeof(rawbuf)-1,OPENED)); } while - /* allow comments in logfiles */ - (!feof(OPENED) && raw_input[0] == '#'); + (!feof(OPENED) && rawbuf[0] == '#'); if (feof(OPENED)) { if (logfp && OPENED == stdin) fclose(logfp); } else { - if (logfp) - IGNORE(fputs(raw_input, logfp)); + if (logfp && OPENED == stdin) + IGNORE(fputs(rawbuf, logfp)); else if (!isatty(0)) - IGNORE(fputs(raw_input, stdout)); - for (cp = raw_input; *cp; cp++) - INLINE[cp - raw_input + 1]=MAP1[*cp + 1]; - LNLENG = (cp - raw_input); + IGNORE(fputs(rawbuf, stdout)); + strcpy(INLINE+1, rawbuf); + 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 */ LNPOSN=1; } }