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 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