Sectors need space for items, deliveries and distribution thresholds.

To save space, the ancients invented `variables': a collection of
key-value pairs, missing means zero value, space for `enough' keys.
This complicates the code, as assigning to a `variable' can fail for
lack of space.  Over time, `enough' increased, and for quite some time
now `variables' have been *wasting* space.  This changeset replaces
them, except in struct mchrstr, struct lchrstr and struct pchrstr,
where they are read-only, and will be replaced later.  It is only a
first step; further cleanup is required.  To simplify and minimize
this necessarily huge changeset, the new item[] arrays have an unused
slot 0, and the old variable types V_CIVIL, ... are still defined, but
must have the same values as the item types I_CIVIL, ...
This commit is contained in:
Markus Armbruster 2004-03-03 16:54:22 +00:00
parent ba86513b01
commit eccc5cb7d7
86 changed files with 853 additions and 1226 deletions

View file

@ -54,15 +54,14 @@ takeover(register struct sctstr *sp, natid newown)
int che;
int che_count;
int oldche;
int n, vec[I_MAX + 1];
int n;
struct nstr_item ni;
struct plnstr p;
struct lndstr land;
/* Wipe all the distribution info */
memset(vec, 0, sizeof(vec));
putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR);
putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR);
memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
memset(sp->sct_del, 0, sizeof(sp->sct_del));
if (sp->sct_own == 0)
sp->sct_off = 0;
else
@ -116,8 +115,8 @@ takeover(register struct sctstr *sp, natid newown)
}
sp->sct_avail = 0;
civ = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
oldche = get_che_value(getvar(V_CHE, (s_char *)sp, EF_SECTOR));
civ = sp->sct_item[I_CIVIL];
oldche = get_che_value(sp->sct_che);
/*
* create guerrillas from civilians
* how spunky are these guys?
@ -143,8 +142,8 @@ takeover(register struct sctstr *sp, natid newown)
set_che_value(che, che_count);
if (newown != sp->sct_oldown)
set_che_cnum(che, newown);
(void)putvar(V_CHE, che, (s_char *)sp, EF_SECTOR);
(void)putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
sp->sct_che = che;
sp->sct_item[I_CIVIL] = civ;
if (sp->sct_oldown == newown || civ == 0) {
/*
* taking over one of your old sectors