Attachment persistence!!! Patch #9170 (Mantis #1171)

Attachments now persist across logouts. Mostly untested.
0.6.0-stable
Melanie Thielker 2008-08-19 07:11:58 +00:00
parent b4355e4564
commit 29530f3029
4 changed files with 61 additions and 16 deletions

View File

@ -528,22 +528,26 @@ namespace OpenSim.Framework
m_attachments[attachpoint][1] = asset; m_attachments[attachpoint][1] = asset;
} }
public void DetachAttachment(LLUUID itemID) public int GetAttachpoint(LLUUID itemID)
{ {
int attachpoint = 0;
foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments) foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments)
{ {
if(kvp.Value[0] == itemID) if(kvp.Value[0] == itemID)
{ {
attachpoint = kvp.Key; return kvp.Key;
break;
} }
} }
return 0;
}
public void DetachAttachment(LLUUID itemID)
{
int attachpoint = GetAttachpoint(itemID);
if(attachpoint > 0) if(attachpoint > 0)
m_attachments.Remove(attachpoint); m_attachments.Remove(attachpoint);
} }
string GetAttachmentsString() string GetAttachmentsString()
{ {
List<string> strings = new List<string>(); List<string> strings = new List<string>();

View File

@ -47,11 +47,15 @@ namespace OpenSim.Framework.Communications.Cache
internal delegate void SendInventoryDescendentsDelegate( internal delegate void SendInventoryDescendentsDelegate(
IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems);
public delegate void OnItemReceivedDelegate(LLUUID itemID);
/// <summary> /// <summary>
/// Stores user profile and inventory data received from backend services for a particular user. /// Stores user profile and inventory data received from backend services for a particular user.
/// </summary> /// </summary>
public class CachedUserInfo public class CachedUserInfo
{ {
public event OnItemReceivedDelegate OnItemReceived;
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -306,6 +310,9 @@ namespace OpenSim.Framework.Communications.Cache
{ {
folder.Items[itemInfo.ID] = itemInfo; folder.Items[itemInfo.ID] = itemInfo;
} }
if (OnItemReceived != null)
OnItemReceived(itemInfo.ID);
} }
/// <summary> /// <summary>

View File

@ -2308,15 +2308,6 @@ namespace OpenSim.Region.Environment.Scenes
EventManager.TriggerStopScript(part.LocalId, itemID); EventManager.TriggerStopScript(part.LocalId, itemID);
} }
// public void TestFunction()
// {
// IInventoryModule imod = RequestModuleInterface<IInventoryModule>();
// if (imod == null)
// return;
//
// imod.TestFunction();
// }
public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID,
uint AttachmentPt, uint ItemFlags, uint NextOwnerMask) uint AttachmentPt, uint ItemFlags, uint NextOwnerMask)
{ {
@ -2328,13 +2319,21 @@ namespace OpenSim.Region.Environment.Scenes
return; 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) if (att.RootPart != null)
AttachmentPt = att.RootPart.AttachmentPoint; AttachmentPt = att.RootPart.AttachmentPoint;
ScenePresence presence; ScenePresence presence;
if(TryGetAvatar(remoteClient.AgentId, out 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<IAvatarFactory>(); IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
if(ava != null) if(ava != null)
{ {

View File

@ -36,6 +36,7 @@ using libsecondlife.Packets;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Types; using OpenSim.Region.Environment.Types;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
@ -416,7 +417,8 @@ namespace OpenSim.Region.Environment.Scenes
RegisterToEvents(); RegisterToEvents();
SetDirectionVectors(); SetDirectionVectors();
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
userInfo.OnItemReceived += ItemReceived;
} }
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
@ -604,6 +606,12 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void MakeRootAgent(LLVector3 pos, bool isFlying) public void MakeRootAgent(LLVector3 pos, bool isFlying)
{ {
IAvatarFactory ava = m_scene.RequestModuleInterface<IAvatarFactory>();
if(ava != null)
{
ava.TryGetAvatarAppearance(m_uuid, out m_appearance);
}
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}", // "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}",
// Name, UUID, m_scene.RegionInfo.RegionName, pos); // 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 //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
return flags; 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);
}
}
} }
} }