summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-18 20:07:26 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-18 20:07:26 (GMT)
commitff7428fc70385287204832048bcf2f3c72aaabe8 (patch)
tree0cd77151a728f114adc73df0b307ebdfe334b21b /src/simulation
parentea37facf83bae0b25b3826e04f7da2f7ee8e889d (diff)
downloadpowder-ff7428fc70385287204832048bcf2f3c72aaabe8.zip
powder-ff7428fc70385287204832048bcf2f3c72aaabe8.tar.gz
TPT: Fix crash when flood fill deleting life 7a844f51ff
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Simulation.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 017925a..fdc94ab 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -1703,13 +1703,22 @@ void Simulation::kill_part(int i)//kills particle number i
{
int x, y;
+ // Remove from pmap even if type==0, otherwise infinite recursion occurs when flood fill deleting
+ // a particle which sets type to 0 without calling kill_part (such as LIFE)
+ x = (int)(parts[i].x+0.5f);
+ y = (int)(parts[i].y+0.5f);
+ if (x>=0 && y>=0 && x<XRES && y<YRES) {
+ if ((pmap[y][x]>>8)==i)
+ pmap[y][x] = 0;
+ else if ((photons[y][x]>>8)==i)
+ photons[y][x] = 0;
+ }
+
if (parts[i].type == PT_NONE)
return;
if(elementCount[parts[i].type] && parts[i].type)
elementCount[parts[i].type]--;
- x = (int)(parts[i].x+0.5f);
- y = (int)(parts[i].y+0.5f);
if (parts[i].type == PT_STKM)
{
player.spwn = 0;
@@ -1727,12 +1736,6 @@ void Simulation::kill_part(int i)//kills particle number i
{
detach(i);
}
- if (x>=0 && y>=0 && x<XRES && y<YRES) {
- if ((pmap[y][x]>>8)==i)
- pmap[y][x] = 0;
- else if ((photons[y][x]>>8)==i)
- photons[y][x] = 0;
- }
parts[i].type = PT_NONE;
parts[i].life = pfree;