attempt to fix random deletion bug (can't reproduce easily, so can't tell if it's fixed easily)
This commit is contained in:
parent
267cf9281b
commit
226a85a18d
@ -2594,12 +2594,8 @@ void Simulation::detach(int i)
|
|||||||
|
|
||||||
void Simulation::kill_part(int i)//kills particle number i
|
void Simulation::kill_part(int i)//kills particle number i
|
||||||
{
|
{
|
||||||
int x, y;
|
int x = (int)(parts[i].x+0.5f);
|
||||||
|
int y = (int)(parts[i].y+0.5f);
|
||||||
// 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 (x>=0 && y>=0 && x<XRES && y<YRES) {
|
||||||
if ((pmap[y][x]>>8)==i)
|
if ((pmap[y][x]>>8)==i)
|
||||||
pmap[y][x] = 0;
|
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.
|
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;
|
return;
|
||||||
if (!elements[t].Enabled)
|
if (!elements[t].Enabled)
|
||||||
t = PT_NONE;
|
t = PT_NONE;
|
||||||
|
if (t == PT_NONE)
|
||||||
|
{
|
||||||
|
kill_part(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (parts[i].type == PT_STKM)
|
if (parts[i].type == PT_STKM)
|
||||||
player.spwn = 0;
|
player.spwn = 0;
|
||||||
|
Reference in New Issue
Block a user