From 98ba079e95ef0c967f138ac49c5e8f3c0961c848 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 16 Nov 2010 01:33:24 +0100
Subject: Diva needs a spanking! Serializing OldItemID breaks script state
 persistence in agent inventory.

---
 .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 7f37878..fb4ef28 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -735,7 +735,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
 
         private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
         {
-            item.OldItemID = ReadUUID(reader, "OldItemID");
+            ReadUUID(reader, "OldItemID");
+            // On deserialization, the old item id MUST BE UUID.Zero!!!!!
+            // Setting this to the saved value will BREAK script persistence!
+            // item.OldItemID = ReadUUID(reader, "OldItemID");
         }
 
         private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
-- 
cgit v1.1


From 5329e3b9b71237b298550590fa3812ff4759ec2a Mon Sep 17 00:00:00 2001
From: Melanie
Date: Tue, 16 Nov 2010 01:37:44 +0100
Subject: Can't detach an object from within the script thread because it will
 throw. Use FireAndForget for that.

---
 .../Shared/Api/Implementation/LSL_Api.cs             | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c251a49..cc3cf17 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2983,17 +2983,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
             if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
             {
-                SceneObjectGroup grp = m_host.ParentGroup;
-                UUID itemID = grp.GetFromItemID();
-
-                ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
-
                 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
                 if (attachmentsModule != null)
-                    attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient);
+                    Util.FireAndForget(DetachWrapper, m_host);
             }
         }
 
+        private void DetachWrapper(object o)
+        {
+            SceneObjectPart host = (SceneObjectPart)o;
+
+            SceneObjectGroup grp = host.ParentGroup;
+            UUID itemID = grp.GetFromItemID();
+            ScenePresence presence = World.GetScenePresence(host.OwnerID);
+
+            IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
+            if (attachmentsModule != null)
+                attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient);
+        }
+
         public void llTakeCamera(string avatar)
         {
             m_host.AddScriptLPS(1);
-- 
cgit v1.1


From 50202bab7c76782af782949922a4c6b73868ec54 Mon Sep 17 00:00:00 2001
From: Marck
Date: Mon, 15 Nov 2010 19:52:39 +0100
Subject: Add osTeleportOwner.

This provides the same functionality as osTeleportAgent but without the griefing potential. Region owners need not be concerned about the use of this function because it only allows to do what is already possible with the world map.
The intended use is with HUDs. For example, a list of (hypergrid) destinations could be made available for quick access.

Signed-off-by: Melanie <melanie@t-data.com>
---
 .../Shared/Api/Implementation/OSSL_Api.cs          | 32 ++++++++++++++++++++--
 .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs |  3 ++
 .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs   | 15 ++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8a98be7..0b787d8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -639,6 +639,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             //
             CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
 
+            TeleportAgent(agent, regionName, position, lookat);
+        }
+
+        private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+        {
             m_host.AddScriptLPS(1);
             UUID agentId = new UUID();
             if (UUID.TryParse(agent, out agentId))
@@ -651,7 +656,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                         == World.LandChannel.GetLandObject(
                             presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
                     {
-
                         // Check for hostname , attempt to make a hglink
                         // and convert the regionName to the target region
                         if (regionName.Contains(".") && regionName.Contains(":"))
@@ -674,13 +678,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             }
         }
 
-        // Teleport functions
         public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
         {
             // High because there is no security check. High griefer potential
             //
             CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
 
+            TeleportAgent(agent, regionX, regionY, position, lookat);
+        }
+
+        private void TeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+        {
             ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
 
             m_host.AddScriptLPS(1);
@@ -709,6 +717,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
         }
 
+        public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+        {
+            // Threat level None because this is what can already be done with the World Map in the viewer
+            CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
+
+            TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat);
+        }
+
+        public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+        {
+            osTeleportOwner(World.RegionInfo.RegionName, position, lookat);
+        }
+
+        public void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
+        {
+            CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
+
+            TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat);
+        }
+
         // Functions that get information from the agent itself.
         //
         // osGetAgentIP - this is used to determine the IP address of
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 630821b..c9a24f6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -86,6 +86,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
         void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
         void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
         void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+        void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+        void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
+        void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
 
         // Animation commands
         void osAvatarPlayAnimation(string avatar, string animation);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e289554..370bf1d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -227,6 +227,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             m_OSSL_Functions.osTeleportAgent(agent, position, lookat);
         }
 
+        public void osTeleportOwner(string regionName, vector position, vector lookat)
+        {
+            m_OSSL_Functions.osTeleportOwner(regionName, position, lookat);
+        }
+
+        public void osTeleportOwner(int regionX, int regionY, vector position, vector lookat)
+        {
+            m_OSSL_Functions.osTeleportOwner(regionX, regionY, position, lookat);
+        }
+
+        public void osTeleportOwner(vector position, vector lookat)
+        {
+            m_OSSL_Functions.osTeleportOwner(position, lookat);
+        }
+
         // Avatar info functions
         public string osGetAgentIP(string agent)
         {
-- 
cgit v1.1


From 56bd42b438d93469f1c120cdf5ebf5238756453e Mon Sep 17 00:00:00 2001
From: Marck
Date: Mon, 15 Nov 2010 19:50:38 +0100
Subject: Fix osTeleportAgent for hypergrid destinations.

Signed-off-by: Melanie <melanie@t-data.com>
---
 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0b787d8..e6a323e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -665,7 +665,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                             if (regions != null && regions.Count > 0)
                             {
                                 GridRegion regInfo = regions[0];
-                                regionName = regInfo.RegionName;
+                                string[] parts = regInfo.RegionName.Split(new char[] { ':' });
+                                if (parts.Length > 2)
+                                    regionName = parts[2];
+                                else
+                                    regionName = parts[0];
                             }
                         }
                         World.RequestTeleportLocation(presence.ControllingClient, regionName,
-- 
cgit v1.1