refactor: Move another RezSingleAttachment() from Scene.Inventory to AttachmentsModule

slimupdates
Justin Clark-Casey (justincc) 2010-03-12 23:20:38 +00:00
parent 6828d8ecbe
commit 315fa06c75
5 changed files with 57 additions and 37 deletions

View File

@ -169,7 +169,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return true; return true;
} }
public SceneObjectGroup RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
}
public UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
{
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
if (updateInventoryStatus)
{
if (att == null)
{
ShowDetachInUserInventory(itemID, remoteClient);
}
SetAttachmentInventoryStatus(att, remoteClient, itemID, AttachmentPt);
}
if (null == att)
return UUID.Zero;
else
return att.UUID;
}
protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{ {
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null) if (invAccess != null)

View File

@ -59,13 +59,27 @@ namespace OpenSim.Region.Framework.Interfaces
IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent); IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent);
/// <summary> /// <summary>
/// Rez an attachment from user inventory /// Rez an attachment from user inventory and change inventory status to match.
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="itemID"></param> /// <param name="itemID"></param>
/// <param name="AttachmentPt"></param> /// <param name="AttachmentPt"></param>
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns> /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
SceneObjectGroup RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
/// <summary>
/// Rez an attachment from user inventory
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <param name="updateinventoryStatus">
/// If true, we also update the user's inventory to show that the attachment is set. If false, we do not.
/// False is required so that we don't attempt to update information when a user enters a scene with the
/// attachment already correctly set up in inventory.
/// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns>
UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
/// <summary> /// <summary>
/// Update the user inventory to the attachment of an item /// Update the user inventory to the attachment of an item

View File

@ -1842,35 +1842,12 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnAttach(localID, itemID, avatarID); EventManager.TriggerOnAttach(localID, itemID, avatarID);
} }
/// <summary>
/// Called when the client receives a request to rez a single attachment on to the avatar from inventory
/// (RezSingleAttachmentFromInv packet).
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <returns></returns>
public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
SceneObjectGroup att = AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt);
if (att == null)
{
AttachmentsModule.ShowDetachInUserInventory(itemID, remoteClient);
return UUID.Zero;
}
return AttachmentsModule.SetAttachmentInventoryStatus(att, remoteClient, itemID, AttachmentPt);
}
public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
{ {
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
{ {
RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
} }
} }

View File

@ -2643,12 +2643,12 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
{ {
client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
client.OnObjectDetach += m_sceneGraph.DetachObject; client.OnObjectDetach += m_sceneGraph.DetachObject;
if (AttachmentsModule != null) if (AttachmentsModule != null)
{ {
client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
client.OnObjectAttach += AttachmentsModule.AttachObject; client.OnObjectAttach += AttachmentsModule.AttachObject;
client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
} }
@ -2800,11 +2800,11 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
{ {
client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
client.OnObjectDetach -= m_sceneGraph.DetachObject; client.OnObjectDetach -= m_sceneGraph.DetachObject;
if (AttachmentsModule != null) if (AttachmentsModule != null)
{ {
client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
client.OnObjectAttach -= AttachmentsModule.AttachObject; client.OnObjectAttach -= AttachmentsModule.AttachObject;
client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
} }

View File

@ -3738,7 +3738,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (null == m_appearance) if (null == m_appearance)
{ {
m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID);
return; return;
} }
@ -3762,12 +3762,12 @@ namespace OpenSim.Region.Framework.Scenes
try try
{ {
// Rez from inventory // Rez from inventory
UUID asset = m_scene.RezSingleAttachment(ControllingClient, UUID asset
itemID, (uint)p); = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p);
m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", m_log.InfoFormat(
"[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
p, itemID, assetID, asset); p, itemID, assetID, asset);
} }
catch (Exception e) catch (Exception e)
{ {