other. Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special). New header types.h to
help avoid inclusion cycles. Sort include directives. Remove some
superflous includes.
extending any table, empty or not:
(cur_obj_is_blank): New.
(fldval_must_match): Use it instead of initialized[].
(getobj): Set it along with cur_obj.
(setstr): Move fldval_must_match() down, so that cur_obj_is_blank is
defined.
(initialized): Remove.
(xunsymbol1): Use ef_elt_byname().
(setsym): Accept any table reference, not just to symbol table.
(symval): New.
(setsym, add2symset): Use it.
(mtsymset): Last remaining user of getsymtab(); inline and simplify.
(getsymtab): Remove.
(xunsymbol1, xunsymbol): Rename.
(ef_elt_byname): New.
(nstr_match_val): Use it to generalize to arbitrary table with
uniquely named elements. Use ca_type to find table, remove parameter
type. Callers changed.
(nstr_mkselval): Adapt sanity check accordingly.
(NSC_TYPEID): No longer needed, remove, users changed to use
appropriate integer type instead. This fixes signedness of sector
selectors des and newdes.
(meta_type): Remove entry for NSC_TYPEID.
(nstr_coerce_val): Can't detect typeid - integer mismatch anymore.
Was nice to have; perhaps revive it later.
(meta_type): Add its entry.
(setnum, nstr_promote, nstr_exec_val): Deal with it. nstr_exec_val()
implements opt_HIDDEN by mapping unknown values to -1.
(natstr, nat_ca): Use it for member nat_relate. This also halves its
size. Fixes very minor leak: before, player could see relations to
all countries, regardless of contact.
(nation_relations): Add entry for -1.
provided the values all match:
(caseen): New.
(xundump): Initialize and finalize it.
(xundump2): Update it.
(deffld): Deal with repetition.
(fldval_must_match): New, considers repetition as well as NSC_CONST.
(setnum, setstr): Use it.
(ellipsis): New.
(xuheader1): Initialize it. Compute nflds. Allow repetition of index
field in continued tables.
(xundump): Don't set nflds.
(xufldname, defellipsis): Accept ... and call new defellipsis().
(xufldname, chkflds): Update and elaborate check for missing fields,
move it to new chkflds(). Require repetition of index field in
continued tables.
(xundump2): New, factored out of xundump(). Parse continued tables.
(xundump1, setnum, setstr, getobj, cur_id): Delay table lookup until
first field is about to be assigned.
(xundump1): Record largest ID, because it's no longer given by final
value of row.
(xuheader1, xundump1, xundump): Move initialization of cur_type to
xundump().
selectors. That's wrong for EF_SECTOR_CHR and EF_PRODUCT. Don't
allow table shrinking just because it has no NSC_CONST selectors.
That's wrong for EF_NEWS_CHR. Allow it for game state and unit
characteristics.
(has_const): Unused, remove.
still be in order), support abbreviated field names:
(nxt_sel, nxt_idx, nxtfld, ca4fld): Remove.
(nflds, fldca, fldidx, caflds, getfld): New.
(xundump): Initialize and finalize them.
(xundump1): New, factored out of xundump().
(deffld): Match names, record field order in fldca[], fldidx[] for
getfld(). Use caflds[] to detect duplicates.
(xufldname): Catch negative index. Used to pass it to deffld(), which
now interprets it as no index.
(setnum, setstr, setsym, mtsymset, add2symset): Use getfld().
(xufld): Improve error message.
(setstr): Fix for NULL strings.
(xuheader): Catch null ef_cadef().
(xuheader): Don't oops when an unexpected table can't be undumped.
leaks memory; rework it:
(deffld): New; semantic action for field headers.
(xufldname): Use it instead of storing a value for xucolumnheader().
(xucolumnheader): Remove, use xuflds() directly instead.
(setnum, setstr, setsym): New; semantic actions for field values.
(xufld): Use it instead of storing a value for xuloadrow().
(xuloadrow): Remove. Was incomplete.
(xufldname, xufld, xuflds): Remove parameter values. Callers
changed.
(cur_type, cur_obj, nxt_sel, nxt_idx, nxtfld, ca4fld, getsymtab): New
helpers.
(xundump): Initialize them.
(enum_value, value, freeflds, xunsymbol): Remove.
(mtsymset, add2symset): New.
(xufld): Use them to build a symbol set along the parse.
(xufldname, xufld, xuheader, xutrailer, xundump): Increment lineno
when and only when a linefeed is consumed, to make sure it is correct.
Move some semantic checks so that errors get reported for the correct
line.
(xundump): Use compare filenames as pointers, not strings, when
checking whether to reset lineno.
(xundump): Keep empfile[type] consistent during parse, to make
ef_ptr() usable.
(xundump): Don't call ep->init() on sentinels.
(xuinitrow): Unused, remove.
(enum_value, value, xuflds, freeflds): Parse additional syntax:
numeric and symbolic index.
(xucolumnheader): Use it to parse column header line. Check names
and indexes match meta-data. Symbolic indexes not yet implemented.
(xuloadrow): Reject the additional syntax.