diff options
Diffstat (limited to 'indra/newview/llviewerjointattachment.cpp')
-rw-r--r-- | indra/newview/llviewerjointattachment.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp index 2b4b78d82d..86502b1ba8 100644 --- a/indra/newview/llviewerjointattachment.cpp +++ b/indra/newview/llviewerjointattachment.cpp @@ -35,12 +35,12 @@ #include "llviewerjointattachment.h" #include "llagentconstants.h" - #include "llviewercontrol.h" #include "lldrawable.h" #include "llgl.h" +#include "llhudtext.h" #include "llrender.h" -#include "llvoavatar.h" +#include "llvoavatarself.h" #include "llvolume.h" #include "pipeline.h" #include "llspatialpartition.h" @@ -164,6 +164,9 @@ void LLViewerJointAttachment::setupDrawable(LLViewerObject *object) //----------------------------------------------------------------------------- BOOL LLViewerJointAttachment::addObject(LLViewerObject* object) { + object->extractAttachmentItemID(); + + // Same object reattached if (isObjectAttached(object)) { llinfos << "(same object re-attached)" << llendl; @@ -171,20 +174,19 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object) // Pass through anyway to let setupDrawable() // re-connect object to the joint correctly } - - // Find the inventory item ID of the attached object - LLNameValue* item_id_nv = object->getNVPair("AttachItemID"); - if( item_id_nv ) + + // Two instances of the same inventory item attached -- + // Request detach, and kill the object in the meantime. + if (getAttachedObject(object->getAttachmentItemID())) { - const char* s = item_id_nv->getString(); - if( s ) - { - LLUUID item_id; - item_id.set(s); - object->setItemID(item_id); - lldebugs << "getNVPair( AttachItemID ) = " << item_id << llendl; - } + llinfos << "(same object re-attached)" << llendl; + object->markDead(); + + // If this happens to be attached to self, then detach. + LLVOAvatarSelf::detachAttachmentIntoInventory(object->getAttachmentItemID()); + return FALSE; } + mAttachedObjects.push_back(object); setupDrawable(object); @@ -207,7 +209,7 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object) } calcLOD(); mUpdateXform = TRUE; - + return TRUE; } @@ -303,7 +305,7 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object) { mUpdateXform = FALSE; } - object->setItemID(LLUUID::null); + object->setAttachmentItemID(LLUUID::null); } //----------------------------------------------------------------------------- @@ -429,7 +431,7 @@ const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &o ++iter) { const LLViewerObject* attached_object = (*iter); - if (attached_object->getItemID() == object_id) + if (attached_object->getAttachmentItemID() == object_id) { return attached_object; } @@ -444,7 +446,7 @@ LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_ ++iter) { LLViewerObject* attached_object = (*iter); - if (attached_object->getItemID() == object_id) + if (attached_object->getAttachmentItemID() == object_id) { return attached_object; } |