Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
static int
verify_tabref(int type, int row, struct castr *ca, int idx, long val)
{
    int tabno = ca->ca_table;
    struct castr *ca_sym = ef_cadef(tabno);
    int i;

    if (ca->ca_flags & NSC_BITS) {
	/* symbol set */
	if (CANT_HAPPEN(ca_sym != symbol_ca))
	    return -1;
	for (i = 0; i < (int)sizeof(long) * 8; i++) {
	    if (val & (1UL << i)) {
		if (!symbol_by_value(1L << i, ef_ptr(tabno, 0))) {
		    verify_fail(type, row, ca, idx,
				"bit %d is not in symbol table %s",
				i, ef_nameof(tabno));
		    return -1;
		}
	    }
	}
    } else if (ca_sym == symbol_ca) {
	/* symbol */
	if (!symbol_by_value(val, ef_ptr(tabno, 0))) {
	    verify_fail(type, row, ca, idx,
			"value %ld is not in symbol table %s",
			val, ef_nameof(tabno));
	    return -1;
	}
    } else {
	/* table index */
	if (val >= ef_nelem(tabno) || val < -1) {
	    verify_fail(type, row, ca, idx,
			"value %ld indexes table %s out of bounds 0..%d",
			val, ef_nameof(tabno), ef_nelem(tabno));
	    return -1;
	}
	/* laziness: assumes TABNO is EFF_MEM */
	if (val >= 0 && !empobj_in_use(tabno, ef_ptr(tabno, val))) {
	    verify_fail(type, row, ca, idx,
			"value %ld refers to missing element of table %s",
			val, ef_nameof(tabno));
	    return -1;
	}
    }
    return 0;
}
Ejemplo n.º 3
0
static int
verify_plane_chr(void)
{
    int retval = 0;
    int i;

    for (i = 0; plchr[i].pl_name; i++) {
	if (!plchr[i].pl_name[0])
	    continue;
	if ((plchr[i].pl_flags & (P_M | P_V)) == P_M) {
	    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;
	}
    }
    return retval;
}
Ejemplo n.º 4
0
/*
 * Dump symbol with value @key from symbol table @type to @xd.
 * Prefix with @sep, return " ".
 */
static char *
xdprsym(struct xdstr *xd, int key, int type, char *sep)
{
    char *sym = symbol_by_value(key, ef_ptr(type, 0));

    if (!sym) {
	CANT_HAPPEN(!xd->sloppy);
	xd->pr("%s%d", sep, key);
    } else {
	xd->pr("%s", sep);
	xdpresc(xd, sym, INT_MAX);
    }
    return " ";
}