From 29530f30296271f2d5641091e45d5f396a7d4dec Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 07:11:58 +0000 Subject: Attachment persistence!!! Patch #9170 (Mantis #1171) Attachments now persist across logouts. Mostly untested. --- .../Region/Environment/Scenes/Scene.Inventory.cs | 19 ++++++----- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 37 +++++++++++++++++++++- 2 files changed, 45 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 784d04c..e145f4a 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 5669af6..af7ae47 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); + } + } } } -- cgit v1.1