fairland: Make write_newcap_script() failure fatal
When write_newcap_script() fails, it complains to stderr and fails. main() doesn't bother to check for failure. Has always been that way. Fix main() to check. Also adjust write_newcap_script() to return one on success, zero on failure, like the other functions do. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
b28090a6b3
commit
1faab45815
1 changed files with 4 additions and 3 deletions
|
@ -320,7 +320,8 @@ main(int argc, char *argv[])
|
||||||
qprint("designating sectors...\n");
|
qprint("designating sectors...\n");
|
||||||
if (ORE)
|
if (ORE)
|
||||||
qprint("adding resources...\n");
|
qprint("adding resources...\n");
|
||||||
write_newcap_script();
|
if (!write_newcap_script())
|
||||||
|
exit(1);
|
||||||
|
|
||||||
if (chdir(gamedir)) {
|
if (chdir(gamedir)) {
|
||||||
fprintf(stderr, "Can't chdir to %s (%s)\n", gamedir, strerror(errno));
|
fprintf(stderr, "Can't chdir to %s (%s)\n", gamedir, strerror(errno));
|
||||||
|
@ -1279,7 +1280,7 @@ write_newcap_script(void)
|
||||||
|
|
||||||
if (!script) {
|
if (!script) {
|
||||||
printf("fairland: error, unable to write to %s.\n", outfile);
|
printf("fairland: error, unable to write to %s.\n", outfile);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; c < nc; ++c) {
|
for (c = 0; c < nc; ++c) {
|
||||||
|
@ -1290,7 +1291,7 @@ write_newcap_script(void)
|
||||||
}
|
}
|
||||||
fprintf(script, "add %d visitor visitor v\n", c + 1);
|
fprintf(script, "add %d visitor visitor v\n", c + 1);
|
||||||
fclose(script);
|
fclose(script);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue