--- deliantra/server/common/object.C 2007/01/07 02:39:13 1.108 +++ deliantra/server/common/object.C 2007/01/08 14:11:04 1.112 @@ -397,9 +397,11 @@ object * find_object (tag_t i) { - return ((unsigned int)i) < objects.size () - ? objects [i] - : 0; + for_all_objects (op) + if (op->count == i) + return op; + + return 0; } /* @@ -675,16 +677,23 @@ free_key_values (this); } +static int object_count; + void object::link () { + assert (!index);//D uuid = gen_uuid (); + count = ++object_count; + refcnt_inc (); objects.insert (this); } void object::unlink () { + assert (index);//D objects.erase (this); + refcnt_dec (); } void @@ -784,7 +793,8 @@ || op->flag [FLAG_NO_DROP] || op->type == RUNE || op->type == TRAP - || op->flag [FLAG_IS_A_TEMPLATE]) + || op->flag [FLAG_IS_A_TEMPLATE] + || op->flag [FLAG_DESTROY_ON_DEATH]) op->destroy (); else map->insert (op, x, y); @@ -802,6 +812,8 @@ void object::do_destroy () { + attachable::do_destroy (); + if (flag [FLAG_IS_LINKED]) remove_button_link (this); @@ -811,18 +823,13 @@ if (!flag [FLAG_REMOVED]) remove (); - if (flag [FLAG_FREED]) - return; + destroy_inv (true); - set_speed (0); + deactivate (); + unlink (); flag [FLAG_FREED] = 1; - attachable::do_destroy (); - - destroy_inv (true); - unlink (); - // hack to ensure that freed objects still have a valid map { static maptile *freed_map; // freed objects are moved here to avoid crashes