From ff1255afd2883c6fb9ba124cd622fb2d94453a47 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 23 Dec 2010 15:46:06 -0500 Subject: [PATCH 1/2] a fix for 1 pixel brush and flood fill crashing in certain builds. --- src/powder.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/powder.c b/src/powder.c index 4b03e5bcb..19320df64 100644 --- a/src/powder.c +++ b/src/powder.c @@ -5591,6 +5591,8 @@ int flood_parts(int x, int y, int c, int cm, int bm) { int x1, x2, dy = (cYRES||y<0) + return 0; if(cm==PT_INST&&co==PT_SPRK) if((pmap[y][x]&0xFF)==PT_SPRK) return 0; @@ -5775,6 +5777,11 @@ int create_parts(int x, int y, int rx, int ry, int c) if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE) { + if(rx==0&&ry==0) + { + delete_part(x, y); + } + else for(j=-ry; j<=ry; j++) for(i=-rx; i<=rx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) @@ -5784,6 +5791,11 @@ int create_parts(int x, int y, int rx, int ry, int c) if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM) { + if(rx==0&&ry==0) + { + create_part(-2, x, y, c); + } + else for(j=-ry; j<=ry; j++) for(i=-rx; i<=rx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) @@ -5798,6 +5810,11 @@ int create_parts(int x, int y, int rx, int ry, int c) { stemp = SLALT; SLALT = 0; + if(rx==0&&ry==0) + { + delete_part(x, y); + } + else for(j=-ry; j<=ry; j++) for(i=-rx; i<=rx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) @@ -5807,6 +5824,11 @@ int create_parts(int x, int y, int rx, int ry, int c) } if(REPLACE_MODE) { + if(rx==0&&ry==0) + { + create_part(-2, x, y, c); + } + else for(j=-ry; j<=ry; j++) for(i=-rx; i<=rx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) @@ -5823,6 +5845,11 @@ int create_parts(int x, int y, int rx, int ry, int c) return 1; } + if(rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. + { + create_part(-2, x, y, c); + } + else for(j=-ry; j<=ry; j++) for(i=-rx; i<=rx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) From 41d9dca73fd5f29bfd30927ec5429d050718f68c Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Thu, 23 Dec 2010 15:48:11 -0500 Subject: [PATCH 2/2] oops, that wasn't needed --- src/powder.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/powder.c b/src/powder.c index 19320df64..02a740fbf 100644 --- a/src/powder.c +++ b/src/powder.c @@ -5591,8 +5591,6 @@ int flood_parts(int x, int y, int c, int cm, int bm) { int x1, x2, dy = (cYRES||y<0) - return 0; if(cm==PT_INST&&co==PT_SPRK) if((pmap[y][x]&0xFF)==PT_SPRK) return 0;