
			Empire Files


Empire uses a number of files.  Many of them have similar formats,
namely, fixed-sized logical records which describe entities which
are complete in and of themselves.  Examples of these items are
sectors, loans, ships, treaties, and nukes.  Some have actual physical
location on the empire map, some have commodities associated with them,
and others are just for record-keeping.

All empire "items" are accessable by several different methods.  The
most efficient is the buffered read, which assumes that the caller
will be iterating through all of the items in the file and as such
can perform some read-ahead in order to decrease the number of system
calls performed.  The least efficient is the random-access nonbuffered
read, which guarantees to retrieve the "current" version from disk
but does not use any in-core copies of data.

Writing an item to disk always flushes the individual item's cache.
In addition, there is a specific "flush cache" routine available.
These series of routines are called the "empire file" operations,
whose routines prefixed by "ef_".

ef_init()
	Open all files, allocate all memory associated with the
	individual item caches.  Determines the size of the files
	in question (and thus the number of units as well).  Also
	determines the optimal disk read size (the cache size).

ef_read(type, id, ptr)
	int	type;
	int	id;
	caddr_t	ptr;

	Using the item buffer cache, reads in a new batch of items
	into the cache or copies an item from cache depending on
	the id.  A statically-specified post-read operation is
	called with the item id and pointer if defined.

ef_nbread(type, id, ptr)
	int	type;
	int	id;
	caddr_t	ptr;

	Perform an lseek/read operation on the file defined by "type".
	Invalidate the current cache.  Perform post-read if defined.

ef_nbwrite(type, id, ptr)
	int	type;
	int	id;
	caddr_t	ptr;

	Perform an lseek/write operation on the file defined by
	"type".  Invalidate the current cache.  A statically-defined
	pre-write call is available quite similar to those available
	to the read routines.  This is called if defined before
	the write occurs.

ef_zapcache(type)
	int	type;

	Invalidate the item cache.

ef_flags(type)
	int	type;

	Return the item-specific flags associated with the unit.
		EF_COM	item has commodities
		EF_XY	item has a location
	others to be added as important.

ef_getvec(type, itemp, type_vec, amt_vec, nvp)
	int	type;
	char	*itemp;
	u_char	*type_vec;
	short	*amt_vec;
	u_char	*nvp;

	Assuming the item has commodities associated with it, using the
	passed item pointer, return the offsets into the item which
	contain the commodity storage vectors.
