Skip to content

Commit

Permalink
Glob on previous handling for Login response home field. I thought LL…
Browse files Browse the repository at this point in the history
… had realized their mistake on breaking API. My bad.
  • Loading branch information
cinderblocks committed Dec 7, 2021
1 parent bd3705f commit a680277
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions LibreMetaverse/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,22 +495,41 @@ public void Parse(Hashtable reply)
// Home
if (Home.RegionHandle == 0 && reply.ContainsKey("home"))
{
var osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].ToString());

if (osdHome.Type == OSDType.Map)
{
var home = (OSDMap)osdHome;

OSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
{
var coords = (OSDArray)homeRegion;
Home.RegionHandle = (coords.Count == 2)
? Utils.UIntsToLong((uint)coords[0].AsInteger(), (uint)coords[1].AsInteger()) : 0;

if (reply?["home"] is Hashtable map)
{
Home.Position = ParseVector3("position", map);
Home.LookAt = ParseVector3("look_at", 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?["home"] is string osdString)
{
var osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].ToString());

if (osdHome.Type == OSDType.Map)
{
var home = (OSDMap)osdHome;

OSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
{
var coords = (OSDArray)homeRegion;
Home.RegionHandle = (coords.Count == 2)
? Utils.UIntsToLong((uint)coords[0].AsInteger(), (uint)coords[1].AsInteger()) : 0;

}
Home.Position = ParseVector3("position", home);
Home.LookAt = ParseVector3("look_at", home);
}
Home.Position = ParseVector3("position", home);
Home.LookAt = ParseVector3("look_at", home);
}
else
{
throw new Exception("Could not parse 'home' in Login Response");
}
}
} catch (Exception ex)
Expand Down

0 comments on commit a680277

Please sign in to comment.