Mercurial > hg > early-roguelike
diff arogue5/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 | 56e748983fa8 |
children | d3968e9cb98d |
line wrap: on
line diff
--- a/arogue5/main.c Sat Jan 28 11:45:36 2017 -0500 +++ b/arogue5/main.c Sat Jan 28 15:49:41 2017 -0500 @@ -49,8 +49,6 @@ main(int argc, char *argv[], char *envp[]) { register char *env; - int lowtime; - time_t now; char *roguedir; roguedir = md_getroguedir(); @@ -100,7 +98,7 @@ strucpy(whoami, md_getusername(), strlen(md_getusername())); if (env == NULL || fruit[0] == '\0') { - md_srand((long)(getpid()+time(0))); + md_srand(md_random_seed()); strcpy(fruit, funfruit[rnd(NFRUIT)]); } @@ -177,10 +175,9 @@ else if (argc == 2) if (!restore(argv[1], envp)) /* Note: restore will never return */ exit(1); - lowtime = (int) time(&now); dnum = (wizard && getenv("SEED") != NULL ? atoi(getenv("SEED")) : - lowtime + getpid()); + md_random_seed()); if (wizard) printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum); else