-#if !defined(_WIN32)
-#define max(a,b) (a>b?a:b)
-#endif
-#define rnd(x) (random() % (x))
-
-int secs; /* number of sectors grown */
-int ctot; /* total number of continents and islands grown */
-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 *capx, *capy; /* location of the nc capitals */
-int *mc, mcc; /* array and counter used for stability
- check when perturbing */
-int spike; /* are we spiking? */
-int mind; /* the final distance between capitals that
- we achieved */
-int dirx[] = {-2, -1, 1, 2, 1, -1}; /* gyujnb */
-int diry[] = {0, -1, -1, 0, 1, 1};
-
-int **own; /* owner of the sector. -1 means water */
-int **elev; /* elevation of the sectors */
-int **sectx, **secty; /* the sectors for each continent */
-int **sectc; /* which sectors are on the coast? */
-int *vector; /* used for measuring distances */
-int *weight; /* used for placing mountains */
-int *dsea, *dmoun; /* the dist to the ocean and mountain */
-int the_file; /* the file we write everything to */
-struct sctstr **sects;
-struct sctstr *sectsbuf;
-int fl_status; /* is anything wrong? */
-#define STATUS_NO_ROOM (1) /* there was no room to grow */
-#define NUMTRIES 10 /* keep trying to grow this many times */
-
-const char *numletter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-void parse_args(int argc, char *argv[]);
-int allocate_memory(void);
-void init(void);
-int drift(void);
-void grow_continents(void);
-void create_elevations(void);
-void write_sects(void);
-int write_file(void);
-void output(void);
-int write_newcap_script(void);
-int stable(void);
-void elevate_land(void);
-void elevate_sea(void);
-void translate_continents(void);
-int map_symbol(int x, int y);
-static void fl_sct_init(coord x, coord y, s_char *ptr);
-
-void print_vars();
-void fl_move(int);
-void next_coast();
-void grow_islands();
+
+static int secs; /* number of sectors grown */
+static int ctot; /* total number of continents and islands grown */
+static int *isecs; /* array of how large each island is */
+
+static int nc, sc, di, sp, pm, ni, is, id; /* the 8 args to this program */
+static unsigned long rnd_seed; /* optional seed argument */
+static int *capx, *capy; /* location of the nc capitals */
+static int *mc, mcc; /* array and counter used for stability
+ check when perturbing */
+static int spike; /* are we spiking? */
+static int mind; /* the final distance between capitals that
+ we achieved */
+static int dirx[] = { -2, -1, 1, 2, 1, -1 }; /* gyujnb */
+static int diry[] = { 0, -1, -1, 0, 1, 1 };
+
+static int **own; /* owner of the sector. -1 means water */
+static int **elev; /* elevation of the sectors */
+static int **sectx, **secty; /* the sectors for each continent */
+static int **sectc; /* which sectors are on the coast? */
+static int *vector; /* used for measuring distances */
+static int *weight; /* used for placing mountains */
+static int *dsea, *dmoun; /* the dist to the ocean and mountain */
+static int fl_status; /* is anything wrong? */
+#define STATUS_NO_ROOM 1 /* there was no room to grow */
+#define NUMTRIES 10 /* keep trying to grow this many times */
+
+static const char *numletter =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+static void help(char *);
+static void usage(void);
+static void parse_args(int argc, char *argv[]);
+static void allocate_memory(void);
+static void init(void);
+static int drift(void);
+static void grow_continents(void);
+static void create_elevations(void);
+static void write_sects(void);
+static void output(void);
+static int write_newcap_script(void);
+static int stable(void);
+static void elevate_land(void);
+static void elevate_sea(void);
+static int map_symbol(int x, int y);
+static void set_coastal_flags(void);
+
+static void print_vars(void);
+static void fl_move(int);
+static void next_coast(int c, int x, int y, int *xp, int *yp);
+static void grow_islands(void);