]> git.pond.sub.org Git - empserver/commitdiff
(produce): When player->simulation, level production executed item
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 19 Mar 2005 16:50:22 +0000 (16:50 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 19 Mar 2005 16:50:22 +0000 (16:50 +0000)
production code for item I_NONE.  This tries to put products into
vec[I_NONE].  Until item.h rev. 1.12, vec[I_NONE] was unused and zero,
so it worked.  Since then, it's a subscript out of bounds, clobbering
two bytes of stack.  The (unpredictable) stack contents could make the
code believe that there's not enough space for the `products', which
then reduced predicted production, typically to zero.

src/lib/update/produce.c

index cd8597f73912dee30b7899db0178506c2b372454..02e7d5cb3b91525f8fff65a10b13cf724eb8608a 100644 (file)
@@ -108,10 +108,12 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
      * Adjust produced amount by commodity production ratio
      */
     output = material_consume * prodeff;
-    if (item == I_NONE && !player->simulation) {
-       levels[sp->sct_own][product->p_level] += output;
-       wu((natid)0, sp->sct_own, "%s (%.2f) produced in %s\n",
-          product->p_name, output, ownxy(sp));
+    if (item == I_NONE) {
+       if (!player->simulation) {
+           levels[sp->sct_own][product->p_level] += output;
+           wu((natid)0, sp->sct_own, "%s (%.2f) produced in %s\n",
+              product->p_name, output, ownxy(sp));
+       }
     } else {
        if ((actual = roundavg(output)) <= 0)
            return 0;