From 2184d35b28a42358ed232b7c448e7462e403e172 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 20 Feb 2013 21:11:50 -0500 Subject: [PATCH] reset colored and partsRemaining, to fix bugs when CRAY is sparked multiple times at once --- src/simulation/elements/CRAY.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp index f0c0c9f68..525ba2f06 100644 --- a/src/simulation/elements/CRAY.cpp +++ b/src/simulation/elements/CRAY.cpp @@ -49,9 +49,7 @@ Element_CRAY::Element_CRAY() //#TPT-Directive ElementHeader Element_CRAY static int update(UPDATE_FUNC_ARGS) int Element_CRAY::update(UPDATE_FUNC_ARGS) { - int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1, partsRemaining = 255; - if (parts[i].tmp) //how far it shoots - partsRemaining = parts[i].tmp; + int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1; // set ctype to things that touch it if it doesn't have one already if(parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled) { int r, rx, ry; @@ -70,7 +68,6 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS) } } } else if (parts[i].life==0) { // only fire when life is 0, but nothing sets the life right now - unsigned int colored = 0; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx>8].life==3) { //spark found, start creating + unsigned int colored = 0; int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; int nostop = (parts[r>>8].ctype==PT_INST)?1:0; + int partsRemaining = 255; + if (parts[i].tmp) //how far it shoots + partsRemaining = parts[i].tmp; for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) { if (!(x+nxi+nxx= 0 && y+nyi+nyy >= 0)) { break;