Mercurial > hg > early-roguelike
comparison rogue3/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 | e5a15b09ce1d |
children | e52a8a7ad4c5 |
comparison
equal
deleted
inserted
replaced
251:e7862a021609 | 252:3d4252fa2ed3 |
---|---|
29 main(int argc, char *argv[], char *envp[]) | 29 main(int argc, char *argv[], char *envp[]) |
30 { | 30 { |
31 char *env; | 31 char *env; |
32 struct linked_list *item; | 32 struct linked_list *item; |
33 struct object *obj; | 33 struct object *obj; |
34 int lowtime; | |
35 time_t now; | |
36 | 34 |
37 md_init(MD_STRIP_CTRL_KEYPAD); | 35 md_init(MD_STRIP_CTRL_KEYPAD); |
38 | 36 |
39 open_score(); | 37 open_score(); |
40 open_log(); | 38 open_log(); |
128 */ | 126 */ |
129 | 127 |
130 if (!use_savedir) | 128 if (!use_savedir) |
131 md_normaluser(); | 129 md_normaluser(); |
132 | 130 |
133 time(&now); | |
134 lowtime = (int) now; | |
135 | |
136 env = getenv("SEED"); | 131 env = getenv("SEED"); |
137 | 132 |
138 if (env) | 133 if (env) |
139 seed = atoi(env); | 134 seed = atoi(env); |
140 else | 135 else |
144 { | 139 { |
145 waswizard = 1; /* don't save scores if SEED specified */ | 140 waswizard = 1; /* don't save scores if SEED specified */ |
146 dnum = seed; | 141 dnum = seed; |
147 } | 142 } |
148 else | 143 else |
149 dnum = lowtime + md_getpid(); | 144 dnum = md_random_seed(); |
150 | 145 |
151 if (wizard || env) | 146 if (wizard || env) |
152 printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum); | 147 printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum); |
153 else | 148 else |
154 printf("Hello %s, just a moment while I dig the dungeon...\n", whoami); | 149 printf("Hello %s, just a moment while I dig the dungeon...\n", whoami); |