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

@ -69,18 +69,14 @@ give(void)
return RET_SYN;
if ((amt = atoi(p)) == 0)
return RET_SYN;
n = getvar(ip->i_vtype, (s_char *)&sect, EF_SECTOR);
n = sect.sct_item[ip->i_vtype];
if (amt < 0 && -amt > n) {
m = 0;
} else if (amt > 0 && amt + n > 9990) {
m = 9990;
} else
m = n + amt;
if (putvar(ip->i_vtype, m, (s_char *)&sect, EF_SECTOR) < 0) {
pr("No room to store %s in %s\n", ip->i_name,
xyas(sect.sct_x, sect.sct_y, player->cnum));
return RET_FAIL;
}
sect.sct_item[ip->i_vtype] = m;
putsect(&sect);
if (sect.sct_own != 0 && m != n) {
if (m > n) {