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.127 by elmex, Mon Jan 29 21:04:32 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);
817 819
818 if (flag [FLAG_IS_LINKED]) 820 if (flag [FLAG_IS_LINKED])
819 remove_button_link (this); 821 remove_button_link (this);
820 822
821 if (flag [FLAG_FRIENDLY]) 823 if (flag [FLAG_FRIENDLY])
824 {
822 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 }
823 833
824 if (!flag [FLAG_REMOVED]) 834 if (!flag [FLAG_REMOVED])
825 remove (); 835 remove ();
826 836
827 destroy_inv (true); 837 destroy_inv (true);
899 * 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
900 * 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
901 * object will have no environment. If the object previously had an 911 * object will have no environment. If the object previously had an
902 * environment, the x and y coordinates will be updated to 912 * environment, the x and y coordinates will be updated to
903 * the previous environment. 913 * the previous environment.
904 * Beware: This function is called from the editor as well!
905 */ 914 */
906void 915void
907object::remove_slow () 916object::remove_slow ()
908{ 917{
909 object *tmp, *last = 0; 918 object *tmp, *last = 0;
1749 if ((!op->move_type && tmp->move_slow & MOVE_WALK) || 1758 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)) 1759 ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0))
1751 { 1760 {
1752 1761
1753 float 1762 float
1754 diff = tmp->move_slow_penalty * FABS (op->speed); 1763 diff = tmp->move_slow_penalty * fabs (op->speed);
1755 1764
1756 if (op->type == PLAYER) 1765 if (op->type == PLAYER)
1757 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)) ||
1758 (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)))
1759 diff /= 4.0; 1768 diff /= 4.0;
1966 } 1975 }
1967 1976
1968 if (!index) 1977 if (!index)
1969 return -1; 1978 return -1;
1970 1979
1971 return altern[RANDOM () % index]; 1980 return altern [rndm (index)];
1972} 1981}
1973 1982
1974/* 1983/*
1975 * find_first_free_spot(archetype, maptile, x, y) works like 1984 * find_first_free_spot(archetype, maptile, x, y) works like
1976 * find_free_spot(), but it will search max number of squares. 1985 * find_free_spot(), but it will search max number of squares.
1997{ 2006{
1998 arr += begin; 2007 arr += begin;
1999 end -= begin; 2008 end -= begin;
2000 2009
2001 while (--end) 2010 while (--end)
2002 swap (arr [end], arr [RANDOM () % (end + 1)]); 2011 swap (arr [end], arr [rndm (end + 1)]);
2003} 2012}
2004 2013
2005/* new function to make monster searching more efficient, and effective! 2014/* new function to make monster searching more efficient, and effective!
2006 * This basically returns a randomized array (in the passed pointer) of 2015 * 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 2016 * the spaces to find monsters. In this way, it won't always look for
2569{ 2578{
2570 char flagdesc[512]; 2579 char flagdesc[512];
2571 char info2[256 * 4]; 2580 char info2[256 * 4];
2572 char *p = info; 2581 char *p = info;
2573 2582
2574 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}",
2575 count, uuid.seq, 2584 count, uuid.seq,
2576 &name, 2585 &name,
2577 title ? "\",title:\"" : "", 2586 title ? "\",title:\"" : "",
2578 title ? (const char *)title : "", 2587 title ? (const char *)title : "",
2579 flag_desc (flagdesc, 512), type); 2588 flag_desc (flagdesc, 512), type);
2599{ 2608{
2600 static char info[256 * 4]; 2609 static char info[256 * 4];
2601 return debug_desc (info); 2610 return debug_desc (info);
2602} 2611}
2603 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