From 86d18d61498659a18baf30d18d2f74bb6fcdd9da Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 12 Dec 2021 18:06:54 -0600 Subject: [PATCH] Attempting to reach parsing parity with xmlrpc on LLSD login code. Appears Second Life is broken, but this should do for now... --- .../StructuredData.cs | 10 ++ LibreMetaverse/Login.cs | 102 +++++++++++++++--- 2 files changed, 99 insertions(+), 13 deletions(-) diff --git a/LibreMetaverse.StructuredData/StructuredData.cs b/LibreMetaverse.StructuredData/StructuredData.cs index 73dbb20b..8f911e3e 100644 --- a/LibreMetaverse.StructuredData/StructuredData.cs +++ b/LibreMetaverse.StructuredData/StructuredData.cs @@ -893,6 +893,11 @@ public override OSD Copy() return new OSDMap(new Dictionary(_mMap)); } + public Hashtable ToHashtable() + { + return new Hashtable(_mMap); + } + #region IDictionary Implementation public int Count => _mMap.Count; @@ -1125,6 +1130,11 @@ public override string ToString() return OSDParser.SerializeJsonString(this, true); } + public ArrayList ToArrayList() + { + return new ArrayList(_mArray); + } + #region IList Implementation public int Count => _mArray.Count; diff --git a/LibreMetaverse/Login.cs b/LibreMetaverse/Login.cs index 77056edf..1601c1e3 100644 --- a/LibreMetaverse/Login.cs +++ b/LibreMetaverse/Login.cs @@ -365,27 +365,46 @@ public void Parse(OSDMap reply) } catch (OSDException e) { - Logger.Log("Login server returned (some) invalid data: " + e.Message, Helpers.LogLevel.Warning); + Logger.Log("Login server returned (some) invalid data", Helpers.LogLevel.Warning, e); } // Home - var osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString()); + if (reply.ContainsKey("home_info")) + { + if (reply["home_info"].Type == OSDType.Map) + { + var map = (OSDMap)reply["home_info"]; + Home.Position = ParseVector3("position", map); + Home.LookAt = ParseVector3("look_at", map); - if (osdHome.Type == OSDType.Map) + var coords = (OSDArray)OSDParser.DeserializeLLSDNotation(map["region_handle"].ToString()); + if (coords.Type == OSDType.Array) + { + Home.RegionHandle = (coords.Count == 2) + ? Utils.UIntsToLong((uint)coords[0].AsInteger(), (uint)coords[1].AsInteger()) : 0; + } + } + } + else if (reply.ContainsKey("home")) { - var home = (OSDMap)osdHome; + var osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString()); - OSD homeRegion; - if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array) + if (osdHome.Type == OSDType.Map) { - var homeArray = (OSDArray)homeRegion; - Home.RegionHandle = homeArray.Count == 2 - ? Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()) - : 0; - } + var home = (OSDMap)osdHome; - Home.Position = ParseVector3("position", home); - Home.LookAt = ParseVector3("look_at", home); + OSD homeRegion; + if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array) + { + var homeArray = (OSDArray)homeRegion; + Home.RegionHandle = homeArray.Count == 2 + ? Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()) + : 0; + } + + Home.Position = ParseVector3("position", home); + Home.LookAt = ParseVector3("look_at", home); + } } else { @@ -433,6 +452,63 @@ public void Parse(OSDMap reply) LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply); LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply); LibrarySkeleton = ParseInventorySkeleton("inventory-skel-lib", reply); + + if (reply.ContainsKey("account_level_benefits")) + { + if (reply["account_level_benefits"].Type == OSDType.Map) + { + AccountLevelBenefits = ((OSDMap)reply["account_level_benefits"]).ToHashtable(); + } + } + + if (reply.ContainsKey("classified_categories")) + { + if (reply["classified_categories"].Type == OSDType.Array) + { + ClassifiedCategories = ((OSDArray)reply["classified_categories"]).ToArrayList(); + } + } + + if (reply.ContainsKey("event_categories")) + { + if (reply["event_categories"].Type == OSDType.Array) + { + EventCategories = ((OSDArray)reply["event_categories"]).ToArrayList(); + } + } + + if (reply.ContainsKey("global-textures")) + { + if (reply["global-textures"].Type == OSDType.Array) + { + GlobalTextures = ((OSDArray)reply["global-textures"]).ToArrayList(); + } + } + + if (reply.ContainsKey("premium_packages")) + { + if (reply["premium_packages"].Type == OSDType.Map) + { + PremiumPackages = ((OSDMap)reply["premium_packages"]).ToHashtable(); + } + } + + if (reply.ContainsKey("ui-config")) + { + if (reply["ui-config"].Type == OSDType.Array) + { + UiConfig = ((OSDArray)reply["ui-config"]).ToArrayList(); + } + } + + if (reply.ContainsKey("max-agent-groups")) + { + MaxAgentGroups = (int)ParseUInt("max-agent-groups", reply); + } + else + { + MaxAgentGroups = -1; + } } public void Parse(Hashtable reply)