#include <unistd.h>
#endif /* aix or linux */
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define PLATMIN 36 /* plate altitude for plateau */
#define HIGHMIN 98 /* plate altitude for mountains */
-static void qprint(const char *str);
+static void qprint(const char * const fmt, ...)
+ ATTRIBUTE((format (printf, 1, 2)));
static const char *outfile = "newcap_script";
/* mark the continents with a * so you can tell them
do {
init();
- if (!quiet && i)
- printf("\ntry #%d (out of %d)...", i + 1, NUMTRIES);
+ if (i)
+ qprint("\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("seed is %lu\n", rnd_seed);
qprint("placing capitals...\n");
if (!drift())
qprint("fairland: unstable drift -- try increasisg DRIFT_MAX\n");
exit(-1);
output();
write_newcap_script();
- if (!ORE && !quiet)
- printf("\t*** Resources have not been added ***\n");
+ if (!ORE)
+ qprint("\t*** Resources have not been added ***\n");
exit(0);
}
} while (!done && coast_search < COAST_SEARCH_MAX &&
(secs == 1 || x != sx || y != sy));
if (!done && c < nc) {
- if (!quiet)
- printf("fairland: error -- continent %c had no room to grow!\n",
- numletter[c % 62]);
+ qprint("fairland: error -- continent %c had no room to grow!\n",
+ numletter[c % 62]);
fl_status |= STATUS_NO_ROOM;
}
return done;
grow_one_sector(c);
}
}
- if (fl_status && !quiet)
- printf("Only managed to grow %d out of %d sectors.\n", secs, sc);
+ if (fl_status)
+ qprint("Only managed to grow %d out of %d sectors.\n", secs, sc);
ctot = nc;
}
++secs;
find_coast(c);
} while (secs < isiz && grow_one_sector(c));
- if (quiet == 0)
- printf(" %d(%d)", c - nc + 1, secs);
+ qprint(" %d(%d)", c - nc + 1, secs);
isecs[c] = secs;
ctot = c;
}
fprintf(script, "add %d visitor visitor v i\n", c + 1);
++c;
fclose(script);
- if (quiet == 0)
- printf("\n\nA script for adding all the countries can be found in \"%s\".\n",
- outfile);
+ qprint("\n\nA script for adding all the countries can be found in \"%s\".\n",
+ outfile);
return 0;
}
static void
-qprint(const char *str)
+qprint(const char * const fmt, ...)
{
- if (quiet == 0)
- fputs(str, stdout);
+ va_list ap;
+
+ if (!quiet) {
+ va_start(ap, fmt);
+ vfprintf(stdout, fmt, ap);
+ va_end(ap);
+ }
}
static void