From 17f8ffee1b8bbd86e7e07be7ca80aa6df20c910b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 19 Mar 2005 16:50:22 +0000 Subject: [PATCH] (produce): When player->simulation, level production executed item 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/update/produce.c b/src/lib/update/produce.c index cd8597f7..02e7d5cb 100644 --- a/src/lib/update/produce.c +++ b/src/lib/update/produce.c @@ -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;