From cdd3ef857c296a3aee88eea0386d166222684c04 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Jan 2018 08:02:45 +0000 Subject: a few changes to encoder and a few more uses --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 130 ++++++++++++--------- 1 file changed, 75 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 85e5ec3..5c5d2b9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1376,30 +1376,37 @@ namespace OpenSim.Region.ClientStack.Linden IOSHttpResponse httpResponse) { OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); - OSDMap resp = new OSDMap(); OSDArray object_ids = (OSDArray)req["object_ids"]; - for (int i = 0 ; i < object_ids.Count ; i++) + StringBuilder lsl = new StringBuilder(256); + LLSDxmlEncode.AddStart(lsl); + if(object_ids.Count == 0) + LLSDxmlEncode.AddEmpyMap(lsl); + else { - UUID uuid = object_ids[i].AsUUID(); - - SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); - if (obj != null) + LLSDxmlEncode.AddMap(lsl); + for (int i = 0 ; i < object_ids.Count ; i++) { - OSDMap object_data = new OSDMap(); + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + LLSDxmlEncode.AddMap(uuid.ToString(),lsl); - object_data["PhysicsShapeType"] = obj.PhysicsShapeType; - object_data["Density"] = obj.Density; - object_data["Friction"] = obj.Friction; - object_data["Restitution"] = obj.Restitution; - object_data["GravityMultiplier"] = obj.GravityModifier; + LLSDxmlEncode.AddElem("PhysicsShapeType", obj.PhysicsShapeType, lsl); + LLSDxmlEncode.AddElem("Density", obj.Density, lsl); + LLSDxmlEncode.AddElem("Friction", obj.Friction, lsl); + LLSDxmlEncode.AddElem("Restitution", obj.Restitution, lsl); + LLSDxmlEncode.AddElem("GravityMultiplier", obj.GravityModifier, lsl); - resp[uuid.ToString()] = object_data; + LLSDxmlEncode.AddEndMap(lsl); + } + LLSDxmlEncode.AddEndMap(lsl); } } - - string response = OSDParser.SerializeLLSDXmlString(resp); - return response; + LLSDxmlEncode.AddEnd(lsl); + return lsl.ToString(); } public string GetObjectCost(string request, string path, @@ -1407,47 +1414,60 @@ namespace OpenSim.Region.ClientStack.Linden IOSHttpResponse httpResponse) { OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); - OSDMap resp = new OSDMap(); - OSDArray object_ids = (OSDArray)req["object_ids"]; - for (int i = 0; i < object_ids.Count; i++) + StringBuilder lsl = new StringBuilder(512); + LLSDxmlEncode.AddStart(lsl); + if(object_ids.Count == 0) + LLSDxmlEncode.AddEmpyMap(lsl); + else { - UUID uuid = object_ids[i].AsUUID(); + bool haveone = false; + LLSDxmlEncode.AddMap(lsl); + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); + SceneObjectGroup grp = null; + if (part != null) + grp = part.ParentGroup; + if (grp != null) + { + haveone = true; + float linksetCost; + float linksetPhysCost; + float partCost; + float partPhysCost; - SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); - SceneObjectGroup grp = null; - if (part != null) - grp = part.ParentGroup; - if (grp != null) + grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost); + + LLSDxmlEncode.AddMap(uuid.ToString(), lsl); + + LLSDxmlEncode.AddElem("linked_set_resource_cost", linksetCost, lsl); + LLSDxmlEncode.AddElem("resource_cost", partCost, lsl); + LLSDxmlEncode.AddElem("physics_cost", partPhysCost, lsl); + LLSDxmlEncode.AddElem("linked_set_physics_cost", linksetPhysCost, lsl); + LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl); + + LLSDxmlEncode.AddEndMap(lsl); + } + } + if(!haveone) { - float linksetCost; - float linksetPhysCost; - float partCost; - float partPhysCost; - - grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost); - - OSDMap object_data = new OSDMap(); - object_data["linked_set_resource_cost"] = linksetCost; - object_data["resource_cost"] = partCost; - object_data["physics_cost"] = partPhysCost; - object_data["linked_set_physics_cost"] = linksetPhysCost; - object_data["resource_limiting_type"] = "legacy"; - resp[uuid.ToString()] = object_data; + LLSDxmlEncode.AddMap(UUID.Zero.ToString(), lsl); + LLSDxmlEncode.AddElem("linked_set_resource_cost", 0, lsl); + LLSDxmlEncode.AddElem("resource_cost", 0, lsl); + LLSDxmlEncode.AddElem("physics_cost", 0, lsl); + LLSDxmlEncode.AddElem("linked_set_physics_cost", 0, lsl); + LLSDxmlEncode.AddElem("resource_limiting_type", "legacy", lsl); + LLSDxmlEncode.AddEndMap(lsl); } + LLSDxmlEncode.AddEndMap(lsl); } - if(resp.Count == 0) - { - OSDMap object_data = new OSDMap(); - object_data["linked_set_resource_cost"] = 0; - object_data["resource_cost"] = 0; - object_data["physics_cost"] = 0; - object_data["linked_set_physics_cost"] = 0; - resp[UUID.Zero.ToString()] = object_data; - } - string response = OSDParser.SerializeLLSDXmlString(resp); - return response; + + LLSDxmlEncode.AddEnd(lsl); + return lsl.ToString(); } public string ResourceCostSelected(string request, string path, @@ -1825,13 +1845,13 @@ namespace OpenSim.Region.ClientStack.Linden Dictionary names = m_UserManager.GetUsersNames(ids); StringBuilder lsl = new StringBuilder(names.Count * 256 + 256); - LLSDxmlEncode.AddStartHeader(lsl); - LLSDxmlEncode.AddStartMap(lsl); + LLSDxmlEncode.AddStart(lsl); + LLSDxmlEncode.AddMap(lsl); if(names.Count == 0) LLSDxmlEncode.AddEmpyArray("agents", lsl); else { - LLSDxmlEncode.AddStartArray("agents", lsl); + LLSDxmlEncode.AddArray("agents", lsl); foreach (KeyValuePair kvp in names) { @@ -1846,7 +1866,7 @@ namespace OpenSim.Region.ClientStack.Linden if(parts[0] == "Unknown") continue; - LLSDxmlEncode.AddStartMap(lsl); + LLSDxmlEncode.AddMap(lsl); LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl); LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl); LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl); @@ -1861,7 +1881,7 @@ namespace OpenSim.Region.ClientStack.Linden } LLSDxmlEncode.AddEndMap(lsl); - LLSDxmlEncode.AddEndHeader(lsl); + LLSDxmlEncode.AddEnd(lsl); // Full content request httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; -- cgit v1.1