/*
 * sect.h
 *
 * things having to do with sectors
 *
 * from PSL Empire, 1985
 * $Revision: 2.1 $ $Date: 1995/10/16 17:55:44 $
 */


/*
 * each "point" of MAXSCTV costs 32k for 128x128.
 * MAXSCTV = 20 ==> 655k for the commodities alone!
 *
 * If you set this to I_MAX*3, you'll never run ou
 * of slots, which is nice. (You'll eat a lot of
 * space, tho)
 */

#ifndef _SECT_H_
#define _SECT_H_

#define	MAXSCTV 42

/* The order of the following elements is there to match up with genitem */

struct	sctstr {
	short	ef_type;
	natid	sct_own;	/* owner's country num */
	short	sct_elev;	/* elevation/depth */
	coord	sct_x;		/* x coord of sector */
	coord	sct_y;		/* y coord of sector */
	u_char	sct_type;	/* sector type */
	u_char	sct_effic;	/* 0% to 100% */
	short	sct_mobil;	/* mobility units */
	u_char	sct_loyal;	/* updates until civilans "converted" */
	u_char	sct_terr;	/* territory id # of sector */
	coord	sct_dist_x;	/* Dist sector */
	coord	sct_dist_y;
	short	sct_avail;	/* available workforce for "other things" */
	short	sct_fill;	/* gunk */
	u_char	sct_work;	/* pct of civ actually working */
	u_char	sct_coastal;	/* is this a coastal sector? */
	u_char	sct_newtype;	/* for changing designations */
	u_char	sct_min;	/* ease of mining ore */
	u_char	sct_gmin;	/* amount of gold ore */
	u_char	sct_fertil;	/* fertility of soil */
	u_char	sct_oil;	/* oil content */
	u_char	sct_uran;	/* uranium ore content */
	natid	sct_oldown;	/* old owner of sector (for liberation) */
	u_char	sct_updated;	/* Has this sect been updated? */
	u_char	sct_off;	/* Should this sector produce? */
	u_char	sct_nv;		/* current number of variables */
	u_char	sct_vtype[MAXSCTV];
	u_short	sct_vamt[MAXSCTV];
#ifndef SMALL_SERVER
	s_char	sct_sparec;	/* not used */
	int	sct_sparei;	/* not used */
	long	sct_sparel;	/* not used */
#endif /* SMALL_SERVER */
};

struct	dchrstr	{
	int	d_mnem;		/* map symbol */
	int	d_prd;		/* product vtype */
	int	d_mcst;		/* movement cost */
	int	d_flg;		/* movement cost */
	int	d_pkg;		/* type of packaging in these sects */
	int	d_ostr;		/* offensive strength */
	int	d_dstr;		/* defensive strength */
	int	d_value;	/* resale ("collect") value */
	int	d_cost;		/* cost to designate the sect */
	int	d_build;	/* cost multiplier for eff */
	int	d_lcms;		/* lcm's needed per point of eff */
	int	d_hcms;		/* hcm's needed per point of eff */
	s_char	*d_name;	/* full name of sector type */
};

#define	NPKG	0		/* no special packaging */
#define	WPKG	1		/* "warehouse" packaging */
#define	UPKG	2		/* "urban" packaging */
#define	BPKG	3		/* "bank" packaging */

/* for d_flg */
#define	NAVOK	1		/* ships can always navigate */
#define	NAV_02	2		/* requires 2% effic to navigate */
#define	NAV_60	3		/* requires 60% effic to navigate */

	/* sector types (must agree with order in dchr, empglb.c) */

#define	SCT_WATER	0       /* basics */
#define	SCT_MOUNT	1
#define	SCT_SANCT	2
#define	SCT_WASTE	3
#define	SCT_RURAL	4
#define	SCT_CAPIT	5
#define	SCT_URAN	6
#define	SCT_PARK	7
#define	SCT_ARMSF	8       /* industries */
#define	SCT_AMMOF	9
#define	SCT_MINE	10
#define	SCT_GMINE	11
#define	SCT_HARBR	12
#define	SCT_WAREH	13
#define	SCT_AIRPT	14
#define	SCT_AGRI	15
#define	SCT_OIL		16
#define	SCT_LIGHT	17
#define	SCT_HEAVY	18
#define	SCT_FORTR	19      /* military/scientific */
#define	SCT_TECH	20
#define	SCT_RSRCH	21
#define	SCT_NUKE	22
#define	SCT_LIBR	23
#define	SCT_HIWAY	24      /* communications */
#define	SCT_RADAR	25
#define	SCT_HEADQ	26	/* headquarters */
#define	SCT_BHEAD	27
#define	SCT_BSPAN	28
#define	SCT_BANK	29      /* financial */
#define	SCT_REFINE	30	/* refinery */
#define SCT_ENLIST	31	/* enlistment center */

#define	SCT_MAXDEF	31	/* highest sector type in header files */

#define getsect(x, y, p) \
	ef_read(EF_SECTOR, sctoff((int) x, (int) y), (caddr_t)p)
#define putsect(p) \
	ef_write(EF_SECTOR, sctoff((int) (p)->sct_x, \
		(int) (p)->sct_y), (caddr_t)p)
#define getsectp(x, y) \
	(struct sctstr *) ef_ptr(EF_SECTOR, sctoff((int)x, (int)y))
#define getsectid(id) \
	(struct sctstr *) ef_ptr(EF_SECTOR, id)

/* things relating to sectors */
extern	int sctoff();
extern	double landgun();

extern	int sct_maxno;
extern	struct dchrstr dchr[];

#define MIN_MOBCOST	0.01	/* lowest cost a sector can have to move into */
#define FORTEFF 5	/* forts must be 5% efficient to fire. */

#endif /* _SECT_H_ */
