--------------------------------------------- DRAW SHAPES ------------------------------------------------
| 210 | #define positive( x ) ( (x) > 1 ? (x) : 1 ) |
| 211 | //--------------------------------------------- DRAW SHAPES ------------------------------------------------ |
| 212 | int GameImpl::drawShapes() |
| 213 | { |
| 214 | for ( int i = 0; i < data->shapeCount; i++ ) |
| 215 | { |
| 216 | BWAPIC::ShapeType::Enum s = data->shapes[i].type; |
| 217 | int x1 = data->shapes[i].x1; |
| 218 | int y1 = data->shapes[i].y1; |
| 219 | int x2, y2, w, h; |
| 220 | int radius, f, ddF_x, ddF_y, xi, yi; |
| 221 | int xrad, yrad; |
| 222 | CoordinateType::Enum ctype = data->shapes[i].ctype; |
| 223 | bool isSolid = data->shapes[i].isSolid; |
| 224 | BWAPI::Color color = Color(data->shapes[i].color); |
| 225 | switch ( s ) |
| 226 | { |
| 227 | case BWAPIC::ShapeType::Text: |
| 228 | bwDrawText(x1,y1,data->strings[data->shapes[i].extra1],ctype,(char)data->shapes[i].extra2); |
| 229 | break; |
| 230 | case BWAPIC::ShapeType::Box: |
| 231 | x2 = data->shapes[i].x2; |
| 232 | y2 = data->shapes[i].y2; |
| 233 | w = abs(x2 - x1); |
| 234 | h = abs(y2 - y1); |
| 235 | if (isSolid) |
| 236 | { |
| 237 | bwDrawBox(x1, y1, w, h, color, ctype); |
| 238 | } |
| 239 | else |
| 240 | { |
| 241 | bwDrawBox( x1, y1, 1, h, color, ctype); |
| 242 | bwDrawBox( x1, y1, w, 1, color, ctype); |
| 243 | bwDrawBox(x2-1, y1, 1, h, color, ctype); |
| 244 | bwDrawBox( x1, y2-1, w, 1, color, ctype); |
| 245 | } |
| 246 | break; |
| 247 | case BWAPIC::ShapeType::Triangle: |
| 248 | { |
| 249 | x2 = data->shapes[i].x2; |
| 250 | y2 = data->shapes[i].y2; |
| 251 | int x3 = data->shapes[i].extra1; |
| 252 | int y3 = data->shapes[i].extra2; |
| 253 | if (isSolid) |
| 254 | { |
| 255 | int ly, ry, lx, rx; |
| 256 | if (y1 > y2) { std::swap(x1, x2); std::swap(y1, y2); } |
| 257 | if (y1 > y3) { std::swap(x1, x3); std::swap(y1, y3); } |
| 258 | if (y2 > y3) { std::swap(x2, x3); std::swap(y2, y3); } |
| 259 | |
| 260 | int dx1 = int2Fixed(x2 - x1); |
| 261 | int dx2 = int2Fixed(x3 - x1); |
| 262 | int dx3 = int2Fixed(x3 - x2); |
| 263 | if (y2 - y1 > 0) dx1 /= (y2 - y1); |
| 264 | if (y3 - y1 > 0) dx2 /= (y3 - y1); |
| 265 | if (y3 - y2 > 0) dx3 /= (y3 - y2); |
| 266 | |
| 267 | rx = lx = int2Fixed(x1); |
| 268 | ry = ly = y1; |
| 269 | if (dx1 > dx2) |
no test coverage detected