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.87 by root, Thu Feb 15 21:07:48 2007 UTC

542 return false; 542 return false;
543 543
544 if (skip_header) 544 if (skip_header)
545 for (;;) 545 for (;;)
546 { 546 {
547 keyword kw = thawer.get_kv ();
548
549 if (kw == KW_end) 547 if (thawer.kw == KW_end)
550 break; 548 break;
551 549
552 thawer.skip_kv (kw); 550 thawer.skip_kv ();
553 } 551 }
554 552
555 return _load_objects (thawer); 553 return _load_objects (thawer);
556} 554}
557 555
803 801
804 case KW_end: 802 case KW_end:
805 return true; 803 return true;
806 804
807 default: 805 default:
808 if (!thawer.parse_error (kw, "map", 0)) 806 if (!thawer.parse_error ("map", 0))
809 return false; 807 return false;
810 break; 808 break;
811 } 809 }
812 } 810 }
813 811
1581get_rangevector (object *op1, object *op2, rv_vector * retval, int flags) 1579get_rangevector (object *op1, object *op2, rv_vector * retval, int flags)
1582{ 1580{
1583 if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y)) 1581 if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y))
1584 { 1582 {
1585 /* be conservative and fill in _some_ data */ 1583 /* be conservative and fill in _some_ data */
1586 retval->distance = 100000; 1584 retval->distance = 10000;
1587 retval->distance_x = 32767; 1585 retval->distance_x = 10000;
1588 retval->distance_y = 32767; 1586 retval->distance_y = 10000;
1589 retval->direction = 0; 1587 retval->direction = 0;
1590 retval->part = 0; 1588 retval->part = 0;
1591 } 1589 }
1592 else 1590 else
1593 { 1591 {
1598 1596
1599 best = op1; 1597 best = op1;
1600 /* If this is multipart, find the closest part now */ 1598 /* If this is multipart, find the closest part now */
1601 if (!(flags & 0x1) && op1->more) 1599 if (!(flags & 0x1) && op1->more)
1602 { 1600 {
1603 object *tmp;
1604 int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; 1601 int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi;
1605 1602
1606 /* we just take the offset of the piece to head to figure 1603 /* we just take the offset of the piece to head to figure
1607 * distance instead of doing all that work above again 1604 * distance instead of doing all that work above again
1608 * since the distance fields we set above are positive in the 1605 * since the distance fields we set above are positive in the
1609 * same axis as is used for multipart objects, the simply arithmetic 1606 * same axis as is used for multipart objects, the simply arithmetic
1610 * below works. 1607 * below works.
1611 */ 1608 */
1612 for (tmp = op1->more; tmp != NULL; tmp = tmp->more) 1609 for (object *tmp = op1->more; tmp; tmp = tmp->more)
1613 { 1610 {
1614 tmpi = (op1->x - tmp->x + retval->distance_x) * (op1->x - tmp->x + retval->distance_x) + 1611 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); 1612 (op1->y - tmp->y + retval->distance_y) * (op1->y - tmp->y + retval->distance_y);
1616 if (tmpi < best_distance) 1613 if (tmpi < best_distance)
1617 { 1614 {
1626 retval->distance_y += op1->y - best->y; 1623 retval->distance_y += op1->y - best->y;
1627 } 1624 }
1628 } 1625 }
1629 1626
1630 retval->part = best; 1627 retval->part = best;
1631 retval->distance = idistance (retval->distance_x, retval->distance_y); 1628 retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y));
1632 retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); 1629 retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y);
1633 } 1630 }
1634} 1631}
1635 1632
1636/* this is basically the same as get_rangevector above, but instead of 1633/* this is basically the same as get_rangevector above, but instead of

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines