From e0a2b4ca4c6ba30df86ae7f0bc1c0b6f8cc623c6 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 21 May 2009 18:57:55 +0200 Subject: [PATCH] Fix mine production resource limit for peffic != 100% With etu_per_update large and resource depletion quick, a sector can produce more work than is required to fully deplete a mine. In that case, produce() and prod() limit production to what is actually in the ground. Except produce() got it wrong for sector types with production efficiency other than 100%. This affects mountains in the stock game, but only with impractically large etu_per_update. --- src/lib/update/produce.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/update/produce.c b/src/lib/update/produce.c index 31111695..8fbc569f 100644 --- a/src/lib/update/produce.c +++ b/src/lib/update/produce.c @@ -90,6 +90,10 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, worker_limit = roundavg(work * p_e / unit_work); if (material_consume > worker_limit) material_consume = worker_limit; + if (product->p_nrdep != 0) { + if (*resource * 100 < product->p_nrdep * material_consume) + material_consume = *resource * 100 / product->p_nrdep; + } if (material_consume == 0) return 0; prodeff = prod_eff(desig, np->nat_level[product->p_nlndx]); @@ -114,10 +118,6 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work, actual = roundavg(output); if (actual <= 0) return 0; - if (product->p_nrdep != 0) { - if (*resource * 100 < product->p_nrdep * actual) - actual = *resource * 100 / product->p_nrdep; - } if (actual > 999) { material_consume = roundavg(999.0 * material_consume / actual); actual = 999;