attempt to fix random deletion bug (can't reproduce easily, so can't tell if it's fixed easily)

This commit is contained in:
jacob1 2013-01-19 23:02:12 -05:00
parent 267cf9281b
commit 226a85a18d

View File

@ -2594,12 +2594,8 @@ void Simulation::detach(int i)
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);
int x = (int)(parts[i].x+0.5f);
int 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;
@ -2637,10 +2633,15 @@ void Simulation::kill_part(int i)//kills particle number i
void Simulation::part_change_type(int i, int x, int y, int t)//changes the type of particle number i, to t. This also changes pmap at the same time.
{
if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM)
if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM || !parts[i].type)
return;
if (!elements[t].Enabled)
t = PT_NONE;
if (t == PT_NONE)
{
kill_part(i);
return;
}
if (parts[i].type == PT_STKM)
player.spwn = 0;