X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=3e0bb4145adcc2182c4c32e1cdd4f3d294c3eab9;hb=3a2c0ca199cba2efbce5849285c910f02b961441;hp=320d002a753a6384c768ad5dd42d25809cade628;hpb=8a8770375ebcf69b18749be85838dc46132cbe9f;p=open-adventure.git diff --git a/misc.c b/misc.c index 320d002..3e0bb41 100644 --- a/misc.c +++ b/misc.c @@ -173,7 +173,7 @@ void fSETPRM(long FIRST, long P1, long P2) { #define WORD1X (*wORD1X) #define WORD2 (*wORD2) #define WORD2X (*wORD2X) -void fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) { +bool fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) { long JUNK; /* Get a command from the adventurer. Snarf out the first word, pad it with @@ -185,7 +185,8 @@ long JUNK; L10: if(BLKLIN)TYPE0(); MAPLIN(input); - if(input == stdin && feof(stdin)) score(1); + if (feof(input)) + return false; WORD1=GETTXT(true,true,true,0); if(BLKLIN && WORD1 < 0) goto L10; WORD1X=GETTXT(false,true,true,0); @@ -195,7 +196,7 @@ L12: JUNK=GETTXT(false,true,true,0); WORD2X=GETTXT(false,true,true,0); L22: JUNK=GETTXT(false,true,true,0); if(JUNK > 0) goto L22; - if(GETTXT(true,true,true,0) <= 0)return; + if(GETTXT(true,true,true,0) <= 0)return true; RSPEAK(53); goto L10; } @@ -757,14 +758,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 +781,7 @@ long randrange(long range) return(result); } +#undef RNDVOC long fRNDVOC(long CHAR, long FORCE) { long DIV, I, J, RNDVOC; @@ -886,11 +885,11 @@ long I, VAL; if(MAP2[1] == 0)MPINIT(); - if (!oldstyle && SETUP) + if (!oldstyle && SETUP && OPENED == stdin) fputs("> ", stdout); IGNORE(fgets(INLINE+1,sizeof(INLINE)-1,OPENED)); if (feof(OPENED)) { - if (logfp) + if (logfp && OPENED == stdin) fclose(logfp); } else { if (logfp)