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.35 by root, Tue Sep 12 18:15:34 2006 UTC vs.
Revision 1.38 by root, Wed Sep 13 01:09:24 2006 UTC

254 { 254 {
255 if (inv->inv) 255 if (inv->inv)
256 sum_weight (inv); 256 sum_weight (inv);
257 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); 257 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1);
258 } 258 }
259
259 if (op->type == CONTAINER && op->stats.Str) 260 if (op->type == CONTAINER && op->stats.Str)
260 sum = (sum * (100 - op->stats.Str)) / 100; 261 sum = (sum * (100 - op->stats.Str)) / 100;
262
261 if (op->carrying != sum) 263 if (op->carrying != sum)
262 op->carrying = sum; 264 op->carrying = sum;
265
263 return sum; 266 return sum;
264} 267}
265 268
266/** 269/**
267 * Return the outermost environment object for a given object. 270 * Return the outermost environment object for a given object.
836 if (op->more != NULL) 839 if (op->more != NULL)
837 update_object (op->more, action); 840 update_object (op->more, action);
838} 841}
839 842
840static unordered_vector<object *> mortals; 843static unordered_vector<object *> mortals;
841static std::vector<object *> freed; 844static std::vector<object *, slice_allocator <object *> > freed;
842 845
843void object::free_mortals () 846void object::free_mortals ()
844{ 847{
845 for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) 848 for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();)
846 if ((*i)->refcnt) 849 if ((*i)->refcnt)
885 888
886void object::unlink () 889void object::unlink ()
887{ 890{
888 count = 0; 891 count = 0;
889 892
893 if (this == objects)
894 objects = next;
895
890 /* Remove this object from the list of used objects */ 896 /* Remove this object from the list of used objects */
891 if (prev) 897 if (prev)
892 { 898 {
893 prev->next = next; 899 prev->next = next;
894 prev = 0; 900 prev = 0;
897 if (next) 903 if (next)
898 { 904 {
899 next->prev = prev; 905 next->prev = prev;
900 next = 0; 906 next = 0;
901 } 907 }
902
903 if (this == objects)
904 objects = next;
905} 908}
906 909
907object *object::create () 910object *object::create ()
908{ 911{
909 object *op; 912 object *op;
1222 * This function goes through all objects below and including top, and 1225 * This function goes through all objects below and including top, and
1223 * merges op to the first matching object. 1226 * merges op to the first matching object.
1224 * If top is NULL, it is calculated. 1227 * If top is NULL, it is calculated.
1225 * Returns pointer to object if it succeded in the merge, otherwise NULL 1228 * Returns pointer to object if it succeded in the merge, otherwise NULL
1226 */ 1229 */
1227
1228object * 1230object *
1229merge_ob (object *op, object *top) 1231merge_ob (object *op, object *top)
1230{ 1232{
1231 if (!op->nrof) 1233 if (!op->nrof)
1232 return 0; 1234 return 0;
2857 } 2859 }
2858 else 2860 else
2859 item = item->env; 2861 item = item->env;
2860} 2862}
2861 2863
2864// return a suitable string describing an objetc in enough detail to find it
2865const char *
2866object::debug_desc (char *info) const
2867{
2868 char info2[256 * 3];
2869 char *p = info;
2870
2871 p += snprintf (p, 256, "%d=\"%s%s%s\"",
2872 count,
2873 &name,
2874 title ? " " : "",
2875 title ? (const char *)title : "");
2876
2877 if (env)
2878 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2879
2880 if (map)
2881 p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y);
2882
2883 return info;
2884}
2885
2886const char *
2887object::debug_desc () const
2888{
2889 static char info[256 * 3];
2890 return debug_desc (info);
2891}
2892

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines