Forbid omitting rows in config item and sect-chr
Forbid omitting rows for tables with const fields: item and sect-chr. This is consistent with the rule for truncation. The server expects certain entries in these two tables, and malfunctions when they're blank. Omitting them in the builtin tables has always left them blank, but deities are not supposed to edit them, and maintainers are supposed to know what they're doing, so the issue was deemed unimportant and ignored. However, I plan to blank out omitted rows in custom tables as well, and then the issue isn't unimportant anymore.
This commit is contained in:
parent
4e23c45e61
commit
4a4ec917f6
1 changed files with 5 additions and 1 deletions
|
@ -82,6 +82,7 @@ static struct castr **fldca; /* Map field number to selector */
|
||||||
static int *fldidx; /* Map field number to index */
|
static int *fldidx; /* Map field number to index */
|
||||||
static int *caflds; /* Map selector number to #fields seen */
|
static int *caflds; /* Map selector number to #fields seen */
|
||||||
static int *cafldspp; /* ditto, in previous parts */
|
static int *cafldspp; /* ditto, in previous parts */
|
||||||
|
static int may_omit_id; /* Okay to omit IDs? */
|
||||||
static int may_trunc; /* Okay to truncate? */
|
static int may_trunc; /* Okay to truncate? */
|
||||||
|
|
||||||
static int gripe(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
static int gripe(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
||||||
|
@ -224,6 +225,8 @@ tbl_skip_to_obj(int id)
|
||||||
int max_id, exp_id;
|
int max_id, exp_id;
|
||||||
|
|
||||||
if (partno == 0) {
|
if (partno == 0) {
|
||||||
|
if (!may_omit_id && id != cur_id + 1)
|
||||||
|
return gripe("Expected %d in field %d", cur_id + 1, 1);
|
||||||
if (id <= cur_id)
|
if (id <= cur_id)
|
||||||
return gripe("Field %d must be > %d", 1, cur_id);
|
return gripe("Field %d must be > %d", 1, cur_id);
|
||||||
max_id = ef_id_limit(cur_type);
|
max_id = ef_id_limit(cur_type);
|
||||||
|
@ -1075,13 +1078,14 @@ xundump(FILE *fp, char *file, int *plno, int expected_table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nca = nf = 0;
|
nca = nf = 0;
|
||||||
|
may_omit_id = 1;
|
||||||
may_trunc = empfile[type].nent < 0;
|
may_trunc = empfile[type].nent < 0;
|
||||||
for (i = 0; ca[i].ca_name; i++) {
|
for (i = 0; ca[i].ca_name; i++) {
|
||||||
nca++;
|
nca++;
|
||||||
if (!(ca[i].ca_flags & NSC_EXTRA)) {
|
if (!(ca[i].ca_flags & NSC_EXTRA)) {
|
||||||
nf += MAX(1, ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0);
|
nf += MAX(1, ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0);
|
||||||
if (ca[i].ca_flags & NSC_CONST)
|
if (ca[i].ca_flags & NSC_CONST)
|
||||||
may_trunc = 0;
|
may_omit_id = may_trunc = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fldca = malloc(nf * sizeof(*fldca));
|
fldca = malloc(nf * sizeof(*fldca));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue