/* coastal.c */
extern void set_coastal(struct sctstr *, int, int);
/* control.c */
+extern int security_strength(struct sctstr *, int *);
extern int military_control(struct sctstr *);
extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *);
extern int would_abandon(struct sctstr *, i_type, int, struct ulist *);
*
* Known contributors to this file:
* Dave Pare, 1986
- * Markus Armbruster, 2004-2015
+ * Markus Armbruster, 2004-2016
*/
/*
struct sctstr sect;
struct nstr_sect nstr;
int uwtoconvert, newuw, totaluw, uw;
- int maxpop, civ, mil, adj_mob, mob;
+ int maxpop, civ, mil, nsec, adj_mob, mob;
double security_extra = 1.0;
- struct lndstr land;
- struct nstr_item ni;
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
natp = getnatp(sect.sct_own);
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
civ = sect.sct_item[I_CIVIL];
- mil = sect.sct_item[I_MILIT];
-
- /*
- * Military units count according to the number of
- * mil in them. (i.e. attack/defense modifier don't
- * count.
- */
- snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
- while (nxtitem(&ni, &land)) {
- mil += land.lnd_item[I_MILIT];
-
- /* Anti-terrorist units count double */
- if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {
- /*
- * They also increase the efficiency of
- * the conversion process by 10% each.
- */
- security_extra += .1;
- mil += land.lnd_item[I_MILIT];
- }
- }
+ mil = security_strength(§, &nsec);
/*
* Must have military control to convert captured civs.
*/
mob = sect.sct_mobil * 5;
/* security troops make conversion more effective */
+ security_extra = 1.0 + nsec / 10.0;
adj_mob = ldround(((double)mob * security_extra), 1);
if (adj_mob < newuw)
{
struct sctstr sect;
struct nstr_sect nstr;
- struct nstr_item ni;
int nshot;
double m;
i_type item;
struct ichrstr *ip;
- struct lndstr land;
int targets;
char *p;
int mil, nsec;
while (nxtsct(&nstr, §)) {
if (!player->owner)
continue;
- mil = sect.sct_item[I_MILIT];
- nsec = 0;
- snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
- while (nxtitem(&ni, &land)) {
- mil += land.lnd_item[I_MILIT];
-
- if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {
- mil += land.lnd_item[I_MILIT];
- nsec++;
- }
- }
-
+ mil = security_strength(§, &nsec);
if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10)
continue;
nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item];
#include "sect.h"
#include "unit.h"
+/*
+ * Return strength of security detail in @sp.
+ * Store number of land units with security capability in @nsecurity.
+ */
+int
+security_strength(struct sctstr *sp, int *nsecurity)
+{
+ int strength;
+ int nsec;
+ struct nstr_item ni;
+ struct lndstr land;
+
+ strength = sp->sct_item[I_MILIT];
+ nsec = 0;
+ snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
+ while (nxtitem(&ni, &land)) {
+ strength += land.lnd_item[I_MILIT];
+ if (lchr[land.lnd_type].l_flags & L_SECURITY) {
+ strength += land.lnd_item[I_MILIT];
+ nsec++;
+ }
+ }
+
+ *nsecurity = nsec;
+ return strength;
+}
+
/*
* Does the player->owner have military control of this sector?
*/