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.41 by root, Thu Sep 14 01:12:28 2006 UTC vs.
Revision 1.42 by root, Thu Sep 14 01:19:47 2006 UTC

918 if (op->more != NULL) 918 if (op->more != NULL)
919 update_object (op->more, action); 919 update_object (op->more, action);
920} 920}
921 921
922static unordered_vector<object *> mortals; 922static unordered_vector<object *> mortals;
923static std::vector<object *, slice_allocator <object *> > freed;
924 923
925void object::free_mortals () 924void object::free_mortals ()
926{ 925{
927 for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) 926 for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();)
928 if ((*i)->refcnt) 927 if ((*i)->refcnt)
929 ++i; // further delay freeing 928 ++i; // further delay freeing
930 else 929 else
931 { 930 {
932 //printf ("free_mortal(%p,%ld,%ld)\n", *i, pticks, (*i)->count);//D
933 //freed.push_back (*i);//D
934 delete *i; 931 delete *i;
935 mortals.erase (i); 932 mortals.erase (i);
936 } 933 }
937 934
938 if (mortals.size() && 0)//D 935 static int lastmortals = 0;//D
936
937 if (mortals.size() != lastmortals)//D
938 {
939 lastmortals = mortals.size ();//D
939 LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D 940 LOG (llevDebug, "%d objects in mortal queue\n", lastmortals);//D
941 }
940} 942}
941 943
942object::object () 944object::object ()
943{ 945{
944 SET_FLAG (this, FLAG_REMOVED); 946 SET_FLAG (this, FLAG_REMOVED);
983 next = 0; 985 next = 0;
984} 986}
985 987
986object *object::create () 988object *object::create ()
987{ 989{
988 object *op;
989
990 if (freed.empty ())
991 op = new object; 990 object *op = new object;
992 else
993 {
994 // highly annoying, but the only way to get it stable right now
995 op = freed.back ();
996 freed.pop_back ();
997 op->~object ();
998 new ((void *) op) object;
999 }
1000
1001 op->link (); 991 op->link ();
1002 return op; 992 return op;
1003} 993}
1004 994
1005/* 995/*
1022 1012
1023 if (!QUERY_FLAG (this, FLAG_REMOVED)) 1013 if (!QUERY_FLAG (this, FLAG_REMOVED))
1024 remove_ob (this); 1014 remove_ob (this);
1025 1015
1026 SET_FLAG (this, FLAG_FREED); 1016 SET_FLAG (this, FLAG_FREED);
1027
1028 //printf ("free(%p,%ld,%ld)\n", this, pticks, count);//D
1029 1017
1030 if (more) 1018 if (more)
1031 { 1019 {
1032 more->free (free_inventory); 1020 more->free (free_inventory);
1033 more = 0; 1021 more = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines