+static int
+verify_table(int type)
+{
+ int retval = 0;
+ int i;
+
+ verify_ca(type);
+ for (i = 0; i < ef_nelem(type); i++)
+ retval |= verify_row(type, i);
+ return retval;
+}
+
+static int
+verify_sectors(int may_put)
+{
+ int i;
+ struct sctstr *sp;
+ coord x, y;
+
+ /* laziness: assumes sector file is EFF_MEM */
+ for (i = 0; (sp = getsectid(i)); i++) {
+ sctoff2xy(&x, &y, sp->sct_uid);
+ if (sp->sct_x != x || sp->sct_y != y) {
+ sp->sct_x = x;
+ sp->sct_y = y;
+ if (may_put)
+ putsect(sp);
+ verify_fail(EF_SECTOR, i, NULL, 0, "bogus coordinates (fixed)");
+ }
+ }
+ return 0;
+}
+
+static int
+verify_planes(int may_put)
+{
+ int retval = 0;
+ int i;
+ struct plnstr *pp;
+
+ /* laziness: assumes plane file is EFF_MEM */
+ for (i = 0; (pp = getplanep(i)); i++) {
+ if (pp->pln_own) {
+ if (pp->pln_flags & PLN_LAUNCHED
+ && (plchr[pp->pln_type].pl_flags & (P_M | P_O)) != P_O) {
+ pp->pln_flags &= ~PLN_LAUNCHED;
+ /* FIXME missile should be destroyed instead */
+ if (may_put)
+ putplane(i, pp);
+ verify_fail(EF_PLANE, i, NULL, 0, "stuck in the air (fixed)");
+ }
+ if (pp->pln_ship >= 0 && pp->pln_land >= 0) {
+ verify_fail(EF_PLANE, i, NULL, 0, "on two carriers");
+ retval = -1;
+ }
+ } else {
+ if (pp->pln_ship >= 0 || pp->pln_land >= 0) {
+ pp->pln_ship = pp->pln_land = -1;
+ if (may_put)
+ putplane(i, pp);
+ verify_fail(EF_PLANE, i, NULL, 0,
+ "ghost stuck on carrier (fixed)");
+ }
+ }
+ }
+ return retval;
+}
+
+static int
+verify_lands(int may_put)
+{
+ int retval = 0;
+ int i;
+ struct lndstr *lp;
+
+ /* laziness: assumes land file is EFF_MEM */
+ for (i = 0; (lp = getlandp(i)); i++) {
+ if (lp->lnd_own) {
+ if (lp->lnd_ship >= 0 && lp->lnd_land >= 0) {
+ verify_fail(EF_LAND, i, NULL, 0, "on two carriers");
+ retval = -1;
+ }
+ } else {
+ if (lp->lnd_ship >= 0 || lp->lnd_land >= 0) {
+ lp->lnd_ship = lp->lnd_land = -1;
+ if (may_put)
+ putland(i, lp);
+ verify_fail(EF_LAND, i, NULL, 0,
+ "ghost stuck on carrier (fixed)");
+ }
+ }
+ }
+ return retval;
+}
+
+static int
+verify_nukes(int may_put)
+{
+ int retval = 0;
+ int i;
+ struct nukstr *np;
+
+ /* laziness: assumes nuke file is EFF_MEM */
+ for (i = 0; (np = getnukep(i)); i++) {
+ if (!np->nuk_own) {
+ if (np->nuk_plane >= 0) {
+ np->nuk_plane = -1;
+ if (may_put)
+ putnuke(i, np);
+ verify_fail(EF_NUKE, i, NULL, 0,
+ "ghost stuck on carrier (fixed)");
+ }
+ }
+ }
+ return retval;
+}
+
+static int
+verify_ship_chr(void)
+{
+ int retval = 0;
+ int i;
+
+ for (i = 0; mchr[i].m_name; i++) {
+ if (!mchr[i].m_name[0])
+ continue;
+ if ((mchr[i].m_flags & M_DCH) && !mchr[i].m_glim) {
+ verify_fail(EF_SHIP_CHR, i, NULL, 0,
+ "flag %s requires non-zero glim",
+ symbol_by_value(M_DCH, ship_chr_flags));
+ retval = -1;
+ }
+ if (mchr[i].m_nplanes && !(mchr[i].m_flags & (M_MSL | M_FLY))) {
+ verify_fail(EF_SHIP_CHR, i, NULL, 0,
+ "non-zero nplanes needs flag %s or %s",
+ symbol_by_value(M_FLY, ship_chr_flags),
+ symbol_by_value(M_MSL, ship_chr_flags));
+ retval = -1;
+ }
+ }
+ return retval;
+}
+
+static int
+verify_plane_chr(void)
+{
+ int retval = 0;
+ int i, flags, accepted_flags;
+ char buf[1024];
+
+ for (i = 0; plchr[i].pl_name; i++) {
+ if (!plchr[i].pl_name[0])
+ continue;
+ flags = plchr[i].pl_flags;
+ accepted_flags = P_V | P_K | P_L;
+ if (flags & P_M) {
+ /* missile */
+ accepted_flags |= P_M | P_E;
+ if (flags & P_N)
+ accepted_flags |= P_N;
+ else if (flags & P_O)
+ accepted_flags |= P_O;
+ else if (flags & P_F)
+ accepted_flags |= P_F;
+ else
+ accepted_flags |= P_T | P_MAR;
+ if (!(flags & P_V)) {
+ verify_fail(EF_PLANE_CHR, i, NULL, 0,
+ "flag %s requires flag %s",
+ symbol_by_value(P_M, plane_chr_flags),
+ symbol_by_value(P_V, plane_chr_flags));
+ retval = -1;
+ }
+ } else if (flags & P_O) {
+ /* satellite */
+ accepted_flags |= P_O | P_S | P_I;
+ } else {
+ /* plane */
+ accepted_flags |= P_B | P_T | P_F | P_C | P_S | P_I | P_A | P_P
+ | P_ESC | P_MINE | P_SWEEP;
+ if ((flags & (P_P | P_C)) == P_P) {
+ verify_fail(EF_PLANE_CHR, i, NULL, 0,
+ "flag %s requires flag %s",
+ symbol_by_value(P_P, plane_chr_flags),
+ symbol_by_value(P_C, plane_chr_flags));
+ retval = -1;
+ }
+ }
+ if (flags & ~accepted_flags) {
+ symbol_set_fmt(buf, sizeof(buf), flags & ~accepted_flags,
+ plane_chr_flags, ", ", 1);
+ verify_fail(EF_PLANE_CHR, i, NULL, 0,
+ "invalid flag combination, can't have %s", buf);
+ retval = -1;
+ }
+ }
+ return retval;
+}
+
+static int
+verify_land_chr(void)
+{
+ int retval = 0;
+ int i;
+
+ for (i = 0; lchr[i].l_name; i++) {
+ if (!lchr[i].l_name[0])
+ continue;
+ if ((lchr[i].l_flags & L_SPY) && lchr[i].l_item[I_MILIT]) {
+ verify_fail(EF_LAND_CHR, i, NULL, 0,
+ "flag %s requires zero milit",
+ symbol_by_value(L_SPY, land_chr_flags));
+ retval = -1;
+ }
+ }
+ return retval;
+}
+
+static int
+verify_products(void)