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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.119 by root, Fri Jan 19 18:06:51 2007 UTC vs.
Revision 1.124 by root, Sat Jan 27 02:19:36 2007 UTC

670 face = blank_face; 670 face = blank_face;
671} 671}
672 672
673object::~object () 673object::~object ()
674{ 674{
675 if (index)
676 unlink (); 675 unlink ();
677 676
678 free_key_values (this); 677 free_key_values (this);
679} 678}
680 679
681static int object_count; 680static int object_count;
690 objects.insert (this); 689 objects.insert (this);
691} 690}
692 691
693void object::unlink () 692void object::unlink ()
694{ 693{
695 assert (index);//D 694 if (!index)
695 return;
696
696 objects.erase (this); 697 objects.erase (this);
697 refcnt_dec (); 698 refcnt_dec ();
698} 699}
699 700
700void 701void
774 * drop on that space. 775 * drop on that space.
775 */ 776 */
776 if (!drop_to_ground 777 if (!drop_to_ground
777 || !map 778 || !map
778 || map->in_memory != MAP_IN_MEMORY 779 || map->in_memory != MAP_IN_MEMORY
780 || map->nodrop
779 || ms ().move_block == MOVE_ALL) 781 || ms ().move_block == MOVE_ALL)
780 { 782 {
781 while (inv) 783 while (inv)
782 { 784 {
783 inv->destroy_inv (drop_to_ground); 785 inv->destroy_inv (drop_to_ground);
899 * This function removes the object op from the linked list of objects 901 * This function removes the object op from the linked list of objects
900 * which it is currently tied to. When this function is done, the 902 * which it is currently tied to. When this function is done, the
901 * object will have no environment. If the object previously had an 903 * object will have no environment. If the object previously had an
902 * environment, the x and y coordinates will be updated to 904 * environment, the x and y coordinates will be updated to
903 * the previous environment. 905 * the previous environment.
904 * Beware: This function is called from the editor as well!
905 */ 906 */
906void 907void
907object::remove_slow () 908object::remove_slow ()
908{ 909{
909 object *tmp, *last = 0; 910 object *tmp, *last = 0;
1749 if ((!op->move_type && tmp->move_slow & MOVE_WALK) || 1750 if ((!op->move_type && tmp->move_slow & MOVE_WALK) ||
1750 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) 1751 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0))
1751 { 1752 {
1752 1753
1753 float 1754 float
1754 diff = tmp->move_slow_penalty * FABS (op->speed); 1755 diff = tmp->move_slow_penalty * fabs (op->speed);
1755 1756
1756 if (op->type == PLAYER) 1757 if (op->type == PLAYER)
1757 if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || 1758 if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) ||
1758 (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) 1759 (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN)))
1759 diff /= 4.0; 1760 diff /= 4.0;
1966 } 1967 }
1967 1968
1968 if (!index) 1969 if (!index)
1969 return -1; 1970 return -1;
1970 1971
1971 return altern[RANDOM () % index]; 1972 return altern [rndm (index)];
1972} 1973}
1973 1974
1974/* 1975/*
1975 * find_first_free_spot(archetype, maptile, x, y) works like 1976 * find_first_free_spot(archetype, maptile, x, y) works like
1976 * find_free_spot(), but it will search max number of squares. 1977 * find_free_spot(), but it will search max number of squares.
1997{ 1998{
1998 arr += begin; 1999 arr += begin;
1999 end -= begin; 2000 end -= begin;
2000 2001
2001 while (--end) 2002 while (--end)
2002 swap (arr [end], arr [RANDOM () % (end + 1)]); 2003 swap (arr [end], arr [rndm (end + 1)]);
2003} 2004}
2004 2005
2005/* new function to make monster searching more efficient, and effective! 2006/* new function to make monster searching more efficient, and effective!
2006 * This basically returns a randomized array (in the passed pointer) of 2007 * This basically returns a randomized array (in the passed pointer) of
2007 * the spaces to find monsters. In this way, it won't always look for 2008 * the spaces to find monsters. In this way, it won't always look for

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines