Seed command fully implemented but apparently buggy.
Dwarf appearance is not yet reproducible.
This commit is contained in:
parent
65c081a0ac
commit
cf219e920b
4 changed files with 19 additions and 9 deletions
10
actions1.c
10
actions1.c
|
@ -625,6 +625,14 @@ L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011);
|
|||
RSPEAK(241);
|
||||
return(2);
|
||||
|
||||
L8350: printf("I see a SEED command. %s\n", raw_input);
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
|
5
main.c
5
main.c
|
@ -58,6 +58,7 @@ static void do_command(FILE *);
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ch;
|
||||
time_t starttime = time(NULL);
|
||||
|
||||
/* Adventure (rev 2: 20 treasures) */
|
||||
|
||||
|
@ -101,7 +102,7 @@ int main(int argc, char *argv[]) {
|
|||
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 */
|
||||
|
||||
|
@ -134,6 +135,8 @@ L1: SETUP= -1;
|
|||
LIMIT=330;
|
||||
if(NOVICE)LIMIT=1000;
|
||||
|
||||
if (logfp)
|
||||
fprintf(logfp, "seed %ld\n", starttime);
|
||||
for (;;) {
|
||||
do_command(stdin);
|
||||
}
|
||||
|
|
7
misc.c
7
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,10 +758,9 @@ 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));
|
||||
srand(seedval);
|
||||
lcgstate.x = (unsigned long) rand() % lcgstate.m;
|
||||
}
|
||||
|
||||
|
|
2
misc.h
2
misc.h
|
@ -72,6 +72,6 @@ extern long fIABS(long);
|
|||
#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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue