#ifndef lint
static char *RCSid = "$Header: /sequent2/empire/EMP/update/RCS/sect.c,v 1.11 89/09/18 00:55:24 mr-frog Exp $";
#endif

/*
 * sect.c
 *
 * perform production updates of the sect and
 * ship files.
 * 
 * from PSL Empire, 1985
 * and Dave Pare, 1986
 */

#include <math.h>
#include "misc.h"
#ifdef BUDGET
#include "var.h"
#include "sect.h"
#include "nat.h"
#include "item.h"
#include "news.h"
#include "file.h"
#include "xy.h"
#ifdef	FALLOUT
#include "path.h"
#endif	FALLOUT

finish_sects(etu)
	int	etu;
{
	extern	int pops[];
	register struct sctstr *sp;
	struct	natstr *np;
	int	n;
	int	vec[I_MAX+1];
	int	changed;

	for (n=0; sp = getsectid(n); n++) {
		if (sp->sct_type == SCT_WATER)
			continue;
		if (sp->sct_own == 0)
			continue;
		np = getnatp(sp->sct_own);
		if (np->nat_money < 0)
			continue;
		changed = 0;
		if (getvec(VT_ITEM, vec, (char *)sp, EF_SECTOR) > 0)
			changed += dodeliver(sp, vec);
		changed += dodistribute(sp, vec);
		if (changed)
			putvec(VT_ITEM, vec, (char *)sp, EF_SECTOR);
	}
}
#endif /* BUDGET */
