#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/subs/control.c,v 2.0 1995/01/25 19:58:54 empire Exp $";
#endif

/*
 * populace.c
 *
 * return workforce available
 *
 * Dave Pare, 1986
 */

#include "misc.h"
#include "player.h"
#include "var.h"
#include "sect.h"
#include "nat.h"
#include "var.h"
#include "file.h"
#include "path.h"
#include "xy.h"
#include "land.h"
#include "nsc.h"
#include "item.h"
#include "deity.h"

/*
 * Does the player->owner have military control of this sector?
 *
 */

military_control(sp)
struct	sctstr *sp;
{
	int     tot_mil=0;
	struct  nstr_item ni;
	struct  lndstr land;

	if (sp->sct_oldown != sp->sct_own){
		snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
		while (nxtitem(&ni, (s_char *)&land)){
			if (land.lnd_own == sp->sct_own)
				tot_mil += total_mil(&land);
		}
		if ((getvar(V_MILIT, (s_char *)sp, EF_SECTOR)+tot_mil) * 10
			< getvar(V_CIVIL, (s_char *)sp, EF_SECTOR))
			return 0;
	}

	return 1;
}
