--- deliantra/server/common/object.C 2008/05/03 08:50:30 1.226 +++ deliantra/server/common/object.C 2008/05/03 09:04:17 1.227 @@ -605,33 +605,39 @@ op->key_values = 0; } -object & -object::operator =(const object &src) +/* + * copy_to first frees everything allocated by the dst object, + * and then copies the contents of itself into the second + * object, allocating what needs to be allocated. Basically, any + * data that is malloc'd needs to be re-malloc/copied. Otherwise, + * if the first object is freed, the pointers in the new object + * will point at garbage. + */ +void +object::copy_to (object *dst) { - remove (); - - *(object_copy *)this = src; - - flag [FLAG_REMOVED] = true; + dst->remove (); + *(object_copy *)dst = *this; + dst->flag [FLAG_REMOVED] = true; /* Copy over key_values, if any. */ - if (src.key_values) + if (key_values) { key_value *tail = 0; - key_values = 0; + dst->key_values = 0; - for (key_value *i = src.key_values; i; i = i->next) + for (key_value *i = key_values; i; i = i->next) { key_value *new_link = new key_value; - new_link->next = 0; - new_link->key = i->key; + new_link->next = 0; + new_link->key = i->key; new_link->value = i->value; /* Try and be clever here, too. */ - if (!key_values) + if (!dst->key_values) { - key_values = new_link; + dst->key_values = new_link; tail = new_link; } else @@ -641,20 +647,6 @@ } } } -} - -/* - * copy_to first frees everything allocated by the dst object, - * and then copies the contents of itself into the second - * object, allocating what needs to be allocated. Basically, any - * data that is malloc'd needs to be re-malloc/copied. Otherwise, - * if the first object is freed, the pointers in the new object - * will point at garbage. - */ -void -object::copy_to (object *dst) -{ - *dst = *this; if (speed < 0) dst->speed_left -= rndm ();