comparison rogue5/main.c @ 252:3d4252fa2ed3

Use more portable random seed generation. The new function md_random_seed() has replaced time() + getpid() and similar methods. Putting everything in mdport.c slightly reduces the warnings and workarounds.
author John "Elwin" Edwards
date Sat, 28 Jan 2017 15:49:41 -0500
parents ee250e3646fd
children
comparison
equal deleted inserted replaced
251:e7862a021609 252:3d4252fa2ed3
21 */ 21 */
22 int 22 int
23 main(int argc, char **argv) 23 main(int argc, char **argv)
24 { 24 {
25 char *env; 25 char *env;
26 time_t lowtime;
27 26
28 md_init(); 27 md_init();
29 28
30 #ifdef MASTER 29 #ifdef MASTER
31 /* 30 /*
75 74
76 if ((env = getenv("ROGUEOPTS")) != NULL) 75 if ((env = getenv("ROGUEOPTS")) != NULL)
77 parse_opts(env); 76 parse_opts(env);
78 if (!use_savedir && (env == NULL || whoami[0] == '\0')) 77 if (!use_savedir && (env == NULL || whoami[0] == '\0'))
79 strucpy(whoami, md_getusername(), strlen(md_getusername())); 78 strucpy(whoami, md_getusername(), strlen(md_getusername()));
80 lowtime = time(NULL);
81 if (getenv("SEED") != NULL) 79 if (getenv("SEED") != NULL)
82 { 80 {
83 dnum = atoi(getenv("SEED")); 81 dnum = atoi(getenv("SEED"));
84 noscore = 1; 82 noscore = 1;
85 } 83 }
86 else 84 else
87 dnum = (unsigned int) lowtime + md_getpid(); 85 dnum = md_random_seed();
88 seed = dnum; 86 seed = dnum;
89 87
90 /* 88 /*
91 * check for print-score option 89 * check for print-score option
92 */ 90 */