update: Clean up share_incr()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-19 14:06:07 +02:00
parent 4be4a2c540
commit 35d6779e55

View file

@ -55,7 +55,7 @@
* level of 0 yields (1) 0.4, (6) 2.2, (12) 3.9, (18) 5.2. * level of 0 yields (1) 0.4, (6) 2.2, (12) 3.9, (18) 5.2.
*/ */
static void share_incr(double *, double *); static void share_incr(double[], double[]);
/* /*
* for values below the "easy level" values, production is * for values below the "easy level" values, production is
@ -235,19 +235,18 @@ prod_nat(int etu)
* find out everyones increment * find out everyones increment
*/ */
static void static void
share_incr(double *res, double *tech) share_incr(double res[], double tech[])
{ {
struct natstr *np; struct natstr *np, *other;
struct natstr *other; natid i, j;
natid i; int rnc, tnc;
natid j; float other_tlev, other_rlev;
int rnc;
int tnc;
for (i = 0; NULL != (np = getnatp(i)); i++) { for (i = 0; NULL != (np = getnatp(i)); i++) {
res[i] = tech[i] = 0.0; res[i] = tech[i] = 0.0;
if (np->nat_stat < STAT_SANCT || np->nat_stat == STAT_GOD) if (np->nat_stat < STAT_SANCT || np->nat_stat == STAT_GOD)
continue; continue;
rnc = tnc = 0; rnc = tnc = 0;
for (j = 0; NULL != (other = getnatp(j)); j++) { for (j = 0; NULL != (other = getnatp(j)); j++) {
if (j == i) if (j == i)
@ -258,22 +257,26 @@ share_incr(double *res, double *tech)
if (!getcontact(np, j)) if (!getcontact(np, j))
continue; continue;
} }
other_tlev = levels[j][NAT_TLEV];
other_rlev = levels[j][NAT_RLEV];
if (!opt_ALL_BLEED) { if (!opt_ALL_BLEED) {
if (relations_with(i, j) != ALLIED) if (relations_with(i, j) != ALLIED)
continue; continue;
if (relations_with(j, i) != ALLIED) if (relations_with(j, i) != ALLIED)
continue; continue;
res[i] += levels[j][NAT_RLEV]; res[i] += other_rlev;
tech[i] += levels[j][NAT_TLEV]; tech[i] += other_tlev;
rnc++; rnc++;
tnc++; tnc++;
} else { } else {
if (levels[j][NAT_TLEV] > 0.001) { if (other_tlev > 0.001) {
tech[i] += levels[j][NAT_TLEV]; tech[i] += other_tlev;
tnc++; tnc++;
} }
if (levels[j][NAT_RLEV] > 0.001) { if (other_rlev > 0.001) {
res[i] += levels[j][NAT_RLEV]; res[i] += other_rlev;
rnc++; rnc++;
} }
} }