If crossing attachments into another region pre-fatpack, clone objects before changing properties to avoid hud display race condition with update threads.

This matches behaviour in fatpack crossing, where attachments are cloned before their properties are changed.
This only applies to crossings to simulators running code released before April 2011.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-06-26 21:06:47 +01:00
parent 19c2f08a8b
commit 3106a0f25e
1 changed files with 26 additions and 17 deletions

View File

@ -1660,6 +1660,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
#endregion #endregion
#region Object Transfers #region Object Transfers
/// <summary> /// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved /// Move the given scene object into a new region depending on which region its absolute position has moved
/// into. /// into.
@ -1961,35 +1962,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return successYN; return successYN;
} }
protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) /// <summary>
/// Cross the attachments for an avatar into the destination region.
/// </summary>
/// <remarks>
/// This is only invoked for simulators released prior to April 2011. Versions of OpenSimulator since then
/// transfer attachments in one go as part of the ChildAgentDataUpdate data passed in the update agent call.
/// </remarks>
/// <param name='destination'></param>
/// <param name='sp'></param>
/// <param name='silent'></param>
protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
{ {
List<SceneObjectGroup> m_attachments = sp.GetAttachments(); List<SceneObjectGroup> attachments = sp.GetAttachments();
// Validate // m_log.DebugFormat(
// foreach (SceneObjectGroup gobj in m_attachments) // "[ENTITY TRANSFER MODULE]: Crossing {0} attachments into {1} for {2}",
// { // m_attachments.Count, destination.RegionName, sp.Name);
// if (gobj == null || gobj.IsDeleted)
// return false;
// }
foreach (SceneObjectGroup gobj in m_attachments) foreach (SceneObjectGroup gobj in attachments)
{ {
// If the prim group is null then something must have happened to it! // If the prim group is null then something must have happened to it!
if (gobj != null && !gobj.IsDeleted) if (gobj != null && !gobj.IsDeleted)
{ {
// Set the parent localID to 0 so it transfers over properly. SceneObjectGroup clone = (SceneObjectGroup)gobj.CloneForNewScene();
gobj.RootPart.SetParentLocalId(0); clone.RootPart.GroupPosition = gobj.RootPart.AttachedPos;
gobj.AbsolutePosition = gobj.RootPart.AttachedPos; clone.IsAttachment = false;
gobj.IsAttachment = false;
//gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); m_log.DebugFormat(
CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, gobj, silent); "[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}",
clone.UUID, destination.RegionName);
CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, clone, silent);
} }
} }
sp.ClearAttachments(); sp.ClearAttachments();
return true;
} }
#endregion #endregion