From 3bcad4c0dc7e296f620e594db7ce812ff9c64664 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 1 Jun 2016 22:05:41 +0200 Subject: [PATCH] update: Enforce sector population limit only right after growth The update kills people to enforce sector population limits, right after growing people. However, the population limit may decrease between that killing and the end of the update: * Research declines (only with RES_POP), but the lower population limit isn't enforced. Even with an insanely fast decline of 60% (level_age_rate = 1, etu_per_update = 60), the population limit decreases by less than 10%. Not applying the new level to this update is consistent with how we use levels elsewhere. * upd_buildeff() changes sector type and efficiency, but a lower new population limit is enforced only when this changes the sector type from big city to not big city (since option BIG_CITY was added in Empire 2). It isn't enforced on other sector type changes. Might change the population limit since the type's limit became configurable in commit 153527a (v4.2.20). Sane configurations don't let players redesignate sectors to a type with different maximum population. The server doesn't enforce this, though. It isn't enforced when a big city's efficiency decreases, but sector type change isn't achieved. Having population exceed the new limit without having produced enough work to change the type seems unlikely, as 25 will do even in the worst case, but should be possible with a sufficiently low work percentage. None of this is documented in info Update-sequence. Inconsistent mess. Drop it. Signed-off-by: Markus Armbruster --- src/lib/update/sect.c | 15 +++------------ tests/update/setup-POGO | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 1249cf22..8c193b13 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -50,13 +50,12 @@ * Return amount of work used. */ static int -upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp, - short *vec, int etu, int *desig, int *cost) +upd_buildeff(struct sctstr *sp, int *workp, short vec[], int *desig, + int *cost) { int work_cost = 0; int buildeff_work = *workp / 2; int n, hcms, lcms, neweff; - unsigned char old_type = *desig; *cost = 0; neweff = sp->sct_effic; @@ -77,14 +76,6 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp, } neweff = n; *cost += work_cost; - if (!n && IS_BIG_CITY(old_type) && !IS_BIG_CITY(*desig)) { - /* FIXME use trunc_people() */ - int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n); - if (vec[I_CIVIL] > maxpop) - vec[I_CIVIL] = maxpop; - if (vec[I_UW] > maxpop) - vec[I_UW] = maxpop; - } } if (*desig == sp->sct_newtype) { work_cost = 100 - neweff; @@ -324,7 +315,7 @@ produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2]) if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) && np->nat_money >= 0) { - neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, &cost); + neweff = upd_buildeff(sp, &work, vec, &desig, &cost); bp_put_items(bp, sp, vec); p_sect[SCT_EFFIC][0]++; p_sect[SCT_EFFIC][1] += cost; diff --git a/tests/update/setup-POGO b/tests/update/setup-POGO index 75333633..8e6af9a0 100644 --- a/tests/update/setup-POGO +++ b/tests/update/setup-POGO @@ -283,7 +283,6 @@ give h 10,2 10 edit l 12,2 s c S c e 1 give l 12,2 10 give h 12,2 50 -| TODO pop truncation on big city teardown || ship building | #0 100% | #60 stopped