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.118 by root, Thu Jan 18 19:42:09 2007 UTC vs.
Revision 1.128 by root, Mon Feb 5 01:24:45 2007 UTC

670 face = blank_face; 670 face = blank_face;
671} 671}
672 672
673object::~object () 673object::~object ()
674{ 674{
675 unlink ();
676
675 free_key_values (this); 677 free_key_values (this);
676} 678}
677 679
678static int object_count; 680static int object_count;
679 681
687 objects.insert (this); 689 objects.insert (this);
688} 690}
689 691
690void object::unlink () 692void 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
697void 701void
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);
814 819
815 if (flag [FLAG_IS_LINKED]) 820 if (flag [FLAG_IS_LINKED])
816 remove_button_link (this); 821 remove_button_link (this);
817 822
818 if (flag [FLAG_FRIENDLY]) 823 if (flag [FLAG_FRIENDLY])
824 {
819 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 }
820 833
821 if (!flag [FLAG_REMOVED]) 834 if (!flag [FLAG_REMOVED])
822 remove (); 835 remove ();
823 836
824 destroy_inv (true); 837 destroy_inv (true);
896 * 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
897 * 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
898 * object will have no environment. If the object previously had an 911 * object will have no environment. If the object previously had an
899 * environment, the x and y coordinates will be updated to 912 * environment, the x and y coordinates will be updated to
900 * the previous environment. 913 * the previous environment.
901 * Beware: This function is called from the editor as well!
902 */ 914 */
903void 915void
904object::remove_slow () 916object::do_remove ()
905{ 917{
906 object *tmp, *last = 0; 918 object *tmp, *last = 0;
907 object *otmp; 919 object *otmp;
908 920
909 if (QUERY_FLAG (this, FLAG_REMOVED)) 921 if (QUERY_FLAG (this, FLAG_REMOVED))
1746 if ((!op->move_type && tmp->move_slow & MOVE_WALK) || 1758 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)) 1759 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0))
1748 { 1760 {
1749 1761
1750 float 1762 float
1751 diff = tmp->move_slow_penalty * FABS (op->speed); 1763 diff = tmp->move_slow_penalty * fabs (op->speed);
1752 1764
1753 if (op->type == PLAYER) 1765 if (op->type == PLAYER)
1754 if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || 1766 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))) 1767 (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN)))
1756 diff /= 4.0; 1768 diff /= 4.0;
1963 } 1975 }
1964 1976
1965 if (!index) 1977 if (!index)
1966 return -1; 1978 return -1;
1967 1979
1968 return altern[RANDOM () % index]; 1980 return altern [rndm (index)];
1969} 1981}
1970 1982
1971/* 1983/*
1972 * find_first_free_spot(archetype, maptile, x, y) works like 1984 * find_first_free_spot(archetype, maptile, x, y) works like
1973 * find_free_spot(), but it will search max number of squares. 1985 * find_free_spot(), but it will search max number of squares.
1994{ 2006{
1995 arr += begin; 2007 arr += begin;
1996 end -= begin; 2008 end -= begin;
1997 2009
1998 while (--end) 2010 while (--end)
1999 swap (arr [end], arr [RANDOM () % (end + 1)]); 2011 swap (arr [end], arr [rndm (end + 1)]);
2000} 2012}
2001 2013
2002/* new function to make monster searching more efficient, and effective! 2014/* new function to make monster searching more efficient, and effective!
2003 * This basically returns a randomized array (in the passed pointer) of 2015 * 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 2016 * the spaces to find monsters. In this way, it won't always look for
2566{ 2578{
2567 char flagdesc[512]; 2579 char flagdesc[512];
2568 char info2[256 * 4]; 2580 char info2[256 * 4];
2569 char *p = info; 2581 char *p = info;
2570 2582
2571 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}",
2572 count, uuid.seq, 2584 count, uuid.seq,
2573 &name, 2585 &name,
2574 title ? "\",title:\"" : "", 2586 title ? "\",title:\"" : "",
2575 title ? (const char *)title : "", 2587 title ? (const char *)title : "",
2576 flag_desc (flagdesc, 512), type); 2588 flag_desc (flagdesc, 512), type);
2596{ 2608{
2597 static char info[256 * 4]; 2609 static char info[256 * 4];
2598 return debug_desc (info); 2610 return debug_desc (info);
2599} 2611}
2600 2612
2613struct region *
2614object::region () const
2615{
2616 return map ? map->region (x, y)
2617 : region::default_region ();
2618}
2619

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines