(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.
This commit is contained in:
Markus Armbruster 2005-03-19 16:50:22 +00:00
parent ab509c22ef
commit 17f8ffee1b

View 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;