summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob1 <jfu614@gmail.com>2011-11-22 22:46:01 (GMT)
committer Jacob1 <jfu614@gmail.com>2012-03-14 22:50:29 (GMT)
commitdea920680bd25d8fd15e1db1a62324a4f13a2ed2 (patch)
tree4ce7bf3149be66de8b83a7bc97dc6c0866dd7368 /src
parent5f51cb30429b20c99b008f3c00791678bce6475f (diff)
downloadpowder-dea920680bd25d8fd15e1db1a62324a4f13a2ed2.zip
powder-dea920680bd25d8fd15e1db1a62324a4f13a2ed2.tar.gz
Specific delete speed increase, delete useless(?) if statement
Diffstat (limited to 'src')
-rw-r--r--src/powder.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/powder.c b/src/powder.c
index 45b9e6c..bcc3427 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -3111,32 +3111,23 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
delete_part(x, y, flags);
}
else
- for (j=-ry; j<=ry; j++)
- for (i=-rx; i<=rx; i++)
- if (InCurrentBrush(i ,j ,rx ,ry))
- delete_part(x+i, y+j, flags);
- return 1;
- }
-
- //why do these need a special if
- if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV)
- {
- if (rx==0&&ry==0)
{
- create_part(-2, x, y, c);
+ int tempy = y, i, j, jmax;
+ if (CURRENT_BRUSH == TRI_BRUSH)
+ tempy = y + ry;
+ for (i = x - rx; i <= x; i++) {
+ while (InCurrentBrush(i-x,tempy-y,rx,ry))
+ tempy = tempy - 1;
+ tempy = tempy + 1;
+ jmax = 2*y - tempy;
+ if (CURRENT_BRUSH == TRI_BRUSH)
+ jmax = y + ry;
+ for (j = tempy; j <= jmax; j++) {
+ delete_part(i, j, flags);
+ delete_part(2*x-i, j, flags);
+ }
+ }
}
- else
- for (j=-ry; j<=ry; j++)
- for (i=-rx; i<=rx; i++)
- if (InCurrentBrush(i ,j ,rx ,ry))
- {
- if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
- continue;
- if (!REPLACE_MODE)
- create_part(-2, x+i, y+j, c);
- else if ((pmap[y+j][x+i]&0xFF)==SLALT&&SLALT!=0)
- create_part(-2, x+i, y+j, c);
- }
return 1;
}