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.39 by root, Wed Sep 13 02:05:19 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 freed.push_back (*i);//D
933 //delete *i; 931 delete *i;
934 mortals.erase (i); 932 mortals.erase (i);
935 } 933 }
936 934
937 if (mortals.size() && 0)//D 935 static int lastmortals = 0;//D
936
937 if (mortals.size() != lastmortals)//D
938 {
939 lastmortals = mortals.size ();//D
938 LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D 940 LOG (llevDebug, "%d objects in mortal queue\n", lastmortals);//D
941 }
939} 942}
940 943
941object::object () 944object::object ()
942{ 945{
943 SET_FLAG (this, FLAG_REMOVED); 946 SET_FLAG (this, FLAG_REMOVED);
953} 956}
954 957
955void object::link () 958void object::link ()
956{ 959{
957 count = ++ob_count; 960 count = ++ob_count;
961 uuid = gen_uuid ();
958 962
959 prev = 0; 963 prev = 0;
960 next = objects; 964 next = objects;
961 965
962 if (objects) 966 if (objects)
965 objects = this; 969 objects = this;
966} 970}
967 971
968void object::unlink () 972void object::unlink ()
969{ 973{
970 count = 0; 974 //count = 0;//D
971 uuid = gen_uuid (); 975 if (!prev && !next) return;//D
972 976
973 if (this == objects) 977 if (this == objects)
974 objects = next; 978 objects = next;
975 979
976 /* Remove this object from the list of used objects */ 980 /* Remove this object from the list of used objects */
977 if (prev)
978 {
979 prev->next = next; 981 if (prev) prev->next = next;
982 if (next) next->prev = prev;
983
980 prev = 0; 984 prev = 0;
981 }
982
983 if (next)
984 {
985 next->prev = prev;
986 next = 0; 985 next = 0;
987 }
988} 986}
989 987
990object *object::create () 988object *object::create ()
991{ 989{
992 object *op;
993
994 if (freed.empty ())
995 op = new object; 990 object *op = new object;
996 else
997 {
998 // highly annoying, but the only way to get it stable right now
999 op = freed.back ();
1000 freed.pop_back ();
1001 op->~object ();
1002 new ((void *) op) object;
1003 }
1004
1005 op->link (); 991 op->link ();
1006 return op; 992 return op;
1007} 993}
1008 994
1009/* 995/*
2735 2721
2736 if (tempfile == NULL) 2722 if (tempfile == NULL)
2737 { 2723 {
2738 LOG (llevError, "Error - Unable to access load object temp file\n"); 2724 LOG (llevError, "Error - Unable to access load object temp file\n");
2739 return NULL; 2725 return NULL;
2740 }; 2726 }
2727
2741 fprintf (tempfile, obstr); 2728 fprintf (tempfile, obstr);
2742 fclose (tempfile); 2729 fclose (tempfile);
2743 2730
2744 op = get_object (); 2731 op = get_object ();
2745 2732

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines