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.109 by root, Sun Jan 7 21:54:59 2007 UTC vs.
Revision 1.114 by root, Sun Jan 14 22:06:05 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.
658 660
659 if (op->more) 661 if (op->more)
660 update_object (op->more, action); 662 update_object (op->more, action);
661} 663}
662 664
663object *object::first;
664
665object::object () 665object::object ()
666{ 666{
667 SET_FLAG (this, FLAG_REMOVED); 667 SET_FLAG (this, FLAG_REMOVED);
668 668
669 expmul = 1.0; 669 expmul = 1.0;
673object::~object () 673object::~object ()
674{ 674{
675 free_key_values (this); 675 free_key_values (this);
676} 676}
677 677
678static int object_count;
679
678void object::link () 680void object::link ()
679{ 681{
682 assert (!index);//D
680 uuid = gen_uuid (); 683 uuid = gen_uuid ();
684 count = ++object_count;
681 685
682 refcnt_inc (); 686 refcnt_inc ();
683 objects.insert (this); 687 objects.insert (this);
684} 688}
685 689
686void object::unlink () 690void object::unlink ()
687{ 691{
692 assert (index);//D
688 objects.erase (this); 693 objects.erase (this);
689 refcnt_dec (); 694 refcnt_dec ();
690} 695}
691 696
692void 697void
784 789
785 if (op->flag [FLAG_STARTEQUIP] 790 if (op->flag [FLAG_STARTEQUIP]
786 || op->flag [FLAG_NO_DROP] 791 || op->flag [FLAG_NO_DROP]
787 || op->type == RUNE 792 || op->type == RUNE
788 || op->type == TRAP 793 || op->type == TRAP
789 || op->flag [FLAG_IS_A_TEMPLATE]) 794 || op->flag [FLAG_IS_A_TEMPLATE]
795 || op->flag [FLAG_DESTROY_ON_DEATH])
790 op->destroy (); 796 op->destroy ();
791 else 797 else
792 map->insert (op, x, y); 798 map->insert (op, x, y);
793 } 799 }
794 } 800 }
802} 808}
803 809
804void 810void
805object::do_destroy () 811object::do_destroy ()
806{ 812{
813 attachable::do_destroy ();
814
807 if (flag [FLAG_IS_LINKED]) 815 if (flag [FLAG_IS_LINKED])
808 remove_button_link (this); 816 remove_button_link (this);
809 817
810 if (flag [FLAG_FRIENDLY]) 818 if (flag [FLAG_FRIENDLY])
811 remove_friendly_object (this); 819 remove_friendly_object (this);
812 820
813 if (!flag [FLAG_REMOVED]) 821 if (!flag [FLAG_REMOVED])
814 remove (); 822 remove ();
815 823
816 if (flag [FLAG_FREED]) 824 destroy_inv (true);
817 return;
818 825
819 set_speed (0); 826 deactivate ();
827 unlink ();
820 828
821 flag [FLAG_FREED] = 1; 829 flag [FLAG_FREED] = 1;
822
823 attachable::do_destroy ();
824
825 destroy_inv (true);
826 unlink ();
827 830
828 // hack to ensure that freed objects still have a valid map 831 // hack to ensure that freed objects still have a valid map
829 { 832 {
830 static maptile *freed_map; // freed objects are moved here to avoid crashes 833 static maptile *freed_map; // freed objects are moved here to avoid crashes
831 834
2630{ 2633{
2631 static char info[256 * 4]; 2634 static char info[256 * 4];
2632 return debug_desc (info); 2635 return debug_desc (info);
2633} 2636}
2634 2637
2638const char *
2639object::debug_desc2 () const
2640{
2641 static char info[256 * 4];
2642 return debug_desc (info);
2643}
2644

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines