aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2019-07-30 23:26:29 +0100
committerUbitUmarov2019-07-30 23:26:29 +0100
commit944a785a324c203c7ca5b8bdf770ec024b7b9a14 (patch)
tree3df8e0ade9b5891d5ef5da5d671f523f19a14103
parentcosmetics (diff)
downloadopensim-SC-944a785a324c203c7ca5b8bdf770ec024b7b9a14.zip
opensim-SC-944a785a324c203c7ca5b8bdf770ec024b7b9a14.tar.gz
opensim-SC-944a785a324c203c7ca5b8bdf770ec024b7b9a14.tar.bz2
opensim-SC-944a785a324c203c7ca5b8bdf770ec024b7b9a14.tar.xz
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
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs133
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs58
-rw-r--r--OpenSim/Framework/AvatarAttachment.cs15
-rw-r--r--OpenSim/Framework/AvatarWearable.cs6
-rw-r--r--OpenSim/Framework/EntityTransferContext.cs14
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs11
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs228
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs124
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs83
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
267 /// <param name="args"></param> 267 /// <param name="args"></param>
268 public void UnpackAgentCircuitData(OSDMap args) 268 public void UnpackAgentCircuitData(OSDMap args)
269 { 269 {
270 if (args["agent_id"] != null) 270 OSD tmpOSD;
271 AgentID = args["agent_id"].AsUUID(); 271 if (args.TryGetValue("agent_id", out tmpOSD))
272 if (args["base_folder"] != null) 272 AgentID = tmpOSD.AsUUID();
273 BaseFolder = args["base_folder"].AsUUID(); 273 if (args.TryGetValue("base_folder", out tmpOSD))
274 if (args["caps_path"] != null) 274 BaseFolder =tmpOSD.AsUUID();
275 CapsPath = args["caps_path"].AsString(); 275 if (args.TryGetValue("caps_path", out tmpOSD))
276 276 CapsPath = tmpOSD.AsString();
277 if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) 277
278 if ((args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray))
278 { 279 {
279 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); 280 OSDArray childrenSeeds = (OSDArray)tmpOSD;
280 ChildrenCapSeeds = new Dictionary<ulong, string>(); 281 ChildrenCapSeeds = new Dictionary<ulong, string>();
281 foreach (OSD o in childrenSeeds) 282 foreach (OSD o in childrenSeeds)
282 { 283 {
@@ -285,53 +286,59 @@ namespace OpenSim.Framework
285 ulong handle = 0; 286 ulong handle = 0;
286 string seed = ""; 287 string seed = "";
287 OSDMap pair = (OSDMap)o; 288 OSDMap pair = (OSDMap)o;
288 if (pair["handle"] != null) 289 if (pair.TryGetValue("handle", out tmpOSD))
289 if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) 290 {
291 if (!UInt64.TryParse(tmpOSD.AsString(), out handle))
290 continue; 292 continue;
291 if (pair["seed"] != null) 293 }
292 seed = pair["seed"].AsString();
293 if (!ChildrenCapSeeds.ContainsKey(handle)) 294 if (!ChildrenCapSeeds.ContainsKey(handle))
294 ChildrenCapSeeds.Add(handle, seed); 295 {
296 if (pair.TryGetValue("seed", out tmpOSD))
297 {
298 seed = tmpOSD.AsString();
299 ChildrenCapSeeds.Add(handle, seed);
300 }
301 }
295 } 302 }
296 } 303 }
297 } 304 }
298 else 305 else
299 ChildrenCapSeeds = new Dictionary<ulong, string>(); 306 ChildrenCapSeeds = new Dictionary<ulong, string>();
300 307
301 if (args["child"] != null) 308 if (args.TryGetValue("child", out tmpOSD))
302 child = args["child"].AsBoolean(); 309 child = tmpOSD.AsBoolean();
303 if (args["circuit_code"] != null) 310 if (args.TryGetValue("circuit_code", out tmpOSD))
304 UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode); 311 UInt32.TryParse(tmpOSD.AsString(), out circuitcode);
305 if (args["first_name"] != null) 312 if (args.TryGetValue("first_name", out tmpOSD))
306 firstname = args["first_name"].AsString(); 313 firstname = tmpOSD.AsString();
307 if (args["last_name"] != null) 314 if (args.TryGetValue("last_name", out tmpOSD))
308 lastname = args["last_name"].AsString(); 315 lastname = tmpOSD.AsString();
309 if (args["inventory_folder"] != null) 316 if (args.TryGetValue("inventory_folder", out tmpOSD))
310 InventoryFolder = args["inventory_folder"].AsUUID(); 317 InventoryFolder = tmpOSD.AsUUID();
311 if (args["secure_session_id"] != null) 318 if (args.TryGetValue("secure_session_id", out tmpOSD))
312 SecureSessionID = args["secure_session_id"].AsUUID(); 319 SecureSessionID = tmpOSD.AsUUID();
313 if (args["session_id"] != null) 320 if (args.TryGetValue("session_id", out tmpOSD))
314 SessionID = args["session_id"].AsUUID(); 321 SessionID = tmpOSD.AsUUID();
315 if (args["service_session_id"] != null) 322 if (args.TryGetValue("service_session_id", out tmpOSD))
316 ServiceSessionID = args["service_session_id"].AsString(); 323 ServiceSessionID = tmpOSD.AsString();
317 if (args["client_ip"] != null) 324 if (args.TryGetValue("client_ip", out tmpOSD))
318 IPAddress = args["client_ip"].AsString(); 325 IPAddress = tmpOSD.AsString();
319 if (args["viewer"] != null) 326 if (args.TryGetValue("viewer", out tmpOSD))
320 Viewer = args["viewer"].AsString(); 327 Viewer = tmpOSD.AsString();
321 if (args["channel"] != null) 328 if (args.TryGetValue("channel", out tmpOSD))
322 Channel = args["channel"].AsString(); 329 Channel = tmpOSD.AsString();
323 if (args["mac"] != null) 330 if (args.TryGetValue("mac", out tmpOSD))
324 Mac = args["mac"].AsString(); 331 Mac = tmpOSD.AsString();
325 if (args["id0"] != null) 332 if (args.TryGetValue("id0", out tmpOSD))
326 Id0 = args["id0"].AsString(); 333 Id0 = tmpOSD.AsString();
327 if (args["teleport_flags"] != null) 334 if (args.TryGetValue("teleport_flags", out tmpOSD))
328 teleportFlags = args["teleport_flags"].AsUInteger(); 335 teleportFlags = tmpOSD.AsUInteger();
329 336
330 if (args["start_pos"] != null) 337 if (args.TryGetValue("start_pos", out tmpOSD))
331 Vector3.TryParse(args["start_pos"].AsString(), out startpos); 338 Vector3.TryParse(tmpOSD.AsString(), out startpos);
332 339
333 if(args["far"] != null) 340 if(args.TryGetValue("far", out tmpOSD))
334 startfar = (float)args["far"].AsReal(); 341 startfar = (float)tmpOSD.AsReal();
335 342
336 //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos); 343 //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);
337 344
@@ -342,12 +349,12 @@ namespace OpenSim.Framework
342 349
343 // Eventually this code should be deprecated, use full appearance 350 // Eventually this code should be deprecated, use full appearance
344 // packing in packed_appearance 351 // packing in packed_appearance
345 if (args["appearance_serial"] != null) 352 if (args.TryGetValue("appearance_serial", out tmpOSD))
346 Appearance.Serial = args["appearance_serial"].AsInteger(); 353 Appearance.Serial = tmpOSD.AsInteger();
347 354
348 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map)) 355 if (args.TryGetValue("packed_appearance", out tmpOSD) && (tmpOSD is OSDMap))
349 { 356 {
350 Appearance.Unpack((OSDMap)args["packed_appearance"]); 357 Appearance.Unpack((OSDMap)tmpOSD);
351// m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance"); 358// m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
352 } 359 }
353 else 360 else
@@ -362,31 +369,31 @@ namespace OpenSim.Framework
362 369
363 ServiceURLs = new Dictionary<string, object>(); 370 ServiceURLs = new Dictionary<string, object>();
364 // Try parse the new way, OSDMap 371 // Try parse the new way, OSDMap
365 if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map) 372 if (args.TryGetValue("serviceurls", out tmpOSD) && (tmpOSD is OSDMap))
366 { 373 {
367 OSDMap urls = (OSDMap)(args["serviceurls"]); 374 OSDMap urls = (OSDMap)tmpOSD;
368 foreach (KeyValuePair<String, OSD> kvp in urls) 375 foreach (KeyValuePair<String, OSD> kvp in urls)
369 { 376 {
370 ServiceURLs[kvp.Key] = kvp.Value.AsString(); 377 tmpOSD = kvp.Value;
378 ServiceURLs[kvp.Key] = tmpOSD.AsString();
371 //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]); 379 //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
372
373 } 380 }
374 } 381 }
375 // else try the old way, OSDArray 382 // else try the old way, OSDArray
376 // OBSOLETE -- soon to be deleted 383 // OBSOLETE -- soon to be deleted
377 else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) 384 else if (args.TryGetValue("service_urls", out tmpOSD) && (tmpOSD is OSDArray))
378 { 385 {
379 OSDArray urls = (OSDArray)(args["service_urls"]); 386 OSDArray urls = (OSDArray)tmpOSD;
380 for (int i = 0; i < urls.Count / 2; i++) 387 OSD tmpOSDb;
388 for (int i = 0; i < urls.Count - 1; i += 2)
381 { 389 {
382 ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString(); 390 tmpOSD = urls[i];
391 tmpOSDb = urls[i + 1];
392 ServiceURLs[tmpOSD.AsString()] = tmpOSDb.AsString();
383 //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString()); 393 //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());
384
385 } 394 }
386 } 395 }
387 } 396 }
388 397
389 } 398 }
390
391
392} 399}
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
796 /// </summary> 796 /// </summary>
797 public void Unpack(OSDMap data) 797 public void Unpack(OSDMap data)
798 { 798 {
799 if ((data != null) && (data["serial"] != null)) 799 SetDefaultWearables();
800 m_serial = data["serial"].AsInteger(); 800 SetDefaultTexture();
801 if ((data != null) && (data["height"] != null)) 801 SetDefaultParams();
802 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
803
804 if(data == null)
805 {
806 m_log.Warn("[AVATAR APPEARANCE]: data to unpack is null");
807 return;
808 }
809
810 OSD tmpOSD;
811 if (data.TryGetValue("serial", out tmpOSD))
812 m_serial = tmpOSD.AsInteger();
813 if (data.TryGetValue("height", out tmpOSD))
802// m_avatarHeight = (float)data["height"].AsReal(); 814// m_avatarHeight = (float)data["height"].AsReal();
803 SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); 815 SetSize(new Vector3(0.45f,0.6f, (float)tmpOSD.AsReal()));
804 816
805 try 817 try
806 { 818 {
807 // Wearables 819 // Wearables
808 SetDefaultWearables(); 820 if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray))
809 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
810 { 821 {
811 OSDArray wears = (OSDArray)(data["wearables"]); 822 OSDArray wears = (OSDArray)tmpOSD;
812 823 m_wearables = new AvatarWearable[wears.Count];
813 int count = wears.Count;
814
815 m_wearables = new AvatarWearable[count];
816 824
817 for (int i = 0; i < count; i++) 825 for (int i = 0; i < wears.Count; i++)
818 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 826 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
819 } 827 }
820 else 828 else
@@ -823,15 +831,15 @@ namespace OpenSim.Framework
823 } 831 }
824 832
825 // Avatar Textures 833 // Avatar Textures
826 SetDefaultTexture(); 834 if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
827 if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
828 { 835 {
829 OSDArray textures = (OSDArray)(data["textures"]); 836 OSDArray textures = (OSDArray)tmpOSD;
830 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) 837 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
831 { 838 {
832 UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; 839 UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
833 if (textures[i] != null) 840 tmpOSD = textures[i];
834 textureID = textures[i].AsUUID(); 841 if (tmpOSD != null)
842 textureID = tmpOSD.AsUUID();
835 m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); 843 m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
836 } 844 }
837 } 845 }
@@ -840,18 +848,17 @@ namespace OpenSim.Framework
840 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); 848 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
841 } 849 }
842 850
843 if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array) 851 if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray))
844 { 852 {
845 OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]); 853 OSDArray bakedOSDArray = (OSDArray)tmpOSD;
846 m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray); 854 m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
847 } 855 }
848 856
849 // Visual Parameters 857 // Visual Parameters
850 SetDefaultParams(); 858 if (data.TryGetValue("visualparams", out tmpOSD))
851 if ((data != null) && (data["visualparams"] != null))
852 { 859 {
853 if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array)) 860 if (tmpOSD is OSDBinary || tmpOSD is OSDArray)
854 m_visualparams = data["visualparams"].AsBinary(); 861 m_visualparams = tmpOSD.AsBinary();
855 } 862 }
856 else 863 else
857 { 864 {
@@ -859,10 +866,9 @@ namespace OpenSim.Framework
859 } 866 }
860 867
861 // Attachments 868 // Attachments
862 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 869 if (data.TryGetValue("attachments", out tmpOSD) && tmpOSD is OSDArray)
863 if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
864 { 870 {
865 OSDArray attachs = (OSDArray)(data["attachments"]); 871 OSDArray attachs = (OSDArray)tmpOSD;
866 for (int i = 0; i < attachs.Count; i++) 872 for (int i = 0; i < attachs.Count; i++)
867 { 873 {
868 AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); 874 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
68 68
69 public void Unpack(OSDMap args) 69 public void Unpack(OSDMap args)
70 { 70 {
71 if (args["point"] != null) 71 OSD tmpOSD;
72 AttachPoint = args["point"].AsInteger(); 72 if (args.TryGetValue("point", out tmpOSD))
73 AttachPoint = tmpOSD.AsInteger();
74 if (args.TryGetValue("item", out tmpOSD))
75 ItemID = tmpOSD.AsUUID();
76 else
77 ItemID = UUID.Zero;
73 78
74 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero; 79 if (args.TryGetValue("asset", out tmpOSD))
75 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero; 80 AssetID = tmpOSD.AsUUID();
81 else
82 AssetID = UUID.Zero;
76 } 83 }
77 } 84 }
78} 85}
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
132 public void Unpack(OSDArray args) 132 public void Unpack(OSDArray args)
133 { 133 {
134 Clear(); 134 Clear();
135 135 OSD tmpOSDA, tmpOSDB;
136 foreach (OSDMap weardata in args) 136 foreach (OSDMap weardata in args)
137 { 137 {
138 Add(weardata["item"].AsUUID(), weardata["asset"].AsUUID()); 138 tmpOSDA = weardata["item"];
139 tmpOSDB = weardata["asset"];
140 Add(tmpOSDA.AsUUID(), tmpOSDB.AsUUID());
139 } 141 }
140 } 142 }
141 143
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
58 public void Unpack(OSD data) 58 public void Unpack(OSD data)
59 { 59 {
60 OSDMap map = (OSDMap)data; 60 OSDMap map = (OSDMap)data;
61 61 OSD tmpOSD;
62 if (map.ContainsKey("InboundVersion")) 62 if (map.TryGetValue("InboundVersion", out tmpOSD))
63 InboundVersion = (float)map["InboundVersion"].AsReal(); 63 InboundVersion = (float)tmpOSD.AsReal();
64 if (map.ContainsKey("OutboundVersion")) 64 if (map.TryGetValue("OutboundVersion", out tmpOSD))
65 OutboundVersion = (float)map["OutboundVersion"].AsReal(); 65 OutboundVersion = (float)tmpOSD.AsReal();
66 if (map.ContainsKey("WearablesCount")) 66 if (map.TryGetValue("WearablesCount", out tmpOSD))
67 WearablesCount = map["WearablesCount"].AsInteger(); 67 WearablesCount = tmpOSD.AsInteger();
68 } 68 }
69 } 69 }
70} 70}
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
161 public static WearableCacheItem[] BakedFromOSD(OSD pInput) 161 public static WearableCacheItem[] BakedFromOSD(OSD pInput)
162 { 162 {
163 WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem(); 163 WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
164 164 OSD tmpOSD;
165 if (pInput.Type == OSDType.Array) 165 if (pInput.Type == OSDType.Array)
166 { 166 {
167 OSDArray itemarray = (OSDArray)pInput; 167 OSDArray itemarray = (OSDArray)pInput;
168 foreach (OSDMap item in itemarray) 168 foreach (OSDMap item in itemarray)
169 { 169 {
170 int idx = (int)item["textureindex"].AsUInteger(); 170 tmpOSD = item["textureindex"];
171 int idx = tmpOSD.AsInteger();
171 if (idx < 0 || idx > pcache.Length) 172 if (idx < 0 || idx > pcache.Length)
172 continue; 173 continue;
173 pcache[idx].CacheId = item["cacheid"].AsUUID(); 174 tmpOSD = item["cacheid"];
174 pcache[idx].TextureID = item["textureid"].AsUUID(); 175 pcache[idx].CacheId = tmpOSD.AsUUID();
176 tmpOSD = item["textureid"];
177 pcache[idx].TextureID = tmpOSD.AsUUID();
175/* 178/*
176 if (item.ContainsKey("assetdata")) 179 if (item.ContainsKey("assetdata"))
177 { 180 {
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
267 if (matsArr == null) 267 if (matsArr == null)
268 return partchanged; 268 return partchanged;
269 269
270 OSD tmpOSD;
270 foreach (OSD elemOsd in matsArr) 271 foreach (OSD elemOsd in matsArr)
271 { 272 {
272 if (elemOsd != null && elemOsd is OSDMap) 273 if (elemOsd != null && elemOsd is OSDMap)
@@ -278,7 +279,8 @@ namespace OpenSim.Region.OptionalModules.Materials
278 { 279 {
279 lock (materialslock) 280 lock (materialslock)
280 { 281 {
281 UUID id = matMap["ID"].AsUUID(); 282 tmpOSD = matMap["ID"];
283 UUID id = tmpOSD.AsUUID();
282 if(m_Materials.ContainsKey(id)) 284 if(m_Materials.ContainsKey(id))
283 continue; 285 continue;
284 286
@@ -459,12 +461,13 @@ namespace OpenSim.Region.OptionalModules.Materials
459 OSDMap resp = new OSDMap(); 461 OSDMap resp = new OSDMap();
460 462
461 OSDArray respArr = new OSDArray(); 463 OSDArray respArr = new OSDArray();
464 OSD tmpOSD;
462 465
463 if (req.ContainsKey("Zipped")) 466 if (req.TryGetValue("Zipped", out tmpOSD))
464 { 467 {
465 OSD osd = null; 468 OSD osd = null;
466 469
467 byte[] inBytes = req["Zipped"].AsBinary(); 470 byte[] inBytes = tmpOSD.AsBinary();
468 471
469 try 472 try
470 { 473 {
@@ -531,12 +534,13 @@ namespace OpenSim.Region.OptionalModules.Materials
531 534
532 OSDArray respArr = new OSDArray(); 535 OSDArray respArr = new OSDArray();
533 536
537 OSD tmpOSD;
534 HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>(); 538 HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>();
535 if (req.ContainsKey("Zipped")) 539 if (req.TryGetValue("Zipped", out tmpOSD))
536 { 540 {
537 OSD osd = null; 541 OSD osd = null;
538 542
539 byte[] inBytes = req["Zipped"].AsBinary(); 543 byte[] inBytes = tmpOSD.AsBinary();
540 544
541 try 545 try
542 { 546 {
@@ -546,145 +550,141 @@ namespace OpenSim.Region.OptionalModules.Materials
546 { 550 {
547 materialsFromViewer = osd as OSDMap; 551 materialsFromViewer = osd as OSDMap;
548 552
549 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) 553 if (materialsFromViewer.TryGetValue("FullMaterialsPerFace", out tmpOSD) && (tmpOSD is OSDArray))
550 { 554 {
551 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; 555 OSDArray matsArr = tmpOSD as OSDArray;
552 if (matsOsd is OSDArray) 556 try
553 { 557 {
554 OSDArray matsArr = matsOsd as OSDArray; 558 foreach (OSDMap matsMap in matsArr)
555
556 try
557 { 559 {
558 foreach (OSDMap matsMap in matsArr) 560 uint primLocalID = 0;
561 try
559 { 562 {
560 uint primLocalID = 0; 563 tmpOSD = matsMap["ID"];
561 try 564 primLocalID = tmpOSD.AsUInteger();
562 { 565 }
563 primLocalID = matsMap["ID"].AsUInteger(); 566 catch (Exception e)
564 } 567 {
565 catch (Exception e) 568 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
566 { 569 continue;
567 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); 570 }
568 continue;
569 }
570 571
571 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); 572 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
572 if (sop == null) 573 if (sop == null)
573 { 574 {
574 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); 575 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
575 continue; 576 continue;
576 } 577 }
577 578
578 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) 579 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
579 { 580 {
580 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); 581 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
581 continue; 582 continue;
582 } 583 }
583 584
584 OSDMap mat = null; 585 OSDMap mat = null;
585 try 586 try
586 { 587 {
587 mat = matsMap["Material"] as OSDMap; 588 mat = matsMap["Material"] as OSDMap;
588 } 589 }
589 catch (Exception e) 590 catch (Exception e)
590 { 591 {
591 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message); 592 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
592 continue; 593 continue;
593 } 594 }
594 595
595 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); 596 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
596 if (te == null) 597 if (te == null)
597 { 598 {
598 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); 599 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
599 continue; 600 continue;
600 } 601 }
601 602
602 int face = -1; 603 int face = -1;
603 UUID oldid = UUID.Zero; 604 UUID oldid = UUID.Zero;
604 Primitive.TextureEntryFace faceEntry = null; 605 Primitive.TextureEntryFace faceEntry = null;
605 if (matsMap.ContainsKey("Face")) 606 if (matsMap.TryGetValue("Face", out tmpOSD))
606 { 607 {
607 face = matsMap["Face"].AsInteger(); 608 face = tmpOSD.AsInteger();
608 faceEntry = te.CreateFace((uint)face); 609 faceEntry = te.CreateFace((uint)face);
609 } 610 }
610 else 611 else
611 faceEntry = te.DefaultTexture; 612 faceEntry = te.DefaultTexture;
612 613
613 if (faceEntry == null) 614 if (faceEntry == null)
614 continue; 615 continue;
615 616
616 UUID id; 617 UUID id;
617 FaceMaterial newFaceMat = null; 618 FaceMaterial newFaceMat = null;
618 if (mat == null) 619 if (mat == null)
619 { 620 {
620 // This happens then the user removes a material from a prim 621 // This happens then the user removes a material from a prim
622 id = UUID.Zero;
623 }
624 else
625 {
626 newFaceMat = new FaceMaterial(mat);
627 if(newFaceMat.DiffuseAlphaMode == 1
628 && newFaceMat.NormalMapID == UUID.Zero
629 && newFaceMat.SpecularMapID == UUID.Zero
630 )
621 id = UUID.Zero; 631 id = UUID.Zero;
622 }
623 else 632 else
624 { 633 {
625 newFaceMat = new FaceMaterial(mat); 634 newFaceMat.genID();
626 if(newFaceMat.DiffuseAlphaMode == 1 635 id = newFaceMat.ID;
627 && newFaceMat.NormalMapID == UUID.Zero
628 && newFaceMat.SpecularMapID == UUID.Zero
629 )
630 id = UUID.Zero;
631 else
632 {
633 newFaceMat.genID();
634 id = newFaceMat.ID;
635 }
636 } 636 }
637 }
637 638
638 oldid = faceEntry.MaterialID; 639 oldid = faceEntry.MaterialID;
639 640
640 if(oldid == id) 641 if(oldid == id)
641 continue; 642 continue;
642 643
643 if (faceEntry != null) 644 if (faceEntry != null)
644 { 645 {
645 faceEntry.MaterialID = id; 646 faceEntry.MaterialID = id;
646 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); 647 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
647 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually 648 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
648 sop.Shape.TextureEntry = te.GetBytes(9); 649 sop.Shape.TextureEntry = te.GetBytes(9);
649 } 650 }
650 651
651 if(oldid != UUID.Zero) 652 if(oldid != UUID.Zero)
652 RemoveMaterial(oldid); 653 RemoveMaterial(oldid);
653 654
654 lock(materialslock) 655 lock(materialslock)
656 {
657 if(id != UUID.Zero)
655 { 658 {
656 if(id != UUID.Zero) 659 if (m_Materials.ContainsKey(id))
660 m_MaterialsRefCount[id]++;
661 else
657 { 662 {
658 if (m_Materials.ContainsKey(id)) 663 m_Materials[id] = newFaceMat;
659 m_MaterialsRefCount[id]++; 664 m_MaterialsRefCount[id] = 1;
660 else 665 m_changed[newFaceMat] = Util.GetTimeStamp();
661 {
662 m_Materials[id] = newFaceMat;
663 m_MaterialsRefCount[id] = 1;
664 m_changed[newFaceMat] = Util.GetTimeStamp();
665 }
666 } 666 }
667 } 667 }
668
669 if(!parts.Contains(sop))
670 parts.Add(sop);
671 } 668 }
672 669
673 foreach(SceneObjectPart sop in parts) 670 if(!parts.Contains(sop))
674 { 671 parts.Add(sop);
675 if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
676 {
677 sop.TriggerScriptChangedEvent(Changed.TEXTURE);
678 sop.ScheduleFullUpdate();
679 sop.ParentGroup.HasGroupChanged = true;
680 }
681 }
682 } 672 }
683 catch (Exception e) 673
674 foreach(SceneObjectPart sop in parts)
684 { 675 {
685 m_log.Warn("[Materials]: exception processing received material ", e); 676 if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
677 {
678 sop.TriggerScriptChangedEvent(Changed.TEXTURE);
679 sop.ScheduleFullUpdate();
680 sop.ParentGroup.HasGroupChanged = true;
681 }
686 } 682 }
687 } 683 }
684 catch (Exception e)
685 {
686 m_log.Warn("[Materials]: exception processing received material ", e);
687 }
688 } 688 }
689 } 689 }
690 } 690 }
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
115 115
116 return responsedata; 116 return responsedata;
117 } 117 }
118
119 } 118 }
120 119
121 protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID) 120 protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID)
122 { 121 {
123 Culture.SetCurrentCulture();
124
125 EntityTransferContext ctx = new EntityTransferContext();
126
127 if (m_SimulationService == null) 122 if (m_SimulationService == null)
128 { 123 {
129 m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless."); 124 m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless.");
@@ -134,33 +129,37 @@ namespace OpenSim.Server.Handlers.Simulation
134 return; 129 return;
135 } 130 }
136 131
132 Culture.SetCurrentCulture();
133
137 // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]); 134 // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]);
138 OSDMap args = Utils.GetOSDMap((string)request["body"]); 135 OSDMap args = Utils.GetOSDMap((string)request["body"]);
139 136
140 bool viaTeleport = true; 137 bool viaTeleport = true;
141 if (args.ContainsKey("viaTeleport")) 138 OSD tmpOSD;
142 viaTeleport = args["viaTeleport"].AsBoolean(); 139 if (args.TryGetValue("viaTeleport",out tmpOSD))
140 viaTeleport = tmpOSD.AsBoolean();
143 141
144 Vector3 position = Vector3.Zero; 142 Vector3 position = Vector3.Zero;
145 if (args.ContainsKey("position")) 143 if (args.TryGetValue("position", out tmpOSD))
146 position = Vector3.Parse(args["position"].AsString()); 144 position = Vector3.Parse(tmpOSD.AsString());
147 145
148 string agentHomeURI = null; 146 string agentHomeURI = null;
149 if (args.ContainsKey("agent_home_uri")) 147 if (args.TryGetValue("agent_home_uri", out tmpOSD))
150 agentHomeURI = args["agent_home_uri"].AsString(); 148 agentHomeURI = tmpOSD.AsString();
151 149
152 // Decode the legacy (string) version and extract the number 150 // Decode the legacy (string) version and extract the number
153 float theirVersion = 0f; 151 float theirVersion = 0f;
154 if (args.ContainsKey("my_version")) 152 if (args.TryGetValue("my_version", out tmpOSD))
155 { 153 {
156 string theirVersionStr = args["my_version"].AsString(); 154 string theirVersionStr = tmpOSD.AsString();
157 string[] parts = theirVersionStr.Split(new char[] {'/'}); 155 string[] parts = theirVersionStr.Split(new char[] {'/'});
158 if (parts.Length > 1) 156 if (parts.Length > 1)
159 theirVersion = float.Parse(parts[1], Culture.FormatProvider); 157 theirVersion = float.Parse(parts[1], Culture.FormatProvider);
160 } 158 }
161 159
162 if (args.ContainsKey("context")) 160 EntityTransferContext ctx = new EntityTransferContext();
163 ctx.Unpack((OSDMap)args["context"]); 161 if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
162 ctx.Unpack((OSDMap)tmpOSD);
164 163
165 // Decode the new versioning data 164 // Decode the new versioning data
166 float minVersionRequired = 0f; 165 float minVersionRequired = 0f;
@@ -168,15 +167,15 @@ namespace OpenSim.Server.Handlers.Simulation
168 float minVersionProvided = 0f; 167 float minVersionProvided = 0f;
169 float maxVersionProvided = 0f; 168 float maxVersionProvided = 0f;
170 169
171 if (args.ContainsKey("simulation_service_supported_min")) 170 if (args.TryGetValue("simulation_service_supported_min", out tmpOSD))
172 minVersionProvided = (float)args["simulation_service_supported_min"].AsReal(); 171 minVersionProvided = (float)tmpOSD.AsReal();
173 if (args.ContainsKey("simulation_service_supported_max")) 172 if (args.TryGetValue("simulation_service_supported_max", out tmpOSD))
174 maxVersionProvided = (float)args["simulation_service_supported_max"].AsReal(); 173 maxVersionProvided = (float)tmpOSD.AsReal();
175 174
176 if (args.ContainsKey("simulation_service_accepted_min")) 175 if (args.TryGetValue("simulation_service_accepted_min", out tmpOSD))
177 minVersionRequired = (float)args["simulation_service_accepted_min"].AsReal(); 176 minVersionRequired = (float)tmpOSD.AsReal();
178 if (args.ContainsKey("simulation_service_accepted_max")) 177 if (args.TryGetValue("simulation_service_accepted_max", out tmpOSD))
179 maxVersionRequired = (float)args["simulation_service_accepted_max"].AsReal(); 178 maxVersionRequired = (float)tmpOSD.AsReal();
180 179
181 responsedata["int_response_code"] = HttpStatusCode.OK; 180 responsedata["int_response_code"] = HttpStatusCode.OK;
182 OSDMap resp = new OSDMap(3); 181 OSDMap resp = new OSDMap(3);
@@ -239,9 +238,9 @@ namespace OpenSim.Server.Handlers.Simulation
239 238
240 List<UUID> features = new List<UUID>(); 239 List<UUID> features = new List<UUID>();
241 240
242 if (args.ContainsKey("features")) 241 if (args.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray)
243 { 242 {
244 OSDArray array = (OSDArray)args["features"]; 243 OSDArray array = (OSDArray)tmpOSD;
245 244
246 foreach (OSD o in array) 245 foreach (OSD o in array)
247 features.Add(new UUID(o.AsString())); 246 features.Add(new UUID(o.AsString()));
@@ -414,8 +413,6 @@ namespace OpenSim.Server.Handlers.Simulation
414 413
415 protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) 414 protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
416 { 415 {
417 EntityTransferContext ctx = new EntityTransferContext();
418
419 OSDMap args = Utils.GetOSDMap((string)request["body"]); 416 OSDMap args = Utils.GetOSDMap((string)request["body"]);
420 if (args == null) 417 if (args == null)
421 { 418 {
@@ -424,8 +421,10 @@ namespace OpenSim.Server.Handlers.Simulation
424 return; 421 return;
425 } 422 }
426 423
427 if (args.ContainsKey("context")) 424 OSD tmpOSD;
428 ctx.Unpack((OSDMap)args["context"]); 425 EntityTransferContext ctx = new EntityTransferContext();
426 if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
427 ctx.Unpack((OSDMap)tmpOSD);
429 428
430 AgentDestinationData data = CreateAgentDestinationData(); 429 AgentDestinationData data = CreateAgentDestinationData();
431 UnpackData(args, data, request); 430 UnpackData(args, data, request);
@@ -453,16 +452,19 @@ namespace OpenSim.Server.Handlers.Simulation
453 452
454 GridRegion source = null; 453 GridRegion source = null;
455 454
456 if (args.ContainsKey("source_uuid")) 455 if (args.TryGetValue("source_uuid", out tmpOSD))
457 { 456 {
458 source = new GridRegion(); 457 source = new GridRegion();
459 source.RegionLocX = Int32.Parse(args["source_x"].AsString()); 458 source.RegionID = UUID.Parse(tmpOSD.AsString());
460 source.RegionLocY = Int32.Parse(args["source_y"].AsString()); 459 tmpOSD = args["source_x"];
461 source.RegionName = args["source_name"].AsString(); 460 source.RegionLocX = Int32.Parse(tmpOSD.AsString());
462 source.RegionID = UUID.Parse(args["source_uuid"].AsString()); 461 tmpOSD = args["source_y"];
463 462 source.RegionLocY = Int32.Parse(tmpOSD.AsString());
464 if (args.ContainsKey("source_server_uri")) 463 tmpOSD = args["source_name"];
465 source.RawServerURI = args["source_server_uri"].AsString(); 464 source.RegionName = tmpOSD.AsString();
465
466 if (args.TryGetValue("source_server_uri", out tmpOSD))
467 source.RawServerURI = tmpOSD.AsString();
466 else 468 else
467 source.RawServerURI = null; 469 source.RawServerURI = null;
468 } 470 }
@@ -493,21 +495,26 @@ namespace OpenSim.Server.Handlers.Simulation
493 495
494 protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request) 496 protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
495 { 497 {
498 OSD tmpOSD;
496 // retrieve the input arguments 499 // retrieve the input arguments
497 if (args.ContainsKey("destination_x") && args["destination_x"] != null) 500 if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
498 Int32.TryParse(args["destination_x"].AsString(), out data.x); 501 Int32.TryParse(tmpOSD.AsString(), out data.x);
499 else 502 else
500 m_log.WarnFormat(" -- request didn't have destination_x"); 503 m_log.WarnFormat(" -- request didn't have destination_x");
501 if (args.ContainsKey("destination_y") && args["destination_y"] != null) 504
502 Int32.TryParse(args["destination_y"].AsString(), out data.y); 505 if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
506 Int32.TryParse(tmpOSD.AsString(), out data.y);
503 else 507 else
504 m_log.WarnFormat(" -- request didn't have destination_y"); 508 m_log.WarnFormat(" -- request didn't have destination_y");
505 if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) 509
506 UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid); 510 if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
507 if (args.ContainsKey("destination_name") && args["destination_name"] != null) 511 UUID.TryParse(tmpOSD.AsString(), out data.uuid);
508 data.name = args["destination_name"].ToString(); 512
509 if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null) 513 if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
510 data.flags = args["teleport_flags"].AsUInteger(); 514 data.name = tmpOSD.ToString();
515
516 if (args.TryGetValue("teleport_flags", out tmpOSD) && tmpOSD != null)
517 data.flags = tmpOSD.AsUInteger();
511 } 518 }
512 519
513 protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data) 520 protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
@@ -674,7 +681,6 @@ namespace OpenSim.Server.Handlers.Simulation
674 protected void DoAgentPut(Hashtable request, Hashtable responsedata) 681 protected void DoAgentPut(Hashtable request, Hashtable responsedata)
675 { 682 {
676 // TODO: Encode the ENtityTransferContext 683 // TODO: Encode the ENtityTransferContext
677 EntityTransferContext ctx = new EntityTransferContext();
678 684
679 OSDMap args = Utils.GetOSDMap((string)request["body"]); 685 OSDMap args = Utils.GetOSDMap((string)request["body"]);
680 if (args == null) 686 if (args == null)
@@ -685,19 +691,21 @@ namespace OpenSim.Server.Handlers.Simulation
685 } 691 }
686 692
687 // retrieve the input arguments 693 // retrieve the input arguments
694 OSD tmpOSD;
695 EntityTransferContext ctx = new EntityTransferContext();
688 int x = 0, y = 0; 696 int x = 0, y = 0;
689 UUID uuid = UUID.Zero; 697 UUID uuid = UUID.Zero;
690 string regionname = string.Empty; 698 string regionname = string.Empty;
691 if (args.ContainsKey("destination_x") && args["destination_x"] != null) 699 if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
692 Int32.TryParse(args["destination_x"].AsString(), out x); 700 Int32.TryParse(tmpOSD.AsString(), out x);
693 if (args.ContainsKey("destination_y") && args["destination_y"] != null) 701 if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
694 Int32.TryParse(args["destination_y"].AsString(), out y); 702 Int32.TryParse(tmpOSD.AsString(), out y);
695 if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) 703 if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
696 UUID.TryParse(args["destination_uuid"].AsString(), out uuid); 704 UUID.TryParse(tmpOSD.AsString(), out uuid);
697 if (args.ContainsKey("destination_name") && args["destination_name"] != null) 705 if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
698 regionname = args["destination_name"].ToString(); 706 regionname = tmpOSD.ToString();
699 if (args.ContainsKey("context")) 707 if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
700 ctx.Unpack((OSDMap)args["context"]); 708 ctx.Unpack((OSDMap)tmpOSD);
701 709
702 GridRegion destination = new GridRegion(); 710 GridRegion destination = new GridRegion();
703 destination.RegionID = uuid; 711 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
112 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); 112 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
113 113
114 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; 114 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
115 115 OSD tmpOSD;
116 try 116 try
117 { 117 {
118 OSDMap args = aCircuit.PackAgentCircuitData(ctx); 118 OSDMap args = aCircuit.PackAgentCircuitData(ctx);
@@ -120,27 +120,37 @@ namespace OpenSim.Services.Connectors.Simulation
120 PackData(args, source, aCircuit, destination, flags); 120 PackData(args, source, aCircuit, destination, flags);
121 121
122 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 122 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
123 bool success = result["success"].AsBoolean(); 123 tmpOSD = result["success"];
124 if (success && result.ContainsKey("_Result")) 124 bool success = tmpOSD.AsBoolean();
125 if (success && result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
125 { 126 {
126 OSDMap data = (OSDMap)result["_Result"]; 127 OSDMap data = (OSDMap)tmpOSD;
128
129 tmpOSD = data["reason"];
130 reason = tmpOSD.AsString();
127 131
128 reason = data["reason"].AsString(); 132 tmpOSD = data["success"];
129 success = data["success"].AsBoolean(); 133 success = tmpOSD.AsBoolean();
130 return success; 134 return success;
131 } 135 }
132 136
133 // Try the old version, uncompressed 137 // Try the old version, uncompressed
134 result = WebUtil.PostToService(uri, args, 30000, false); 138 result = WebUtil.PostToService(uri, args, 30000, false);
135 139
136 if (result["Success"].AsBoolean()) 140 tmpOSD = result["success"];
141 success = tmpOSD.AsBoolean();
142 if (success)
137 { 143 {
138 if (result.ContainsKey("_Result")) 144 if (result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
139 { 145 {
140 OSDMap data = (OSDMap)result["_Result"]; 146 OSDMap data = (OSDMap)tmpOSD;
147
148 tmpOSD = data["reason"];
149 reason = tmpOSD.AsString();
150
151 tmpOSD = data["success"];
152 success = tmpOSD.AsBoolean();
141 153
142 reason = data["reason"].AsString();
143 success = data["success"].AsBoolean();
144 m_log.WarnFormat( 154 m_log.WarnFormat(
145 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); 155 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
146 return success; 156 return success;
@@ -312,34 +322,47 @@ namespace OpenSim.Services.Connectors.Simulation
312 if (agentHomeURI != null) 322 if (agentHomeURI != null)
313 request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); 323 request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
314 324
325 OSD tmpOSD;
315 try 326 try
316 { 327 {
317 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true); 328 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true);
318 bool success = result["success"].AsBoolean(); 329
319 if (result.ContainsKey("_Result")) 330 tmpOSD = result["success"];
331 bool success = tmpOSD.AsBoolean();
332
333 bool has_Result = false;
334 if (result.TryGetValue("_Result", out tmpOSD))
320 { 335 {
321 OSDMap data = (OSDMap)result["_Result"]; 336 has_Result = true;
337 OSDMap data = (OSDMap)tmpOSD;
322 338
323 // FIXME: If there is a _Result map then it's the success key here that indicates the true success 339 // FIXME: If there is a _Result map then it's the success key here that indicates the true success
324 // or failure, not the sibling result node. 340 // or failure, not the sibling result node.
325 success = data["success"].AsBoolean(); 341 //nte4.8 crap
342 tmpOSD = data["success"];
343 success = tmpOSD.AsBoolean();
326 344
327 reason = data["reason"].AsString(); 345 tmpOSD = data["reason"];
346 reason = tmpOSD.AsString();
328 // We will need to plumb this and start sing the outbound version as well 347 // We will need to plumb this and start sing the outbound version as well
329 // TODO: lay the pipe for version plumbing 348 // TODO: lay the pipe for version plumbing
330 if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null) 349 if (data.TryGetValue("negotiated_inbound_version", out tmpOSD) && tmpOSD != null)
331 { 350 {
332 ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal(); 351 ctx.InboundVersion = (float)tmpOSD.AsReal();
333 ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal(); 352 tmpOSD = data["negotiated_outbound_version"];
353 ctx.OutboundVersion = (float)tmpOSD.AsReal();
334 } 354 }
335 else if (data["version"] != null && data["version"].AsString() != string.Empty) 355 else if (data.TryGetValue("version", out tmpOSD) && tmpOSD != null)
336 { 356 {
337 string versionString = data["version"].AsString(); 357 string versionString = tmpOSD.AsString();
338 String[] parts = versionString.Split(new char[] {'/'}); 358 if(versionString != string.Empty)
339 if (parts.Length > 1)
340 { 359 {
341 ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider); 360 String[] parts = versionString.Split(new char[] {'/'});
342 ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider); 361 if (parts.Length > 1)
362 {
363 ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider);
364 ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider);
365 }
343 } 366 }
344 } 367 }
345 368
@@ -352,11 +375,11 @@ namespace OpenSim.Services.Connectors.Simulation
352 { 375 {
353 // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the 376 // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
354 // actual failure message 377 // actual failure message
355 if (!result.ContainsKey("_Result")) 378 if (!has_Result)
356 { 379 {
357 if (result.ContainsKey("Message")) 380 if (result.TryGetValue("Message", out tmpOSD))
358 { 381 {
359 string message = result["Message"].AsString(); 382 string message = tmpOSD.AsString();
360 if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region 383 if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region
361 { 384 {
362 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"); 385 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
376 399
377 featuresAvailable.Clear(); 400 featuresAvailable.Clear();
378 401
379 if (result.ContainsKey("features")) 402 if (result.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray)
380 { 403 {
381 OSDArray array = (OSDArray)result["features"]; 404 OSDArray array = (OSDArray)tmpOSD;
382 405
383 foreach (OSD o in array) 406 foreach (OSD o in array)
384 featuresAvailable.Add(new UUID(o.AsString())); 407 featuresAvailable.Add(new UUID(o.AsString()));