--- deliantra/server/common/object.C 2008/04/24 00:30:52 1.220 +++ deliantra/server/common/object.C 2008/05/02 20:16:24 1.224 @@ -608,13 +608,11 @@ object & object::operator =(const object &src) { - bool is_freed = flag [FLAG_FREED]; - bool is_removed = flag [FLAG_REMOVED]; + remove (); *(object_copy *)this = src; - flag [FLAG_FREED] = is_freed; - flag [FLAG_REMOVED] = is_removed; + flag [FLAG_REMOVED] = true; /* Copy over key_values, if any. */ if (src.key_values) @@ -748,14 +746,14 @@ void update_object (object *op, int action) { - if (op == NULL) + if (!op) { /* this should never happen */ - LOG (llevDebug, "update_object() called for NULL object.\n"); + LOG (llevError | logBacktrace, "update_object() called for NULL object.\n"); return; } - if (op->env) + if (!op->is_on_map ()) { /* Animation is currently handled by client, so nothing * to do in this case. @@ -763,12 +761,6 @@ return; } - /* If the map is saving, don't do anything as everything is - * going to get freed anyways. - */ - if (!op->map || op->map->in_memory == MAP_SAVING) - return; - /* make sure the object is within map boundaries */ if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height) { @@ -967,6 +959,21 @@ return op; } +static struct freed_map : maptile +{ + freed_map () + { + path = ""; + name = "/internal/freed_objects_map"; + width = 3; + height = 3; + nodrop = 1; + + alloc (); + in_memory = MAP_ACTIVE; + } +} freed_map; // freed objects are moved here to avoid crashes + void object::do_destroy () { @@ -986,27 +993,9 @@ flag [FLAG_FREED] = 1; // hack to ensure that freed objects still have a valid map - { - static maptile *freed_map; // freed objects are moved here to avoid crashes - - if (!freed_map) - { - freed_map = new maptile; - - freed_map->path = ""; - freed_map->name = "/internal/freed_objects_map"; - freed_map->width = 3; - freed_map->height = 3; - freed_map->nodrop = 1; - - freed_map->alloc (); - freed_map->in_memory = MAP_ACTIVE; - } - - map = freed_map; - x = 1; - y = 1; - } + map = &freed_map; + x = 1; + y = 1; if (more) { @@ -1033,6 +1022,7 @@ { LOG (llevError | logBacktrace, "tried to destroy the tail of an object"); head->destroy (destroy_inventory); + return; } destroy_inv (!destroy_inventory); @@ -1075,8 +1065,10 @@ */ if (env) { + flag [FLAG_REMOVED] = false; // hack around the issue of visible_to checking flag_removed if (object *pl = visible_to ()) esrv_del_item (pl->contr, count); + flag [FLAG_REMOVED] = true; // hack around the issue of visible_to checking flag_removed adjust_weight (env, -total_weight ()); @@ -2334,17 +2326,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; @@ -2364,7 +2357,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;