--- deliantra/server/common/object.C 2008/04/30 08:29:31 1.223 +++ deliantra/server/common/object.C 2008/05/03 09:04:17 1.227 @@ -605,35 +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) { - bool is_freed = flag [FLAG_FREED]; - bool is_removed = flag [FLAG_REMOVED]; - - *(object_copy *)this = src; - - flag [FLAG_FREED] = is_freed; - flag [FLAG_REMOVED] = is_removed; + 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 @@ -643,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 (); @@ -688,6 +678,7 @@ { object *neu = create (); copy_to (neu); + neu->map = map; // not copied by copy_to return neu; } @@ -1163,7 +1154,10 @@ pl->close_container (); //TODO: the floorbox prev/next might need updating - esrv_del_item (pl->contr, count); + //esrv_del_item (pl->contr, count); + //TODO: update floorbox to preserve ordering + if (pl->contr->ns) + pl->contr->ns->floorbox_update (); } for (tmp = ms.bot; tmp; tmp = tmp->above) @@ -1471,7 +1465,10 @@ if (object *pl = ms.player ()) //TODO: the floorbox prev/next might need updating - esrv_send_item (pl, op); + //esrv_send_item (pl, op); + //TODO: update floorbox to preserve ordering + if (pl->contr->ns) + pl->contr->ns->floorbox_update (); /* If this object glows, it may affect lighting conditions that are * visible to others on this map. But update_all_los is really @@ -2328,17 +2325,18 @@ object * object_create_clone (object *asrc) { - object *dst = 0, *tmp, *src, *prev, *item; + object *dst = 0; if (!asrc) return 0; - src = asrc->head_ (); + object *src = asrc->head_ (); - prev = 0; + object *prev = 0; for (object *part = src; part; part = part->more) { - tmp = part->clone (); + object *tmp = part->clone (); + tmp->x -= src->x; tmp->y -= src->y; @@ -2358,7 +2356,7 @@ prev = tmp; } - for (item = src->inv; item; item = item->below) + for (object *item = src->inv; item; item = item->below) insert_ob_in_ob (object_create_clone (item), dst); return dst;