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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-08-10 15:52:02 +02:00
parent 8dab67c116
commit 82ed4c9d25

View file

@ -129,6 +129,11 @@
#include "version.h" #include "version.h"
#include "xy.h" #include "xy.h"
/*
* Number of retries when growing land fails
*/
#define NUMTRIES 10
/* do not change these defines */ /* do not change these defines */
#define LANDMIN 1 /* plate altitude for normal land */ #define LANDMIN 1 /* plate altitude for normal land */
#define PLATMIN 36 /* plate altitude for plateau */ #define PLATMIN 36 /* plate altitude for plateau */
@ -188,9 +193,6 @@ struct resource_point uran_conf[] = {
{ 98, 0 }, { 98, 0 },
{ 127, 0 } }; { 127, 0 } };
static void qprint(const char * const fmt, ...)
ATTRIBUTE((format (printf, 1, 2)));
/* /*
* Program arguments and options * Program arguments and options
*/ */
@ -300,30 +302,29 @@ static unsigned short *distance;
static int *bfs_queue; static int *bfs_queue;
static int bfs_queue_head, bfs_queue_tail; static int bfs_queue_head, bfs_queue_tail;
#define NUMTRIES 10 /* keep trying to grow this many times */
static const char *numletter = static const char *numletter =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static void print_vars(void);
static void qprint(const char * const fmt, ...)
ATTRIBUTE((format (printf, 1, 2)));
static void help(char *); static void help(char *);
static void usage(void); static void usage(void);
static void parse_args(int argc, char *argv[]); static void parse_args(int argc, char *argv[]);
static void allocate_memory(void); static void allocate_memory(void);
static void init(void); static void init(void);
static int drift(void); static int drift(void);
static int 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(int); 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 elevate_prep(void); static void elevate_prep(void);
static void elevate_land(void); static void elevate_land(void);
static void elevate_sea(void); static void elevate_sea(void);
static void write_sects(void);
static void print_vars(void); static void output(void);
static void fl_move(int); static int write_newcap_script(void);
static int grow_islands(void);
/* Debugging aids: */ /* Debugging aids: */
void print_own_map(void); void print_own_map(void);
@ -453,6 +454,18 @@ print_vars(void)
printf("World dimensions: %dx%d\n", WORLD_X, WORLD_Y); 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 static void
help(char *complaint) help(char *complaint)
{ {
@ -1665,15 +1678,3 @@ write_newcap_script(void)
fclose(script); fclose(script);
return 1; 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);
}
}