ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.85 by root, Wed Feb 7 23:50:01 2007 UTC vs.
Revision 1.86 by root, Thu Feb 15 15:43:36 2007 UTC

1581get_rangevector (object *op1, object *op2, rv_vector * retval, int flags) 1581get_rangevector (object *op1, object *op2, rv_vector * retval, int flags)
1582{ 1582{
1583 if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y)) 1583 if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y))
1584 { 1584 {
1585 /* be conservative and fill in _some_ data */ 1585 /* be conservative and fill in _some_ data */
1586 retval->distance = 100000; 1586 retval->distance = 10000;
1587 retval->distance_x = 32767; 1587 retval->distance_x = 10000;
1588 retval->distance_y = 32767; 1588 retval->distance_y = 10000;
1589 retval->direction = 0; 1589 retval->direction = 0;
1590 retval->part = 0; 1590 retval->part = 0;
1591 } 1591 }
1592 else 1592 else
1593 { 1593 {
1598 1598
1599 best = op1; 1599 best = op1;
1600 /* If this is multipart, find the closest part now */ 1600 /* If this is multipart, find the closest part now */
1601 if (!(flags & 0x1) && op1->more) 1601 if (!(flags & 0x1) && op1->more)
1602 { 1602 {
1603 object *tmp;
1604 int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; 1603 int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi;
1605 1604
1606 /* we just take the offset of the piece to head to figure 1605 /* we just take the offset of the piece to head to figure
1607 * distance instead of doing all that work above again 1606 * distance instead of doing all that work above again
1608 * since the distance fields we set above are positive in the 1607 * since the distance fields we set above are positive in the
1609 * same axis as is used for multipart objects, the simply arithmetic 1608 * same axis as is used for multipart objects, the simply arithmetic
1610 * below works. 1609 * below works.
1611 */ 1610 */
1612 for (tmp = op1->more; tmp != NULL; tmp = tmp->more) 1611 for (object *tmp = op1->more; tmp; tmp = tmp->more)
1613 { 1612 {
1614 tmpi = (op1->x - tmp->x + retval->distance_x) * (op1->x - tmp->x + retval->distance_x) + 1613 tmpi = (op1->x - tmp->x + retval->distance_x) * (op1->x - tmp->x + retval->distance_x) +
1615 (op1->y - tmp->y + retval->distance_y) * (op1->y - tmp->y + retval->distance_y); 1614 (op1->y - tmp->y + retval->distance_y) * (op1->y - tmp->y + retval->distance_y);
1616 if (tmpi < best_distance) 1615 if (tmpi < best_distance)
1617 { 1616 {
1626 retval->distance_y += op1->y - best->y; 1625 retval->distance_y += op1->y - best->y;
1627 } 1626 }
1628 } 1627 }
1629 1628
1630 retval->part = best; 1629 retval->part = best;
1631 retval->distance = idistance (retval->distance_x, retval->distance_y); 1630 retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y));
1632 retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); 1631 retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y);
1633 } 1632 }
1634} 1633}
1635 1634
1636/* this is basically the same as get_rangevector above, but instead of 1635/* this is basically the same as get_rangevector above, but instead of

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines