]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/ef_verify.c
Update copyright notice
[empserver] / src / lib / common / ef_verify.c
index fb677145fb54d9d98009695612a23d5b90b01124..7660507480da44d9bf910f32b04d2c177e84731e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  ef_verify.c: Verify game configuration
- * 
+ *
  *  Known contributors to this file:
  *     Ron Koenderink, 2005
  *     Markus Armbruster, 2006-2008
@@ -70,6 +70,25 @@ verify_fail(int type, int row, struct castr *ca, int idx, char *fmt, ...)
     putc('\n', stderr);
 }
 
+static int
+verify_ca(int type)
+{
+    struct castr *ca = ef_cadef(type);
+    int i;
+
+    for (i = 0; ca[i].ca_name; i++) {
+       /*
+        * Virtual selectors must be NSC_EXTRA, because xundump can't
+        * cope with them without setter methods.  Exception: if
+        * EFF_MEM is not set, xundump doesn't touch the table.
+        */
+       if (CANT_HAPPEN((ef_flags(type) & EFF_MEM)
+                       && ca[i].ca_get && !(ca[i].ca_flags & NSC_EXTRA)))
+           ca[i].ca_flags |= NSC_EXTRA;
+    }
+    return 0;
+}
+
 static int
 verify_row(int type, int row)
 {
@@ -80,11 +99,11 @@ verify_row(int type, int row)
     struct valstr val;
     int ret_val = 0;
     int flags = ef_flags(type);
+
     if (flags & EFF_MEM)
-       row_ref = ef_ptr(type, row); 
+       row_ref = ef_ptr(type, row);
     else {
-       row_ref = malloc(empfile[type].size); 
+       row_ref = malloc(empfile[type].size);
        ef_read(type, row, row_ref);
     }
 
@@ -158,7 +177,7 @@ verify_row(int type, int row)
                }
            }
        } while (++j < n);
-    } 
+    }
     if (!(flags & EFF_MEM))
         free(row_ref);
     return ret_val;
@@ -169,19 +188,26 @@ pln_zap_transient_flags(void)
 {
     int i;
     struct plnstr *pp;
+    int dirty = 0;
 
     /* laziness: assumes plane file is EFF_MEM */
     for (i = 0; (pp = getplanep(i)) != NULL; i++) {
+       if (!pp->pln_own)
+           continue;
        if (pp->pln_flags & PLN_LAUNCHED
            && (plchr[pp->pln_type].pl_flags & (P_M | P_O)) != P_O) {
            pp->pln_flags &= ~PLN_LAUNCHED;
-           verify_fail(EF_PLANE, i, NULL, 0, "stuck in the air (patched)");
+           /* FIXME missile should be destroyed instead */
+           dirty = 1;
+           verify_fail(EF_PLANE, i, NULL, 0, "stuck in the air (fixed)");
            /*
             * Can't putplane() here, because pln_prewrite() crashes
             * without a valid player.
             */
        }
     }
+    if (dirty)
+       ef_flush(EF_PLANE);     /* pretty wasteful */
 }
 
 int
@@ -194,6 +220,7 @@ ef_verify()
     for (ep = empfile; ep->name; ep++) {
        if (!ef_cadef(ep->uid))
            continue;
+       verify_ca(ep->uid);
        for (i = 0; i < ef_nelem(ep->uid); i++) {
            retval += verify_row(ep->uid, i);
        }