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:
parent
1e9c9c8273
commit
84d88442b3
7 changed files with 72 additions and 7 deletions
|
@ -37,6 +37,7 @@
|
|||
#include "empobj.h"
|
||||
#include "news.h"
|
||||
#include "optlist.h"
|
||||
#include "product.h"
|
||||
#include "version.h"
|
||||
#include "xdump.h"
|
||||
|
||||
|
@ -52,6 +53,7 @@ xdvisible(int type, void *p)
|
|||
struct lonstr *lp = p;
|
||||
struct natstr *natp;
|
||||
int tlev;
|
||||
char *name;
|
||||
|
||||
switch (type) {
|
||||
case EF_SECTOR:
|
||||
|
@ -84,19 +86,27 @@ xdvisible(int type, void *p)
|
|||
case EF_TRADE:
|
||||
case EF_COMM:
|
||||
return gp->own != 0;
|
||||
case EF_PRODUCT:
|
||||
return ((struct pchrstr *)p)->p_sname[0] != 0;
|
||||
case EF_SHIP_CHR:
|
||||
tlev = ((struct mchrstr *)p)->m_tech;
|
||||
name = ((struct mchrstr *)p)->m_name;
|
||||
goto tech;
|
||||
case EF_PLANE_CHR:
|
||||
tlev = ((struct plchrstr *)p)->pl_tech;
|
||||
name = ((struct plchrstr *)p)->pl_name;
|
||||
goto tech;
|
||||
case EF_LAND_CHR:
|
||||
tlev = ((struct lchrstr *)p)->l_tech;
|
||||
name = ((struct lchrstr *)p)->l_name;
|
||||
tech:
|
||||
natp = getnatp(player->cnum);
|
||||
if (!name[0])
|
||||
return 0;
|
||||
return player->god || tlev <= (int)(1.25 * natp->nat_level[NAT_TLEV]);
|
||||
case EF_NUKE_CHR:
|
||||
tlev = ((struct nchrstr *)p)->n_tech;
|
||||
name = ((struct nchrstr *)p)->n_name;
|
||||
if (drnuke_const > MIN_DRNUKE_CONST) {
|
||||
natp = getnatp(player->cnum);
|
||||
if (tlev > (int)((int)(1.25 * natp->nat_level[NAT_RLEV])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue