diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-04-14 18:12:08 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-04-14 18:12:08 (GMT) |
| commit | 7a844f51ff7673aa49aee0f04517235c9a4da84a (patch) | |
| tree | 0777739fa5f65d2987a6c01c28caabf466e6412d /src | |
| parent | db9e38d1e37d24ed8f02ae2607a4d993224c5b58 (diff) | |
| download | powder-7a844f51ff7673aa49aee0f04517235c9a4da84a.zip powder-7a844f51ff7673aa49aee0f04517235c9a4da84a.tar.gz | |
Fix crash when flood fill deleting life
Diffstat (limited to 'src')
| -rw-r--r-- | src/powder.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/powder.c b/src/powder.c index ceab90e..6dc0655 100644 --- a/src/powder.c +++ b/src/powder.c @@ -592,11 +592,20 @@ void 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); + if (x>=0 && y>=0 && x<XRES && y<YRES) { + if ((pmap[y][x]>>8)==i) + pmap[y][x] = 0; + else if ((photons[y][x]>>8)==i) + photons[y][x] = 0; + } + if (parts[i].type == PT_NONE) //This shouldn't happen anymore, but it's here just in case return; - x = (int)(parts[i].x+0.5f); - y = (int)(parts[i].y+0.5f); if (parts[i].type == PT_STKM) { player.spwn = 0; @@ -622,12 +631,6 @@ void kill_part(int i)//kills particle number i { detach(i); } - if (x>=0 && y>=0 && x<XRES && y<YRES) { - if ((pmap[y][x]>>8)==i) - pmap[y][x] = 0; - else if ((photons[y][x]>>8)==i) - photons[y][x] = 0; - } parts[i].type = PT_NONE; parts[i].life = pfree; |
