… | |
… | |
775 | * drop on that space. |
775 | * drop on that space. |
776 | */ |
776 | */ |
777 | if (!drop_to_ground |
777 | if (!drop_to_ground |
778 | || !map |
778 | || !map |
779 | || map->in_memory != MAP_IN_MEMORY |
779 | || map->in_memory != MAP_IN_MEMORY |
|
|
780 | || map->nodrop |
780 | || ms ().move_block == MOVE_ALL) |
781 | || ms ().move_block == MOVE_ALL) |
781 | { |
782 | { |
782 | while (inv) |
783 | while (inv) |
783 | { |
784 | { |
784 | inv->destroy_inv (drop_to_ground); |
785 | inv->destroy_inv (drop_to_ground); |
… | |
… | |
818 | |
819 | |
819 | if (flag [FLAG_IS_LINKED]) |
820 | if (flag [FLAG_IS_LINKED]) |
820 | remove_button_link (this); |
821 | remove_button_link (this); |
821 | |
822 | |
822 | if (flag [FLAG_FRIENDLY]) |
823 | if (flag [FLAG_FRIENDLY]) |
|
|
824 | { |
823 | remove_friendly_object (this); |
825 | remove_friendly_object (this); |
|
|
826 | |
|
|
827 | if (type == GOLEM |
|
|
828 | && owner |
|
|
829 | && owner->type == PLAYER |
|
|
830 | && owner->contr->ranges[range_golem] == this) |
|
|
831 | owner->contr->ranges[range_golem] = 0; |
|
|
832 | } |
824 | |
833 | |
825 | if (!flag [FLAG_REMOVED]) |
834 | if (!flag [FLAG_REMOVED]) |
826 | remove (); |
835 | remove (); |
827 | |
836 | |
828 | destroy_inv (true); |
837 | destroy_inv (true); |
… | |
… | |
900 | * This function removes the object op from the linked list of objects |
909 | * This function removes the object op from the linked list of objects |
901 | * which it is currently tied to. When this function is done, the |
910 | * which it is currently tied to. When this function is done, the |
902 | * object will have no environment. If the object previously had an |
911 | * object will have no environment. If the object previously had an |
903 | * environment, the x and y coordinates will be updated to |
912 | * environment, the x and y coordinates will be updated to |
904 | * the previous environment. |
913 | * the previous environment. |
905 | * Beware: This function is called from the editor as well! |
|
|
906 | */ |
914 | */ |
907 | void |
915 | void |
908 | object::remove_slow () |
916 | object::do_remove () |
909 | { |
917 | { |
910 | object *tmp, *last = 0; |
918 | object *tmp, *last = 0; |
911 | object *otmp; |
919 | object *otmp; |
912 | |
920 | |
913 | if (QUERY_FLAG (this, FLAG_REMOVED)) |
921 | if (QUERY_FLAG (this, FLAG_REMOVED)) |
… | |
… | |
1967 | } |
1975 | } |
1968 | |
1976 | |
1969 | if (!index) |
1977 | if (!index) |
1970 | return -1; |
1978 | return -1; |
1971 | |
1979 | |
1972 | return altern[RANDOM () % index]; |
1980 | return altern [rndm (index)]; |
1973 | } |
1981 | } |
1974 | |
1982 | |
1975 | /* |
1983 | /* |
1976 | * find_first_free_spot(archetype, maptile, x, y) works like |
1984 | * find_first_free_spot(archetype, maptile, x, y) works like |
1977 | * find_free_spot(), but it will search max number of squares. |
1985 | * find_free_spot(), but it will search max number of squares. |
… | |
… | |
1998 | { |
2006 | { |
1999 | arr += begin; |
2007 | arr += begin; |
2000 | end -= begin; |
2008 | end -= begin; |
2001 | |
2009 | |
2002 | while (--end) |
2010 | while (--end) |
2003 | swap (arr [end], arr [RANDOM () % (end + 1)]); |
2011 | swap (arr [end], arr [rndm (end + 1)]); |
2004 | } |
2012 | } |
2005 | |
2013 | |
2006 | /* new function to make monster searching more efficient, and effective! |
2014 | /* new function to make monster searching more efficient, and effective! |
2007 | * This basically returns a randomized array (in the passed pointer) of |
2015 | * This basically returns a randomized array (in the passed pointer) of |
2008 | * the spaces to find monsters. In this way, it won't always look for |
2016 | * the spaces to find monsters. In this way, it won't always look for |
… | |
… | |
2570 | { |
2578 | { |
2571 | char flagdesc[512]; |
2579 | char flagdesc[512]; |
2572 | char info2[256 * 4]; |
2580 | char info2[256 * 4]; |
2573 | char *p = info; |
2581 | char *p = info; |
2574 | |
2582 | |
2575 | p += snprintf (p, 512, "{cnt:%d,uuid:<1,%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", |
2583 | p += snprintf (p, 512, "{cnt:%d,uuid:<1.%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", |
2576 | count, uuid.seq, |
2584 | count, uuid.seq, |
2577 | &name, |
2585 | &name, |
2578 | title ? "\",title:\"" : "", |
2586 | title ? "\",title:\"" : "", |
2579 | title ? (const char *)title : "", |
2587 | title ? (const char *)title : "", |
2580 | flag_desc (flagdesc, 512), type); |
2588 | flag_desc (flagdesc, 512), type); |
… | |
… | |
2600 | { |
2608 | { |
2601 | static char info[256 * 4]; |
2609 | static char info[256 * 4]; |
2602 | return debug_desc (info); |
2610 | return debug_desc (info); |
2603 | } |
2611 | } |
2604 | |
2612 | |
|
|
2613 | struct region * |
|
|
2614 | object::region () const |
|
|
2615 | { |
|
|
2616 | return map ? map->region (x, y) |
|
|
2617 | : region::default_region (); |
|
|
2618 | } |
|
|
2619 | |
|
|
2620 | const materialtype_t * |
|
|
2621 | object::dominant_material () const |
|
|
2622 | { |
|
|
2623 | if (materialtype_t *mat = name_to_material (materialname)) |
|
|
2624 | return mat; |
|
|
2625 | |
|
|
2626 | // omfg this is slow, this has to be temporary :) |
|
|
2627 | shstr unknown ("unknown"); |
|
|
2628 | |
|
|
2629 | return name_to_material (unknown); |
|
|
2630 | } |
|
|
2631 | |