… | |
… | |
1445 | object *best = op1; |
1445 | object *best = op1; |
1446 | |
1446 | |
1447 | /* If this is multipart, find the closest part now */ |
1447 | /* If this is multipart, find the closest part now */ |
1448 | if (!(flags & 1) && op1->more) |
1448 | if (!(flags & 1) && op1->more) |
1449 | { |
1449 | { |
1450 | int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; |
1450 | int best_distance = idistance (retval->distance_x, retval->distance_y); |
1451 | |
1451 | |
1452 | /* we just take the offset of the piece to head to figure |
1452 | /* we just take the offset of the piece to head to figure |
1453 | * distance instead of doing all that work above again |
1453 | * distance instead of doing all that work above again |
1454 | * since the distance fields we set above are positive in the |
1454 | * since the distance fields we set above are positive in the |
1455 | * same axis as is used for multipart objects, the simply arithmetic |
1455 | * same axis as is used for multipart objects, the simply arithmetic |
1456 | * below works. |
1456 | * below works. |
1457 | */ |
1457 | */ |
1458 | for (object *tmp = op1->more; tmp; tmp = tmp->more) |
1458 | for (object *tmp = op1->more; tmp; tmp = tmp->more) |
1459 | { |
1459 | { |
1460 | tmpi = (op1->x - tmp->x + retval->distance_x) * (op1->x - tmp->x + retval->distance_x) + |
1460 | int tmpi = idistance (op1->x - tmp->x + retval->distance_x, op1->y - tmp->y + retval->distance_y); |
1461 | (op1->y - tmp->y + retval->distance_y) * (op1->y - tmp->y + retval->distance_y); |
1461 | |
1462 | if (tmpi < best_distance) |
1462 | if (tmpi < best_distance) |
1463 | { |
1463 | { |
1464 | best_distance = tmpi; |
1464 | best_distance = tmpi; |
1465 | best = tmp; |
1465 | best = tmp; |
1466 | } |
1466 | } |
1467 | } |
1467 | } |
1468 | |
1468 | |
1469 | if (best != op1) |
1469 | if (best != op1) |
1470 | { |
1470 | { |