the PRNG seed. Print the seed. From Marc Olzheim.
.I configfile
(by default, the file "econfig" in the data directory is used)
.TP
.I configfile
(by default, the file "econfig" in the data directory is used)
.TP
+.BI \-R\ seed
+Use
+.I seed
+as seed for the pseudo-random number generator. This can be used to reproduce
+a previously created world. (by default the current time and process id of
+the server are used as seed.) The seed used to generate a world is printed
+along with the map.
+.TP
.IR nc
number of continents
.TP
.IR nc
number of continents
.TP
#endif /* aix or linux */
#include <stdio.h>
#endif /* aix or linux */
#include <stdio.h>
#include <fcntl.h>
#include "var.h"
#include "misc.h"
#include <fcntl.h>
#include "var.h"
#include "misc.h"
int *isecs; /* array of how large each island is */
int nc, sc, di, sp, pm, ni, is, id; /* the 8 arguments to this program */
int *isecs; /* array of how large each island is */
int nc, sc, di, sp, pm, ni, is, id; /* the 8 arguments to this program */
+unsigned long rnd_seed; /* optional seed can be passed as an argument */
int *capx, *capy; /* location of the nc capitals */
int *mc, mcc; /* array and counter used for stability
check when perturbing */
int *capx, *capy; /* location of the nc capitals */
int *mc, mcc; /* array and counter used for stability
check when perturbing */
char tbuf[512];
int i = 0;
char tbuf[512];
int i = 0;
- while ((opt = getopt(argc, argv, "ae:ioqs:")) != EOF) {
+ rnd_seed += getpid();
+
+ while ((opt = getopt(argc, argv, "ae:ioqs:R:")) != EOF) {
switch (opt) {
case 'a':
AIRPORT_MARKER = 1;
switch (opt) {
case 'a':
AIRPORT_MARKER = 1;
case 's':
outfile = optarg;
break;
case 's':
outfile = optarg;
break;
+ case 'R':
+ rnd_seed = strtoul(optarg, NULL, 10);
+ break;
if (config_file == NULL) {
sprintf(tbuf, "%s/econfig", datadir);
config_file = tbuf;
if (config_file == NULL) {
sprintf(tbuf, "%s/econfig", datadir);
config_file = tbuf;
if (!quiet && i)
printf("\ntry #%d (out of %d)...", i + 1, NUMTRIES);
qprint("\n\n #*# ...fairland rips open a rift in the datumplane... #*#\n\n");
if (!quiet && i)
printf("\ntry #%d (out of %d)...", i + 1, NUMTRIES);
qprint("\n\n #*# ...fairland rips open a rift in the datumplane... #*#\n\n");
+ if (!quiet)
+ printf("seed is %lu\n", rnd_seed);
qprint("placing capitals...\n");
if (!drift())
qprint("fairland: unstable drift -- try increasisg DRIFT_MAX\n");
qprint("placing capitals...\n");
if (!drift())
qprint("fairland: unstable drift -- try increasisg DRIFT_MAX\n");
{
if (argc < 2 || argc > 8) {
puts("fairland syntax:\n");
{
if (argc < 2 || argc > 8) {
puts("fairland syntax:\n");
- puts("fairland [-e config] [-aiqo] [-s script] <nc> <sc> [<ni>] [<is>] [<sp>] [<pm>] [<di>] [<id>]");
+ puts("fairland [-e config] [-aiqo] [-s script] [-R seed] <nc> <sc> [<ni>] [<is>] [<sp>] [<pm>] [<di>] [<id>]");
puts("-q = quiet, -o = no ore produced");
puts("-a = Airport marker for continents, -i = islands not distinct");
puts("-q = quiet, -o = no ore produced");
puts("-a = Airport marker for continents, -i = islands not distinct");
- printf("-e = read config file, -s = name of script (default %s)\n",
+ puts("-R = seed to use for random, -e = read config file");
+ printf("-s = name of script (default %s)\n",
outfile);
puts("nc = number of continents [MANDATORY]");
puts("sc = continent size [MANDATORY]");
outfile);
puts("nc = number of continents [MANDATORY]");
puts("sc = continent size [MANDATORY]");
allocate_memory(void)
{
int i;
allocate_memory(void)
{
int i;
#if !defined(_WIN32)
the_file =
#if !defined(_WIN32)
the_file =
sects = (struct sctstr **)calloc(YSIZE, sizeof(struct sctstr *));
for (i = 0; i < YSIZE; i++)
sects[i] = §sbuf[XSIZE * i];
sects = (struct sctstr **)calloc(YSIZE, sizeof(struct sctstr *));
for (i = 0; i < YSIZE; i++)
sects[i] = §sbuf[XSIZE * i];
- time(&now);
-#if !defined(_WIN32)
- srandom(now + getpid());
-#else
- srandom(now);
-#endif
capx = (int *)calloc(nc, sizeof(int));
capy = (int *)calloc(nc, sizeof(int));
vector = (int *)calloc(WORLD_X + WORLD_Y, sizeof(int));
capx = (int *)calloc(nc, sizeof(int));
capy = (int *)calloc(nc, sizeof(int));
vector = (int *)calloc(WORLD_X + WORLD_Y, sizeof(int));