
			Empire Variables

Several item types can have variables associated with them.
Things such as deliveries, distributions, plague, and commodites
exist to one degree or another in both ships and sectors.  Perhaps
new items will also be allowed to have variables in the future
as well.

Empire variables are stored using two vectors and a variable count.
One vector stores the types, another stores the amount of each type.
The variable count defines the number of variables in each of the
vectors.

Variables in the list are not sorted.  Deleting a variable is accomplished
by copying the last variable on top of the to-be-deleted variable,
or by simply decrementing the variable count if the to-be-deleted
variable is the last in the list.  Adding a variable consists of simply
appending the variable to the end of the list, and incrementing the
variable count.

The following routines exist to work on the variable lists.

int
vl_findvar(vtype, type_vec, amt_vec, nv)
	int	vtype;
	u_char	*type_vec;
	short	*amt_vec;
	int	nv;

Search the type_vec for "vtype" (values can be between 0..255) and 
return the associated quantity stored in amt_vec.  Once nv variables
are examined, the item is determined not to be present.  If an
error occurs, -1 is returned.

int
vl_setvar(vtype, vamt, type_vec, amt_vec, nvp, max)
	int	vtype;
	int	vamt;
	u_char	*type_vec;
	short	*amt_vec;
	u_char	*nvp;
	int	nv;

Try and set the type_vec and amt_vec to the specified values.  If the
item isn't present, try and add it.  If the item is present, just
reset the value.  Problems occur when the item isn't present, and
the list is full.  When this happens, and the to-be-added vtype is
"important", then the list is scanned for any less important variables
which might be present.  The first "less important" item found is
deleted, and the to-be-added vtype is inserted in its place.

int
vl_getvec(mask, type_vec, amt_vec, nv, dst_amt_vec)
	int	mask;
	u_char	*type_vec;
	short	*amt_vec;
	int	nv;
	int	dst_amt_vec[I_MAX+1];

Every item which matches the "mask" has it's value copied into
the correct place in the dst_amt_vec.  Masks are of the type
VT_ITEM, VT_DEL, VT_DIST, VT_COND.  For example, the amount associated
with a V_MILIT vtype will be dropped into the slot defined by
I_MILIT, because V_MILIT = I_MILIT | VT_ITEM;

int
vl_damage(damage, type_vec, amt_vec, nvp)
	int	damage;
	u_char	*type_vec;
	short	*amt_vec;
	u_char	*nvp;

Inflict the specified amount of damage to each VT_ITEM which exists in
the type_vec.  If the damage is >= 100, then remove all entries.  Any
vtype which has been removed completely will be deleted.
