diff options
| author | jacob1 <jfu614@gmail.com> | 2013-01-20 04:02:12 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-01-20 04:02:12 (GMT) |
| commit | 226a85a18dfaddb29031d428ac11561136f28c66 (patch) | |
| tree | d2bd24fba8a8a258cb40c0236bd87451fea96b32 /src/simulation/Simulation.cpp | |
| parent | 267cf9281be25d1dfc1338de42cb7a0c67704f32 (diff) | |
| download | powder-226a85a18dfaddb29031d428ac11561136f28c66.zip powder-226a85a18dfaddb29031d428ac11561136f28c66.tar.gz | |
attempt to fix random deletion bug (can't reproduce easily, so can't tell if it's fixed easily)
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 7956409..9826670 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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; |
