--- deliantra/server/common/object.C 2010/04/02 03:41:24 1.317 +++ deliantra/server/common/object.C 2010/04/07 19:54:44 1.320 @@ -576,55 +576,6 @@ this->owner = owner; } -int -object::slottype () const -{ - if (type == SKILL) - { - if (IS_COMBAT_SKILL (subtype)) return slot_combat; - if (IS_RANGED_SKILL (subtype)) return slot_ranged; - } - else - { - if (slot [body_combat].info) return slot_combat; - if (slot [body_range ].info) return slot_ranged; - } - - return slot_none; -} - -bool -object::change_weapon (object *ob) -{ - if (current_weapon == ob) - return true; - - if (current_weapon && current_weapon->flag [FLAG_APPLIED]) - { - manual_apply (this, current_weapon, AP_UNAPPLY); - - if (current_weapon && !current_weapon->flag [FLAG_APPLIED])//D - LOG (llevError, "FATAL: did not clear current_weapon (%s)\n", current_weapon->debug_desc ()); - - if (current_weapon && current_weapon->flag [FLAG_APPLIED]) - return false; - } - - current_weapon = 0; - - if (ob && !ob->flag [FLAG_APPLIED]) - { - manual_apply (this, ob, AP_APPLY); - - if (ob->flag [FLAG_APPLIED]) - current_weapon = ob; - else - return false; - } - - return true; -} - /* Zero the key_values on op, decrementing the shared-string * refcounts and freeing the links. */ @@ -990,6 +941,27 @@ } } +/* + * Remove and free all objects in the inventory of the given object. + * Unlike destroy_inv, this assumes the *this is destroyed as well + * well, so we can (and have to!) take shortcuts. + */ +void +object::destroy_inv_fast () +{ + while (object *op = inv) + { + // remove from object the fast way + op->flag [FLAG_REMOVED] = true; + op->env = 0; + if ((inv = inv->below)) + inv->above = 0; + + // then destroy + op->destroy (); + } +} + object *object::create () { object *op = new object; @@ -1069,7 +1041,7 @@ return; } - destroy_inv (false); + destroy_inv_fast (); if (is_head ()) if (sound_destroy)