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