… | |
… | |
670 | face = blank_face; |
670 | face = blank_face; |
671 | } |
671 | } |
672 | |
672 | |
673 | object::~object () |
673 | object::~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 | |
681 | static int object_count; |
680 | static int object_count; |
… | |
… | |
690 | objects.insert (this); |
689 | objects.insert (this); |
691 | } |
690 | } |
692 | |
691 | |
693 | void object::unlink () |
692 | void 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 | |
700 | void |
701 | void |
… | |
… | |
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 | */ |
906 | void |
907 | void |
907 | object::remove_slow () |
908 | object::remove_slow () |
908 | { |
909 | { |
909 | object *tmp, *last = 0; |
910 | object *tmp, *last = 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 |
… | |
… | |
2599 | { |
2600 | { |
2600 | static char info[256 * 4]; |
2601 | static char info[256 * 4]; |
2601 | return debug_desc (info); |
2602 | return debug_desc (info); |
2602 | } |
2603 | } |
2603 | |
2604 | |
|
|
2605 | struct region * |
|
|
2606 | object::region () const |
|
|
2607 | { |
|
|
2608 | return map ? map->region (x, y) |
|
|
2609 | : region::default_region (); |
|
|
2610 | } |
|
|
2611 | |