From 87eb2fa9da4c59fa897b9959cca323f63a32825a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 30 Jul 2019 17:51:20 +0100
Subject: cosmetics

---
 OpenSim/Capabilities/Handlers/GetAssets/GetAssetsHandler.cs | 2 --
 OpenSim/Region/CoreModules/World/Land/LandObject.cs         | 2 +-
 OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs  | 5 ++++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/OpenSim/Capabilities/Handlers/GetAssets/GetAssetsHandler.cs b/OpenSim/Capabilities/Handlers/GetAssets/GetAssetsHandler.cs
index 099c7b4..a5f0056 100644
--- a/OpenSim/Capabilities/Handlers/GetAssets/GetAssetsHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetAssets/GetAssetsHandler.cs
@@ -138,8 +138,6 @@ namespace OpenSim.Capabilities.Handlers
 
             if(type == AssetType.Mesh || type == AssetType.Texture)
                 responsedata["throttle"] = true;
-//            else
-//                m_log.Warn("[GETASSETS]: type: " + query);
 
             responsedata["content_type"] = asset.Metadata.ContentType;
             responsedata["bin_response_data"] = asset.Data;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 094b0f5..9111d28 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -994,7 +994,7 @@ namespace OpenSim.Region.CoreModules.World.Land
                         }
                         else
                         {
-                            // keeping previus odd average
+                            // keeping previous odd average
                             avgx = (avgx * tempArea + x) / (tempArea + 1);
                             avgy = (avgy * tempArea + y) / (tempArea + 1);
                         }
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
index 4b9f207..f60beaf 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
@@ -441,6 +441,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
                 startHeights[0], startHeights[2],
                 startHeights[1], startHeights[3],
                 pctX, pctY);
+            if (float.IsNaN(startHeight))
+                return 0;
+
             startHeight = Utils.Clamp(startHeight, 0f, 255f);
 
             float heightRange = ImageUtils.Bilinear(
@@ -448,7 +451,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
                 heightRanges[1], heightRanges[3],
                 pctX, pctY);
             heightRange = Utils.Clamp(heightRange, 0f, 255f);
-            if(heightRange == 0f)
+            if(heightRange == 0f || float.IsNaN(heightRange))
                 return 0;
 
             // Generate two frequencies of perlin noise based on our global position
-- 
cgit v1.1


From 185ed42123e6dc0c89baa9786b7db2e6cac21cce Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 30 Jul 2019 18:34:32 +0100
Subject: cosmetics

---
 OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index 8449596..ac32f75 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -294,7 +294,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
 
             if(numCoords < 3 || (!needsConvexProcessing && numFaces < 1))
             {
-                m_log.ErrorFormat("[MESH]: invalid degenerated mesh for prim {0} ignored", primName);
+                m_log.ErrorFormat("[ubODEMesh]: invalid degenerated mesh for prim {0} ignored", primName);
                 return null;
             }
 
@@ -331,7 +331,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
 
             if(mesh.numberVertices() < 3 || mesh.numberTriangles() < 1)
             {
-                m_log.ErrorFormat("[MESH]: invalid degenerated mesh for prim {0} ignored", primName);
+                m_log.ErrorFormat("[ubODEMesh]: invalid degenerated mesh for prim {0} ignored", primName);
                 return null;
             }
 
-- 
cgit v1.1


From 944a785a324c203c7ca5b8bdf770ec024b7b9a14 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 30 Jul 2019 23:26:29 +0100
Subject: now i can login on win .net4.8, but just a little drop on a large
 (broken) OSD ocean. some of this changes are actually good even on good JIT.
 Failure seems to be on same code pattern, but same points seem to vary with
 each JIT compilation, sometimes work, others don't, others always fail, etc

---
 OpenSim/Framework/AgentCircuitData.cs              | 133 ++++++------
 OpenSim/Framework/AvatarAppearance.cs              |  58 +++---
 OpenSim/Framework/AvatarAttachment.cs              |  15 +-
 OpenSim/Framework/AvatarWearable.cs                |   6 +-
 OpenSim/Framework/EntityTransferContext.cs         |  14 +-
 OpenSim/Framework/WearableCacheItem.cs             |  11 +-
 .../OptionalModules/Materials/MaterialsModule.cs   | 228 ++++++++++-----------
 .../Server/Handlers/Simulation/AgentHandlers.cs    | 124 +++++------
 .../Simulation/SimulationServiceConnector.cs       |  83 +++++---
 9 files changed, 364 insertions(+), 308 deletions(-)

diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 330a41e..dcd5cc7 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -267,16 +267,17 @@ namespace OpenSim.Framework
         /// <param name="args"></param>
         public void UnpackAgentCircuitData(OSDMap args)
         {
-            if (args["agent_id"] != null)
-                AgentID = args["agent_id"].AsUUID();
-            if (args["base_folder"] != null)
-                BaseFolder = args["base_folder"].AsUUID();
-            if (args["caps_path"] != null)
-                CapsPath = args["caps_path"].AsString();
-
-            if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
+            OSD tmpOSD;
+            if (args.TryGetValue("agent_id", out tmpOSD))
+                AgentID = tmpOSD.AsUUID();
+            if (args.TryGetValue("base_folder", out tmpOSD))
+                BaseFolder =tmpOSD.AsUUID();
+            if (args.TryGetValue("caps_path", out tmpOSD))
+                CapsPath = tmpOSD.AsString();
+
+            if ((args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray))
             {
-                OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
+                OSDArray childrenSeeds = (OSDArray)tmpOSD;
                 ChildrenCapSeeds = new Dictionary<ulong, string>();
                 foreach (OSD o in childrenSeeds)
                 {
@@ -285,53 +286,59 @@ namespace OpenSim.Framework
                         ulong handle = 0;
                         string seed = "";
                         OSDMap pair = (OSDMap)o;
-                        if (pair["handle"] != null)
-                            if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
+                        if (pair.TryGetValue("handle", out tmpOSD))
+                        {
+                            if (!UInt64.TryParse(tmpOSD.AsString(), out handle))
                                 continue;
-                        if (pair["seed"] != null)
-                            seed = pair["seed"].AsString();
+                        }
                         if (!ChildrenCapSeeds.ContainsKey(handle))
-                            ChildrenCapSeeds.Add(handle, seed);
+                        {
+                            if (pair.TryGetValue("seed", out tmpOSD))
+                            {
+                                seed = tmpOSD.AsString();
+                                ChildrenCapSeeds.Add(handle, seed);
+                            }
+                        }
                     }
                 }
             }
             else
                 ChildrenCapSeeds = new Dictionary<ulong, string>();
 
-            if (args["child"] != null)
-                child = args["child"].AsBoolean();
-            if (args["circuit_code"] != null)
-                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
-            if (args["first_name"] != null)
-                firstname = args["first_name"].AsString();
-            if (args["last_name"] != null)
-                lastname = args["last_name"].AsString();
-            if (args["inventory_folder"] != null)
-                InventoryFolder = args["inventory_folder"].AsUUID();
-            if (args["secure_session_id"] != null)
-                SecureSessionID = args["secure_session_id"].AsUUID();
-            if (args["session_id"] != null)
-                SessionID = args["session_id"].AsUUID();
-            if (args["service_session_id"] != null)
-                ServiceSessionID = args["service_session_id"].AsString();
-            if (args["client_ip"] != null)
-                IPAddress = args["client_ip"].AsString();
-            if (args["viewer"] != null)
-                Viewer = args["viewer"].AsString();
-            if (args["channel"] != null)
-                Channel = args["channel"].AsString();
-            if (args["mac"] != null)
-                Mac = args["mac"].AsString();
-            if (args["id0"] != null)
-                Id0 = args["id0"].AsString();
-            if (args["teleport_flags"] != null)
-                teleportFlags = args["teleport_flags"].AsUInteger();
-
-            if (args["start_pos"] != null)
-                Vector3.TryParse(args["start_pos"].AsString(), out startpos);
-
-            if(args["far"] != null)
-                startfar = (float)args["far"].AsReal();
+            if (args.TryGetValue("child", out tmpOSD))
+                child = tmpOSD.AsBoolean();
+            if (args.TryGetValue("circuit_code", out tmpOSD))
+                UInt32.TryParse(tmpOSD.AsString(), out circuitcode);
+            if (args.TryGetValue("first_name", out tmpOSD))
+                firstname = tmpOSD.AsString();
+            if (args.TryGetValue("last_name", out tmpOSD))
+                lastname = tmpOSD.AsString();
+            if (args.TryGetValue("inventory_folder", out tmpOSD))
+                InventoryFolder = tmpOSD.AsUUID();
+            if (args.TryGetValue("secure_session_id", out tmpOSD))
+                SecureSessionID = tmpOSD.AsUUID();
+            if (args.TryGetValue("session_id", out tmpOSD))
+                SessionID = tmpOSD.AsUUID();
+            if (args.TryGetValue("service_session_id", out tmpOSD))
+                ServiceSessionID = tmpOSD.AsString();
+            if (args.TryGetValue("client_ip", out tmpOSD))
+                IPAddress = tmpOSD.AsString();
+            if (args.TryGetValue("viewer", out tmpOSD))
+                Viewer = tmpOSD.AsString();
+            if (args.TryGetValue("channel", out tmpOSD))
+                Channel = tmpOSD.AsString();
+            if (args.TryGetValue("mac", out tmpOSD))
+                Mac = tmpOSD.AsString();
+            if (args.TryGetValue("id0", out tmpOSD))
+                Id0 = tmpOSD.AsString();
+            if (args.TryGetValue("teleport_flags", out tmpOSD))
+                teleportFlags = tmpOSD.AsUInteger();
+
+            if (args.TryGetValue("start_pos", out tmpOSD))
+                Vector3.TryParse(tmpOSD.AsString(), out startpos);
+
+            if(args.TryGetValue("far", out tmpOSD))
+                startfar = (float)tmpOSD.AsReal();
 
             //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);
 
@@ -342,12 +349,12 @@ namespace OpenSim.Framework
 
                 // Eventually this code should be deprecated, use full appearance
                 // packing in packed_appearance
-                if (args["appearance_serial"] != null)
-                    Appearance.Serial = args["appearance_serial"].AsInteger();
+                if (args.TryGetValue("appearance_serial", out tmpOSD))
+                    Appearance.Serial = tmpOSD.AsInteger();
 
-                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
+                if (args.TryGetValue("packed_appearance", out tmpOSD) && (tmpOSD is OSDMap))
                 {
-                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
+                    Appearance.Unpack((OSDMap)tmpOSD);
 //                    m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
                 }
                 else
@@ -362,31 +369,31 @@ namespace OpenSim.Framework
 
             ServiceURLs = new Dictionary<string, object>();
             // Try parse the new way, OSDMap
-            if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
+            if (args.TryGetValue("serviceurls", out tmpOSD) && (tmpOSD is OSDMap))
             {
-                OSDMap urls = (OSDMap)(args["serviceurls"]);
+                OSDMap urls = (OSDMap)tmpOSD;
                 foreach (KeyValuePair<String, OSD> kvp in urls)
                 {
-                    ServiceURLs[kvp.Key] = kvp.Value.AsString();
+                    tmpOSD = kvp.Value;
+                    ServiceURLs[kvp.Key] = tmpOSD.AsString();
                     //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
-
                 }
             }
             // else try the old way, OSDArray
             // OBSOLETE -- soon to be deleted
-            else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
+            else if (args.TryGetValue("service_urls", out tmpOSD) && (tmpOSD is OSDArray))
             {
-                OSDArray urls = (OSDArray)(args["service_urls"]);
-                for (int i = 0; i < urls.Count / 2; i++)
+                OSDArray urls = (OSDArray)tmpOSD;
+                OSD tmpOSDb;
+                for (int i = 0; i < urls.Count - 1; i += 2)
                 {
-                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
+                    tmpOSD = urls[i];
+                    tmpOSDb = urls[i + 1];
+                    ServiceURLs[tmpOSD.AsString()] = tmpOSDb.AsString();
                     //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());
-
                 }
             }
         }
 
     }
-
-
 }
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 77a7621..f1713a6 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -796,25 +796,33 @@ namespace OpenSim.Framework
         /// </summary>
         public void Unpack(OSDMap data)
         {
-            if ((data != null) && (data["serial"] != null))
-                m_serial = data["serial"].AsInteger();
-            if ((data != null) && (data["height"] != null))
+            SetDefaultWearables();
+            SetDefaultTexture();
+            SetDefaultParams();
+            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
+
+            if(data == null)
+            {
+                m_log.Warn("[AVATAR APPEARANCE]: data to unpack is null");
+                return;
+            }
+
+            OSD tmpOSD;
+            if (data.TryGetValue("serial", out tmpOSD))
+                m_serial = tmpOSD.AsInteger();
+            if (data.TryGetValue("height", out tmpOSD))
 //                m_avatarHeight = (float)data["height"].AsReal();
-                SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));
+                SetSize(new Vector3(0.45f,0.6f, (float)tmpOSD.AsReal()));
 
             try
             {
                 // Wearables
-                SetDefaultWearables();
-                if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
+                if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray))
                 {
-                    OSDArray wears = (OSDArray)(data["wearables"]);
-
-                    int count = wears.Count;
-
-                    m_wearables = new AvatarWearable[count];
+                    OSDArray wears = (OSDArray)tmpOSD;
+                    m_wearables = new AvatarWearable[wears.Count];
 
-                    for (int i = 0; i < count; i++)
+                    for (int i = 0; i < wears.Count; i++)
                         m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
                 }
                 else
@@ -823,15 +831,15 @@ namespace OpenSim.Framework
                 }
 
                 // Avatar Textures
-                SetDefaultTexture();
-                if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
+                if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
                 {
-                    OSDArray textures = (OSDArray)(data["textures"]);
+                    OSDArray textures = (OSDArray)tmpOSD;
                     for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
                     {
                         UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
-                        if (textures[i] != null)
-                            textureID = textures[i].AsUUID();
+                        tmpOSD = textures[i];
+                        if (tmpOSD != null)
+                            textureID = tmpOSD.AsUUID();
                         m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
                     }
                 }
@@ -840,18 +848,17 @@ namespace OpenSim.Framework
                     m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                 }
 
-                if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array)
+                if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray))
                 {
-                    OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]);
+                    OSDArray bakedOSDArray = (OSDArray)tmpOSD;
                     m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
                 }
 
                 // Visual Parameters
-                SetDefaultParams();
-                if ((data != null) && (data["visualparams"] != null))
+                if (data.TryGetValue("visualparams", out tmpOSD))
                 {
-                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
-                        m_visualparams = data["visualparams"].AsBinary();
+                    if (tmpOSD is OSDBinary || tmpOSD is OSDArray)
+                        m_visualparams = tmpOSD.AsBinary();
                 }
                 else
                 {
@@ -859,10 +866,9 @@ namespace OpenSim.Framework
                 }
 
                 // Attachments
-                m_attachments = new Dictionary<int, List<AvatarAttachment>>();
-                if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
+                if (data.TryGetValue("attachments", out tmpOSD) && tmpOSD is OSDArray)
                 {
-                    OSDArray attachs = (OSDArray)(data["attachments"]);
+                    OSDArray attachs = (OSDArray)tmpOSD;
                     for (int i = 0; i < attachs.Count; i++)
                     {
                         AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
diff --git a/OpenSim/Framework/AvatarAttachment.cs b/OpenSim/Framework/AvatarAttachment.cs
index 07dd385..d8a0ffc 100644
--- a/OpenSim/Framework/AvatarAttachment.cs
+++ b/OpenSim/Framework/AvatarAttachment.cs
@@ -68,11 +68,18 @@ namespace OpenSim.Framework
 
         public void Unpack(OSDMap args)
         {
-            if (args["point"] != null)
-                AttachPoint = args["point"].AsInteger();
+            OSD tmpOSD;
+            if (args.TryGetValue("point", out tmpOSD))
+                AttachPoint = tmpOSD.AsInteger();
+            if (args.TryGetValue("item", out tmpOSD))
+                ItemID = tmpOSD.AsUUID();
+            else
+                ItemID = UUID.Zero;
 
-            ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
-            AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
+            if (args.TryGetValue("asset", out tmpOSD))
+                AssetID = tmpOSD.AsUUID();
+            else
+                AssetID = UUID.Zero;
         }
     }
 }
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index fddd0f0..abf5759 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -132,10 +132,12 @@ namespace OpenSim.Framework
         public void Unpack(OSDArray args)
         {
             Clear();
-
+            OSD tmpOSDA, tmpOSDB;
             foreach (OSDMap weardata in args)
             {
-                Add(weardata["item"].AsUUID(), weardata["asset"].AsUUID());
+                tmpOSDA = weardata["item"];
+                tmpOSDB = weardata["asset"];
+                Add(tmpOSDA.AsUUID(), tmpOSDB.AsUUID());
             }
         }
 
diff --git a/OpenSim/Framework/EntityTransferContext.cs b/OpenSim/Framework/EntityTransferContext.cs
index 860414e..257c6d1 100644
--- a/OpenSim/Framework/EntityTransferContext.cs
+++ b/OpenSim/Framework/EntityTransferContext.cs
@@ -58,13 +58,13 @@ namespace OpenSim.Framework
         public void Unpack(OSD data)
         {
             OSDMap map = (OSDMap)data;
-
-            if (map.ContainsKey("InboundVersion"))
-                InboundVersion = (float)map["InboundVersion"].AsReal();
-            if (map.ContainsKey("OutboundVersion"))
-                OutboundVersion = (float)map["OutboundVersion"].AsReal();
-            if (map.ContainsKey("WearablesCount"))
-                WearablesCount = map["WearablesCount"].AsInteger();
+            OSD tmpOSD;
+            if (map.TryGetValue("InboundVersion", out tmpOSD))
+                InboundVersion = (float)tmpOSD.AsReal();
+            if (map.TryGetValue("OutboundVersion", out tmpOSD))
+                OutboundVersion = (float)tmpOSD.AsReal();
+            if (map.TryGetValue("WearablesCount", out tmpOSD))
+                WearablesCount = tmpOSD.AsInteger();
         }
     }
 }
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 427e149..84b9ee9 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -161,17 +161,20 @@ namespace OpenSim.Framework
         public static WearableCacheItem[] BakedFromOSD(OSD pInput)
         {
             WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
-
+            OSD tmpOSD;
             if (pInput.Type == OSDType.Array)
             {
                 OSDArray itemarray = (OSDArray)pInput;
                 foreach (OSDMap item in itemarray)
                 {
-                    int idx = (int)item["textureindex"].AsUInteger();
+                    tmpOSD = item["textureindex"];
+                    int idx = tmpOSD.AsInteger();
                     if (idx < 0 || idx > pcache.Length)
                         continue;
-                    pcache[idx].CacheId = item["cacheid"].AsUUID();
-                    pcache[idx].TextureID = item["textureid"].AsUUID();
+                    tmpOSD = item["cacheid"];
+                    pcache[idx].CacheId = tmpOSD.AsUUID();
+                    tmpOSD = item["textureid"];
+                    pcache[idx].TextureID = tmpOSD.AsUUID();
 /*
                     if (item.ContainsKey("assetdata"))
                     {
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index 2aea7f9..4a92120 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -267,6 +267,7 @@ namespace OpenSim.Region.OptionalModules.Materials
             if (matsArr == null)
                 return partchanged;
             
+            OSD tmpOSD;
             foreach (OSD elemOsd in matsArr)
             {
                 if (elemOsd != null && elemOsd is OSDMap)
@@ -278,7 +279,8 @@ namespace OpenSim.Region.OptionalModules.Materials
                         {
                             lock (materialslock)
                             {
-                                UUID id = matMap["ID"].AsUUID();
+                                tmpOSD = matMap["ID"];
+                                UUID id = tmpOSD.AsUUID();
                                 if(m_Materials.ContainsKey(id))
                                     continue;
 
@@ -459,12 +461,13 @@ namespace OpenSim.Region.OptionalModules.Materials
             OSDMap resp = new OSDMap();
 
             OSDArray respArr = new OSDArray();
+            OSD tmpOSD;
 
-            if (req.ContainsKey("Zipped"))
+            if (req.TryGetValue("Zipped", out tmpOSD))
             {
                 OSD osd = null;
 
-                byte[] inBytes = req["Zipped"].AsBinary();
+                byte[] inBytes = tmpOSD.AsBinary();
 
                 try
                 {
@@ -531,12 +534,13 @@ namespace OpenSim.Region.OptionalModules.Materials
 
             OSDArray respArr = new OSDArray();
 
+            OSD tmpOSD;
             HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>();
-            if (req.ContainsKey("Zipped"))
+            if (req.TryGetValue("Zipped", out tmpOSD))
             {
                 OSD osd = null;
 
-                byte[] inBytes = req["Zipped"].AsBinary();
+                byte[] inBytes = tmpOSD.AsBinary();
 
                 try
                 {
@@ -546,145 +550,141 @@ namespace OpenSim.Region.OptionalModules.Materials
                     {
                         materialsFromViewer = osd as OSDMap;
 
-                        if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
+                        if (materialsFromViewer.TryGetValue("FullMaterialsPerFace", out tmpOSD) && (tmpOSD is OSDArray))
                         {
-                            OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
-                            if (matsOsd is OSDArray)
+                            OSDArray matsArr = tmpOSD as OSDArray;
+                            try
                             {
-                                OSDArray matsArr = matsOsd as OSDArray;
-
-                                try
+                                foreach (OSDMap matsMap in matsArr)
                                 {
-                                    foreach (OSDMap matsMap in matsArr)
+                                    uint primLocalID = 0;
+                                    try
                                     {
-                                        uint primLocalID = 0;
-                                        try
-                                        {
-                                            primLocalID = matsMap["ID"].AsUInteger();
-                                        }
-                                        catch (Exception e)
-                                        {
-                                            m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
-                                            continue;
-                                        }
+                                        tmpOSD = matsMap["ID"];
+                                        primLocalID = tmpOSD.AsUInteger();
+                                    }
+                                    catch (Exception e)
+                                    {
+                                        m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
+                                        continue;
+                                    }
 
-                                        SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
-                                        if (sop == null)
-                                        {
-                                            m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
-                                            continue;
-                                        }
+                                    SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
+                                    if (sop == null)
+                                    {
+                                        m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
+                                        continue;
+                                    }
 
-                                        if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
-                                        {
-                                            m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
-                                            continue;
-                                        }
+                                    if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
+                                    {
+                                        m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
+                                        continue;
+                                    }
 
-                                        OSDMap mat = null;
-                                        try
-                                        {
-                                            mat = matsMap["Material"] as OSDMap;
-                                        }
-                                        catch (Exception e)
-                                        {
-                                            m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
-                                            continue;
-                                        }
+                                    OSDMap mat = null;
+                                    try
+                                    {
+                                        mat = matsMap["Material"] as OSDMap;
+                                    }
+                                    catch (Exception e)
+                                    {
+                                        m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
+                                        continue;
+                                    }
 
-                                        Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
-                                        if (te == null)
-                                        {
-                                            m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
-                                            continue;
-                                        }
+                                    Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
+                                    if (te == null)
+                                    {
+                                        m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
+                                        continue;
+                                    }
 
-                                        int face = -1;
-                                        UUID oldid = UUID.Zero;
-                                        Primitive.TextureEntryFace faceEntry = null;
-                                        if (matsMap.ContainsKey("Face"))
-                                        {
-                                            face = matsMap["Face"].AsInteger();
-                                            faceEntry = te.CreateFace((uint)face);
-                                        }
-                                        else
-                                            faceEntry = te.DefaultTexture;
+                                    int face = -1;
+                                    UUID oldid = UUID.Zero;
+                                    Primitive.TextureEntryFace faceEntry = null;
+                                    if (matsMap.TryGetValue("Face", out tmpOSD))
+                                    {
+                                        face = tmpOSD.AsInteger();
+                                        faceEntry = te.CreateFace((uint)face);
+                                    }
+                                    else
+                                        faceEntry = te.DefaultTexture;
 
-                                        if (faceEntry == null)
-                                            continue;
+                                    if (faceEntry == null)
+                                        continue;
 
-                                        UUID id;
-                                        FaceMaterial newFaceMat = null;
-                                        if (mat == null)
-                                        {
-                                            // This happens then the user removes a material from a prim
+                                    UUID id;
+                                    FaceMaterial newFaceMat = null;
+                                    if (mat == null)
+                                    {
+                                        // This happens then the user removes a material from a prim
+                                        id = UUID.Zero;
+                                    }
+                                    else
+                                    {
+                                        newFaceMat = new FaceMaterial(mat);
+                                        if(newFaceMat.DiffuseAlphaMode == 1 
+                                                && newFaceMat.NormalMapID == UUID.Zero 
+                                                && newFaceMat.SpecularMapID == UUID.Zero
+                                                )
                                             id = UUID.Zero;
-                                        }
                                         else
                                         {
-                                            newFaceMat = new FaceMaterial(mat);
-                                            if(newFaceMat.DiffuseAlphaMode == 1 
-                                                    && newFaceMat.NormalMapID == UUID.Zero 
-                                                    && newFaceMat.SpecularMapID == UUID.Zero
-                                                    )
-                                                id = UUID.Zero;
-                                            else
-                                            {
-                                                newFaceMat.genID();
-                                                id = newFaceMat.ID;
-                                            }
+                                            newFaceMat.genID();
+                                            id = newFaceMat.ID;
                                         }
+                                    }
 
-                                        oldid = faceEntry.MaterialID;
+                                    oldid = faceEntry.MaterialID;
 
-                                        if(oldid == id)
-                                            continue;
+                                    if(oldid == id)
+                                        continue;
 
-                                        if (faceEntry != null)
-                                        {
-                                            faceEntry.MaterialID = id;
-                                            //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
-                                            // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
-                                            sop.Shape.TextureEntry = te.GetBytes(9);
-                                        }
+                                    if (faceEntry != null)
+                                    {
+                                        faceEntry.MaterialID = id;
+                                        //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
+                                        // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
+                                        sop.Shape.TextureEntry = te.GetBytes(9);
+                                    }
 
-                                        if(oldid != UUID.Zero)
-                                            RemoveMaterial(oldid);
+                                    if(oldid != UUID.Zero)
+                                        RemoveMaterial(oldid);
 
-                                        lock(materialslock)
+                                    lock(materialslock)
+                                    {
+                                        if(id != UUID.Zero)
                                         {
-                                            if(id != UUID.Zero)
+                                            if (m_Materials.ContainsKey(id))
+                                                m_MaterialsRefCount[id]++;
+                                            else
                                             {
-                                                if (m_Materials.ContainsKey(id))
-                                                    m_MaterialsRefCount[id]++;
-                                                else
-                                                {
-                                                    m_Materials[id] = newFaceMat;
-                                                    m_MaterialsRefCount[id] = 1;
-                                                    m_changed[newFaceMat] = Util.GetTimeStamp();
-                                                }
+                                                m_Materials[id] = newFaceMat;
+                                                m_MaterialsRefCount[id] = 1;
+                                                m_changed[newFaceMat] = Util.GetTimeStamp();
                                             }
                                         }
-
-                                        if(!parts.Contains(sop))
-                                            parts.Add(sop);
                                     }
 
-                                    foreach(SceneObjectPart sop in parts)
-                                    {
-                                        if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
-                                        {
-                                            sop.TriggerScriptChangedEvent(Changed.TEXTURE);
-                                            sop.ScheduleFullUpdate();
-                                            sop.ParentGroup.HasGroupChanged = true;
-                                        }
-                                    }
+                                    if(!parts.Contains(sop))
+                                        parts.Add(sop);
                                 }
-                                catch (Exception e)
+
+                                foreach(SceneObjectPart sop in parts)
                                 {
-                                    m_log.Warn("[Materials]: exception processing received material ", e);
+                                    if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
+                                    {
+                                        sop.TriggerScriptChangedEvent(Changed.TEXTURE);
+                                        sop.ScheduleFullUpdate();
+                                        sop.ParentGroup.HasGroupChanged = true;
+                                    }
                                 }
                             }
+                            catch (Exception e)
+                            {
+                                m_log.Warn("[Materials]: exception processing received material ", e);
+                            }
                         }
                     }
                 }
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 1c1930a..788bd3d 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -115,15 +115,10 @@ namespace OpenSim.Server.Handlers.Simulation
 
                 return responsedata;
             }
-
         }
 
         protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID)
         {
-            Culture.SetCurrentCulture();
-
-            EntityTransferContext ctx = new EntityTransferContext();
-
             if (m_SimulationService == null)
             {
                 m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless.");
@@ -134,33 +129,37 @@ namespace OpenSim.Server.Handlers.Simulation
                 return;
             }
 
+            Culture.SetCurrentCulture();
+
             // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]);
             OSDMap args = Utils.GetOSDMap((string)request["body"]);
 
             bool viaTeleport = true;
-            if (args.ContainsKey("viaTeleport"))
-                viaTeleport = args["viaTeleport"].AsBoolean();
+            OSD tmpOSD;
+            if (args.TryGetValue("viaTeleport",out tmpOSD))
+                viaTeleport = tmpOSD.AsBoolean();
 
             Vector3 position = Vector3.Zero;
-            if (args.ContainsKey("position"))
-                position = Vector3.Parse(args["position"].AsString());
+            if (args.TryGetValue("position", out tmpOSD))
+                position = Vector3.Parse(tmpOSD.AsString());
 
             string agentHomeURI = null;
-            if (args.ContainsKey("agent_home_uri"))
-                agentHomeURI = args["agent_home_uri"].AsString();
+            if (args.TryGetValue("agent_home_uri", out tmpOSD))
+                agentHomeURI = tmpOSD.AsString();
 
             // Decode the legacy (string) version and extract the number
             float theirVersion = 0f;
-            if (args.ContainsKey("my_version"))
+            if (args.TryGetValue("my_version", out tmpOSD))
             {
-                string theirVersionStr = args["my_version"].AsString();
+                string theirVersionStr = tmpOSD.AsString();
                 string[] parts = theirVersionStr.Split(new char[] {'/'});
                 if (parts.Length > 1)
                     theirVersion = float.Parse(parts[1], Culture.FormatProvider);
             }
 
-            if (args.ContainsKey("context"))
-                ctx.Unpack((OSDMap)args["context"]);
+            EntityTransferContext ctx = new EntityTransferContext();
+            if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
+                ctx.Unpack((OSDMap)tmpOSD);
 
             // Decode the new versioning data
             float minVersionRequired = 0f;
@@ -168,15 +167,15 @@ namespace OpenSim.Server.Handlers.Simulation
             float minVersionProvided = 0f;
             float maxVersionProvided = 0f;
 
-            if (args.ContainsKey("simulation_service_supported_min"))
-                minVersionProvided = (float)args["simulation_service_supported_min"].AsReal();
-            if (args.ContainsKey("simulation_service_supported_max"))
-                maxVersionProvided = (float)args["simulation_service_supported_max"].AsReal();
+            if (args.TryGetValue("simulation_service_supported_min", out tmpOSD))
+                minVersionProvided = (float)tmpOSD.AsReal();
+            if (args.TryGetValue("simulation_service_supported_max", out tmpOSD))
+                maxVersionProvided = (float)tmpOSD.AsReal();
 
-            if (args.ContainsKey("simulation_service_accepted_min"))
-                minVersionRequired = (float)args["simulation_service_accepted_min"].AsReal();
-            if (args.ContainsKey("simulation_service_accepted_max"))
-                maxVersionRequired = (float)args["simulation_service_accepted_max"].AsReal();
+            if (args.TryGetValue("simulation_service_accepted_min", out tmpOSD))
+                minVersionRequired = (float)tmpOSD.AsReal();
+            if (args.TryGetValue("simulation_service_accepted_max", out tmpOSD))
+                maxVersionRequired = (float)tmpOSD.AsReal();
 
             responsedata["int_response_code"] = HttpStatusCode.OK;
             OSDMap resp = new OSDMap(3);
@@ -239,9 +238,9 @@ namespace OpenSim.Server.Handlers.Simulation
 
             List<UUID> features = new List<UUID>();
 
-            if (args.ContainsKey("features"))
+            if (args.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray)
             {
-                OSDArray array = (OSDArray)args["features"];
+                OSDArray array = (OSDArray)tmpOSD;
 
                 foreach (OSD o in array)
                     features.Add(new UUID(o.AsString()));
@@ -414,8 +413,6 @@ namespace OpenSim.Server.Handlers.Simulation
 
         protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
         {
-            EntityTransferContext ctx = new EntityTransferContext();
-
             OSDMap args = Utils.GetOSDMap((string)request["body"]);
             if (args == null)
             {
@@ -424,8 +421,10 @@ namespace OpenSim.Server.Handlers.Simulation
                 return;
             }
 
-            if (args.ContainsKey("context"))
-                ctx.Unpack((OSDMap)args["context"]);
+            OSD tmpOSD;
+            EntityTransferContext ctx = new EntityTransferContext();
+            if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
+                ctx.Unpack((OSDMap)tmpOSD);
 
             AgentDestinationData data = CreateAgentDestinationData();
             UnpackData(args, data, request);
@@ -453,16 +452,19 @@ namespace OpenSim.Server.Handlers.Simulation
 
             GridRegion source = null;
 
-            if (args.ContainsKey("source_uuid"))
+            if (args.TryGetValue("source_uuid", out tmpOSD))
             {
                 source = new GridRegion();
-                source.RegionLocX = Int32.Parse(args["source_x"].AsString());
-                source.RegionLocY = Int32.Parse(args["source_y"].AsString());
-                source.RegionName = args["source_name"].AsString();
-                source.RegionID = UUID.Parse(args["source_uuid"].AsString());
-
-                if (args.ContainsKey("source_server_uri"))
-                    source.RawServerURI = args["source_server_uri"].AsString();
+                source.RegionID = UUID.Parse(tmpOSD.AsString());
+                tmpOSD = args["source_x"];
+                source.RegionLocX = Int32.Parse(tmpOSD.AsString());
+                tmpOSD = args["source_y"];
+                source.RegionLocY = Int32.Parse(tmpOSD.AsString());
+                tmpOSD = args["source_name"];
+                source.RegionName = tmpOSD.AsString();
+
+                if (args.TryGetValue("source_server_uri", out tmpOSD))
+                    source.RawServerURI = tmpOSD.AsString();
                 else
                     source.RawServerURI = null;
             }
@@ -493,21 +495,26 @@ namespace OpenSim.Server.Handlers.Simulation
 
         protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
         {
+            OSD tmpOSD;
             // retrieve the input arguments
-            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
-                Int32.TryParse(args["destination_x"].AsString(), out data.x);
+            if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
+                Int32.TryParse(tmpOSD.AsString(), out data.x);
             else
                 m_log.WarnFormat("  -- request didn't have destination_x");
-            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
-                Int32.TryParse(args["destination_y"].AsString(), out data.y);
+
+            if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
+                Int32.TryParse(tmpOSD.AsString(), out data.y);
             else
                 m_log.WarnFormat("  -- request didn't have destination_y");
-            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
-                UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid);
-            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
-                data.name = args["destination_name"].ToString();
-            if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
-                data.flags = args["teleport_flags"].AsUInteger();
+
+            if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
+                UUID.TryParse(tmpOSD.AsString(), out data.uuid);
+
+            if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
+                data.name = tmpOSD.ToString();
+
+            if (args.TryGetValue("teleport_flags", out tmpOSD) && tmpOSD != null)
+                data.flags = tmpOSD.AsUInteger();
         }
 
         protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
@@ -674,7 +681,6 @@ namespace OpenSim.Server.Handlers.Simulation
         protected void DoAgentPut(Hashtable request, Hashtable responsedata)
         {
             // TODO: Encode the ENtityTransferContext
-            EntityTransferContext ctx = new EntityTransferContext();
 
             OSDMap args = Utils.GetOSDMap((string)request["body"]);
             if (args == null)
@@ -685,19 +691,21 @@ namespace OpenSim.Server.Handlers.Simulation
             }
 
             // retrieve the input arguments
+            OSD tmpOSD;
+            EntityTransferContext ctx = new EntityTransferContext();
             int x = 0, y = 0;
             UUID uuid = UUID.Zero;
             string regionname = string.Empty;
-            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
-                Int32.TryParse(args["destination_x"].AsString(), out x);
-            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
-                Int32.TryParse(args["destination_y"].AsString(), out y);
-            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
-                UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
-            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
-                regionname = args["destination_name"].ToString();
-            if (args.ContainsKey("context"))
-                ctx.Unpack((OSDMap)args["context"]);
+            if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
+                Int32.TryParse(tmpOSD.AsString(), out x);
+            if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
+                Int32.TryParse(tmpOSD.AsString(), out y);
+            if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
+                UUID.TryParse(tmpOSD.AsString(), out uuid);
+            if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
+                regionname = tmpOSD.ToString();
+            if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
+                ctx.Unpack((OSDMap)tmpOSD);
 
             GridRegion destination = new GridRegion();
             destination.RegionID = uuid;
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index e15ac8c..b7dbb79 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Services.Connectors.Simulation
             m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
 
             string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
-
+            OSD tmpOSD;
             try
             {
                 OSDMap args = aCircuit.PackAgentCircuitData(ctx);
@@ -120,27 +120,37 @@ namespace OpenSim.Services.Connectors.Simulation
                 PackData(args, source, aCircuit, destination, flags);
 
                 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
-                bool success = result["success"].AsBoolean();
-                if (success && result.ContainsKey("_Result"))
+                tmpOSD = result["success"];
+                bool success = tmpOSD.AsBoolean();
+                if (success && result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                 {
-                    OSDMap data = (OSDMap)result["_Result"];
+                    OSDMap data = (OSDMap)tmpOSD;
+
+                    tmpOSD = data["reason"];
+                    reason = tmpOSD.AsString();
 
-                    reason = data["reason"].AsString();
-                    success = data["success"].AsBoolean();
+                    tmpOSD = data["success"];
+                    success = tmpOSD.AsBoolean();
                     return success;
                 }
 
                 // Try the old version, uncompressed
                 result = WebUtil.PostToService(uri, args, 30000, false);
 
-                if (result["Success"].AsBoolean())
+                tmpOSD = result["success"];
+                success = tmpOSD.AsBoolean();
+                if (success)
                 {
-                    if (result.ContainsKey("_Result"))
+                    if (result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                     {
-                        OSDMap data = (OSDMap)result["_Result"];
+                        OSDMap data = (OSDMap)tmpOSD;
+
+                        tmpOSD = data["reason"];
+                        reason = tmpOSD.AsString();
+
+                        tmpOSD = data["success"];
+                        success = tmpOSD.AsBoolean();
 
-                        reason = data["reason"].AsString();
-                        success = data["success"].AsBoolean();
                         m_log.WarnFormat(
                             "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
                         return success;
@@ -312,34 +322,47 @@ namespace OpenSim.Services.Connectors.Simulation
             if (agentHomeURI != null)
                 request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
 
+            OSD tmpOSD;
             try
             {
                 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true);
-                bool success = result["success"].AsBoolean();
-                if (result.ContainsKey("_Result"))
+
+                tmpOSD = result["success"];
+                bool success = tmpOSD.AsBoolean();
+
+                bool has_Result = false;
+                if (result.TryGetValue("_Result", out tmpOSD))
                 {
-                    OSDMap data = (OSDMap)result["_Result"];
+                    has_Result = true;
+                    OSDMap data = (OSDMap)tmpOSD;
 
                     // FIXME: If there is a _Result map then it's the success key here that indicates the true success
                     // or failure, not the sibling result node.
-                    success = data["success"].AsBoolean();
+                    //nte4.8 crap
+                    tmpOSD = data["success"];
+                    success = tmpOSD.AsBoolean();
 
-                    reason = data["reason"].AsString();
+                    tmpOSD = data["reason"];
+                    reason = tmpOSD.AsString();
                     // We will need to plumb this and start sing the outbound version as well
                     // TODO: lay the pipe for version plumbing
-                    if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null)
+                    if (data.TryGetValue("negotiated_inbound_version", out tmpOSD) && tmpOSD != null)
                     {
-                        ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal();
-                        ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal();
+                        ctx.InboundVersion = (float)tmpOSD.AsReal();
+                        tmpOSD = data["negotiated_outbound_version"];
+                        ctx.OutboundVersion = (float)tmpOSD.AsReal();
                     }
-                    else if (data["version"] != null && data["version"].AsString() != string.Empty)
+                    else if (data.TryGetValue("version", out tmpOSD) && tmpOSD != null)
                     {
-                        string versionString = data["version"].AsString();
-                        String[] parts = versionString.Split(new char[] {'/'});
-                        if (parts.Length > 1)
+                        string versionString = tmpOSD.AsString();
+                        if(versionString != string.Empty)
                         {
-                            ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider);
-                            ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider);
+                            String[] parts = versionString.Split(new char[] {'/'});
+                            if (parts.Length > 1)
+                            {
+                                ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider);
+                                ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider);
+                            }
                         }
                     }
 
@@ -352,11 +375,11 @@ namespace OpenSim.Services.Connectors.Simulation
                 {
                     // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
                     // actual failure message
-                    if (!result.ContainsKey("_Result"))
+                    if (!has_Result)
                     {
-                        if (result.ContainsKey("Message"))
+                        if (result.TryGetValue("Message", out tmpOSD))
                         {
-                            string message = result["Message"].AsString();
+                            string message = tmpOSD.AsString();
                             if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region
                             {
                                 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
@@ -376,9 +399,9 @@ namespace OpenSim.Services.Connectors.Simulation
 
                 featuresAvailable.Clear();
 
-                if (result.ContainsKey("features"))
+                if (result.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray)
                 {
-                    OSDArray array = (OSDArray)result["features"];
+                    OSDArray array = (OSDArray)tmpOSD;
 
                     foreach (OSD o in array)
                         featuresAvailable.Add(new UUID(o.AsString()));
-- 
cgit v1.1


From cd641e8629dc0f53c1ee2034b7c43b11a988781a Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 31 Jul 2019 00:37:27 +0100
Subject: fix configuration loader test

---
 OpenSim/Tests/ConfigurationLoaderTest.cs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs
index a409a13..2a67b84 100644
--- a/OpenSim/Tests/ConfigurationLoaderTest.cs
+++ b/OpenSim/Tests/ConfigurationLoaderTest.cs
@@ -114,6 +114,7 @@ namespace OpenSim.Tests
             IConfigSource argvSource = new IniConfigSource();
             EnvConfigSource envConfigSource = new EnvConfigSource();
             argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
+            argvSource.AddConfig("Network");
             ConfigSettings configSettings;
             NetworkServersInfo networkInfo;
 
-- 
cgit v1.1


From 8de67dad760a3c7f23a0a96f868f63f0d4efbc0e Mon Sep 17 00:00:00 2001
From: TBG Renfold
Date: Fri, 26 Jul 2019 19:02:23 +0100
Subject: Mantis #8481 part one.

Add llGetParcelDetails(vector pos, [PARCEL_DETAILS_LANDDWELL])

Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
---
 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 +++
 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs  | 1 +
 2 files changed, 4 insertions(+)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5d72858..e59bfe8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -14343,6 +14343,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     case "5":
                         ret.Add(new LSL_Key(land.GlobalID.ToString()));
                         break;
+                    case "20":
+                        ret.Add(new LSL_Integer(land.Dwell));
+                        break;
                     default:
                         ret.Add(new LSL_Integer(0));
                         break;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index fa0e25c..371460a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -721,6 +721,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
         // constants for llGetParcelDetails
         public const int PARCEL_DETAILS_NAME = 0;
         public const int PARCEL_DETAILS_DESC = 1;
+        public const int PARCEL_DETAILS_DWELL = 20;
         public const int PARCEL_DETAILS_OWNER = 2;
         public const int PARCEL_DETAILS_GROUP = 3;
         public const int PARCEL_DETAILS_AREA = 4;
-- 
cgit v1.1


From 0163af970f7c0bf792ee12d2267c6122ca35fb98 Mon Sep 17 00:00:00 2001
From: TBG Renfold
Date: Fri, 26 Jul 2019 19:08:40 +0100
Subject: Mantis #8481 part two.

Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
---
 .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs  | 10 ++++++++++
 OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs  |  1 +
 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs    |  5 +++++
 3 files changed, 16 insertions(+)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7d3c832..ab3a768 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1600,6 +1600,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return 0.0f;
         }
 
+        public int osGetParcelDwell(LSL_Vector pos)
+        {
+            LandData land = World.GetLandData(pos);
+            if (land != null)
+            {
+                return (int)land.Dwell;
+            }
+            return 0;
+        }
+
         // Routines for creating and managing parcels programmatically
         public void osParcelJoin(LSL_Vector pos1, LSL_Vector pos2)
         {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 194df36..5d964b8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -260,6 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
         LSL_Float osGetWindParam(string plugin, string param);
 
         // Parcel commands
+        int osGetParcelDwell(vector pos);
         void osParcelJoin(vector pos1, vector pos2);
         void osParcelSubdivide(vector pos1, vector pos2);
         void osSetParcelDetails(vector pos, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 88ea9d5..abdf0df 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -116,6 +116,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_OSSL_Functions.osGetWindParam(plugin, param);
         }
 
+        public int osGetParcelDwell(vector pos)
+        {
+            return m_OSSL_Functions.osGetParcelDwell(pos);
+        }
+
         public void osParcelJoin(vector pos1, vector pos2)
         {
             m_OSSL_Functions.osParcelJoin(pos1,pos2);
-- 
cgit v1.1


From b5b518dc0d1996c3ed0effe7c39b7daff2d1441b Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 31 Jul 2019 13:38:49 +0100
Subject: change value of PARCEL_DETAILS_DWELL to a higher value to give more
 room for standard values, change return types, update script syntaxe

---
 .../Shared/Api/Implementation/LSL_Api.cs           |  2 +-
 .../Shared/Api/Implementation/OSSL_Api.cs          |  2 +-
 .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs |  2 +-
 .../Shared/Api/Runtime/LSL_Constants.cs            |  5 +++--
 .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs   |  2 +-
 bin/ScriptSyntax.xml                               | 25 +++++++++++++++++-----
 6 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e59bfe8..980b2a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -14343,7 +14343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     case "5":
                         ret.Add(new LSL_Key(land.GlobalID.ToString()));
                         break;
-                    case "20":
+                    case "64":
                         ret.Add(new LSL_Integer(land.Dwell));
                         break;
                     default:
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ab3a768..62da221 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1600,7 +1600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return 0.0f;
         }
 
-        public int osGetParcelDwell(LSL_Vector pos)
+        public LSL_Integer osGetParcelDwell(LSL_Vector pos)
         {
             LandData land = World.GetLandData(pos);
             if (land != null)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 5d964b8..7c5ced8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -260,7 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
         LSL_Float osGetWindParam(string plugin, string param);
 
         // Parcel commands
-        int osGetParcelDwell(vector pos);
+        LSL_Integer osGetParcelDwell(vector pos);
         void osParcelJoin(vector pos1, vector pos2);
         void osParcelSubdivide(vector pos1, vector pos2);
         void osSetParcelDetails(vector pos, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 371460a..f93cea8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
     public partial class ScriptBaseClass
     {
         // SCRIPTS CONSTANTS
-        public static readonly LSLInteger OS_APIVERSION = 4;
+        public static readonly LSLInteger OS_APIVERSION = 5;
 
         public static readonly LSLInteger TRUE = 1;
         public static readonly LSLInteger FALSE = 0;
@@ -721,7 +721,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
         // constants for llGetParcelDetails
         public const int PARCEL_DETAILS_NAME = 0;
         public const int PARCEL_DETAILS_DESC = 1;
-        public const int PARCEL_DETAILS_DWELL = 20;
         public const int PARCEL_DETAILS_OWNER = 2;
         public const int PARCEL_DETAILS_GROUP = 3;
         public const int PARCEL_DETAILS_AREA = 4;
@@ -729,6 +728,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
         public const int PARCEL_DETAILS_SEE_AVATARS = 6;
         public const int PARCEL_DETAILS_ANY_AVATAR_SOUNDS = 7;
         public const int PARCEL_DETAILS_GROUP_SOUNDS = 8;
+        // constants for llGetParcelDetails os specific
+        public const int PARCEL_DETAILS_DWELL = 64;
 
         //osSetParcelDetails
         public const int PARCEL_DETAILS_CLAIMDATE = 10;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index abdf0df..6a70305 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -116,7 +116,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_OSSL_Functions.osGetWindParam(plugin, param);
         }
 
-        public int osGetParcelDwell(vector pos)
+        public LSL_Integer osGetParcelDwell(vector pos)
         {
             return m_OSSL_Functions.osGetParcelDwell(pos);
         }
diff --git a/bin/ScriptSyntax.xml b/bin/ScriptSyntax.xml
index 2282ada..34cd1cc 100644
--- a/bin/ScriptSyntax.xml
+++ b/bin/ScriptSyntax.xml
@@ -1,4 +1,4 @@
-24121ec8-c0a3-099d-8d83-64feaa32418c
+d2556181-baf5-e5b9-c8ec-99eda597b9f6
 <llsd><map><key>llsd-lsl-syntax-version</key><integer>2</integer>
 <key>controls</key>
 <map>
@@ -1513,7 +1513,7 @@
  </map>
  <key>OS_APIVERSION</key><map>
   <key>type</key><string>integer</string>
-  <key>value</key><string>4</string>
+  <key>value</key><string>5</string>
  </map>
  <key>OS_ATTACH_MSG_ALL</key><map>
   <key>type</key><string>integer</string>
@@ -1665,6 +1665,10 @@
   <key>type</key><string>integer</string>
   <key>value</key><string>1</string>
  </map>
+ <key>PARCEL_DETAILS_DWELL</key><map>
+  <key>type</key><string>integer</string>
+  <key>value</key><string>64</string>
+ </map>
  <key>PARCEL_DETAILS_GROUP</key><map>
   <key>type</key><string>integer</string>
   <key>value</key><string>3</string>
@@ -3017,6 +3021,10 @@
   <key>type</key><string>integer</string>
   <key>value</key><string>1</string>
  </map>
+ <key>VEHICLE_FLAG_NO_FLY_UP</key><map>
+  <key>type</key><string>integer</string>
+  <key>value</key><string>1</string>
+ </map>
  <key>VEHICLE_FLAG_NO_X</key><map>
   <key>type</key><string>integer</string>
   <key>value</key><string>1024</string>
@@ -6665,6 +6673,13 @@
    <map><key>name</key><map><key>type</key><string>string</string></map></map>
   </array>
  </map>
+ <key>osGetParcelDwell</key>
+ <map>
+  <key>return</key><string>integer</string>
+  <key>arguments</key><array>
+   <map><key>pos</key><map><key>type</key><string>vector</string></map></map>
+  </array>
+ </map>
  <key>osGetPhysicsEngineName</key>
  <map>
   <key>return</key><string>string</string>
@@ -7581,7 +7596,6 @@
   <key>arguments</key><array>
    <map><key>src</key><map><key>type</key><string>string</string></map></map>
    <map><key>start</key><map><key>type</key><string>integer</string></map></map>
-   <map><key>length</key><map><key>type</key><string>integer</string></map></map>
   </array>
  </map>
  <key>osStringSubString</key>
@@ -7590,6 +7604,7 @@
   <key>arguments</key><array>
    <map><key>src</key><map><key>type</key><string>string</string></map></map>
    <map><key>start</key><map><key>type</key><string>integer</string></map></map>
+   <map><key>length</key><map><key>type</key><string>integer</string></map></map>
   </array>
  </map>
  <key>osSunGetParam</key>
@@ -7619,6 +7634,8 @@
  <map>
   <key>arguments</key><array>
    <map><key>agent</key><map><key>type</key><string>string</string></map></map>
+   <map><key>regionX</key><map><key>type</key><string>integer</string></map></map>
+   <map><key>regionY</key><map><key>type</key><string>integer</string></map></map>
    <map><key>position</key><map><key>type</key><string>vector</string></map></map>
    <map><key>lookat</key><map><key>type</key><string>vector</string></map></map>
   </array>
@@ -7627,8 +7644,6 @@
  <map>
   <key>arguments</key><array>
    <map><key>agent</key><map><key>type</key><string>string</string></map></map>
-   <map><key>regionX</key><map><key>type</key><string>integer</string></map></map>
-   <map><key>regionY</key><map><key>type</key><string>integer</string></map></map>
    <map><key>position</key><map><key>type</key><string>vector</string></map></map>
    <map><key>lookat</key><map><key>type</key><string>vector</string></map></map>
   </array>
-- 
cgit v1.1


From 1499baf13ed19563a0acc84caae8e7ea6f5d7ff5 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 31 Jul 2019 14:34:35 +0100
Subject: mantis8564: add region_up_time to llGetEnv. Returns string with
 seconds since region start. There where ways do get it, but this makes life
 easier

---
 .../Shared/Api/Implementation/LSL_Api.cs           | 121 ++++++++++-----------
 1 file changed, 55 insertions(+), 66 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 980b2a5..24d3615 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6387,75 +6387,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         public LSL_String llGetEnv(LSL_String name)
         {
             m_host.AddScriptLPS(1);
-            if (name == "agent_limit")
+            switch(name)
             {
-                return World.RegionInfo.RegionSettings.AgentLimit.ToString();
-            }
-            else if (name == "dynamic_pathfinding")
-            {
-                return "0";
-            }
-            else if (name == "estate_id")
-            {
-                return World.RegionInfo.EstateSettings.EstateID.ToString();
-            }
-            else if (name == "estate_name")
-            {
-                return World.RegionInfo.EstateSettings.EstateName;
-            }
-            else if (name == "frame_number")
-            {
-                return World.Frame.ToString();
-            }
-            else if (name == "region_cpu_ratio")
-            {
-                return "1";
-            }
-            else if (name == "region_idle")
-            {
-                return "0";
-            }
-            else if (name == "region_product_name")
-            {
-                if (World.RegionInfo.RegionType != String.Empty)
-                    return World.RegionInfo.RegionType;
-                else
+                case "agent_limit":
+                    return World.RegionInfo.RegionSettings.AgentLimit.ToString();
+
+                case "dynamic_pathfinding":
+                    return "0";
+
+                case "estate_id":
+                    return World.RegionInfo.EstateSettings.EstateID.ToString();
+
+                case "estate_name":
+                    return World.RegionInfo.EstateSettings.EstateName;
+
+                case "frame_number":
+                    return World.Frame.ToString();
+
+                case "region_cpu_ratio":
+                    return "1";
+
+                case "region_idle":
+                    return "0";
+
+                case "region_product_name":
+                    if (World.RegionInfo.RegionType != String.Empty)
+                        return World.RegionInfo.RegionType;
+                    else
+                        return "";
+
+                case "region_product_sku":
+                    return "OpenSim";
+
+                case "region_start_time":
+                    return World.UnixStartTime.ToString();
+
+                case "region_up_time":
+                    int time = Util.UnixTimeSinceEpoch() - World.UnixStartTime;
+                    return time.ToString();
+
+                case "sim_channel":
+                    return "OpenSim";
+
+                case "sim_version":
+                    return World.GetSimulatorVersion();
+
+                case "simulator_hostname":
+                    IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>();
+                    return UrlModule.ExternalHostNameForLSL;
+
+                case "region_max_prims":
+                    return World.RegionInfo.ObjectCapacity.ToString();
+
+                case "region_object_bonus":
+                    return World.RegionInfo.RegionSettings.ObjectBonus.ToString();
+
+                default:
                     return "";
             }
-            else if (name == "region_product_sku")
-            {
-                return "OpenSim";
-            }
-            else if (name == "region_start_time")
-            {
-                return World.UnixStartTime.ToString();
-            }
-            else if (name == "sim_channel")
-            {
-                return "OpenSim";
-            }
-            else if (name == "sim_version")
-            {
-                return World.GetSimulatorVersion();
-            }
-            else if (name == "simulator_hostname")
-            {
-                IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>();
-                return UrlModule.ExternalHostNameForLSL;
-            }
-            else if (name == "region_max_prims")
-            {
-                return World.RegionInfo.ObjectCapacity.ToString();
-            }
-            else if (name == "region_object_bonus")
-            {
-                return World.RegionInfo.RegionSettings.ObjectBonus.ToString();
-            }
-            else
-            {
-                return "";
-            }
-
         }
 
         /// <summary>
-- 
cgit v1.1


From 0bcd58fd0f590be629f89e22382dd6a2e5b9f15f Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 31 Jul 2019 16:27:36 +0100
Subject: mantis8548: change more LSL arguments declarations to their formal
 form. Still a lot more to do. This is a case where coerence matters over
 performance, to avoid more future issues

---
 .../Shared/Api/Implementation/LSL_Api.cs           | 98 ++++++++++++----------
 .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs  | 50 +++++------
 .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs    | 60 ++++++-------
 3 files changed, 108 insertions(+), 100 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 24d3615..9a0c836 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -784,25 +784,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         public LSL_Float llCos(double f)
         {
             m_host.AddScriptLPS(1);
-            return (double)Math.Cos(f);
+            return Math.Cos(f);
         }
 
         public LSL_Float llTan(double f)
         {
             m_host.AddScriptLPS(1);
-            return (double)Math.Tan(f);
+            return Math.Tan(f);
         }
 
-        public LSL_Float llAtan2(double x, double y)
+        public LSL_Float llAtan2(LSL_Float x, LSL_Float y)
         {
             m_host.AddScriptLPS(1);
-            return (double)Math.Atan2(x, y);
+            return Math.Atan2(x, y);
         }
 
         public LSL_Float llSqrt(double f)
         {
             m_host.AddScriptLPS(1);
-            return (double)Math.Sqrt(f);
+            return Math.Sqrt(f);
         }
 
         public LSL_Float llPow(double fbase, double fexponent)
@@ -811,7 +811,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return (double)Math.Pow(fbase, fexponent);
         }
 
-        public LSL_Integer llAbs(int i)
+        public LSL_Integer llAbs(LSL_Integer i)
         {
             // changed to replicate LSL behaviour whereby minimum int value is returned untouched.
             m_host.AddScriptLPS(1);
@@ -3069,7 +3069,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             m_host.ParentGroup.StopMoveToTarget();
         }
 
-        public void llApplyImpulse(LSL_Vector force, int local)
+        public void llApplyImpulse(LSL_Vector force, LSL_Integer local)
         {
             m_host.AddScriptLPS(1);
             //No energy force yet
@@ -3526,7 +3526,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return src.ToLower();
         }
 
-        public LSL_Integer llGiveMoney(string destination, int amount)
+        public LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount)
         {
             Util.FireAndForget(x =>
             {
@@ -3785,7 +3785,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return 100f * llGetMass();
         }
 
-        public void llCollisionFilter(string name, string id, int accept)
+        public void llCollisionFilter(LSL_String name, LSL_Key id, LSL_Integer accept)
         {
             m_host.AddScriptLPS(1);
             m_host.CollisionFilter.Clear();
@@ -4513,7 +4513,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             }
         }
 
-        public void llCreateLink(LSL_String target, LSL_Integer parent)
+        public void llCreateLink(LSL_Key target, LSL_Integer parent)
         {
             m_host.AddScriptLPS(1);
 
@@ -4847,7 +4847,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return 1.0f;
         }
 
-        public void llGiveInventory(string destination, string inventory)
+        public void llGiveInventory(LSL_Key destination, LSL_String inventory)
         {
             m_host.AddScriptLPS(1);
 
@@ -5317,7 +5317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             }
         }
 
-        public void llCollisionSound(string impact_sound, double impact_volume)
+        public void llCollisionSound(LSL_String impact_sound, LSL_Float impact_volume)
         {
             m_host.AddScriptLPS(1);
 
@@ -5344,11 +5344,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             m_host.aggregateScriptEvents();
         }
 
-        public LSL_String llGetAnimation(string id)
+        public LSL_String llGetAnimation(LSL_Key id)
         {
             // This should only return a value if the avatar is in the same region
             m_host.AddScriptLPS(1);
-            UUID avatar = (UUID)id;
+            UUID avatar;
+            if(!UUID.TryParse(id, out avatar))
+                return "";
             ScenePresence presence = World.GetScenePresence(avatar);
             if (presence == null)
                 return "";
@@ -5698,13 +5700,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return angle;
         }
 
-        public LSL_Float llAcos(double val)
+        public LSL_Float llAcos(LSL_Float val)
         {
             m_host.AddScriptLPS(1);
             return (double)Math.Acos(val);
         }
 
-        public LSL_Float llAsin(double val)
+        public LSL_Float llAsin(LSL_Float val)
         {
             m_host.AddScriptLPS(1);
             return (double)Math.Asin(val);
@@ -5744,7 +5746,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return UUID.Zero.ToString();
         }
 
-        public void llAllowInventoryDrop(int add)
+        public void llAllowInventoryDrop(LSL_Integer add)
         {
             m_host.AddScriptLPS(1);
 
@@ -6639,7 +6641,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         /// AGENT_BUSY
         /// Remove as they are done
         /// </summary>
-        public LSL_Integer llGetAgentInfo(string id)
+        public LSL_Integer llGetAgentInfo(LSL_Key id)
         {
             m_host.AddScriptLPS(1);
 
@@ -6746,7 +6748,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return flags;
         }
 
-        public LSL_String llGetAgentLanguage(string id)
+        public LSL_String llGetAgentLanguage(LSL_Key id)
         {
             // This should only return a value if the avatar is in the same region, but eh. idc.
             m_host.AddScriptLPS(1);
@@ -6857,7 +6859,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return result;
         }
 
-        public void llAdjustSoundVolume(double volume)
+        public void llAdjustSoundVolume(LSL_Float volume)
         {
             m_host.AddScriptLPS(1);
             m_host.AdjustSoundGain(volume);
@@ -6870,7 +6872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             m_host.SoundRadius = radius;
         }
 
-        public LSL_String llKey2Name(string id)
+        public LSL_String llKey2Name(LSL_Key id)
         {
             m_host.AddScriptLPS(1);
             UUID key = new UUID();
@@ -7044,22 +7046,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         /// only the height of avatars vary and that says:
         /// Width (x) and depth (y) are constant. (0.45m and 0.6m respectively).
         /// </summary>
-        public LSL_Vector llGetAgentSize(string id)
+        public LSL_Vector llGetAgentSize(LSL_Key id)
         {
             m_host.AddScriptLPS(1);
-            ScenePresence avatar = World.GetScenePresence((UUID)id);
-            LSL_Vector agentSize;
+            UUID avID;
+            if(!UUID.TryParse(id, out avID))
+                return ScriptBaseClass.ZERO_VECTOR;
+
+            ScenePresence avatar = World.GetScenePresence(avID);
             if (avatar == null || avatar.IsChildAgent) // Fail if not in the same region
-            {
-                agentSize = ScriptBaseClass.ZERO_VECTOR;
-            }
-            else
-            {
+                return ScriptBaseClass.ZERO_VECTOR;
+
 //                agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight);
-                Vector3 s = avatar.Appearance.AvatarSize;
-                agentSize = new LSL_Vector(s.X, s.Y, s.Z);
-            }
-            return agentSize;
+            Vector3 s = avatar.Appearance.AvatarSize;
+            return new LSL_Vector(s.X, s.Y, s.Z);
         }
 
         public LSL_Integer llSameGroup(string id)
@@ -7235,12 +7235,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return m_host.ParentGroup.AttachmentPoint;
         }
 
-        public LSL_List llGetAttachedList(string id)
+        public LSL_List llGetAttachedList(LSL_Key id)
         {
             m_host.AddScriptLPS(1);
 
-            ScenePresence av = World.GetScenePresence((UUID)id);
+            UUID avID;
+            if(!UUID.TryParse(id, out avID))
+                return new LSL_List("NOT_FOUND");
 
+            ScenePresence av = World.GetScenePresence(avID);
             if (av == null || av.IsDeleted)
                 return new LSL_List("NOT_FOUND");
 
@@ -7825,7 +7828,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             }
         }
 
-        public void llGiveInventoryList(string destination, string category, LSL_List inventory)
+        public void llGiveInventoryList(LSL_Key destination, LSL_String category, LSL_List inventory)
         {
             m_host.AddScriptLPS(1);
 
@@ -8003,7 +8006,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         }
 
 
-        public void llAddToLandPassList(LSL_Key avatar, double hours)
+        public void llAddToLandPassList(LSL_Key avatar, LSL_Float hours)
         {
             m_host.AddScriptLPS(1);
             UUID key;
@@ -11075,16 +11078,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return (double)Math.Log(val);
         }
 
-        public LSL_List llGetAnimationList(string id)
+        public LSL_List llGetAnimationList(LSL_Key id)
         {
             m_host.AddScriptLPS(1);
 
-            LSL_List l = new LSL_List();
-            ScenePresence av = World.GetScenePresence((UUID)id);
+            UUID avID;
+            if(!UUID.TryParse(id, out avID))
+                return new LSL_List();
+
+            ScenePresence av = World.GetScenePresence(avID);
             if (av == null || av.IsChildAgent) // only if in the region
-                return l;
+                return new LSL_List();
+
             UUID[] anims;
             anims = av.Animator.GetAnimationArray();
+            LSL_List l = new LSL_List();
             foreach (UUID foo in anims)
                 l.Add(new LSL_Key(foo.ToString()));
             return l;
@@ -13608,7 +13616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             ScriptSleep(m_sleepMsOnMapDestination);
         }
 
-        public void llAddToLandBanList(LSL_Key avatar, double hours)
+        public void llAddToLandBanList(LSL_Key avatar, LSL_Float hours)
         {
             m_host.AddScriptLPS(1);
             UUID key;
@@ -15048,7 +15056,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             return name.Replace(" ", ".").ToLower();
         }
 
-        public LSL_String llGetUsername(string id)
+        public LSL_String llGetUsername(LSL_Key id)
         {
             return Name2Username(llKey2Name(id));
         }
@@ -16591,7 +16599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                 m_SoundModule.SetSoundQueueing(m_host.UUID, queue == ScriptBaseClass.TRUE.value);
         }
 
-        public void llCollisionSprite(string impact_sprite)
+        public void llCollisionSprite(LSL_String impact_sprite)
         {
             m_host.AddScriptLPS(1);
             // Viewer 2.0 broke this and it's likely LL has no intention
@@ -16652,7 +16660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                     new DetectParams[0]));
         }
 
-        public LSL_Key llTransferLindenDollars(string destination, int amount)
+        public LSL_Key llTransferLindenDollars(LSL_Key destination, LSL_Integer amount)
         {
             UUID txn = UUID.Random();
 
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 8e1192c..6599c22 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -41,20 +41,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
     {
         void state(string newState);
 
-       LSL_Integer llAbs(int val);
-         LSL_Float llAcos(double val);
+       LSL_Integer llAbs(LSL_Integer val);
+         LSL_Float llAcos(LSL_Float val);
                    //ApiDesc Sleep 0.1
-              void llAddToLandBanList(LSL_Key avatarId, double hours);
+              void llAddToLandBanList(LSL_Key avatarId, LSL_Float hours);
                     //ApiDesc Sleep 0.1
-              void llAddToLandPassList(LSL_Key avatarId, double hours);
+              void llAddToLandPassList(LSL_Key avatarId, LSL_Float hours);
                    //ApiDesc Sleep 0.1
-              void llAdjustSoundVolume(double volume);
-              void llAllowInventoryDrop(int add);
+              void llAdjustSoundVolume(LSL_Float volume);
+              void llAllowInventoryDrop(LSL_Integer add);
          LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b);
-              void llApplyImpulse(LSL_Vector force, int local);
+              void llApplyImpulse(LSL_Vector force, LSL_Integer local);
               void llApplyRotationalImpulse(LSL_Vector force, int local);
-         LSL_Float llAsin(double val);
-         LSL_Float llAtan2(double x, double y);
+         LSL_Float llAsin(LSL_Float val);
+         LSL_Float llAtan2(LSL_Float x, LSL_Float y);
               void llAttachToAvatar(LSL_Integer attachment);
               void llAttachToAvatarTemp(LSL_Integer attachmentPoint);
            LSL_Key llAvatarOnSitTarget();
@@ -74,13 +74,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
                    //ApiDesc Sleep 1.0
               void llCloseRemoteDataChannel(string channel);
          LSL_Float llCloud(LSL_Vector offset);
-              void llCollisionFilter(string name, string id, int accept);
-              void llCollisionSound(string impact_sound, double impact_volume);
+              void llCollisionFilter(LSL_String name, LSL_Key id, LSL_Integer accept);
+              void llCollisionSound(LSL_String impact_sound, LSL_Float impact_volume);
                    //ApiDesc Not Supported - does nothing
-              void llCollisionSprite(string impact_sprite);
+              void llCollisionSprite(LSL_String impact_sprite);
          LSL_Float llCos(double f);
                    //ApiDesc Sleep 1.0
-              void llCreateLink(LSL_String targetId, LSL_Integer parent);
+              void llCreateLink(LSL_Key targetId, LSL_Integer parent);
           LSL_List llCSV2List(string src);
           LSL_List llDeleteSubList(LSL_List src, int start, int end);
         LSL_String llDeleteSubString(string src, int start, int end);
@@ -116,16 +116,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
          LSL_Float llFrand(double mag);
            LSL_Key llGenerateKey();
         LSL_Vector llGetAccel();
-       LSL_Integer llGetAgentInfo(string id);
-        LSL_String llGetAgentLanguage(string id);
+       LSL_Integer llGetAgentInfo(LSL_Key id);
+        LSL_String llGetAgentLanguage(LSL_Key id);
           LSL_List llGetAgentList(LSL_Integer scope, LSL_List options);
-        LSL_Vector llGetAgentSize(string id);
+        LSL_Vector llGetAgentSize(LSL_Key id);
          LSL_Float llGetAlpha(int face);
          LSL_Float llGetAndResetTime();
-        LSL_String llGetAnimation(string id);
-          LSL_List llGetAnimationList(string id);
+        LSL_String llGetAnimation(LSL_Key id);
+          LSL_List llGetAnimationList(LSL_Key id);
        LSL_Integer llGetAttached();
-          LSL_List llGetAttachedList(string id);
+          LSL_List llGetAttachedList(LSL_Key id);
           LSL_List llGetBoundingBox(string obj);
         LSL_Vector llGetCameraPos();
       LSL_Rotation llGetCameraRot();
@@ -217,10 +217,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
        LSL_Integer llGetUnixTime();
         LSL_Vector llGetVel();
          LSL_Float llGetWallclock();
-              void llGiveInventory(string destination, string inventory);
-              void llGiveInventoryList(string destination, string category, LSL_List inventory);
-       LSL_Integer llGiveMoney(string destination, int amount);
-           LSL_Key llTransferLindenDollars(string destination, int amount);
+              void llGiveInventory(LSL_Key destination, LSL_String inventory);
+              void llGiveInventoryList(LSL_Key destination, LSL_String category, LSL_List inventory);
+       LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount);
+           LSL_Key llTransferLindenDollars(LSL_Key destination, LSL_Integer amount);
               void llGodLikeRezObject(string inventory, LSL_Vector pos);
          LSL_Float llGround(LSL_Vector offset);
         LSL_Vector llGroundContour(LSL_Vector offset);
@@ -232,8 +232,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
         LSL_String llInsertString(string dst, int position, string src);
               void llInstantMessage(string user, string message);
         LSL_String llIntegerToBase64(int number);
-        LSL_String llKey2Name(string id);
-        LSL_String llGetUsername(string id);
+        LSL_String llKey2Name(LSL_Key id);
+        LSL_String llGetUsername(LSL_Key id);
            LSL_Key llRequestUsername(string id);
         LSL_String llGetDisplayName(string id);
            LSL_Key llRequestDisplayName(string id);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 0f10d8d..ff5b4c3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -65,32 +65,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
         //
         // Script functions
         //
-        public LSL_Integer llAbs(int i)
+        public LSL_Integer llAbs(LSL_Integer i)
         {
             return m_LSL_Functions.llAbs(i);
         }
 
-        public LSL_Float llAcos(double val)
+        public LSL_Float llAcos(LSL_Float val)
         {
             return m_LSL_Functions.llAcos(val);
         }
 
-        public void llAddToLandBanList(string avatar, double hours)
+        public void llAddToLandBanList(LSL_Key avatar, LSL_Float hours)
         {
             m_LSL_Functions.llAddToLandBanList(avatar, hours);
         }
 
-        public void llAddToLandPassList(string avatar, double hours)
+        public void llAddToLandPassList(LSL_Key avatar, LSL_Float hours)
         {
             m_LSL_Functions.llAddToLandPassList(avatar, hours);
         }
 
-        public void llAdjustSoundVolume(double volume)
+        public void llAdjustSoundVolume(LSL_Float volume)
         {
             m_LSL_Functions.llAdjustSoundVolume(volume);
         }
 
-        public void llAllowInventoryDrop(int add)
+        public void llAllowInventoryDrop(LSL_Integer add)
         {
             m_LSL_Functions.llAllowInventoryDrop(add);
         }
@@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llAngleBetween(a, b);
         }
 
-        public void llApplyImpulse(LSL_Vector force, int local)
+        public void llApplyImpulse(LSL_Vector force, LSL_Integer local)
         {
             m_LSL_Functions.llApplyImpulse(force, local);
         }
@@ -110,12 +110,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             m_LSL_Functions.llApplyRotationalImpulse(force, local);
         }
 
-        public LSL_Float llAsin(double val)
+        public LSL_Float llAsin(LSL_Float val)
         {
             return m_LSL_Functions.llAsin(val);
         }
 
-        public LSL_Float llAtan2(double x, double y)
+        public LSL_Float llAtan2(LSL_Float x, LSL_Float y)
         {
             return m_LSL_Functions.llAtan2(x, y);
         }
@@ -190,17 +190,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llCloud(offset);
         }
 
-        public void llCollisionFilter(string name, string id, int accept)
+        public void llCollisionFilter(LSL_String name, LSL_Key id, LSL_Integer accept)
         {
             m_LSL_Functions.llCollisionFilter(name, id, accept);
         }
 
-        public void llCollisionSound(string impact_sound, double impact_volume)
+        public void llCollisionSound(LSL_String impact_sound, LSL_Float impact_volume)
         {
             m_LSL_Functions.llCollisionSound(impact_sound, impact_volume);
         }
 
-        public void llCollisionSprite(string impact_sprite)
+        public void llCollisionSprite(LSL_String impact_sprite)
         {
             m_LSL_Functions.llCollisionSprite(impact_sprite);
         }
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llCos(f);
         }
 
-        public void llCreateLink(LSL_String target, LSL_Integer parent)
+        public void llCreateLink(LSL_Key target, LSL_Integer parent)
         {
             m_LSL_Functions.llCreateLink(target, parent);
         }
@@ -386,12 +386,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGetAccel();
         }
 
-        public LSL_Integer llGetAgentInfo(string id)
+        public LSL_Integer llGetAgentInfo(LSL_Key id)
         {
             return m_LSL_Functions.llGetAgentInfo(id);
         }
 
-        public LSL_String llGetAgentLanguage(string id)
+        public LSL_String llGetAgentLanguage(LSL_Key id)
         {
             return m_LSL_Functions.llGetAgentLanguage(id);
         }
@@ -401,7 +401,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGetAgentList(scope, options);
         }
 
-        public LSL_Vector llGetAgentSize(string id)
+        public LSL_Vector llGetAgentSize(LSL_Key id)
         {
             return m_LSL_Functions.llGetAgentSize(id);
         }
@@ -416,12 +416,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGetAndResetTime();
         }
 
-        public LSL_String llGetAnimation(string id)
+        public LSL_String llGetAnimation(LSL_Key id)
         {
             return m_LSL_Functions.llGetAnimation(id);
         }
 
-        public LSL_List llGetAnimationList(string id)
+        public LSL_List llGetAnimationList(LSL_Key id)
         {
             return m_LSL_Functions.llGetAnimationList(id);
         }
@@ -431,7 +431,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGetAttached();
         }
 
-        public LSL_List llGetAttachedList(string id)
+        public LSL_List llGetAttachedList(LSL_Key id)
         {
             return m_LSL_Functions.llGetAttachedList(id);
         }
@@ -881,27 +881,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGetWallclock();
         }
 
-        public void llGiveInventory(string destination, string inventory)
+        public void llGiveInventory(LSL_Key destination, LSL_String inventory)
         {
             m_LSL_Functions.llGiveInventory(destination, inventory);
         }
 
-        public void llGiveInventoryList(string destination, string category, LSL_List inventory)
+        public void llGiveInventoryList(LSL_Key destination, LSL_String category, LSL_List inventory)
         {
             m_LSL_Functions.llGiveInventoryList(destination, category, inventory);
         }
 
-        public LSL_Integer llGiveMoney(string destination, int amount)
+        public LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount)
         {
             return m_LSL_Functions.llGiveMoney(destination, amount);
         }
 
-        public LSL_Key llTransferLindenDollars(string destination, int amount)
+        public LSL_Key llTransferLindenDollars(LSL_Key destination, LSL_Integer amount)
         {
             return m_LSL_Functions.llTransferLindenDollars(destination, amount);
         }
 
-        public void llGodLikeRezObject(string inventory, LSL_Vector pos)
+        public void llGodLikeRezObject(LSL_String inventory, LSL_Vector pos)
         {
             m_LSL_Functions.llGodLikeRezObject(inventory, pos);
         }
@@ -931,22 +931,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llGroundSlope(offset);
         }
 
-        public LSL_Key llHTTPRequest(string url, LSL_List parameters, string body)
+        public LSL_Key llHTTPRequest(LSL_String url, LSL_List parameters, LSL_String body)
         {
             return m_LSL_Functions.llHTTPRequest(url, parameters, body);
         }
 
-        public void llHTTPResponse(LSL_Key id, int status, string body)
+        public void llHTTPResponse(LSL_Key id, int status, LSL_String body)
         {
             m_LSL_Functions.llHTTPResponse(id, status, body);
         }
 
-        public LSL_String llInsertString(string dst, int position, string src)
+        public LSL_String llInsertString(LSL_String dst, int position, LSL_String src)
         {
             return m_LSL_Functions.llInsertString(dst, position, src);
         }
 
-        public void llInstantMessage(string user, string message)
+        public void llInstantMessage(LSL_String user, LSL_String message)
         {
             m_LSL_Functions.llInstantMessage(user, message);
         }
@@ -956,12 +956,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
             return m_LSL_Functions.llIntegerToBase64(number);
         }
 
-        public LSL_String llKey2Name(string id)
+        public LSL_String llKey2Name(LSL_Key id)
         {
             return m_LSL_Functions.llKey2Name(id);
         }
 
-        public LSL_String llGetUsername(string id)
+        public LSL_String llGetUsername(LSL_Key id)
         {
             return m_LSL_Functions.llGetUsername(id);
         }
-- 
cgit v1.1


From 6359874d640229d803f6c49d2d42c6ec99331742 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 1 Aug 2019 00:01:27 +0100
Subject: mantis8548: let rotation division be -(olderResult) this is formally
 more correct (and it is the same rotation), keep not normalizing, as SL seems
 to do

---
 OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index dd4f974..b01dadd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -533,8 +533,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
 
             public static Quaternion operator /(Quaternion a, Quaternion b)
             {
-                // assuming normalized
-                b.s = -b.s;
+                // assume normalized
+                // if not, sl seems to not normalize either
+                b.x = -b.x;
+                b.y = -b.y;
+                b.z = -b.z;
+
                 return a * b;
             }
 
-- 
cgit v1.1


From 618c6ceda514190924e8003d4ee895f3e2e9f0cc Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 1 Aug 2019 04:14:31 +0100
Subject: mantis8569: do aggregate script events when a script is deleted;
 block nonphysical drag if a touch event is triggered, add a time guard on
 that

---
 .../Framework/Scenes/Scene.PacketHandlers.cs       |  7 +---
 .../Region/Framework/Scenes/SceneObjectGroup.cs    | 48 +++++++++++++++-------
 .../Framework/Scenes/SceneObjectPartInventory.cs   |  7 +++-
 3 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 2995091..b0ecb80 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -341,7 +341,7 @@ namespace OpenSim.Region.Framework.Scenes
             if(group == null || group.IsDeleted)
                 return;
 
-            if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
+            if (Permissions.CanMoveObject(group, remoteClient))
             {
                 group.GrabMovement(objectID, offset, pos, remoteClient);
             }
@@ -359,16 +359,13 @@ namespace OpenSim.Region.Framework.Scenes
             Vector3 grabOffset = pos - part.AbsolutePosition;
             // If the touched prim handles touches, deliver it
             if ((part.ScriptEvents & scriptEvents.touch) != 0)
-//                EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
                 EventManager.TriggerObjectGrabbing(part.LocalId, 0, grabOffset, remoteClient, surfaceArg);
+
             // Deliver to the root prim if the touched prim doesn't handle touches
             // or if we're meant to pass on touches anyway.
             if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
                 (part.PassTouches && (part.LocalId != group.RootPart.LocalId)))
-            {
-//                EventManager.TriggerObjectGrabbing(group.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
                 EventManager.TriggerObjectGrabbing(group.RootPart.LocalId, part.LocalId, grabOffset, remoteClient, surfaceArg);
-            }
         }
 
         public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index c0bafc5..dcfe79b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2086,13 +2086,20 @@ namespace OpenSim.Region.Framework.Scenes
 
         public void ObjectGrabHandler(uint localId, Vector3 offsetPos, IClientAPI remoteClient)
         {
+
             if (m_rootPart.LocalId == localId)
             {
+                if((RootPart.ScriptEvents & scriptEvents.anytouch) != 0)
+                    lastTouchTime = Util.GetTimeStampMS();
                 OnGrabGroup(offsetPos, remoteClient);
             }
             else
             {
                 SceneObjectPart part = GetPart(localId);
+
+                if (((part.ScriptEvents & scriptEvents.anytouch) != 0) ||
+                    (part.PassTouches && (RootPart.ScriptEvents & scriptEvents.anytouch) != 0))
+                    lastTouchTime = Util.GetTimeStampMS();
                 OnGrabPart(part, offsetPos, remoteClient);
             }
         }
@@ -3615,6 +3622,10 @@ namespace OpenSim.Region.Framework.Scenes
 //            part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
         }
 
+        double lastTouchTime = 0;
+
+
+
         /// <summary>
         /// If object is physical, apply force to move it around
         /// If object is not physical, just put it at the resulting location
@@ -3623,7 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="offset">Always seems to be 0,0,0, so ignoring</param>
         /// <param name="pos">New position.  We do the math here to turn it into a force</param>
         /// <param name="remoteClient"></param>
-        public void GrabMovement(UUID partID, Vector3 offset, Vector3 pos, IClientAPI remoteClient)
+        public void GrabMovement(UUID partID, Vector3 offset, Vector3 pos, IClientAPI remoteClienth)
         {
             if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
             {
@@ -3650,25 +3661,32 @@ namespace OpenSim.Region.Framework.Scenes
                 }
                 else
                 {
-                    NonPhysicalGrabMovement(pos);
+                    if(IsAttachment)
+                        return;
+
+                    // block movement if there was a touch at start
+                    double now = Util.GetTimeStampMS();
+                    if (now - lastTouchTime < 250)
+                    {
+                        lastTouchTime = now;
+                        return;
+                    }
+
+                    // a touch or pass may had become active ??
+                    if (((part.ScriptEvents & scriptEvents.anytouch) != 0) ||
+                        (part.PassTouches && (RootPart.ScriptEvents & scriptEvents.anytouch) != 0))
+                    {
+                        lastTouchTime = now;
+                        return;
+                    }
+
+                    lastTouchTime = 0;
+                    UpdateGroupPosition(pos);
                 }
             }
         }
 
         /// <summary>
-        /// Apply possition for grabbing non-physical linksets (Ctrl+Drag)
-        /// This MUST be blocked for linksets that contain touch scripts because the viewer triggers grab on the touch
-        /// event (Viewer Bug?) This would allow anyone to drag a linkset with a touch script. SL behaviour is also to
-        /// block grab on prims with touch events.
-        /// </summary>
-        /// <param name="pos">New Position</param>
-        public void NonPhysicalGrabMovement(Vector3 pos)
-        {
-            if(!IsAttachment && ScriptCount() == 0)
-                UpdateGroupPosition(pos);
-        }
-
-        /// <summary>
         /// If object is physical, prepare for spinning torques (set flag to save old orientation)
         /// </summary>
         /// <param name="rotation">Rotation.  We do the math here to turn it into a torque</param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a0f8959..1ba74f4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1091,7 +1091,6 @@ namespace OpenSim.Region.Framework.Scenes
                 m_part.ParentGroup.InvalidateDeepEffectivePerms();
 
                 m_inventorySerial++;
-                m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
 
                 HasInventoryChanged = true;
                 m_part.ParentGroup.HasGroupChanged = true;
@@ -1113,8 +1112,12 @@ namespace OpenSim.Region.Framework.Scenes
                     m_part.RemFlag(PrimFlags.Scripted);
                 }
 
-                m_part.ScheduleFullUpdate();
+                if (type == (int)InventoryType.LSL)
+                    m_part.aggregateScriptEvents(); // this also does full update
+                else
+                    m_part.ScheduleFullUpdate();
 
+                m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
                 return type;
             }
             else
-- 
cgit v1.1


From 96dabca85b7112c68466f8ac668b9dc07e206ef8 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 1 Aug 2019 05:31:03 +0100
Subject: make sure XEngine does release script events when a script is
 destroyed

---
 OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs   | 5 +----
 OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 3 +++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 1ba74f4..8c880fc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1112,10 +1112,7 @@ namespace OpenSim.Region.Framework.Scenes
                     m_part.RemFlag(PrimFlags.Scripted);
                 }
 
-                if (type == (int)InventoryType.LSL)
-                    m_part.aggregateScriptEvents(); // this also does full update
-                else
-                    m_part.ScheduleFullUpdate();
+                m_part.ScheduleFullUpdate();
 
                 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
                 return type;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 351fca9..ec2a24e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -490,6 +490,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
         {
             ReleaseControls();
             AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
+            SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
+            if (part != null)
+                part.RemoveScriptEvents(ItemID);
         }
 
         public void RemoveState()
-- 
cgit v1.1


From 0142f102ce046bbd46be7087f84845326bb95044 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Thu, 1 Aug 2019 05:37:27 +0100
Subject: remove redundant code

---
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5e2204e..ec58b97 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3023,11 +3023,6 @@ namespace OpenSim.Region.Framework.Scenes
             {
                 if (m_scriptEvents.ContainsKey(scriptid))
                 {
-                    scriptEvents oldparts = scriptEvents.None;
-                    oldparts = (scriptEvents) m_scriptEvents[scriptid];
-
-                    // remove values from aggregated script events
-                    AggregateScriptEvents &= ~oldparts;
                     m_scriptEvents.Remove(scriptid);
                     aggregateScriptEvents();
                 }
-- 
cgit v1.1


From 04eb4744df1383a5ac364a78891df244e9c42b88 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 2 Aug 2019 02:36:19 +0100
Subject: update libopenmetaverse including a ugly hack to try to workaround
 issues detected with new windows .net4.8 JIT. this can be reverted with that
 is fixed, this can also go wrong, as usual ;)

---
 bin/OpenMetaverse.Rendering.Meshmerizer.dll | Bin 20480 -> 20480 bytes
 bin/OpenMetaverse.StructuredData.dll        | Bin 106496 -> 110592 bytes
 bin/OpenMetaverse.dll                       | Bin 2179072 -> 2183168 bytes
 bin/OpenMetaverseTypes.dll                  | Bin 114688 -> 114688 bytes
 4 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/bin/OpenMetaverse.Rendering.Meshmerizer.dll b/bin/OpenMetaverse.Rendering.Meshmerizer.dll
index 53e9600..de90191 100755
Binary files a/bin/OpenMetaverse.Rendering.Meshmerizer.dll and b/bin/OpenMetaverse.Rendering.Meshmerizer.dll differ
diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll
index f9c8c4f..e3bc15f 100755
Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ
diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll
index 02edd6c..06196c3 100755
Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ
diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll
index befbcf2..a3f65d2 100755
Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ
-- 
cgit v1.1


From 482c51a42a300366c7b07faf4bf0c2258f274549 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 2 Aug 2019 04:28:34 +0100
Subject: cosmetics

---
 OpenSim/Framework/AgentCircuitData.cs              |  4 +--
 OpenSim/Framework/WearableCacheItem.cs             | 12 ++------
 .../OptionalModules/Materials/MaterialsModule.cs   | 15 +++++-----
 .../Simulation/SimulationServiceConnector.cs       | 35 +++++++---------------
 OpenSim/Services/LLLoginService/LLLoginService.cs  |  2 +-
 5 files changed, 22 insertions(+), 46 deletions(-)

diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index dcd5cc7..ebb00d2 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -374,8 +374,7 @@ namespace OpenSim.Framework
                 OSDMap urls = (OSDMap)tmpOSD;
                 foreach (KeyValuePair<String, OSD> kvp in urls)
                 {
-                    tmpOSD = kvp.Value;
-                    ServiceURLs[kvp.Key] = tmpOSD.AsString();
+                    ServiceURLs[kvp.Key] = kvp.Value;
                     //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
                 }
             }
@@ -394,6 +393,5 @@ namespace OpenSim.Framework
                 }
             }
         }
-
     }
 }
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 84b9ee9..e060f22 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -161,20 +161,16 @@ namespace OpenSim.Framework
         public static WearableCacheItem[] BakedFromOSD(OSD pInput)
         {
             WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
-            OSD tmpOSD;
             if (pInput.Type == OSDType.Array)
             {
                 OSDArray itemarray = (OSDArray)pInput;
                 foreach (OSDMap item in itemarray)
                 {
-                    tmpOSD = item["textureindex"];
-                    int idx = tmpOSD.AsInteger();
+                    int idx = item["textureindex"].AsInteger();
                     if (idx < 0 || idx > pcache.Length)
                         continue;
-                    tmpOSD = item["cacheid"];
-                    pcache[idx].CacheId = tmpOSD.AsUUID();
-                    tmpOSD = item["textureid"];
-                    pcache[idx].TextureID = tmpOSD.AsUUID();
+                    pcache[idx].CacheId = item["cacheid"].AsUUID();
+                    pcache[idx].TextureID = item["textureid"].AsUUID();
 /*
                     if (item.ContainsKey("assetdata"))
                     {
@@ -220,6 +216,4 @@ namespace OpenSim.Framework
             return null;
         }
     }
-
-
 }
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index 4a92120..331f1bd 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -267,24 +267,24 @@ namespace OpenSim.Region.OptionalModules.Materials
             if (matsArr == null)
                 return partchanged;
             
-            OSD tmpOSD;
             foreach (OSD elemOsd in matsArr)
             {
                 if (elemOsd != null && elemOsd is OSDMap)
                 {
                     OSDMap matMap = elemOsd as OSDMap;
-                    if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
+                    OSD OSDID;
+                    OSD OSDMaterial;
+                    if (matMap.TryGetValue("ID", out OSDID) && matMap.TryGetValue("Material", out OSDMaterial) && OSDMaterial is OSDMap)
                     {
                         try
                         {
                             lock (materialslock)
                             {
-                                tmpOSD = matMap["ID"];
-                                UUID id = tmpOSD.AsUUID();
+                                UUID id = OSDID.AsUUID();
                                 if(m_Materials.ContainsKey(id))
                                     continue;
 
-                                OSDMap theMatMap = (OSDMap)matMap["Material"];
+                                OSDMap theMatMap = (OSDMap)OSDMaterial;
                                 FaceMaterial fmat = new FaceMaterial(theMatMap);
 
                                 if(fmat == null ||
@@ -292,7 +292,7 @@ namespace OpenSim.Region.OptionalModules.Materials
                                         && fmat.NormalMapID == UUID.Zero
                                         && fmat.SpecularMapID == UUID.Zero))
                                     continue;
-                               
+
                                 fmat.ID = id; 
                                 m_Materials[id] = fmat;
                                 m_MaterialsRefCount[id] = 0;
@@ -560,8 +560,7 @@ namespace OpenSim.Region.OptionalModules.Materials
                                     uint primLocalID = 0;
                                     try
                                     {
-                                        tmpOSD = matsMap["ID"];
-                                        primLocalID = tmpOSD.AsUInteger();
+                                        primLocalID = matsMap["ID"].AsUInteger();
                                     }
                                     catch (Exception e)
                                     {
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index b7dbb79..f5e7771 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -120,36 +120,26 @@ namespace OpenSim.Services.Connectors.Simulation
                 PackData(args, source, aCircuit, destination, flags);
 
                 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
-                tmpOSD = result["success"];
-                bool success = tmpOSD.AsBoolean();
+                bool success = result["success"].AsBoolean();
                 if (success && result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                 {
                     OSDMap data = (OSDMap)tmpOSD;
-
-                    tmpOSD = data["reason"];
-                    reason = tmpOSD.AsString();
-
-                    tmpOSD = data["success"];
-                    success = tmpOSD.AsBoolean();
+                    reason = data["reason"].AsString();
+                    success = data["success"].AsBoolean();
                     return success;
                 }
 
                 // Try the old version, uncompressed
                 result = WebUtil.PostToService(uri, args, 30000, false);
 
-                tmpOSD = result["success"];
-                success = tmpOSD.AsBoolean();
+                success = result["success"].AsBoolean();
                 if (success)
                 {
                     if (result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                     {
                         OSDMap data = (OSDMap)tmpOSD;
-
-                        tmpOSD = data["reason"];
-                        reason = tmpOSD.AsString();
-
-                        tmpOSD = data["success"];
-                        success = tmpOSD.AsBoolean();
+                        reason = data["reason"].AsString();
+                        success = data["success"].AsBoolean();
 
                         m_log.WarnFormat(
                             "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
@@ -327,8 +317,7 @@ namespace OpenSim.Services.Connectors.Simulation
             {
                 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true);
 
-                tmpOSD = result["success"];
-                bool success = tmpOSD.AsBoolean();
+                bool success = result["success"].AsBoolean();
 
                 bool has_Result = false;
                 if (result.TryGetValue("_Result", out tmpOSD))
@@ -339,18 +328,14 @@ namespace OpenSim.Services.Connectors.Simulation
                     // FIXME: If there is a _Result map then it's the success key here that indicates the true success
                     // or failure, not the sibling result node.
                     //nte4.8 crap
-                    tmpOSD = data["success"];
-                    success = tmpOSD.AsBoolean();
-
-                    tmpOSD = data["reason"];
-                    reason = tmpOSD.AsString();
+                    success = data["success"].AsBoolean();
+                    reason = data["reason"].AsString();
                     // We will need to plumb this and start sing the outbound version as well
                     // TODO: lay the pipe for version plumbing
                     if (data.TryGetValue("negotiated_inbound_version", out tmpOSD) && tmpOSD != null)
                     {
                         ctx.InboundVersion = (float)tmpOSD.AsReal();
-                        tmpOSD = data["negotiated_outbound_version"];
-                        ctx.OutboundVersion = (float)tmpOSD.AsReal();
+                        ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal();
                     }
                     else if (data.TryGetValue("version", out tmpOSD) && tmpOSD != null)
                     {
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 22748cc..b923761 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -1051,7 +1051,7 @@ namespace OpenSim.Services.LLLoginService
                     }
                     aCircuit.ServiceURLs[keyName] = keyValue;
 
-                    m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
+//                    m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
                 }
 
                 if (!account.ServiceURLs.ContainsKey("GatekeeperURI") && !string.IsNullOrEmpty(m_GatekeeperURL))
-- 
cgit v1.1


From 5b39860573f56669ffe870acab72ecae43f19da1 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 2 Aug 2019 13:13:53 +0100
Subject: silly bug in libomv

---
 bin/OpenMetaverse.Rendering.Meshmerizer.dll | Bin 20480 -> 20480 bytes
 bin/OpenMetaverse.StructuredData.dll        | Bin 110592 -> 110592 bytes
 bin/OpenMetaverse.dll                       | Bin 2183168 -> 2183168 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/bin/OpenMetaverse.Rendering.Meshmerizer.dll b/bin/OpenMetaverse.Rendering.Meshmerizer.dll
index de90191..2d0aa08 100755
Binary files a/bin/OpenMetaverse.Rendering.Meshmerizer.dll and b/bin/OpenMetaverse.Rendering.Meshmerizer.dll differ
diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll
index e3bc15f..eb96d19 100755
Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ
diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll
index 06196c3..4728719 100755
Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ
-- 
cgit v1.1


From 1e0984b64c91fa007723801aa4fe5864c045948d Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 7 Aug 2019 16:16:49 +0100
Subject: add cap EstateAccess

---
 bin/OpenSimDefaults.ini | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index 1332ce8..9c53b93 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -771,6 +771,7 @@
     Cap_ChatSessionRequest = ""
     Cap_CopyInventoryFromNotecard = "localhost"
     Cap_DispatchRegionInfo = ""
+    Cap_EstateAccess = "localhost"
     Cap_EstateChangeInfo = ""
     Cap_EnvironmentSettings = "localhost"
     Cap_EventQueueGet = "localhost"
-- 
cgit v1.1


From 4ea679d9e8f1e7e640230d189a4a7ec20291466e Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 7 Aug 2019 16:20:43 +0100
Subject: add cap EstateAccess: missing file

---
 .../Region/ClientStack/Linden/Caps/EstateAccess.cs | 226 +++++++++++++++++++++
 1 file changed, 226 insertions(+)
 create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs

diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
new file mode 100644
index 0000000..c76e047
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+using log4net;
+using Nini.Config;
+using OpenMetaverse;
+using Mono.Addins;
+using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using Caps=OpenSim.Framework.Capabilities.Caps;
+
+namespace OpenSim.Region.ClientStack.Linden
+{
+    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateAcessCapModule")]
+    public class EstateAccessCapModule : INonSharedRegionModule
+    {
+//        private static readonly ILog m_log =
+//            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+        private Scene m_scene;
+        private bool m_Enabled = false;
+        private string m_capUrl;
+        IEstateModule m_EstateModule;
+
+        #region INonSharedRegionModule Members
+
+        public void Initialise(IConfigSource pSource)
+        {
+            IConfig config = pSource.Configs["ClientStack.LindenCaps"];
+            if (config == null)
+                return;
+
+            m_capUrl = config.GetString("Cap_EstateAccess", string.Empty);
+            if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost"))
+                m_Enabled = true;
+        }
+
+        public void AddRegion(Scene scene)
+        {
+            if (!m_Enabled)
+                return;
+
+            m_scene = scene;
+        }
+
+        public void RemoveRegion(Scene scene)
+        {
+            if (!m_Enabled)
+                return;
+
+            if (m_scene == scene)
+            {
+                m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
+                m_scene = null;
+            }
+        }
+
+        public void RegionLoaded(Scene scene)
+        {
+            if (!m_Enabled)
+                return;
+
+            if (scene.RegionInfo == null || scene.RegionInfo.EstateSettings == null)
+            {
+                m_Enabled = false;
+                return;
+            }
+
+            IEstateModule m_EstateModule = scene.RequestModuleInterface<IEstateModule>();
+            if(m_EstateModule == null)
+            {
+                m_Enabled = false;
+                return;
+            }
+
+            scene.EventManager.OnRegisterCaps += RegisterCaps;
+        }
+
+        public void Close()
+        {
+        }
+
+        public string Name
+        {
+            get { return "EstateAccessCapModule"; }
+        }
+
+        public Type ReplaceableInterface
+        {
+            get { return null; }
+        }
+
+        #endregion
+
+        public void RegisterCaps(UUID agentID, Caps caps)
+        {
+            string capUrl = "/CAPS/" + UUID.Random() + "/";
+
+            caps.RegisterHandler(
+                "EstateAccess",
+                new RestHTTPHandler(
+                    "GET",
+                    capUrl,
+                    httpMethod => ProcessRequest(httpMethod, agentID, caps),
+                    "EstateAccess",
+                    agentID.ToString())); ;
+        }
+
+        public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap)
+        {
+            Hashtable responsedata = new Hashtable();
+            responsedata["int_response_code"] = 400; //501; //410; //404;
+            responsedata["content_type"] = "text/plain";
+            responsedata["keepalive"] = false;
+            responsedata["str_response_string"] = "Request wasn't what was expected";
+            ScenePresence avatar;
+
+            if (!m_scene.TryGetScenePresence(AgentId, out avatar))
+                return responsedata;
+
+            responsedata["int_response_code"] = 200; //501; //410; //404;
+            responsedata["content_type"] = "text/plain";
+            responsedata["keepalive"] = true;
+
+            if (m_scene.RegionInfo == null 
+                || m_scene.RegionInfo.EstateSettings == null
+                ||!m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
+            {
+                responsedata["str_response_string"] = "<llsd><array /></llsd>"; ;
+                return responsedata;
+            }
+
+            EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings;
+            UUID[] managers = regionSettings.EstateManagers;
+            UUID[] allowed = regionSettings.EstateAccess;
+            UUID[] groups = regionSettings.EstateGroups;
+            EstateBan[] EstateBans = regionSettings.EstateBans;
+
+            StringBuilder sb = LLSDxmlEncode.Start();
+            LLSDxmlEncode.AddArray(sb);
+
+            if (allowed != null && allowed.Length > 0)
+            {
+                LLSDxmlEncode.AddMap("AllowedAgents", sb);
+                for (int i = 0; i < allowed.Length; ++i)
+                {
+                    UUID id = allowed[i];
+                    if (id == UUID.Zero)
+                        continue;
+                    LLSDxmlEncode.AddElem("id", id, sb);
+                }
+                LLSDxmlEncode.AddEndMap(sb);
+            }
+
+            if (groups != null && groups.Length > 0)
+            {
+                LLSDxmlEncode.AddMap("AllowedGroups", sb);
+                for (int i = 0; i < groups.Length; ++i)
+                {
+                    UUID id = groups[i];
+                    if (id == UUID.Zero)
+                        continue;
+                    LLSDxmlEncode.AddElem("id", id, sb);
+                }
+                LLSDxmlEncode.AddEndMap(sb);
+            }
+
+            if (EstateBans != null && EstateBans.Length > 0)
+            {
+                LLSDxmlEncode.AddMap("BannedAgents", sb);
+                for (int i = 0; i < EstateBans.Length; ++i)
+                {
+                    UUID id = EstateBans[i].BannedUserID;
+                    if (id == UUID.Zero)
+                        continue;
+                    LLSDxmlEncode.AddElem("id", id, sb);
+                }
+                LLSDxmlEncode.AddEndMap(sb);
+            }
+
+            if (managers != null && managers.Length > 0)
+            {
+                LLSDxmlEncode.AddMap("Managers", sb);
+                for (int i = 0; i < managers.Length; ++i)
+                    LLSDxmlEncode.AddElem("id", managers[i], sb);
+                LLSDxmlEncode.AddEndMap(sb);
+            }
+
+            LLSDxmlEncode.AddEndArray(sb);
+            responsedata["str_response_string"] = LLSDxmlEncode.End(sb);
+
+            return responsedata;
+        }
+    }
+}
-- 
cgit v1.1


From 8d1c12dfad5d51ae54d9bfe68605c046283e34b6 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 7 Aug 2019 16:29:09 +0100
Subject: pesty warning; btw thx LiruCookies for help on estateaccess cap
 viewer protocol

---
 OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
index c76e047..a9f9456 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ClientStack.Linden
         private Scene m_scene;
         private bool m_Enabled = false;
         private string m_capUrl;
-        IEstateModule m_EstateModule;
+        //IEstateModule m_EstateModule;
 
         #region INonSharedRegionModule Members
 
-- 
cgit v1.1


From 21aa26d79607dfb2f84c9dc2692c0a0bb925afea Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 7 Aug 2019 17:39:17 +0100
Subject: cap EstateAccess: don't meed with keepAlive unless needed

---
 OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
index a9f9456..cd6cdef 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs
@@ -140,18 +140,16 @@ namespace OpenSim.Region.ClientStack.Linden
         public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap)
         {
             Hashtable responsedata = new Hashtable();
-            responsedata["int_response_code"] = 400; //501; //410; //404;
+            responsedata["int_response_code"] = 200; //501; //410; //404;
             responsedata["content_type"] = "text/plain";
-            responsedata["keepalive"] = false;
-            responsedata["str_response_string"] = "Request wasn't what was expected";
-            ScenePresence avatar;
 
+            ScenePresence avatar;
             if (!m_scene.TryGetScenePresence(AgentId, out avatar))
+            {
+                responsedata["str_response_string"] = "<llsd><array /></llsd>"; ;
+                responsedata["keepalive"] = false;
                 return responsedata;
-
-            responsedata["int_response_code"] = 200; //501; //410; //404;
-            responsedata["content_type"] = "text/plain";
-            responsedata["keepalive"] = true;
+            }
 
             if (m_scene.RegionInfo == null 
                 || m_scene.RegionInfo.EstateSettings == null
-- 
cgit v1.1