summaryrefslogtreecommitdiff
path: root/src/simulation/elements/CRAY.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-02-21 02:11:50 (GMT)
committer jacob1 <jfu614@gmail.com>2013-02-21 02:11:50 (GMT)
commit2184d35b28a42358ed232b7c448e7462e403e172 (patch)
tree77b12089207d821354e2d06747d225ce5950eae0 /src/simulation/elements/CRAY.cpp
parent74387040a1b616de6f744e4137cff72880b580d8 (diff)
downloadpowder-2184d35b28a42358ed232b7c448e7462e403e172.zip
powder-2184d35b28a42358ed232b7c448e7462e403e172.tar.gz
reset colored and partsRemaining, to fix bugs when CRAY is sparked multiple times at once
Diffstat (limited to 'src/simulation/elements/CRAY.cpp')
-rw-r--r--src/simulation/elements/CRAY.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp
index f0c0c9f..525ba2f 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<XRES && y+ry<YRES && (rx || ry))
@@ -79,8 +76,12 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>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<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
break;