/*
* 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
* ---
*
* ef_verify.c: Verify game configuration
- *
+ *
* Known contributors to this file:
* Ron Koenderink, 2005
* Markus Armbruster, 2006-2008
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)
{
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);
}
}
}
} while (++j < n);
- }
+ }
if (!(flags & EFF_MEM))
free(row_ref);
return ret_val;
{
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
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);
}