]> git.pond.sub.org Git - empserver/blobdiff - src/util/fairland.c
(main) [_WIN32]: remove getpid() from the random seed as
[empserver] / src / util / fairland.c
index 0b803b51b6063d059df63d48742d4a89d33e027f..4c5e30281ad4faf19f79c063d03c0f08b4e552fd 100644 (file)
@@ -67,12 +67,14 @@ static int quiet = 0;
 #if defined(aix) || defined(linux) || defined(solaris)
 #include <unistd.h>
 #endif /* aix or linux */
+#if defined(_WIN32)
+#include "../lib/gen/getopt.h"
+#endif
 
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
-#include "var.h"
 #include "misc.h"
 #include "power.h"
 #include "nat.h"
@@ -92,7 +94,8 @@ static int quiet = 0;
 static void qprint(const char * const fmt, ...)
     ATTRIBUTE((format (printf, 1, 2)));
 
-static const char *outfile = "newcap_script";
+#define DEFAULT_OUTFILE_NAME "newcap_script"
+static const char *outfile = DEFAULT_OUTFILE_NAME;
 /* mark the continents with a * so you can tell them
    from the islands 1 = mark, 0 = don't mark. */
 static int AIRPORT_MARKER = 0;
@@ -123,13 +126,7 @@ static int DISTINCT_ISLANDS = 1;
 #if !defined(_WIN32)
 #define max(a,b) (a>b?a:b)
 #endif
-#ifndef SRANDOM
-#define SRANDOM srandom
-#endif
-#ifndef RANDOM
-#define RANDOM random
-#endif
-#define rnd(x) (RANDOM() % (x))
+#define rnd(x) (random() % (x))
 
 int secs;                      /* number of sectors grown */
 int ctot;                      /* total number of continents and islands grown */
@@ -193,15 +190,11 @@ int
 main(int argc, char *argv[])
 {
     int opt;
-    extern int optind;
-    extern char *optarg;
     char *config_file = NULL;
     char tbuf[512];
     int i = 0;
 
     rnd_seed = time(NULL);
-#if !defined(_WIN32)
-    rnd_seed += getpid();
 
     while ((opt = getopt(argc, argv, "ae:ioqs:R:")) != EOF) {
        switch (opt) {
@@ -228,19 +221,14 @@ main(int argc, char *argv[])
            break;
        }
     }
-#endif
-    SRANDOM(rnd_seed);
+    srandom(rnd_seed);
     if (config_file == NULL) {
        sprintf(tbuf, "%s/econfig", datadir);
        config_file = tbuf;
     }
     emp_config(config_file);
 
-#if !defined(_WIN32)
     parse_args(argc - optind, argv + optind);
-#else
-    parse_args(argc - 1, argv + 1);
-#endif
     if (allocate_memory() == -1)
        exit(-1);
     print_vars();
@@ -320,8 +308,8 @@ parse_args(int argc, char *argv[])
        puts("-q = quiet, -o = no ore produced");
        puts("-a = Airport marker for continents, -i = islands not distinct");
        puts("-R = seed to use for random, -e = read config file");
-       printf("-s = name of script (default %s)\n",
-              outfile);
+       printf("-s = name of script (default %s)\n",
+              DEFAULT_OUTFILE_NAME);
        puts("nc = number of continents [MANDATORY]");
        puts("sc = continent size [MANDATORY]");
        puts("ni = number of islands (default = nc)");
@@ -1068,7 +1056,7 @@ add_resources(struct sctstr *sct)
 static void
 write_sects(void)
 {
-    register struct sctstr *sct;
+    struct sctstr *sct;
     int c, x, y, total;
 
     /*  sct = &sects[0][0]; */