fairland: Fix checking of distance arguments
main() rejects the distance between continents when it exceeds WORLD_X / 2 and WORLD_Y / 2, and the distance between continents and islands when it exceeds WORLD_Y and WORLD_Y. Nuts. Has always been that way. Reject either when it exceeds the maximum distance between sectors. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
21c311dba2
commit
db71fa497c
1 changed files with 4 additions and 2 deletions
|
@ -382,6 +382,8 @@ usage(void)
|
||||||
static void
|
static void
|
||||||
parse_args(int argc, char *argv[])
|
parse_args(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int dist_max = mapdist(0, 0, WORLD_X / 2, WORLD_Y / 2);
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
help("missing arguments");
|
help("missing arguments");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -448,7 +450,7 @@ parse_args(int argc, char *argv[])
|
||||||
program_name);
|
program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (di > WORLD_X / 2 || di > WORLD_Y / 2) {
|
if (di > dist_max) {
|
||||||
fprintf(stderr, "%s: distance between continents too large\n",
|
fprintf(stderr, "%s: distance between continents too large\n",
|
||||||
program_name);
|
program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -462,7 +464,7 @@ parse_args(int argc, char *argv[])
|
||||||
program_name);
|
program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (id > WORLD_X || id > WORLD_Y) {
|
if (id > dist_max) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: distance from islands to continents too large\n",
|
"%s: distance from islands to continents too large\n",
|
||||||
program_name);
|
program_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue