Skip to content

Commit

Permalink
Attempting to reach parsing parity with xmlrpc on LLSD login code. Ap…
Browse files Browse the repository at this point in the history
…pears Second Life is broken, but this should do for now...
  • Loading branch information
cinderblocks committed Dec 13, 2021
1 parent 51c5fbf commit 86d18d6
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 13 deletions.
10 changes: 10 additions & 0 deletions LibreMetaverse.StructuredData/StructuredData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,11 @@ public override OSD Copy()
return new OSDMap(new Dictionary<string, OSD>(_mMap));
}

public Hashtable ToHashtable()
{
return new Hashtable(_mMap);
}

#region IDictionary Implementation

public int Count => _mMap.Count;
Expand Down Expand Up @@ -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;
Expand Down
102 changes: 89 additions & 13 deletions LibreMetaverse/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 86d18d6

Please sign in to comment.