From b7e50f521c7163b21488c030be3d7bed4cba5807 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sun, 6 Feb 2011 17:16:49 +0000 Subject: [PATCH] Fix flood_parts crashes Crashes due to infinite recursion in flood_parts, which seemed to be caused by the pmap being incorrect. --- src/powder.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/powder.c b/src/powder.c index 4d8ba4598..8348fb04b 100644 --- a/src/powder.c +++ b/src/powder.c @@ -253,11 +253,9 @@ int try_move(int i, int x, int y, int nx, int ny) parts[e].x += x-nx; parts[e].y += y-ny; + pmap[(int)(parts[e].y+0.5f)][(int)(parts[e].x+0.5f)] = (e<<8)|parts[e].type; } - pmap[ny][nx] = (i<<8)|parts[i].type; - pmap[y][x] = r; - return 1; } @@ -2030,10 +2028,18 @@ killed: } nx = (int)(parts[i].x+0.5f); ny = (int)(parts[i].y+0.5f); - if (nx=XRES-CELL || ny=YRES-CELL) + if (ny!=y || nx!=x) { - kill_part(i); - continue; + if ((pmap[y][x]>>8)==i) pmap[y][x] = 0; + if (nx=XRES-CELL || ny=YRES-CELL) + { + kill_part(i); + continue; + } + if (t==PT_PHOT) + photons[ny][nx] = t|(i<<8); + else + pmap[ny][nx] = t|(i<<8); } } if (framerender) {