From 226a85a18dfaddb29031d428ac11561136f28c66 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 19 Jan 2013 23:02:12 -0500 Subject: attempt to fix random deletion bug (can't reproduce easily, so can't tell if it's fixed easily) 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>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; -- cgit v0.9.2-21-gd62e