#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"
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;
#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 */
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) {
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();
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)");
static void
write_sects(void)
{
- register struct sctstr *sct;
+ struct sctstr *sct;
int c, x, y, total;
/* sct = §s[0][0]; */