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.88 by root, Tue Dec 26 09:37:00 2006 UTC vs.
Revision 1.89 by root, Tue Dec 26 09:52:40 2006 UTC

778 778
779 prev = 0; 779 prev = 0;
780 next = 0; 780 next = 0;
781} 781}
782 782
783object *object::create ()
784{
785 object *op = new object;
786 op->link ();
787 return op;
788}
789
790void
791object::do_destroy ()
792{
793 attachable::do_destroy ();
794
795 if (flag [FLAG_IS_LINKED])
796 remove_button_link (this);
797
798 if (flag [FLAG_FRIENDLY])
799 remove_friendly_object (this);
800
801 if (!flag [FLAG_REMOVED])
802 remove ();
803
804 if (flag [FLAG_FREED])
805 return;
806
807 flag [FLAG_FREED] = 1;
808
809 while (inv)
810 inv->destroy ();
811
812 set_speed (0);
813 unlink ();
814
815 // hack to ensure that freed objects still have a valid map
816 {
817 static maptile *freed_map; // freed objects are moved here to avoid crashes
818
819 if (!freed_map)
820 {
821 freed_map = new maptile;
822
823 freed_map->name = "/internal/freed_objects_map";
824 freed_map->width = 3;
825 freed_map->height = 3;
826
827 freed_map->allocate ();
828 }
829
830 map = freed_map;
831 x = 1;
832 y = 1;
833 }
834
835 head = 0;
836
837 if (more)
838 {
839 more->destroy ();
840 more = 0;
841 }
842
843 // clear those pointers that likely might have circular references to us
844 owner = 0;
845 enemy = 0;
846 attacked_by = 0;
847
848 // only relevant for players(?), but make sure of it anyways
849 contr = 0;
850}
851
852/* 783/*
853 * Remove and free all objects in the inventory of the given object. 784 * Remove and free all objects in the inventory of the given object.
854 * object.c ? 785 * object.c ?
855 */ 786 */
856void 787void
886 } 817 }
887 } 818 }
888 } 819 }
889} 820}
890 821
822object *object::create ()
823{
824 object *op = new object;
825 op->link ();
826 return op;
827}
828
829void
830object::do_destroy ()
831{
832 attachable::do_destroy ();
833
834 if (flag [FLAG_IS_LINKED])
835 remove_button_link (this);
836
837 if (flag [FLAG_FRIENDLY])
838 remove_friendly_object (this);
839
840 if (!flag [FLAG_REMOVED])
841 remove ();
842
843 if (flag [FLAG_FREED])
844 return;
845
846 flag [FLAG_FREED] = 1;
847
848 destroy_inv (true);
849 set_speed (0);
850 unlink ();
851
852 // hack to ensure that freed objects still have a valid map
853 {
854 static maptile *freed_map; // freed objects are moved here to avoid crashes
855
856 if (!freed_map)
857 {
858 freed_map = new maptile;
859
860 freed_map->name = "/internal/freed_objects_map";
861 freed_map->width = 3;
862 freed_map->height = 3;
863
864 freed_map->allocate ();
865 }
866
867 map = freed_map;
868 x = 1;
869 y = 1;
870 }
871
872 head = 0;
873
874 if (more)
875 {
876 more->destroy ();
877 more = 0;
878 }
879
880 // clear those pointers that likely might have circular references to us
881 owner = 0;
882 enemy = 0;
883 attacked_by = 0;
884
885 // only relevant for players(?), but make sure of it anyways
886 contr = 0;
887}
888
891void 889void
892object::destroy (bool destroy_inventory) 890object::destroy (bool destroy_inventory)
893{ 891{
894 if (destroyed ()) 892 if (destroyed ())
895 return; 893 return;
896 894
897 if (destroy_inventory) 895 if (destroy_inventory)
898 destroy_inv (true); 896 destroy_inv (false);
899 897
900 attachable::destroy (); 898 attachable::destroy ();
901} 899}
902 900
903/* 901/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines