Don't misinterpret blank configuration entries as sentinels

Configuration table entries not defined by builtin and custom
configuration files remain blank.  They get misinterpreted as sentinel
in tables that use one.  Affected are tables product, ship-chr,
plane-chr, land-chr and nuke-chr.  Tables item, sect-chr and
infrastructure are immune despite using a sentinel, because omitting
entries is not permitted there.

Code relying on the sentinel fails to pick up entries after the first
blank one.  They don't get set up correctly, they're invisible to
build and show, and not recognized as symbolic selector values (the
frg in ship ?type=frg).  xdump is fine, because it doesn't rely on
sentinels.  It dumps blank entries normally.

The bugs don't bite in the stock game, because the builtin
configuration files are all dense.

The sentinels are all null strings.  Set them to "" in the affected
tables' oninit callback.  Fix up code iterating over the tables to
ignore such entries.  This is precisely the code relying on sentinels,
plus xdump's xdvisible().
This commit is contained in:
Markus Armbruster 2011-05-21 17:49:17 +02:00
parent 1e9c9c8273
commit 84d88442b3
7 changed files with 72 additions and 7 deletions

View file

@ -40,6 +40,7 @@
* several.
* Each array element has a pointer to its name stored at offset OFFS.
* Search stops when this name is a null pointer.
* It ignores elements with an empty name.
* NEEDLE is compared to element names with mineq(NEEDLE, NAME).
* SIZE gives the size of an array element.
*/
@ -54,6 +55,8 @@ stmtch(char *needle, void *haystack, ptrdiff_t offs, size_t size)
name = *(char **)((char *)haystack + i * size + offs);
if (!name)
break;
if (!*name)
continue;
switch (mineq(needle, name)) {
case ME_MISMATCH:
break;