Add -r option to selectrandom seed
This commit is contained in:
parent
d4eccd8f6b
commit
d592337f32
16
nexus.c
16
nexus.c
|
@ -136,6 +136,9 @@ int flagcheck = B_FALSE;
|
|||
extern race_t **raceposs;
|
||||
extern int *xpposs;
|
||||
|
||||
// random seed
|
||||
long seed = 0;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
object_t *o;
|
||||
char welcomemsg[BUFLEN];
|
||||
|
@ -153,7 +156,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
atexit(cleanup);
|
||||
|
||||
while ((ch = getopt(argc, argv, "f:hsS:")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "f:hr:sS:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
playerfile = fopen(optarg, "rt");
|
||||
|
@ -162,6 +165,9 @@ int main(int argc, char **argv) {
|
|||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
seed = atol(optarg);
|
||||
break;
|
||||
case 's':
|
||||
showhiscores(NULL, 1, 10);
|
||||
exit(0);
|
||||
|
@ -1604,10 +1610,12 @@ char getpctletter(float num, float max) {
|
|||
|
||||
int init(void) {
|
||||
int i;
|
||||
long l;
|
||||
// random numbers
|
||||
l = time(NULL);
|
||||
srand(l);
|
||||
if (seed) {
|
||||
srand(seed);
|
||||
} else {
|
||||
srand(time(NULL));
|
||||
}
|
||||
//sranddev();
|
||||
|
||||
// preset conditions
|
||||
|
|
Loading…
Reference in New Issue