diff --git a/include/file.h b/include/file.h index 73816c6f..a4e2a7e3 100644 --- a/include/file.h +++ b/include/file.h @@ -225,7 +225,7 @@ extern int ef_nelem(int); extern int ef_flags(int); extern int ef_byname(char *); extern int ef_byname_from(char *, int *); -extern int ef_verify(void); +extern int ef_verify(int); extern int ef_elt_byname(int, char *); extern struct empfile empfile[EF_MAX + 1]; diff --git a/src/lib/common/ef_verify.c b/src/lib/common/ef_verify.c index a288cb4f..139d0431 100644 --- a/src/lib/common/ef_verify.c +++ b/src/lib/common/ef_verify.c @@ -194,7 +194,7 @@ verify_row(int type, int row) } static void -pln_zap_transient_flags(void) +pln_zap_transient_flags(int may_put) { int i; struct plnstr *pp; @@ -216,12 +216,18 @@ pln_zap_transient_flags(void) */ } } - if (dirty) + if (dirty && may_put) ef_flush(EF_PLANE); /* pretty wasteful */ } +/* + * Verify game state and configuration are sane. + * Correct minor problems, but write corrections to backing files only + * if MAY_PUT is non-zero. + * Return -1 if uncorrected problems remain, else 0. + */ int -ef_verify(void) +ef_verify(int may_put) { struct empfile *ep; int retval = 0; @@ -248,6 +254,6 @@ ef_verify(void) } } - pln_zap_transient_flags(); + pln_zap_transient_flags(may_put); return retval; } diff --git a/src/lib/subs/fileinit.c b/src/lib/subs/fileinit.c index 4664b5e3..8e758012 100644 --- a/src/lib/subs/fileinit.c +++ b/src/lib/subs/fileinit.c @@ -72,7 +72,7 @@ ef_init_srv(void) nsc_init(); ef_open_srv(); - if (ef_verify() < 0) + if (ef_verify(1) < 0) exit(EXIT_FAILURE); global_init(); unit_cargo_init(); diff --git a/src/util/empdump.c b/src/util/empdump.c index 1e929682..652beb00 100644 --- a/src/util/empdump.c +++ b/src/util/empdump.c @@ -150,7 +150,7 @@ main(int argc, char *argv[]) exit(1); } - if (ef_verify() < 0) + if (ef_verify(0) < 0) exit(1); /* export to stdout */