$NetBSD: patch-aa,v 1.2 2008/06/02 16:57:37 drochner Exp $ --- src/map/tileitem.cpp.orig 2008-05-16 00:47:34.000000000 +0200 +++ src/map/tileitem.cpp @@ -136,40 +136,42 @@ void TileItem_AlphaSoftware::Dig(const P buf += y * line_size; //Empties each line of the tile horizontaly that are in the circle - while ( (uint) y <= center.y + radius + EXPLOSION_BORDER_SIZE&& y < CELL_SIZE.y ) + for (; (uint)y <= center.y + radius + EXPLOSION_BORDER_SIZE && y < CELL_SIZE.y; + buf += line_size, y++) { //Abscisse distance from the center of the circle to the circle int dac = center.y - y; - //Angle on the circle - float angle = asin( (float)dac / (float)radius); + //Darken the border of the removed ground + int bstart_x, bend_x, blenght; + blenght = lrint(sqrt((radius + EXPLOSION_BORDER_SIZE) * (radius + EXPLOSION_BORDER_SIZE) + - dac * dac)); + + if ((uint)abs(dac) > radius) { + bstart_x = center.x - blenght; + bend_x = center.x + blenght; + Darken(bstart_x, bend_x, buf, bpp); + continue; + } //Zone of the line which needs to be emptied - int start_x, end_x, lenght; - lenght = (int) ((float) radius * cos (angle)); - lenght = lenght > 0 ? lenght : - lenght; - start_x = center.x - lenght; - lenght *= 2; - end_x = start_x + lenght; - Empty(start_x, end_x, buf, bpp); + int lenght; + lenght = lrint(sqrt(radius * radius - dac * dac)); - //Darken the border of the removed ground // Left half of the circle - int bstart_x, bend_x, blenght; - angle = asin( (float)dac / (float)(radius + EXPLOSION_BORDER_SIZE)); - blenght = (int) ((float) (radius + EXPLOSION_BORDER_SIZE) * cos (angle)); - blenght = blenght > 0 ? blenght : - blenght; bstart_x = center.x - blenght; - bend_x = bstart_x + (blenght - lenght/2); + bend_x = center.x - lenght; Darken(bstart_x, bend_x, buf, bpp); // Right half of the circle - bstart_x = center.x + lenght/2 + 1; - bend_x = bstart_x + (blenght - lenght/2); + bstart_x = center.x + lenght; + bend_x = center.x + blenght; Darken(bstart_x, bend_x, buf, bpp); - buf += line_size; - y++; + int start_x, end_x; + start_x = center.x - lenght; + end_x = center.x + lenght; + Empty(start_x, end_x, buf, bpp); } }