Plumb a data path to initialize an attachment from an alternate source

avinationmerge
Melanie Thielker 2010-04-24 16:45:25 +02:00
parent 56f60a04d9
commit 71f42f185a
5 changed files with 57 additions and 4 deletions

View File

@ -27,6 +27,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Xml;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
@ -192,7 +193,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public UUID RezSingleAttachmentFromInventory( public UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
{ {
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null);
}
public UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
{
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc);
if (updateInventoryStatus) if (updateInventoryStatus)
{ {
@ -211,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt) IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc)
{ {
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null) if (invAccess != null)
@ -237,6 +244,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (tainted) if (tainted)
objatt.HasGroupChanged = true; objatt.HasGroupChanged = true;
if (doc != null)
objatt.LoadScriptState(doc);
// Fire after attach, so we don't get messy perms dialogs // Fire after attach, so we don't get messy perms dialogs
// 3 == AttachedRez // 3 == AttachedRez
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3); objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3);
@ -318,6 +328,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{ {
// XXYY!! // XXYY!!
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
if (item == null)
m_log.Error("[ATTACHMENT]: item == null");
if (m_scene == null)
m_log.Error("[ATTACHMENT]: m_scene == null");
if (m_scene.InventoryService == null)
m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null");
item = m_scene.InventoryService.GetItem(item); item = m_scene.InventoryService.GetItem(item);
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);

View File

@ -524,6 +524,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
} }
else else
{ {
throw new Exception("AttachTracer");
group.SetFromItemID(itemID); group.SetFromItemID(itemID);
} }

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Xml;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
@ -82,6 +83,10 @@ namespace OpenSim.Region.Framework.Interfaces
UUID RezSingleAttachmentFromInventory( UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
// Same as above, but also load script states from a separate doc
UUID RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc);
/// <summary> /// <summary>
/// Rez multiple attachments from a user's inventory /// Rez multiple attachments from a user's inventory
/// </summary> /// </summary>

View File

@ -3984,7 +3984,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
{ {
// Rez from inventory // Rez from inventory
UUID asset UUID asset
= m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null);
m_log.InfoFormat( m_log.InfoFormat(
"[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",

View File

@ -0,0 +1,31 @@
////////////////////////////////////////////////////////////////
//
// (c) 2009, 2010 Careminster Limited and Melanie Thielker
//
// All rights reserved
//
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Server.Base;
using OpenSim.Services.Base;
using OpenSim.Services.Interfaces;
using Nini.Config;
using log4net;
using Careminster;
using OpenMetaverse;
namespace Careminster
{
public interface IAttachmentsService
{
string Get(string id);
void Store(string id, string data);
}
}