]> git.pond.sub.org Git - empserver/commitdiff
Split ef_verify() into ef_verify_config(), ef_verify_state()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 10 Jul 2011 15:23:02 +0000 (17:23 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 10 Jul 2011 19:17:01 +0000 (21:17 +0200)
include/file.h
src/lib/common/ef_verify.c
src/lib/subs/fileinit.c
src/util/empdump.c

index a4e2a7e390e866e01313b50b3082badf91c258f8..1c6ec43c071dbb9f91d07e9c9772df52e423c0b2 100644 (file)
@@ -225,7 +225,8 @@ 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(int);
+extern int ef_verify_config(void);
+extern int ef_verify_state(int);
 extern int ef_elt_byname(int, char *);
 
 extern struct empfile empfile[EF_MAX + 1];
index 2017c781eb4f86d2d8658a682a087137f1f8b9ac..e886eb942ee7bb1b5dd877a76a1d5bd561c9c12c 100644 (file)
@@ -312,24 +312,45 @@ verify_products(void)
 }
 
 /*
- * Verify game state and configuration are sane.
+ * Verify game configuration is sane.
+ * Return 0 on success, -1 on failure.
+ */
+int
+ef_verify_config(void)
+{
+    int retval = 0;
+    int i;
+
+    for (i = 0; i < EF_MAX; i++) {
+       if (!EF_IS_GAME_STATE(i) && !EF_IS_VIEW(i))
+           retval |= verify_table(i);
+    }
+
+    /* Special checks */
+    retval |= verify_products();
+    return retval;
+}
+
+/*
+ * Verify game state is 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(int may_put)
+ef_verify_state(int may_put)
 {
-    struct empfile *ep;
     int retval = 0;
+    int i;
 
-    for (ep = empfile; ep->name; ep++)
-       retval |= verify_table(ep->uid);
+    for (i = 0; i < EF_MAX; i++) {
+       if (EF_IS_GAME_STATE(i) || EF_IS_VIEW(i))
+           retval |= verify_table(i);
+    }
 
     /* Special checks */
     retval |= verify_planes(may_put);
     retval |= verify_lands(may_put);
     retval |= verify_nukes(may_put);
-    retval |= verify_products();
     return retval;
 }
index 8e7580127912159fa9614fd7035cc0fc209186af..053d458e95b80b48d03dcfc409d91603393b5e47 100644 (file)
@@ -72,7 +72,9 @@ ef_init_srv(void)
 
     nsc_init();
     ef_open_srv();
-    if (ef_verify(1) < 0)
+    if (ef_verify_config() < 0)
+       exit(EXIT_FAILURE);
+    if (ef_verify_state(1) < 0)
        exit(EXIT_FAILURE);
     global_init();
     unit_cargo_init();
index 652beb0060765952f517993a66ad0a828f488bbd..d2695089bdf8b472aaeef8fccce5212a84972b05 100644 (file)
@@ -150,7 +150,9 @@ main(int argc, char *argv[])
            exit(1);
     }
 
-    if (ef_verify(0) < 0)
+    if (ef_verify_config() < 0)
+       exit(1);
+    if (ef_verify_state(0) < 0)
        exit(1);
 
     /* export to stdout */