Verify game state and configuration reference sanity

Table elements reference other table elements.  Bad things happen when
references dangle.  ef_verify() already checks whether the referenced
table elements exist.  This commit makes it check whether the elements
are "in use".  This catches stuff like living planes on dead carriers.
This commit is contained in:
Markus Armbruster 2011-04-25 09:45:58 +02:00
parent b30c83cd64
commit 7da9aab5a1

View file

@ -122,6 +122,13 @@ verify_tabref(int type, int row, struct castr *ca, int idx, long val)
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;
}