summaryrefslogtreecommitdiff
path: root/src/simulation/Simulation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/Simulation.cpp')
-rw-r--r--src/simulation/Simulation.cpp15
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;