diff options
Diffstat (limited to 'linden/indra/newview/llinventorybridge.cpp')
-rw-r--r-- | linden/indra/newview/llinventorybridge.cpp | 192 |
1 files changed, 131 insertions, 61 deletions
diff --git a/linden/indra/newview/llinventorybridge.cpp b/linden/indra/newview/llinventorybridge.cpp index dc1e0a1..19a5ade 100644 --- a/linden/indra/newview/llinventorybridge.cpp +++ b/linden/indra/newview/llinventorybridge.cpp | |||
@@ -111,6 +111,8 @@ void remove_inventory_category_from_avatar(LLInventoryCategory* category); | |||
111 | void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata); | 111 | void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata); |
112 | void move_task_inventory_callback(S32 option, void* user_data); | 112 | void move_task_inventory_callback(S32 option, void* user_data); |
113 | void confirm_replace_attachment_rez(S32 option, void* user_data); | 113 | void confirm_replace_attachment_rez(S32 option, void* user_data); |
114 | void wear_attachments_on_avatar(const std::set<LLUUID>& item_ids, BOOL remove); | ||
115 | void wear_attachments_on_avatar(const LLInventoryModel::item_array_t& items, BOOL remove); | ||
114 | 116 | ||
115 | std::string ICON_NAME[ICON_NAME_COUNT] = | 117 | std::string ICON_NAME[ICON_NAME_COUNT] = |
116 | { | 118 | { |
@@ -3740,6 +3742,31 @@ private: | |||
3740 | bool mAppend; | 3742 | bool mAppend; |
3741 | }; | 3743 | }; |
3742 | 3744 | ||
3745 | class LLWearAttachmentsCallback : public LLInventoryCallback | ||
3746 | { | ||
3747 | public: | ||
3748 | LLWearAttachmentsCallback(bool append) : mAppend(append) {} | ||
3749 | void fire(const LLUUID& item_id) | ||
3750 | { | ||
3751 | mItemIDs.insert(item_id); | ||
3752 | } | ||
3753 | protected: | ||
3754 | ~LLWearAttachmentsCallback() | ||
3755 | { | ||
3756 | if( LLInventoryCallbackManager::is_instantiated() ) | ||
3757 | { | ||
3758 | wear_attachments_on_avatar(mItemIDs, mAppend); | ||
3759 | } | ||
3760 | else | ||
3761 | { | ||
3762 | llwarns << "Dropping unhandled LLWearAttachments" << llendl; | ||
3763 | } | ||
3764 | } | ||
3765 | private: | ||
3766 | std::set<LLUUID> mItemIDs; | ||
3767 | bool mAppend; | ||
3768 | }; | ||
3769 | |||
3743 | void LLOutfitObserver::done() | 3770 | void LLOutfitObserver::done() |
3744 | { | 3771 | { |
3745 | // We now have an outfit ready to be copied to agent inventory. Do | 3772 | // We now have an outfit ready to be copied to agent inventory. Do |
@@ -4109,67 +4136,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) | |||
4109 | if( obj_count > 0 ) | 4136 | if( obj_count > 0 ) |
4110 | { | 4137 | { |
4111 | // We've found some attachements. Add these. | 4138 | // We've found some attachements. Add these. |
4112 | 4139 | wear_attachments_on_avatar(obj_item_array, !wear_info->mAppend); | |
4113 | LLVOAvatar* avatar = gAgent.getAvatarObject(); | ||
4114 | if( avatar ) | ||
4115 | { | ||
4116 | // Build a compound message to send all the objects that need to be rezzed. | ||
4117 | |||
4118 | // Limit number of packets to send | ||
4119 | const S32 MAX_PACKETS_TO_SEND = 10; | ||
4120 | const S32 OBJECTS_PER_PACKET = 4; | ||
4121 | const S32 MAX_OBJECTS_TO_SEND = MAX_PACKETS_TO_SEND * OBJECTS_PER_PACKET; | ||
4122 | if( obj_count > MAX_OBJECTS_TO_SEND ) | ||
4123 | { | ||
4124 | obj_count = MAX_OBJECTS_TO_SEND; | ||
4125 | } | ||
4126 | |||
4127 | // Create an id to keep the parts of the compound message together | ||
4128 | LLUUID compound_msg_id; | ||
4129 | compound_msg_id.generate(); | ||
4130 | LLMessageSystem* msg = gMessageSystem; | ||
4131 | |||
4132 | for(i = 0; i < obj_count; ++i) | ||
4133 | { | ||
4134 | if( 0 == (i % OBJECTS_PER_PACKET) ) | ||
4135 | { | ||
4136 | // Start a new message chunk | ||
4137 | msg->newMessageFast(_PREHASH_RezMultipleAttachmentsFromInv); | ||
4138 | msg->nextBlockFast(_PREHASH_AgentData); | ||
4139 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
4140 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
4141 | msg->nextBlockFast(_PREHASH_HeaderData); | ||
4142 | msg->addUUIDFast(_PREHASH_CompoundMsgID, compound_msg_id ); | ||
4143 | msg->addU8Fast(_PREHASH_TotalObjects, obj_count ); | ||
4144 | // msg->addBOOLFast(_PREHASH_FirstDetachAll, !wear_info->mAppend ); | ||
4145 | // [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.0.0c) | Added: RLVa-0.2.2a | ||
4146 | // This really should just *always* be FALSE since TRUE can result in loss of the current asset state | ||
4147 | msg->addBOOLFast(_PREHASH_FirstDetachAll, (!wear_info->mAppend) && (!gRlvHandler.hasLockedAttachment()) ); | ||
4148 | // [/RLVa:KB] | ||
4149 | } | ||
4150 | |||
4151 | LLInventoryItem* item = obj_item_array.get(i); | ||
4152 | msg->nextBlockFast(_PREHASH_ObjectData ); | ||
4153 | msg->addUUIDFast(_PREHASH_ItemID, item->getUUID() ); | ||
4154 | msg->addUUIDFast(_PREHASH_OwnerID, item->getPermissions().getOwner()); | ||
4155 | // msg->addU8Fast(_PREHASH_AttachmentPt, 0 ); // Wear at the previous or default attachment point | ||
4156 | // [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.0.0c) | Added: RLVa-0.2.2a | ||
4157 | msg->addU8Fast(_PREHASH_AttachmentPt, | ||
4158 | ( (!rlv_handler_t::isEnabled()) || (RlvSettings::getEnableWear()) || (!gRlvHandler.hasLockedAttachment()) ) | ||
4159 | ? 0 | ||
4160 | : gRlvHandler.getAttachPointIndex(gRlvHandler.getAttachPoint(item, true))); | ||
4161 | // [/RLVa:KB] | ||
4162 | pack_permissions_slam(msg, item->getFlags(), item->getPermissions()); | ||
4163 | msg->addStringFast(_PREHASH_Name, item->getName()); | ||
4164 | msg->addStringFast(_PREHASH_Description, item->getDescription()); | ||
4165 | |||
4166 | if( (i+1 == obj_count) || ((OBJECTS_PER_PACKET-1) == (i % OBJECTS_PER_PACKET)) ) | ||
4167 | { | ||
4168 | // End of message chunk | ||
4169 | msg->sendReliable( gAgent.getRegion()->getHost() ); | ||
4170 | } | ||
4171 | } | ||
4172 | } | ||
4173 | } | 4140 | } |
4174 | } | 4141 | } |
4175 | delete wear_info; | 4142 | delete wear_info; |
@@ -4260,6 +4227,109 @@ void wear_inventory_category_on_avatar_step3(LLWearableHoldingPattern* holder, B | |||
4260 | dec_busy_count(); | 4227 | dec_busy_count(); |
4261 | } | 4228 | } |
4262 | 4229 | ||
4230 | void wear_attachments_on_avatar(const std::set<LLUUID>& item_ids, BOOL remove) | ||
4231 | { | ||
4232 | // NOTE: the inventory items can reside in the user's inventory, the library, or any combination of the two | ||
4233 | |||
4234 | LLInventoryModel::item_array_t items; | ||
4235 | LLPointer<LLInventoryCallback> cb; | ||
4236 | |||
4237 | for (std::set<LLUUID>::const_iterator it = item_ids.begin(); it != item_ids.end(); ++it) | ||
4238 | { | ||
4239 | LLViewerInventoryItem* item = gInventory.getItem(*it); | ||
4240 | if ( (item) && (LLAssetType::AT_OBJECT == item->getType()) ) | ||
4241 | { | ||
4242 | if ( (gInventory.isObjectDescendentOf(*it, gAgent.getInventoryRootID())) ) | ||
4243 | { | ||
4244 | items.put(item); | ||
4245 | } | ||
4246 | else if ( (item->isComplete()) ) | ||
4247 | { | ||
4248 | if (cb.isNull()) | ||
4249 | cb = new LLWearAttachmentsCallback(remove); | ||
4250 | copy_inventory_item(gAgent.getID(), item->getPermissions().getOwner(), item->getUUID(), LLUUID::null, std::string(), cb); | ||
4251 | } | ||
4252 | } | ||
4253 | } | ||
4254 | |||
4255 | wear_attachments_on_avatar(items, remove); | ||
4256 | } | ||
4257 | |||
4258 | void wear_attachments_on_avatar(const LLInventoryModel::item_array_t& items, BOOL remove) | ||
4259 | { | ||
4260 | // NOTE: all inventory items must reside in the user's inventory | ||
4261 | |||
4262 | LLVOAvatar* avatarp = gAgent.getAvatarObject(); | ||
4263 | if(!avatarp) | ||
4264 | { | ||
4265 | llwarns << "No avatar found." << llendl; | ||
4266 | return; | ||
4267 | } | ||
4268 | |||
4269 | // Build a compound message to send all the objects that need to be rezzed. | ||
4270 | |||
4271 | // Limit number of packets to send | ||
4272 | const S32 MAX_PACKETS_TO_SEND = 10; | ||
4273 | const S32 OBJECTS_PER_PACKET = 4; | ||
4274 | const S32 MAX_OBJECTS_TO_SEND = MAX_PACKETS_TO_SEND * OBJECTS_PER_PACKET; | ||
4275 | |||
4276 | S32 count = items.count(); | ||
4277 | if ( !count ) | ||
4278 | { | ||
4279 | return; | ||
4280 | } | ||
4281 | else if ( count > MAX_OBJECTS_TO_SEND ) | ||
4282 | { | ||
4283 | count = MAX_OBJECTS_TO_SEND; | ||
4284 | } | ||
4285 | |||
4286 | // Create an id to keep the parts of the compound message together | ||
4287 | LLUUID compound_msg_id; | ||
4288 | compound_msg_id.generate(); | ||
4289 | LLMessageSystem* msg = gMessageSystem; | ||
4290 | |||
4291 | for(S32 i = 0; i < count; ++i) | ||
4292 | { | ||
4293 | if( 0 == (i % OBJECTS_PER_PACKET) ) | ||
4294 | { | ||
4295 | // Start a new message chunk | ||
4296 | msg->newMessageFast(_PREHASH_RezMultipleAttachmentsFromInv); | ||
4297 | msg->nextBlockFast(_PREHASH_AgentData); | ||
4298 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
4299 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
4300 | msg->nextBlockFast(_PREHASH_HeaderData); | ||
4301 | msg->addUUIDFast(_PREHASH_CompoundMsgID, compound_msg_id ); | ||
4302 | msg->addU8Fast(_PREHASH_TotalObjects, count ); | ||
4303 | // msg->addBOOLFast(_PREHASH_FirstDetachAll, remove ); | ||
4304 | // [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.0.0c) | Added: RLVa-0.2.2a | ||
4305 | // This really should just *always* be FALSE since TRUE can result in loss of the current asset state | ||
4306 | msg->addBOOLFast(_PREHASH_FirstDetachAll, remove && (!gRlvHandler.hasLockedAttachment()) ); | ||
4307 | // [/RLVa:KB] | ||
4308 | } | ||
4309 | |||
4310 | LLInventoryItem* item = items.get(i); | ||
4311 | msg->nextBlockFast(_PREHASH_ObjectData ); | ||
4312 | msg->addUUIDFast(_PREHASH_ItemID, item->getUUID() ); | ||
4313 | msg->addUUIDFast(_PREHASH_OwnerID, item->getPermissions().getOwner()); | ||
4314 | // msg->addU8Fast(_PREHASH_AttachmentPt, 0 ); // Wear at the previous or default attachment point | ||
4315 | // [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.0.0c) | Added: RLVa-0.2.2a | ||
4316 | msg->addU8Fast(_PREHASH_AttachmentPt, | ||
4317 | ( (!rlv_handler_t::isEnabled()) || (RlvSettings::getEnableWear()) || (!gRlvHandler.hasLockedAttachment()) ) | ||
4318 | ? 0 | ||
4319 | : gRlvHandler.getAttachPointIndex(gRlvHandler.getAttachPoint(item, true))); | ||
4320 | // [/RLVa:KB] | ||
4321 | pack_permissions_slam(msg, item->getFlags(), item->getPermissions()); | ||
4322 | msg->addStringFast(_PREHASH_Name, item->getName()); | ||
4323 | msg->addStringFast(_PREHASH_Description, item->getDescription()); | ||
4324 | |||
4325 | if( (i+1 == count) || ((OBJECTS_PER_PACKET-1) == (i % OBJECTS_PER_PACKET)) ) | ||
4326 | { | ||
4327 | // End of message chunk | ||
4328 | msg->sendReliable( gAgent.getRegion()->getHost() ); | ||
4329 | } | ||
4330 | } | ||
4331 | } | ||
4332 | |||
4263 | void remove_inventory_category_from_avatar( LLInventoryCategory* category ) | 4333 | void remove_inventory_category_from_avatar( LLInventoryCategory* category ) |
4264 | { | 4334 | { |
4265 | if(!category) return; | 4335 | if(!category) return; |