X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=2e68901161d0316bf18dae8ac795b5649b55e061;hb=65c081a0acc24707915a2abf80ef64ed70e50f45;hp=320d002a753a6384c768ad5dd42d25809cade628;hpb=8a8770375ebcf69b18749be85838dc46132cbe9f;p=open-adventure.git diff --git a/misc.c b/misc.c index 320d002..2e68901 100644 --- a/misc.c +++ b/misc.c @@ -757,14 +757,11 @@ long TSTBIT; #define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT) -#undef RNDVOC void set_seed_from_time(void) { /* Use the current system time to get seed the ISO rand() function, from which we get a seed for the LCG. */ - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - srand(ts.tv_nsec); + srand(time(NULL)); lcgstate.x = (unsigned long) rand() % lcgstate.m; } @@ -783,6 +780,7 @@ long randrange(long range) return(result); } +#undef RNDVOC long fRNDVOC(long CHAR, long FORCE) { long DIV, I, J, RNDVOC; @@ -857,8 +855,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: @@ -888,21 +886,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; } }