--- deliantra/server/common/object.C 2007/01/07 21:54:59 1.109 +++ deliantra/server/common/object.C 2007/01/09 21:32:41 1.113 @@ -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; } /* @@ -660,8 +662,6 @@ update_object (op->more, action); } -object *object::first; - object::object () { SET_FLAG (this, FLAG_REMOVED); @@ -675,9 +675,13 @@ 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); @@ -685,6 +689,7 @@ void object::unlink () { + assert (index);//D objects.erase (this); refcnt_dec (); } @@ -786,7 +791,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); @@ -804,6 +810,8 @@ void object::do_destroy () { + attachable::do_destroy (); + if (flag [FLAG_IS_LINKED]) remove_button_link (this); @@ -813,18 +821,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