diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 3459504e46..81cf372518 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -528,22 +528,26 @@ namespace OpenSim.Framework m_attachments[attachpoint][1] = asset; } - public void DetachAttachment(LLUUID itemID) + public int GetAttachpoint(LLUUID itemID) { - int attachpoint = 0; - foreach (KeyValuePair kvp in m_attachments) { if(kvp.Value[0] == itemID) { - attachpoint = kvp.Key; - break; + return kvp.Key; } } + return 0; + } + + public void DetachAttachment(LLUUID itemID) + { + int attachpoint = GetAttachpoint(itemID); if(attachpoint > 0) m_attachments.Remove(attachpoint); } + string GetAttachmentsString() { List strings = new List(); diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c337907650..a7d634962a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -47,11 +47,15 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void SendInventoryDescendentsDelegate( IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); + public delegate void OnItemReceivedDelegate(LLUUID itemID); + /// /// Stores user profile and inventory data received from backend services for a particular user. /// public class CachedUserInfo { + public event OnItemReceivedDelegate OnItemReceived; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -306,6 +310,9 @@ namespace OpenSim.Framework.Communications.Cache { folder.Items[itemInfo.ID] = itemInfo; } + + if (OnItemReceived != null) + OnItemReceived(itemInfo.ID); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 784d04c8bb..e145f4a477 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -2308,15 +2308,6 @@ namespace OpenSim.Region.Environment.Scenes EventManager.TriggerStopScript(part.LocalId, itemID); } -// public void TestFunction() -// { -// IInventoryModule imod = RequestModuleInterface(); -// if (imod == null) -// return; -// -// imod.TestFunction(); -// } - public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, uint ItemFlags, uint NextOwnerMask) { @@ -2328,13 +2319,21 @@ namespace OpenSim.Region.Environment.Scenes return; } + RezSingleAttachment(att, remoteClient, itemID, AttachmentPt, + ItemFlags, NextOwnerMask); + } + + public void RezSingleAttachment(SceneObjectGroup att, + IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, + uint ItemFlags, uint NextOwnerMask) + { if (att.RootPart != null) AttachmentPt = att.RootPart.AttachmentPoint; ScenePresence presence; if(TryGetAvatar(remoteClient.AgentId, out presence)) { - presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.GetFromAssetID()); + presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID); IAvatarFactory ava = RequestModuleInterface(); if(ava != null) { diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 5669af61b5..af7ae4775b 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -36,6 +36,7 @@ using libsecondlife.Packets; using log4net; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; @@ -416,7 +417,8 @@ namespace OpenSim.Region.Environment.Scenes RegisterToEvents(); SetDirectionVectors(); - + CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); + userInfo.OnItemReceived += ItemReceived; } public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, @@ -604,6 +606,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void MakeRootAgent(LLVector3 pos, bool isFlying) { + IAvatarFactory ava = m_scene.RequestModuleInterface(); + if(ava != null) + { + ava.TryGetAvatarAppearance(m_uuid, out m_appearance); + } + // m_log.DebugFormat( // "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}", // Name, UUID, m_scene.RegionInfo.RegionName, pos); @@ -2862,5 +2870,32 @@ namespace OpenSim.Region.Environment.Scenes //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG return flags; } + + private void ItemReceived(LLUUID itemID) + { + int attachpoint = m_appearance.GetAttachpoint(itemID); + if (attachpoint == 0) + return; + + SceneObjectPart att = m_scene.GetSceneObjectPart(m_appearance.GetAttachedAsset(attachpoint)); + + + // If this is null, then we have just rezzed in. Non null means + // we're crossing + // + if (att != null) + { + System.Console.WriteLine("Attach from world {0}", itemID.ToString()); + // Attach from world + if(att.ParentGroup != null) + m_scene.RezSingleAttachment(att.ParentGroup, ControllingClient, itemID, (uint)attachpoint, 0, 0); + } + else + { + System.Console.WriteLine("Rez attachment {0}", itemID.ToString()); + // Rez from inventory + m_scene.RezSingleAttachment(ControllingClient, itemID, (uint)attachpoint, 0, 0); + } + } } }