Mercurial > hg > early-roguelike
comparison rogue4/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 | 1b73a8641b37 |
| children | 17005af49963 |
comparison
equal
deleted
inserted
replaced
| 251:e7862a021609 | 252:3d4252fa2ed3 |
|---|---|
| 27 */ | 27 */ |
| 28 int | 28 int |
| 29 main(int argc, char *argv[], char *envp[]) | 29 main(int argc, char *argv[], char *envp[]) |
| 30 { | 30 { |
| 31 register char *env; | 31 register char *env; |
| 32 int lowtime; | |
| 33 | 32 |
| 34 md_init(); | 33 md_init(); |
| 35 | 34 |
| 36 #ifndef DUMP | 35 #ifndef DUMP |
| 37 #ifdef SIGQUIT | 36 #ifdef SIGQUIT |
| 136 } | 135 } |
| 137 | 136 |
| 138 if (!use_savedir) | 137 if (!use_savedir) |
| 139 md_normaluser(); | 138 md_normaluser(); |
| 140 | 139 |
| 141 lowtime = (int) time(NULL); | |
| 142 | |
| 143 #ifdef WIZARD | 140 #ifdef WIZARD |
| 144 noscore = wizard; | 141 noscore = wizard; |
| 145 #endif | 142 #endif |
| 146 if (getenv("SEED") != NULL) | 143 if (getenv("SEED") != NULL) |
| 147 { | 144 { |
| 148 dnum = atoi(getenv("SEED")); | 145 dnum = atoi(getenv("SEED")); |
| 149 noscore = TRUE; | 146 noscore = TRUE; |
| 150 } | 147 } |
| 151 else | 148 else |
| 152 dnum = lowtime + getpid(); | 149 dnum = md_random_seed(); |
| 153 #ifdef WIZARD | 150 #ifdef WIZARD |
| 154 if (wizard) | 151 if (wizard) |
| 155 printf("Hello %s, welcome to dungeon #%d", whoami, dnum); | 152 printf("Hello %s, welcome to dungeon #%d", whoami, dnum); |
| 156 else | 153 else |
| 157 #endif | 154 #endif |
