From: Markus Armbruster Date: Mon, 10 Aug 2020 13:52:02 +0000 (+0200) Subject: fairland: Move qprint() and NUMTRIES X-Git-Tag: v4.4.1~87 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=82ed4c9d2517f6b989cadc386d6f516599e6e917 fairland: Move qprint() and NUMTRIES qprint() was carelessly added at the end of the file in Empire 2, where it's under the "Write a script for placing capitals" headline. Move it to a more sensible place. NUMTRIES was added behind the global variables in Empire 2. Move it before them, and reformat its comment. The order of forward declarations of static functions looks random. Reorder them to match the order of definitions. Signed-off-by: Markus Armbruster --- diff --git a/src/util/fairland.c b/src/util/fairland.c index 338f25967..22a953929 100644 --- a/src/util/fairland.c +++ b/src/util/fairland.c @@ -129,6 +129,11 @@ #include "version.h" #include "xy.h" +/* + * Number of retries when growing land fails + */ +#define NUMTRIES 10 + /* do not change these defines */ #define LANDMIN 1 /* plate altitude for normal land */ #define PLATMIN 36 /* plate altitude for plateau */ @@ -188,9 +193,6 @@ struct resource_point uran_conf[] = { { 98, 0 }, { 127, 0 } }; -static void qprint(const char * const fmt, ...) - ATTRIBUTE((format (printf, 1, 2))); - /* * Program arguments and options */ @@ -300,30 +302,29 @@ static unsigned short *distance; static int *bfs_queue; static int bfs_queue_head, bfs_queue_tail; -#define NUMTRIES 10 /* keep trying to grow this many times */ - static const char *numletter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; +static void print_vars(void); +static void qprint(const char * const fmt, ...) + ATTRIBUTE((format (printf, 1, 2))); 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 int stable(int); +static void fl_move(int); static int grow_continents(void); +static int grow_islands(void); static void create_elevations(void); -static void write_sects(void); -static void output(void); -static int write_newcap_script(void); -static int stable(int); static void elevate_prep(void); static void elevate_land(void); static void elevate_sea(void); - -static void print_vars(void); -static void fl_move(int); -static int grow_islands(void); +static void write_sects(void); +static void output(void); +static int write_newcap_script(void); /* Debugging aids: */ void print_own_map(void); @@ -453,6 +454,18 @@ print_vars(void) printf("World dimensions: %dx%d\n", WORLD_X, WORLD_Y); } +static void +qprint(const char *const fmt, ...) +{ + va_list ap; + + if (!quiet) { + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + } +} + static void help(char *complaint) { @@ -1665,15 +1678,3 @@ write_newcap_script(void) fclose(script); return 1; } - -static void -qprint(const char *const fmt, ...) -{ - va_list ap; - - if (!quiet) { - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - } -}