Dwarf appearance is not yet reproducible.
RSPEAK(241);
return(2);
-L8350: printf("I see a SEED command. %s\n", raw_input);
- return(2);
+/* Seed. Expected in game logs to replicate the LCG state */
+
+L8350: {
+ long sv;
+ int n;
+ n = sscanf(raw_input, "seed %ld\n", &sv);
+ if (n >= 1)
+ set_seed(sv);
+ return(2);
+ }
}
int main(int argc, char *argv[]) {
int ch;
+ time_t starttime = time(NULL);
/* Adventure (rev 2: 20 treasures) */
lcgstate.a = 1093;
lcgstate.c = 221587;
lcgstate.m = 1048576;
- set_seed_from_time();
+ set_seed((long)starttime);
/* Read the database if we have not yet done so */
LIMIT=330;
if(NOVICE)LIMIT=1000;
+ if (logfp)
+ fprintf(logfp, "seed %ld\n", starttime);
for (;;) {
do_command(stdin);
}
-/* 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) {
#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)
#define IABS(N) fIABS(N)
extern long fMOD(long,long);
#define MOD(N,M) fMOD(N,M)
-extern void set_seed_from_time(void);
+extern void set_seed(long);
extern unsigned long get_next_lcg_value(void);
extern long randrange(long);