]> git.pond.sub.org Git - empserver/commitdiff
Fix mine production resource limit for peffic != 100%
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 21 May 2009 16:57:55 +0000 (18:57 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 21 May 2009 16:57:55 +0000 (18:57 +0200)
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

index 31111695a5795b66251971dd51adba12c20d9848..8fbc569fa688b299edb3a55055564fc0e5898c6e 100644 (file)
@@ -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;