From c89161d4961bda73bd4b1cc5412817baacce5e4e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 19 Sep 2016 20:45:56 +0200 Subject: [PATCH] subs/control: Grant bonus for capability security Grant land units with security capability the same bonus as in convert and shoot: multiply by (1 + eff/100). military_control()'s code to count military is now functionally equivalent to security_strength(), except it has no use for its second parameter. Change security_strength() to permit a null argument, and reuse it in military_control(). Signed-off-by: Markus Armbruster --- info/distribute.t | 10 ++++++---- info/move.t | 13 ++++++++----- src/lib/subs/control.c | 19 ++++++------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/info/distribute.t b/info/distribute.t index 2eb958ae..84dfb45e 100644 --- a/info/distribute.t +++ b/info/distribute.t @@ -64,10 +64,12 @@ you must own the distribution sector, and there must be a path of owned sectors to it. In order to export something from a sector, you must have military control of the sector. In order to import something from a distribution sector, you must have military control of the distribution -sector. (Military control is defined as having mil in the sector equal -to at least 1/10th the number of unconverted civilians there. Units count -as if they were straight mil, i.e. a 100% unit that contained 50 mil would -count as 50 mil for the purposes of control) +sector. +.s1 +Military control is defined as having military in the sector equal to +at least 1/10th the number of unconverted civilians there. Military +in land units count towards military control. Military in efficient +security units count double. .s1 Mobility is used from the sector when sending \*Qto\*U the distribution sector. When getting something \*Qfrom\*U the distribution sector, mobility is paid diff --git a/info/move.t b/info/move.t index 344e9782..5d561cee 100644 --- a/info/move.t +++ b/info/move.t @@ -81,13 +81,16 @@ You can also supply additional parameters: is equivalent to a \*Qmap\*U command, like this: .EX map # ls +.s1 .L "Military control" .s1 -In order to move something (other than mil) out of a sector, you must have -military control of the sector. Military control is defined as having mil in -the sector equal to at least 1/10th the number of unconverted civilians there. -Units count as if they were straight mil, i.e. a 100% unit that contained 50 -mil would count as 50 mil for the purposes of control) +In order to move something (other than military) out of a sector, you +must have military control of the sector. Military control is defined +as having military in the sector equal to at least 1/10th the number +of unconverted civilians there. +.s1 +Military in land units count towards military control. Military in +efficient security units count double. .s1 .L Mobility See \*Qinfo Mobility\*U for a description of how much mobility it costs to diff --git a/src/lib/subs/control.c b/src/lib/subs/control.c index a067dae7..57c54c93 100644 --- a/src/lib/subs/control.c +++ b/src/lib/subs/control.c @@ -43,7 +43,7 @@ /* * Return strength of security detail in @sp. * Store sum of efficiency of land units with security capability in - * @seceffp. + * @seceffp unless it is null. */ double security_strength(struct sctstr *sp, int *seceffp) @@ -68,7 +68,8 @@ security_strength(struct sctstr *sp, int *seceffp) } } - *seceffp = seceff; + if (seceffp) + *seceffp = seceff; return strength; } @@ -78,19 +79,11 @@ security_strength(struct sctstr *sp, int *seceffp) int military_control(struct sctstr *sp) { - int tot_mil = 0; - struct nstr_item ni; - struct lndstr land; + int tot_mil; if (sp->sct_oldown != sp->sct_own) { - snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, &land)) { - if (land.lnd_ship >= 0 || land.lnd_land >= 0) - continue; - if (land.lnd_own == sp->sct_own) - tot_mil += land.lnd_item[I_MILIT]; - } - if ((sp->sct_item[I_MILIT] + tot_mil) * 10 < sp->sct_item[I_CIVIL]) + tot_mil = sp->sct_item[I_MILIT] + security_strength(sp, NULL); + if (tot_mil * 10 < sp->sct_item[I_CIVIL]) return 0; }