diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 6472f317a2..c0168e294d 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -215,6 +215,7 @@ namespace OpenSim.Framework
}
}
+
///
/// Serializable Agent Circuit Data
///
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index aacd1272b8..825ab81afa 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -226,6 +226,46 @@ namespace OpenSim.Framework
}
}
+ public class AttachmentData
+ {
+ public int AttachPoint;
+ public UUID ItemID;
+ public UUID AssetID;
+
+ public AttachmentData(int point, UUID item, UUID asset)
+ {
+ AttachPoint = point;
+ ItemID = item;
+ AssetID = asset;
+ }
+
+ public AttachmentData(OSDMap args)
+ {
+ UnpackUpdateMessage(args);
+ }
+
+ public OSDMap PackUpdateMessage()
+ {
+ OSDMap attachdata = new OSDMap();
+ attachdata["point"] = OSD.FromInteger(AttachPoint);
+ attachdata["item"] = OSD.FromUUID(ItemID);
+ attachdata["asset"] = OSD.FromUUID(AssetID);
+
+ return attachdata;
+ }
+
+
+ public void UnpackUpdateMessage(OSDMap args)
+ {
+ if (args["point"] != null)
+ AttachPoint = args["point"].AsInteger();
+ if (args["item"] != null)
+ ItemID = args["item"].AsUUID();
+ if (args["asset"] != null)
+ AssetID = args["asset"].AsUUID();
+ }
+ }
+
public class AgentData : IAgentData
{
private UUID m_id;
@@ -272,6 +312,7 @@ namespace OpenSim.Framework
public byte[] AgentTextures;
public byte[] VisualParams;
public UUID[] Wearables;
+ public AttachmentData[] Attachments;
public string CallbackURI;
@@ -352,6 +393,13 @@ namespace OpenSim.Framework
args["wearables"] = wears;
}
+ if ((Attachments != null) && (Attachments.Length > 0))
+ {
+ OSDArray attachs = new OSDArray(Attachments.Length);
+ foreach (AttachmentData att in Attachments)
+ attachs.Add(att.PackUpdateMessage());
+ args["attachments"] = attachs;
+ }
if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI);
@@ -492,7 +540,21 @@ namespace OpenSim.Framework
foreach (OSD o in wears)
Wearables[i++] = o.AsUUID();
}
-
+
+ if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
+ {
+ OSDArray attachs = (OSDArray)(args["attachments"]);
+ Attachments = new AttachmentData[attachs.Count];
+ int i = 0;
+ foreach (OSD o in attachs)
+ {
+ if (o.Type == OSDType.Map)
+ {
+ Attachments[i++] = new AttachmentData((OSDMap)o);
+ }
+ }
+ }
+
if (args["callback_uri"] != null)
CallbackURI = args["callback_uri"].AsString();
}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 59b20190ba..dd451ef94f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -274,9 +274,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
- m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
// Put the root folder there, as type Folder
folders[AssetType.Folder] = root;
+ m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
return folders;
}
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index cea9044616..f5e9be16dd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2357,7 +2357,9 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence))
{
- presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID);
+ // XXYY!!
+ InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID));
+ presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
IAvatarFactory ava = RequestModuleInterface();
if (ava != null)
{
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 33166df64d..f475c64850 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2042,13 +2042,22 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
+ AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
+
m_log.DebugFormat(
- "[SCENE]: Adding new child agent for {0} in {1}",
- client.Name, RegionInfo.RegionName);
+ "[SCENE]: Adding new {0} agent for {1} in {2}",
+ ((aCircuit.child == true) ? "child" : "root"), client.Name, RegionInfo.RegionName);
CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
- CreateAndAddScenePresence(client);
+ ScenePresence sp = CreateAndAddScenePresence(client);
+
+ // HERE!!! Do the initial attachments here
+ if (aCircuit.child == false) // first agent upon login is root agent
+ {
+ sp.IsChildAgent = false;
+ sp.RezAttachments();
+ }
}
m_LastLogin = Environment.TickCount;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 3bd079a272..fd136331e7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -557,6 +557,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(objectLocalID);
if (group != null)
{
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject got {0}", group.UUID);
if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
{
// If the attachment point isn't the same as the one previously used
@@ -564,6 +565,7 @@ namespace OpenSim.Region.Framework.Scenes
// and not in a weird location somewhere unknown.
if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
{
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 1 got {0}", group.UUID);
attachPos = Vector3.Zero;
}
@@ -572,7 +574,8 @@ namespace OpenSim.Region.Framework.Scenes
{
// Check object for stored attachment point
AttachmentPt = (uint)group.GetAttachmentPoint();
- }
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 2 got {0}", group.UUID);
+ }
// if we still didn't find a suitable attachment point.......
if (AttachmentPt == 0)
@@ -580,8 +583,12 @@ namespace OpenSim.Region.Framework.Scenes
// Stick it on left hand with Zero Offset from the attachment point.
AttachmentPt = (uint)AttachmentPoint.LeftHand;
attachPos = Vector3.Zero;
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 3 got {0}", group.UUID);
+
}
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 4 got {0}", group.UUID);
+
group.SetAttachmentPoint(Convert.ToByte(AttachmentPt));
group.AbsolutePosition = attachPos;
@@ -590,10 +597,12 @@ namespace OpenSim.Region.Framework.Scenes
if (group.GetFromItemID() == UUID.Zero)
{
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 5 got {0}", group.UUID);
m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
}
else
{
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject 6 got {0}", group.GetFromItemID());
itemId = group.GetFromItemID();
}
@@ -611,6 +620,8 @@ namespace OpenSim.Region.Framework.Scenes
remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false);
}
}
+ else
+ m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
}
protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 708c455b61..1b541c41a7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -935,6 +935,7 @@ namespace OpenSim.Region.Framework.Scenes
SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(this);
+ m_log.DebugFormat("[SOG]: Added att {0} to avie {1}", UUID, avatar.UUID);
if (!silent)
{
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index fc8b62e321..b0bb005332 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -652,9 +652,6 @@ namespace OpenSim.Region.Framework.Scenes
RegisterToEvents();
SetDirectionVectors();
- CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
- if (userInfo != null)
- userInfo.OnItemReceived += ItemReceived;
}
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
@@ -1021,7 +1018,9 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Complete Avatar's movement into the region
+ /// Complete Avatar's movement into the region.
+ /// This is called upon a very important packet sent from the client,
+ /// so it's client-controlled. Never call this method directly.
///
public void CompleteMovement()
{
@@ -1042,22 +1041,19 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = pos;
}
- if (m_isChildAgent)
+ m_isChildAgent = false;
+ bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
+ MakeRootAgent(AbsolutePosition, m_flying);
+
+ if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
{
- m_isChildAgent = false;
- bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
- MakeRootAgent(AbsolutePosition, m_flying);
-
- if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
- {
- m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
- Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI);
- m_callbackURI = null;
- }
-
- //m_log.DebugFormat("Completed movement");
+ m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
+ Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI);
+ m_callbackURI = null;
}
+ //m_log.DebugFormat("Completed movement");
+
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
SendInitialData();
@@ -3154,6 +3150,20 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message);
}
+ //Attachments
+ List attPoints = m_appearance.GetAttachedPoints();
+ if (attPoints != null)
+ {
+ m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
+ int i = 0;
+ AttachmentData[] attachs = new AttachmentData[attPoints.Count];
+ foreach (int point in attPoints)
+ {
+ attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
+ }
+ cAgent.Attachments = attachs;
+ }
+
// Animations
try
{
@@ -3219,6 +3229,19 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message);
}
+ // Attachments
+ try
+ {
+ if (cAgent.Attachments != null)
+ {
+ foreach (AttachmentData att in cAgent.Attachments)
+ {
+ m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
+ }
+ }
+ }
+ catch { }
+
// Animations
try
{
@@ -3729,37 +3752,46 @@ namespace OpenSim.Region.Framework.Scenes
return flags;
}
- private void ItemReceived(UUID itemID)
+ ///
+ /// RezAttachments. This should only be called upon login on the first region
+ ///
+ public void RezAttachments()
{
- if (IsChildAgent)
- return;
-
if (null == m_appearance)
{
- m_log.Warn("[ATTACHMENT] Appearance has not been initialized");
+ m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID);
return;
}
- int attachpoint = m_appearance.GetAttachpoint(itemID);
- if (attachpoint == 0)
- return;
-
- UUID asset = m_appearance.GetAttachedAsset(attachpoint);
- if (UUID.Zero == asset) // We have just logged in
+ List attPoints = m_appearance.GetAttachedPoints();
+ foreach (int p in attPoints)
{
+ UUID itemID = m_appearance.GetAttachedItem(p);
+ UUID assetID = m_appearance.GetAttachedAsset(p);
+
+ if (UUID.Zero == assetID)
+ {
+ m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
+ continue;
+ }
+
try
{
// Rez from inventory
- asset = m_scene.RezSingleAttachment(ControllingClient,
- itemID, (uint)attachpoint);
- // Corner case: We are not yet a Scene Entity
- // Setting attachment info in RezSingleAttachment will fail
- // Set it here
- //
- m_appearance.SetAttachment((int)attachpoint, itemID,
- asset);
- m_log.InfoFormat("[ATTACHMENT] Rezzed attachment {0}, inworld asset {1}",
- itemID.ToString(), asset);
+ UUID asset = m_scene.RezSingleAttachment(ControllingClient,
+ itemID, (uint)p);
+
+ m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
+ p, itemID, assetID, asset);
+
+ //SceneObjectPart att = m_scene.GetSceneObjectPart(asset);
+ //m_log.DebugFormat("[ATTCHMENT]: Got scene object parent {0} IsAtt {1}",
+ // ((att.ParentGroup != null) ? "not null" : "null"), att.IsAttachment);
+ //if (att.ParentGroup != null && !att.IsAttachment)
+ //{
+ // att.FromItemID = itemID;
+ // m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false);
+ //}
}
catch (Exception e)
@@ -3767,31 +3799,30 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("[ATTACHMENT] Unable to rez attachment: {0}", e.ToString());
}
- return;
}
- SceneObjectPart att = m_scene.GetSceneObjectPart(asset);
+ //SceneObjectPart att = m_scene.GetSceneObjectPart(asset);
- // If this is null, then the asset has not yet appeared in world
- // so we revisit this when it does
- //
- if (att != null && att.UUID != asset) // Yes. It's really needed
- {
- m_log.DebugFormat("[ATTACHMENT]: Attach from in world: ItemID {0}, Asset ID {1}, Attachment inworld: {2}", itemID.ToString(), asset.ToString(), att.UUID.ToString());
+ //// If this is null, then the asset has not yet appeared in world
+ //// so we revisit this when it does
+ ////
+ //if (att != null && att.UUID != asset) // Yes. It's really needed
+ //{
+ // m_log.DebugFormat("[ATTACHMENT]: Attach from in world: ItemID {0}, Asset ID {1}, Attachment inworld: {2}", itemID.ToString(), asset.ToString(), att.UUID.ToString());
- // This will throw if crossing katty-korner
- // So catch it here to avoid the noid
- //
- try
- {
- // Attach from world, if not already attached
- if (att.ParentGroup != null && !att.IsAttachment)
- m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false);
- }
- catch (NullReferenceException)
- {
- }
- }
+ // // This will throw if crossing katty-korner
+ // // So catch it here to avoid the noid
+ // //
+ // try
+ // {
+ // // Attach from world, if not already attached
+ // if (att.ParentGroup != null && !att.IsAttachment)
+ // m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false);
+ // }
+ // catch (NullReferenceException)
+ // {
+ // }
+ //}
}
}
}