Stop attempts to update/add existing attachments in user inventory when teleporting between regions.
This appears to resolve issues on teleport where attachments disappear or become labelled as invalid within user inventory.user_profiles
parent
2b142f2f9e
commit
c92654fb43
|
@ -322,12 +322,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
sp.ClearAttachments();
|
sp.ClearAttachments();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append)
|
public bool AttachObject(
|
||||||
|
IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append)
|
||||||
{
|
{
|
||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return AttachObjectInternal(sp, group, attachmentPt, silent, temp, true, append);
|
return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, true, append);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -338,10 +339,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
/// <param name='group'>The object to attach.</param>
|
/// <param name='group'>The object to attach.</param>
|
||||||
/// <param name='attachmentPt'></param>
|
/// <param name='attachmentPt'></param>
|
||||||
/// <param name='silent'></param>
|
/// <param name='silent'></param>
|
||||||
/// <param name='temp'></param>
|
/// <param name='addToInventory'>If true then add object to user inventory.</param>
|
||||||
/// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
|
/// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
|
||||||
|
/// <param name='append'>Append to attachment point rather than replace.</param>
|
||||||
private bool AttachObjectInternal(
|
private bool AttachObjectInternal(
|
||||||
IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts, bool append)
|
IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append)
|
||||||
{
|
{
|
||||||
if (group.GetSittingAvatarsCount() != 0)
|
if (group.GetSittingAvatarsCount() != 0)
|
||||||
{
|
{
|
||||||
|
@ -412,8 +414,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
|
|
||||||
lock (sp.AttachmentsSyncLock)
|
lock (sp.AttachmentsSyncLock)
|
||||||
{
|
{
|
||||||
if (sp.PresenceType != PresenceType.Npc)
|
if (addToInventory && sp.PresenceType != PresenceType.Npc)
|
||||||
UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append);
|
UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
|
||||||
|
|
||||||
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
|
||||||
|
|
||||||
|
@ -432,19 +434,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append)
|
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool append)
|
||||||
{
|
{
|
||||||
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
|
||||||
|
|
||||||
// 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;
|
||||||
{
|
if (newAttachmentItemID == UUID.Zero)
|
||||||
UUID newAttachmentItemID = group.FromItemID;
|
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
||||||
if (newAttachmentItemID == UUID.Zero)
|
|
||||||
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
|
||||||
|
|
||||||
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
|
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
|
||||||
|
@ -939,7 +938,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// This will throw if the attachment fails
|
// This will throw if the attachment fails
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AttachObjectInternal(sp, objatt, attachmentPt, false, false, true, append);
|
AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1081,7 +1080,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, false, append))
|
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append))
|
||||||
{
|
{
|
||||||
if (DebugLevel > 0)
|
if (DebugLevel > 0)
|
||||||
m_log.Debug(
|
m_log.Debug(
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
|
||||||
|
|
||||||
m_numberOfAttachEventsFired = 0;
|
m_numberOfAttachEventsFired = 0;
|
||||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
|
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);
|
||||||
|
|
||||||
// Check status on scene presence
|
// Check status on scene presence
|
||||||
Assert.That(sp.HasAttachments(), Is.True);
|
Assert.That(sp.HasAttachments(), Is.True);
|
||||||
|
@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
|
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
|
||||||
|
|
||||||
m_numberOfAttachEventsFired = 0;
|
m_numberOfAttachEventsFired = 0;
|
||||||
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false, false);
|
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false);
|
||||||
|
|
||||||
// Check status on scene presence
|
// Check status on scene presence
|
||||||
Assert.That(sp.HasAttachments(), Is.True);
|
Assert.That(sp.HasAttachments(), Is.True);
|
||||||
|
@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
|
|
||||||
// Test wearing a different attachment from the ground.
|
// Test wearing a different attachment from the ground.
|
||||||
{
|
{
|
||||||
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false);
|
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
|
||||||
|
|
||||||
// Check status on scene presence
|
// Check status on scene presence
|
||||||
Assert.That(sp.HasAttachments(), Is.True);
|
Assert.That(sp.HasAttachments(), Is.True);
|
||||||
|
@ -310,7 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
|
|
||||||
// Test rewearing an already worn attachment from ground. Nothing should happen.
|
// Test rewearing an already worn attachment from ground. Nothing should happen.
|
||||||
{
|
{
|
||||||
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false);
|
scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
|
||||||
|
|
||||||
// Check status on scene presence
|
// Check status on scene presence
|
||||||
Assert.That(sp.HasAttachments(), Is.True);
|
Assert.That(sp.HasAttachments(), Is.True);
|
||||||
|
@ -368,7 +368,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, false, false);
|
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, 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));
|
||||||
|
|
|
@ -80,14 +80,16 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
void DeleteAttachmentsFromScene(IScenePresence sp, bool silent);
|
void DeleteAttachmentsFromScene(IScenePresence sp, bool silent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attach an object to an avatar
|
/// Attach an object to an avatar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sp"></param>
|
/// <param name="sp"></param>
|
||||||
/// <param name="grp"></param>
|
/// <param name="grp"></param>
|
||||||
/// <param name="AttachmentPt"></param>
|
/// <param name="AttachmentPt"></param>
|
||||||
/// <param name="silent"></param>
|
/// <param name="silent"></param>
|
||||||
|
/// <param name="addToInventory">If true then add object to user inventory</param>
|
||||||
|
/// <param name="append">Append to attachment point rather than replace.</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 temp, bool append);
|
bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool addToInventory, bool append);
|
||||||
|
|
||||||
/// <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.
|
||||||
|
|
|
@ -184,7 +184,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
|
||||||
hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
|
hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true) ? 1 : 0;
|
return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue