From 2eaadf2dc0459aa4fc2d7cf7de510213ff31c543 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 22 Aug 2011 23:28:37 +0100
Subject: Add warning log message to say which attachment fails validation in
order to pin down problems with "Inconsistent Attachment State"
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 719f2da..53c3b85 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3525,12 +3525,22 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectGroup gobj in m_attachments)
{
if (gobj == null)
+ {
+ m_log.WarnFormat(
+ "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null", Name);
return false;
+ }
if (gobj.IsDeleted)
+ {
+ m_log.WarnFormat(
+ "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted",
+ gobj.Name, gobj.UUID, Name);
return false;
+ }
}
}
+
return true;
}
--
cgit v1.1
From d328046efbcd7449e0421f72138f48272f514481 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 22 Aug 2011 23:59:48 +0100
Subject: If an attachment fails, then start logging the exception for now, in
order to help with the inconsistent state bug.
This also refactors AttachmentsModules to stop pointlessly refetching the ScenePresence in various methods. However, more of this is required.
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 53c3b85..9f9af45 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3540,7 +3540,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
-
+
return true;
}
--
cgit v1.1
From afd5469eec3111fa2de9b4e5e53f1f104a521086 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 23 Aug 2011 00:08:29 +0100
Subject: Remove pointless contains check in ScenePresence.RemoveAttachment()
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9f9af45..9518161 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3509,12 +3509,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RemoveAttachment(SceneObjectGroup gobj)
{
lock (m_attachments)
- {
- if (m_attachments.Contains(gobj))
- {
- m_attachments.Remove(gobj);
- }
- }
+ m_attachments.Remove(gobj);
}
public bool ValidateAttachments()
--
cgit v1.1
From cf3ffe5bb4c6a8bea9599b6143c2f7793500c984 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 20:49:23 +0100
Subject: Fix llAttachToAvatar()
Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay.
So we now don't do this. The state will be serialized anyway when the avatar normally logs out.
The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state.
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 +++++++---
.../Scenes/Serialization/SceneObjectSerializer.cs | 31 +++++++++++++++-------
2 files changed, 33 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index afc1a4f..94126f0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1873,6 +1873,8 @@ namespace OpenSim.Region.Framework.Scenes
public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
{
+// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
+
itemID = UUID.Zero;
if (grp != null)
{
@@ -1881,16 +1883,20 @@ namespace OpenSim.Region.Framework.Scenes
? 250
: grp.AbsolutePosition.X)
,
- (grp.AbsolutePosition.X > (int)Constants.RegionSize)
+ (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
? 250
- : grp.AbsolutePosition.X,
+ : grp.AbsolutePosition.Y,
grp.AbsolutePosition.Z);
Vector3 originalPosition = grp.AbsolutePosition;
grp.AbsolutePosition = inventoryStoredPosition;
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
+ // If we're being called from a script, then trying to serialize that same script's state will not complete
+ // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
+ // the client/server crashes rather than logging out normally, the attachment's scripts will resume
+ // without state on relog. Arguably, this is what we want anyway.
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
grp.AbsolutePosition = originalPosition;
@@ -1900,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml),
remoteClient.AgentId);
+
AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase();
@@ -1948,6 +1955,7 @@ namespace OpenSim.Region.Framework.Scenes
itemID = item.ID;
return item.AssetID;
}
+
return UUID.Zero;
}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 8fb9fad..a60ee9b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -127,26 +127,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
///
public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
{
+ return ToOriginalXmlFormat(sceneObject, true);
+ }
+
+ ///
+ /// Serialize a scene object to the original xml format
+ ///
+ ///
+ /// Control whether script states are also serialized.
+ ///
+ public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates)
+ {
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
- ToOriginalXmlFormat(sceneObject, writer);
+ ToOriginalXmlFormat(sceneObject, writer, doScriptStates);
}
return sw.ToString();
}
}
-
///
/// Serialize a scene object to the original xml format
///
///
///
- public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
+ public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates)
{
- ToOriginalXmlFormat(sceneObject, writer, false);
+ ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false);
}
///
@@ -156,10 +166,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
///
/// If false, don't write the enclosing SceneObjectGroup element
///
- public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool noRootElement)
+ public static void ToOriginalXmlFormat(
+ SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement)
{
- //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
- //int time = System.Environment.TickCount;
+// m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", sceneObject.Name);
+// int time = System.Environment.TickCount;
if (!noRootElement)
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
@@ -182,12 +193,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
}
writer.WriteEndElement(); // OtherParts
- sceneObject.SaveScriptedState(writer);
+
+ if (doScriptStates)
+ sceneObject.SaveScriptedState(writer);
if (!noRootElement)
writer.WriteEndElement(); // SceneObjectGroup
- //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+// m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", sceneObject.Name, System.Environment.TickCount - time);
}
protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
--
cgit v1.1
From ccf07f6ae337acc9c2b8fa30a784ee01ee3de24e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:14:57 +0100
Subject: refactor: remove pointless AgentId argument from
attachObjectAssetStore()
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 94126f0..66905fe 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1871,7 +1871,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
+ public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
{
// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
--
cgit v1.1
From 0e0d40c810c00dac02d0167866714212351097b0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:18:11 +0100
Subject: minor: remove hardcoded region numbers with the region size constant
and a currently hardcoded offset
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 66905fe..3e87578 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1880,11 +1880,11 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 inventoryStoredPosition = new Vector3
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
- ? 250
+ ? Constants.RegionSize - 6
: grp.AbsolutePosition.X)
,
(grp.AbsolutePosition.Y > (int)Constants.RegionSize)
- ? 250
+ ? Constants.RegionSize - 6
: grp.AbsolutePosition.Y,
grp.AbsolutePosition.Z);
--
cgit v1.1
From 274e354006a7a8426ebf339c333f1d4994231eed Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:23:10 +0100
Subject: get rid of pointless grp null check in attachObjectAssetStore()
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 142 ++++++++++-----------
1 file changed, 69 insertions(+), 73 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3e87578..ac73abd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1876,87 +1876,83 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
itemID = UUID.Zero;
- if (grp != null)
- {
- Vector3 inventoryStoredPosition = new Vector3
- (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
- ? Constants.RegionSize - 6
- : grp.AbsolutePosition.X)
- ,
- (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
- ? Constants.RegionSize - 6
- : grp.AbsolutePosition.Y,
- grp.AbsolutePosition.Z);
-
- Vector3 originalPosition = grp.AbsolutePosition;
-
- grp.AbsolutePosition = inventoryStoredPosition;
-
- // If we're being called from a script, then trying to serialize that same script's state will not complete
- // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
- // the client/server crashes rather than logging out normally, the attachment's scripts will resume
- // without state on relog. Arguably, this is what we want anyway.
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
-
- grp.AbsolutePosition = originalPosition;
-
- AssetBase asset = CreateAsset(
- grp.GetPartName(grp.LocalId),
- grp.GetPartDescription(grp.LocalId),
- (sbyte)AssetType.Object,
- Utils.StringToBytes(sceneObjectXml),
- remoteClient.AgentId);
- AssetService.Store(asset);
+ Vector3 inventoryStoredPosition = new Vector3
+ (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
+ ? Constants.RegionSize - 6
+ : grp.AbsolutePosition.X)
+ ,
+ (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
+ ? Constants.RegionSize - 6
+ : grp.AbsolutePosition.Y,
+ grp.AbsolutePosition.Z);
- InventoryItemBase item = new InventoryItemBase();
- item.CreatorId = grp.RootPart.CreatorID.ToString();
- item.CreatorData = grp.RootPart.CreatorData;
- item.Owner = remoteClient.AgentId;
- item.ID = UUID.Random();
- item.AssetID = asset.FullID;
- item.Description = asset.Description;
- item.Name = asset.Name;
- item.AssetType = asset.Type;
- item.InvType = (int)InventoryType.Object;
-
- InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
- if (folder != null)
- item.Folder = folder.ID;
- else // oopsies
- item.Folder = UUID.Zero;
+ Vector3 originalPosition = grp.AbsolutePosition;
- if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
- {
- item.BasePermissions = grp.RootPart.NextOwnerMask;
- item.CurrentPermissions = grp.RootPart.NextOwnerMask;
- item.NextPermissions = grp.RootPart.NextOwnerMask;
- item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
- item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
- }
- else
- {
- item.BasePermissions = grp.RootPart.BaseMask;
- item.CurrentPermissions = grp.RootPart.OwnerMask;
- item.NextPermissions = grp.RootPart.NextOwnerMask;
- item.EveryOnePermissions = grp.RootPart.EveryoneMask;
- item.GroupPermissions = grp.RootPart.GroupMask;
- }
- item.CreationDate = Util.UnixTimeSinceEpoch();
+ grp.AbsolutePosition = inventoryStoredPosition;
- // sets itemID so client can show item as 'attached' in inventory
- grp.SetFromItemID(item.ID);
+ // If we're being called from a script, then trying to serialize that same script's state will not complete
+ // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
+ // the client/server crashes rather than logging out normally, the attachment's scripts will resume
+ // without state on relog. Arguably, this is what we want anyway.
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
- if (AddInventoryItem(item))
- remoteClient.SendInventoryItemCreateUpdate(item, 0);
- else
- m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
+ grp.AbsolutePosition = originalPosition;
+
+ AssetBase asset = CreateAsset(
+ grp.GetPartName(grp.LocalId),
+ grp.GetPartDescription(grp.LocalId),
+ (sbyte)AssetType.Object,
+ Utils.StringToBytes(sceneObjectXml),
+ remoteClient.AgentId);
+
+ AssetService.Store(asset);
- itemID = item.ID;
- return item.AssetID;
+ InventoryItemBase item = new InventoryItemBase();
+ item.CreatorId = grp.RootPart.CreatorID.ToString();
+ item.CreatorData = grp.RootPart.CreatorData;
+ item.Owner = remoteClient.AgentId;
+ item.ID = UUID.Random();
+ item.AssetID = asset.FullID;
+ item.Description = asset.Description;
+ item.Name = asset.Name;
+ item.AssetType = asset.Type;
+ item.InvType = (int)InventoryType.Object;
+
+ InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
+ if (folder != null)
+ item.Folder = folder.ID;
+ else // oopsies
+ item.Folder = UUID.Zero;
+
+ if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
+ {
+ item.BasePermissions = grp.RootPart.NextOwnerMask;
+ item.CurrentPermissions = grp.RootPart.NextOwnerMask;
+ item.NextPermissions = grp.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
+ item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
+ }
+ else
+ {
+ item.BasePermissions = grp.RootPart.BaseMask;
+ item.CurrentPermissions = grp.RootPart.OwnerMask;
+ item.NextPermissions = grp.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = grp.RootPart.EveryoneMask;
+ item.GroupPermissions = grp.RootPart.GroupMask;
}
+ item.CreationDate = Util.UnixTimeSinceEpoch();
- return UUID.Zero;
+ // sets itemID so client can show item as 'attached' in inventory
+ grp.SetFromItemID(item.ID);
+
+ if (AddInventoryItem(item))
+ remoteClient.SendInventoryItemCreateUpdate(item, 0);
+ else
+ m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
+
+ itemID = item.ID;
+ return item.AssetID;
}
///
--
cgit v1.1
From 5eeee480d47b855774829c94aadcb69af8c0e8da Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:35:44 +0100
Subject: refactor: move Scene.Inventory.attachObjectAssetStore() into
AttachmentsModule.AddSceneObjectAsAttachment()
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 84 ----------------------
1 file changed, 84 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index ac73abd..9358e7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1871,90 +1871,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
- {
-// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
-
- itemID = UUID.Zero;
-
- Vector3 inventoryStoredPosition = new Vector3
- (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
- ? Constants.RegionSize - 6
- : grp.AbsolutePosition.X)
- ,
- (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
- ? Constants.RegionSize - 6
- : grp.AbsolutePosition.Y,
- grp.AbsolutePosition.Z);
-
- Vector3 originalPosition = grp.AbsolutePosition;
-
- grp.AbsolutePosition = inventoryStoredPosition;
-
- // If we're being called from a script, then trying to serialize that same script's state will not complete
- // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
- // the client/server crashes rather than logging out normally, the attachment's scripts will resume
- // without state on relog. Arguably, this is what we want anyway.
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
-
- grp.AbsolutePosition = originalPosition;
-
- AssetBase asset = CreateAsset(
- grp.GetPartName(grp.LocalId),
- grp.GetPartDescription(grp.LocalId),
- (sbyte)AssetType.Object,
- Utils.StringToBytes(sceneObjectXml),
- remoteClient.AgentId);
-
- AssetService.Store(asset);
-
- InventoryItemBase item = new InventoryItemBase();
- item.CreatorId = grp.RootPart.CreatorID.ToString();
- item.CreatorData = grp.RootPart.CreatorData;
- item.Owner = remoteClient.AgentId;
- item.ID = UUID.Random();
- item.AssetID = asset.FullID;
- item.Description = asset.Description;
- item.Name = asset.Name;
- item.AssetType = asset.Type;
- item.InvType = (int)InventoryType.Object;
-
- InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
- if (folder != null)
- item.Folder = folder.ID;
- else // oopsies
- item.Folder = UUID.Zero;
-
- if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
- {
- item.BasePermissions = grp.RootPart.NextOwnerMask;
- item.CurrentPermissions = grp.RootPart.NextOwnerMask;
- item.NextPermissions = grp.RootPart.NextOwnerMask;
- item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
- item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
- }
- else
- {
- item.BasePermissions = grp.RootPart.BaseMask;
- item.CurrentPermissions = grp.RootPart.OwnerMask;
- item.NextPermissions = grp.RootPart.NextOwnerMask;
- item.EveryOnePermissions = grp.RootPart.EveryoneMask;
- item.GroupPermissions = grp.RootPart.GroupMask;
- }
- item.CreationDate = Util.UnixTimeSinceEpoch();
-
- // sets itemID so client can show item as 'attached' in inventory
- grp.SetFromItemID(item.ID);
-
- if (AddInventoryItem(item))
- remoteClient.SendInventoryItemCreateUpdate(item, 0);
- else
- m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
-
- itemID = item.ID;
- return item.AssetID;
- }
-
///
/// Event Handler Rez an object into a scene
/// Calls the non-void event handler
--
cgit v1.1
From 9ba4511d3e6b63d51f951519151aaae1c59250d6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:53:12 +0100
Subject: add SOG helper properties IsPhantom, IsTemporary, etc. to improve
code readability
use these in some sog methods
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 66 +++++++++++++++-------
1 file changed, 46 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fe96152..079148f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -167,6 +167,44 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ///
+ /// Is this scene object phantom?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool IsPhantom
+ {
+ get { return (RootPart.Flags & PrimFlags.Phantom) != 0; }
+ }
+
+ ///
+ /// Does this scene object use physics?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool UsesPhysics
+ {
+ get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
+ }
+
+ ///
+ /// Is this scene object temporary?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool IsTemporary
+ {
+ get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
+ }
+
+ public bool IsVolumeDetect
+ {
+ get { return RootPart.VolumeDetectActive; }
+ }
+
public float scriptScore;
private Vector3 lastPhysGroupPos;
@@ -1510,36 +1548,24 @@ namespace OpenSim.Region.Framework.Scenes
SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
}
- public void ScriptSetPhysicsStatus(bool UsePhysics)
+ public void ScriptSetPhysicsStatus(bool usePhysics)
{
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
}
- public void ScriptSetTemporaryStatus(bool TemporaryStatus)
+ public void ScriptSetTemporaryStatus(bool makeTemporary)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect);
}
- public void ScriptSetPhantomStatus(bool PhantomStatus)
+ public void ScriptSetPhantomStatus(bool makePhantom)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect);
}
- public void ScriptSetVolumeDetect(bool VDStatus)
+ public void ScriptSetVolumeDetect(bool makeVolumeDetect)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect);
/*
ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore
--
cgit v1.1
From 6d4432f44009d7f7f3e52c56e8ccc994494ec529 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 22:34:26 +0100
Subject: refactor: simplify EntityBase.IsDeleted property
---
OpenSim/Region/Framework/Scenes/EntityBase.cs | 7 +------
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +-
3 files changed, 5 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs
index 6fd38e5..213431a 100644
--- a/OpenSim/Region/Framework/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs
@@ -66,12 +66,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Signals whether this entity was in a scene but has since been removed from it.
///
- public bool IsDeleted
- {
- get { return m_isDeleted; }
- set { m_isDeleted = value; }
- }
- protected bool m_isDeleted;
+ public bool IsDeleted { get; protected internal set; }
protected Vector3 m_pos;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 079148f..8f0fa55 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1832,7 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes
// an object has been deleted from a scene before update was processed.
// A more fundamental overhaul of the update mechanism is required to eliminate all
// the race conditions.
- if (m_isDeleted)
+ if (IsDeleted)
return;
// Even temporary objects take part in physics (e.g. temp-on-rez bullets)
@@ -2142,7 +2142,7 @@ namespace OpenSim.Region.Framework.Scenes
}
m_scene.UnlinkSceneObject(objectGroup, true);
- objectGroup.m_isDeleted = true;
+ objectGroup.IsDeleted = true;
objectGroup.m_parts.Clear();
@@ -3385,7 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual ISceneObject CloneForNewScene()
{
SceneObjectGroup sog = Copy(false);
- sog.m_isDeleted = false;
+ sog.IsDeleted = false;
return sog;
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9518161..def4ecb 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3809,7 +3809,7 @@ namespace OpenSim.Region.Framework.Scenes
List attachments = m_appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
- if (m_isDeleted)
+ if (IsDeleted)
return;
int p = attach.AttachPoint;
--
cgit v1.1
From d5dc8133fc05ef682c1caa8dc6b587608de7c384 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 22:37:08 +0100
Subject: remove pointless IsDeleted check on SP.RezAttachments()
IsDeleted is never set for an SP, even though it's on EntityBase.
It might be an idea to set it in the future
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ---
1 file changed, 3 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index def4ecb..fc89473 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3809,9 +3809,6 @@ namespace OpenSim.Region.Framework.Scenes
List attachments = m_appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
- if (IsDeleted)
- return;
-
int p = attach.AttachPoint;
UUID itemID = attach.ItemID;
--
cgit v1.1
From 002313bf132e7eca3d33fdd0c695152146d469b4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:02:23 +0100
Subject: refactor: move sog.DetachToInventoryPrep() into
AttachmentsModule.DetachSingleAttachmentToInv()
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 32 +++-------------------
1 file changed, 4 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8f0fa55..00e3363 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
- ///
+ ///
/// Is this scene object acting as an attachment?
- ///
+ ///
+ ///
/// We return false if the group has already been deleted.
///
/// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I
/// presume either all or no parts in a linkset can be part of an attachment (in which
/// case the value would get proprogated down into all the descendent parts).
- ///
+ ///
public bool IsAttachment
{
get
@@ -1017,31 +1018,6 @@ namespace OpenSim.Region.Framework.Scenes
m_rootPart.ClearUndoState();
}
- public void DetachToInventoryPrep()
- {
- ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
- //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
- if (avatar != null)
- {
- //detachedpos = avatar.AbsolutePosition;
- avatar.RemoveAttachment(this);
- }
-
- m_rootPart.AttachedAvatar = UUID.Zero;
-
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].AttachedAvatar = UUID.Zero;
-
- m_rootPart.SetParentLocalId(0);
- //m_rootPart.SetAttachmentPoint((byte)0);
- m_rootPart.IsAttachment = false;
- AbsolutePosition = m_rootPart.AttachedPos;
- //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
- //AttachToBackup();
- //m_rootPart.ScheduleFullUpdate();
- }
-
///
///
///
--
cgit v1.1
From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:49:11 +0100
Subject: refactor: move SOG.DetachToGround() to
AttachmentsModule.DetachSceneObjectToGround() and remove redundant code
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 46 +++-------------------
1 file changed, 6 insertions(+), 40 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 00e3363..e3b8fc8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -979,43 +979,16 @@ namespace OpenSim.Region.Framework.Scenes
return m_rootPart.Shape.State;
}
- public void ClearPartAttachmentData()
- {
- SetAttachmentPoint((Byte)0);
- }
-
- public void DetachToGround()
+ public void SetAttachmentPoint(byte point)
{
- ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
- if (avatar == null)
- return;
-
- avatar.RemoveAttachment(this);
-
- Vector3 detachedpos = new Vector3(127f,127f,127f);
- if (avatar == null)
- return;
-
- detachedpos = avatar.AbsolutePosition;
- RootPart.FromItemID = UUID.Zero;
-
- AbsolutePosition = detachedpos;
- m_rootPart.AttachedAvatar = UUID.Zero;
-
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
- parts[i].AttachedAvatar = UUID.Zero;
+ parts[i].SetAttachmentPoint(point);
+ }
- m_rootPart.SetParentLocalId(0);
- SetAttachmentPoint((byte)0);
- m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
- HasGroupChanged = true;
- RootPart.Rezzed = DateTime.Now;
- RootPart.RemFlag(PrimFlags.TemporaryOnRez);
- AttachToBackup();
- m_scene.EventManager.TriggerParcelPrimCountTainted();
- m_rootPart.ScheduleFullUpdate();
- m_rootPart.ClearUndoState();
+ public void ClearPartAttachmentData()
+ {
+ SetAttachmentPoint((Byte)0);
}
///
@@ -3349,13 +3322,6 @@ namespace OpenSim.Region.Framework.Scenes
return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
}
- public void SetAttachmentPoint(byte point)
- {
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].SetAttachmentPoint(point);
- }
-
#region ISceneObject
public virtual ISceneObject CloneForNewScene()
--
cgit v1.1
From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 23:06:41 +0100
Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar
This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP
---
OpenSim/Region/Framework/Scenes/Prioritizer.cs | 7 +++----
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++++++--
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +----
3 files changed, 14 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index 4595a29..2a76755 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -116,14 +116,13 @@ namespace OpenSim.Region.Framework.Scenes
return priority;
}
-
private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity)
{
// And anything attached to this avatar gets top priority as well
if (entity is SceneObjectPart)
{
SceneObjectPart sop = (SceneObjectPart)entity;
- if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
+ if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
return 1;
}
@@ -136,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes
if (entity is SceneObjectPart)
{
SceneObjectPart sop = (SceneObjectPart)entity;
- if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
+ if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
return 1;
}
@@ -149,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes
if (entity is SceneObjectPart)
{
SceneObjectPart sop = (SceneObjectPart)entity;
- if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
+ if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
return 1;
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index e3b8fc8..fada688 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -169,6 +169,14 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// The avatar to which this scene object is attached.
+ ///
+ ///
+ /// If we're not attached to an avatar then this is UUID.Zero
+ ///
+ public UUID AttachedAvatar { get; set; }
+
+ ///
/// Is this scene object phantom?
///
///
@@ -1540,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (IsAttachment)
{
- ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
+ ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.PushForce(impulse);
@@ -1622,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (IsAttachment)
{
- ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
+ ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.MoveToTarget(target, false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a0e87d0..e510611 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -221,9 +221,6 @@ namespace OpenSim.Region.Framework.Scenes
public scriptEvents AggregateScriptEvents;
- public UUID AttachedAvatar;
-
-
public Vector3 AttachedPos;
@@ -728,7 +725,7 @@ namespace OpenSim.Region.Framework.Scenes
if (IsAttachment)
{
- ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
+ ScenePresence sp = m_parentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
if (sp != null)
return sp.AbsolutePosition;
}
--
cgit v1.1