]> git.pond.sub.org Git - empserver/commitdiff
(produce): Fix consumed materials when production hits the 999 limit.
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 16 Mar 2004 19:25:13 +0000 (19:25 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 16 Mar 2004 19:25:13 +0000 (19:25 +0000)
This can't happen currently, because produce() never gets called with
work>999.

(produce): Fix rounding of consumed materials on production backlog.
Broken by the previous revision.

src/lib/update/produce.c

index 0d459431f90fc787a0a18cab0b43cc458a63a768..c2580b10a6759bb9512d38e3ad8b5e6776e1f0b7 100644 (file)
@@ -135,17 +135,16 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
                actual = *resource * 100 / product->p_nrdep;
        }
        if (actual > 999) {
+           material_consume = roundavg(999.0 * material_consume / actual);
            actual = 999;
-           material_consume = (int)(actual / (product->p_effic * 0.01));
        }
        if (vec[item] + actual > ITEM_MAX) {
-           material_consume =
-               roundavg((ITEM_MAX - vec[item]) * material_consume / actual);
+           material_consume = roundavg((double)(ITEM_MAX - vec[item])
+                                       * material_consume / actual);
            if (material_consume < 0)
                material_consume = 0;
            vec[item] = ITEM_MAX;
-           if (( /* vtype != V_FOOD && */ sp->sct_own) &&
-               (!player->simulation))
+           if (sp->sct_own && !player->simulation)
                wu(0, sp->sct_own,
                   "%s production backlog in %s\n",
                   product->p_name, ownxy(sp));