Lay some groundwork for temp attachments. Decouple attachments from inventory.
parent
58c630c18e
commit
fe4c3a37c0
|
@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
sp.ClearAttachments();
|
sp.ClearAttachments();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
|
public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp)
|
||||||
{
|
{
|
||||||
lock (sp.AttachmentsSyncLock)
|
lock (sp.AttachmentsSyncLock)
|
||||||
{
|
{
|
||||||
|
@ -298,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
group.AbsolutePosition = attachPos;
|
group.AbsolutePosition = attachPos;
|
||||||
|
|
||||||
if (sp.PresenceType != PresenceType.Npc)
|
if (sp.PresenceType != PresenceType.Npc)
|
||||||
UpdateUserInventoryWithAttachment(sp, group, attachmentPt);
|
UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp);
|
||||||
|
|
||||||
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt)
|
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp)
|
||||||
{
|
{
|
||||||
// Remove any previous attachments
|
// Remove any previous attachments
|
||||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||||
|
@ -316,19 +316,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
{
|
{
|
||||||
if (attachments[0].FromItemID != UUID.Zero)
|
if (attachments[0].FromItemID != UUID.Zero)
|
||||||
DetachSingleAttachmentToInvInternal(sp, attachments[0]);
|
DetachSingleAttachmentToInvInternal(sp, attachments[0]);
|
||||||
else
|
// Error logging commented because UUID.Zero now means temp attachment
|
||||||
m_log.WarnFormat(
|
// else
|
||||||
"[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
|
// m_log.WarnFormat(
|
||||||
attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
|
// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
|
||||||
|
// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new attachment to inventory if we don't already have it.
|
// Add the new attachment to inventory if we don't already have it.
|
||||||
|
if (!temp)
|
||||||
|
{
|
||||||
UUID newAttachmentItemID = group.FromItemID;
|
UUID newAttachmentItemID = group.FromItemID;
|
||||||
if (newAttachmentItemID == UUID.Zero)
|
if (newAttachmentItemID == UUID.Zero)
|
||||||
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
||||||
|
|
||||||
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
|
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
||||||
{
|
{
|
||||||
|
@ -416,7 +420,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
so.PrimCount, sp.UUID, sp.AbsolutePosition))
|
so.PrimCount, sp.UUID, sp.AbsolutePosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool changed = sp.Appearance.DetachAttachment(inventoryID);
|
bool changed = false;
|
||||||
|
if (inventoryID != UUID.Zero)
|
||||||
|
changed = sp.Appearance.DetachAttachment(inventoryID);
|
||||||
if (changed && m_scene.AvatarFactory != null)
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
||||||
|
|
||||||
|
@ -521,6 +527,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
/// <param name="saveAllScripted"></param>
|
/// <param name="saveAllScripted"></param>
|
||||||
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
|
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
|
||||||
{
|
{
|
||||||
|
if (grp.FromItemID == UUID.Zero)
|
||||||
|
{
|
||||||
|
// We can't save temp attachments
|
||||||
|
grp.HasGroupChanged = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Saving attachments for NPCs messes them up for the real owner!
|
// Saving attachments for NPCs messes them up for the real owner!
|
||||||
INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
|
INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
|
||||||
if (module != null)
|
if (module != null)
|
||||||
|
@ -777,7 +790,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// This will throw if the attachment fails
|
// This will throw if the attachment fails
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AttachObject(sp, objatt, attachmentPt, false);
|
AttachObject(sp, objatt, attachmentPt, false, false);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -931,7 +944,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
AttachmentPt &= 0x7f;
|
AttachmentPt &= 0x7f;
|
||||||
|
|
||||||
// Calls attach with a Zero position
|
// Calls attach with a Zero position
|
||||||
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
|
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false))
|
||||||
{
|
{
|
||||||
// m_log.Debug(
|
// m_log.Debug(
|
||||||
// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
||||||
|
|
|
@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
|
|
||||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
||||||
|
|
||||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
|
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);
|
||||||
|
|
||||||
// Check status on scene presence
|
// Check status on scene presence
|
||||||
Assert.That(sp.HasAttachments(), Is.True);
|
Assert.That(sp.HasAttachments(), Is.True);
|
||||||
|
@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
sp2.AbsolutePosition = new Vector3(0, 0, 0);
|
sp2.AbsolutePosition = new Vector3(0, 0, 0);
|
||||||
sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
|
sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
|
||||||
|
|
||||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
|
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);
|
||||||
|
|
||||||
Assert.That(sp.HasAttachments(), Is.False);
|
Assert.That(sp.HasAttachments(), Is.False);
|
||||||
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="AttachmentPt"></param>
|
/// <param name="AttachmentPt"></param>
|
||||||
/// <param name="silent"></param>
|
/// <param name="silent"></param>
|
||||||
/// <returns>true if the object was successfully attached, false otherwise</returns>
|
/// <returns>true if the object was successfully attached, false otherwise</returns>
|
||||||
bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent);
|
bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool temp);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rez an attachment from user inventory and change inventory status to match.
|
/// Rez an attachment from user inventory and change inventory status to match.
|
||||||
|
|
|
@ -2628,7 +2628,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
||||||
|
|
||||||
if (AttachmentsModule != null)
|
if (AttachmentsModule != null)
|
||||||
AttachmentsModule.AttachObject(sp, grp, 0, false);
|
AttachmentsModule.AttachObject(sp, grp, 0, false, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3043,7 +3043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||||
|
|
||||||
if (attachmentsModule != null)
|
if (attachmentsModule != null)
|
||||||
return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
|
return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue