TPT: Fix crash when flood fill deleting life 7a844f51ff

This commit is contained in:
Simon Robertshaw 2012-04-18 21:07:26 +01:00
parent ea37facf83
commit ff7428fc70

View File

@ -1703,13 +1703,22 @@ void Simulation::kill_part(int i)//kills particle number i
{ {
int x, y; 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) if (parts[i].type == PT_NONE)
return; return;
if(elementCount[parts[i].type] && parts[i].type) if(elementCount[parts[i].type] && parts[i].type)
elementCount[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) if (parts[i].type == PT_STKM)
{ {
player.spwn = 0; player.spwn = 0;
@ -1727,12 +1736,6 @@ void Simulation::kill_part(int i)//kills particle number i
{ {
detach(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].type = PT_NONE;
parts[i].life = pfree; parts[i].life = pfree;