From 5d8e08a0726ed49806e2009b37d3e917e279274f Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Thu, 6 Nov 2008 06:23:58 +0000 Subject: - create entries in avatarattachments table when first attaching an object; fix issue 2512 - correct attachment offset; fix issue 2513 - thanks Thomas for the patches --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 11 ++++++- .../Region/Environment/Scenes/Scene.Inventory.cs | 37 +++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 2189670..435ce77 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -542,12 +542,21 @@ namespace OpenSim.Region.Environment.Scenes } group.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); + group.AbsolutePosition = attachPos; // Saves and gets assetID + UUID itemId; if (group.GetFromAssetID() == UUID.Zero) { - m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId); + m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); } + else + { + itemId = group.GetFromAssetID(); + } + + m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); + group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); // In case it is later dropped again, don't let // it get cleaned up diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index e2a0eec..8f38d39 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1815,8 +1815,9 @@ namespace OpenSim.Region.Environment.Scenes } } - public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId) + public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) { + itemID = UUID.Zero; if (grp != null) { string sceneObjectXml = grp.ToXmlString(); @@ -1866,6 +1867,7 @@ namespace OpenSim.Region.Environment.Scenes userInfo.AddItem(item); remoteClient.SendInventoryItemCreateUpdate(item); + itemID = item.ID; return item.AssetID; } return UUID.Zero; @@ -2356,6 +2358,39 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos); } + public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) + { + if (null == itemID) + { + m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); + return; + } + + if (0 == AttachmentPt) + { + m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); + return; + } + + if (null == att.RootPart) + { + m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); + return; + } + + ScenePresence presence; + if (TryGetAvatar(remoteClient.AgentId, out presence)) + { + presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID); + IAvatarFactory ava = RequestModuleInterface(); + if (ava != null) + { + m_log.InfoFormat("[SCENE INVENTORY]: Saving avatar attachment. AgentID:{0} ItemID:{1} AttachmentPoint:{2}", remoteClient.AgentId, itemID, AttachmentPt); + ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } + } + } + public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) { SceneObjectPart part = GetSceneObjectPart(itemID); -- cgit v1.1