Add -r option to selectrandom seed

This commit is contained in:
rob 2022-08-28 14:06:22 +10:00
parent d4eccd8f6b
commit d592337f32
2 changed files with 2333 additions and 1303 deletions

3620
log.txt

File diff suppressed because it is too large Load Diff

16
nexus.c
View File

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