… | |
… | |
1420 | * |
1420 | * |
1421 | * currently, the only flag supported (0x1) is don't translate for |
1421 | * currently, the only flag supported (0x1) is don't translate for |
1422 | * closest body part of 'op1' |
1422 | * closest body part of 'op1' |
1423 | */ |
1423 | */ |
1424 | void |
1424 | void |
1425 | get_rangevector (object *op1, object *op2, rv_vector * retval, int flags) |
1425 | get_rangevector (object *op1, object *op2, rv_vector *retval, int flags) |
1426 | { |
1426 | { |
1427 | if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y)) |
1427 | if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y)) |
1428 | { |
1428 | { |
1429 | /* be conservative and fill in _some_ data */ |
1429 | /* be conservative and fill in _some_ data */ |
1430 | retval->distance = 10000; |
1430 | retval->distance = 10000; |
… | |
… | |
1433 | retval->direction = 0; |
1433 | retval->direction = 0; |
1434 | retval->part = 0; |
1434 | retval->part = 0; |
1435 | } |
1435 | } |
1436 | else |
1436 | else |
1437 | { |
1437 | { |
1438 | object *best; |
|
|
1439 | |
|
|
1440 | retval->distance_x += op2->x - op1->x; |
1438 | retval->distance_x += op2->x - op1->x; |
1441 | retval->distance_y += op2->y - op1->y; |
1439 | retval->distance_y += op2->y - op1->y; |
1442 | |
1440 | |
1443 | best = op1; |
1441 | object *best = op1; |
|
|
1442 | |
1444 | /* If this is multipart, find the closest part now */ |
1443 | /* If this is multipart, find the closest part now */ |
1445 | if (!(flags & 0x1) && op1->more) |
1444 | if (!(flags & 1) && op1->more) |
1446 | { |
1445 | { |
1447 | int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; |
1446 | int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; |
1448 | |
1447 | |
1449 | /* we just take the offset of the piece to head to figure |
1448 | /* we just take the offset of the piece to head to figure |
1450 | * distance instead of doing all that work above again |
1449 | * distance instead of doing all that work above again |