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.111 by root, Mon Jan 8 01:19:02 2007 UTC vs.
Revision 1.112 by root, Mon Jan 8 14:11:04 2007 UTC

395 * Returns the object which has the count-variable equal to the argument. 395 * Returns the object which has the count-variable equal to the argument.
396 */ 396 */
397object * 397object *
398find_object (tag_t i) 398find_object (tag_t i)
399{ 399{
400 return ((unsigned int)i) < objects.size () 400 for_all_objects (op)
401 ? objects [i] 401 if (op->count == i)
402 : 0; 402 return op;
403
404 return 0;
403} 405}
404 406
405/* 407/*
406 * Returns the first object which has a name equal to the argument. 408 * Returns the first object which has a name equal to the argument.
407 * Used only by the patch command, but not all that useful. 409 * Used only by the patch command, but not all that useful.
673object::~object () 675object::~object ()
674{ 676{
675 free_key_values (this); 677 free_key_values (this);
676} 678}
677 679
680static int object_count;
681
678void object::link () 682void object::link ()
679{ 683{
680 assert (!count);//D 684 assert (!index);//D
681 uuid = gen_uuid (); 685 uuid = gen_uuid ();
686 count = ++object_count;
682 687
683 refcnt_inc (); 688 refcnt_inc ();
684 objects.insert (this); 689 objects.insert (this);
685} 690}
686 691
687void object::unlink () 692void object::unlink ()
688{ 693{
689 assert (count);//D 694 assert (index);//D
690 objects.erase (this); 695 objects.erase (this);
691 refcnt_dec (); 696 refcnt_dec ();
692} 697}
693 698
694void 699void
805} 810}
806 811
807void 812void
808object::do_destroy () 813object::do_destroy ()
809{ 814{
815 attachable::do_destroy ();
816
810 if (flag [FLAG_IS_LINKED]) 817 if (flag [FLAG_IS_LINKED])
811 remove_button_link (this); 818 remove_button_link (this);
812 819
813 if (flag [FLAG_FRIENDLY]) 820 if (flag [FLAG_FRIENDLY])
814 remove_friendly_object (this); 821 remove_friendly_object (this);
815 822
816 if (!flag [FLAG_REMOVED]) 823 if (!flag [FLAG_REMOVED])
817 remove (); 824 remove ();
818 825
819 if (flag [FLAG_FREED]) 826 destroy_inv (true);
820 return;
821 827
822 set_speed (0); 828 deactivate ();
829 unlink ();
823 830
824 flag [FLAG_FREED] = 1; 831 flag [FLAG_FREED] = 1;
825
826 attachable::do_destroy ();
827
828 destroy_inv (true);
829 unlink ();
830 832
831 // hack to ensure that freed objects still have a valid map 833 // hack to ensure that freed objects still have a valid map
832 { 834 {
833 static maptile *freed_map; // freed objects are moved here to avoid crashes 835 static maptile *freed_map; // freed objects are moved here to avoid crashes
834 836

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines