Skip to content

Commit

Permalink
Fixing some NULL references and a JSON_INVALID that should have been …
Browse files Browse the repository at this point in the history
…fixed earlier
  • Loading branch information
fly-man- committed Jul 2, 2018
1 parent 5daa6c5 commit 4aef37f
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions WhiteCore/ScriptEngine/DotNetEngine/APIs/LSL/LSL_Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6755,32 +6755,38 @@ public LSL_Integer llOverMyLand(string id)
UUID key = new UUID();
if (UUID.TryParse(id, out key))
{
IScenePresence presence = World.GetScenePresence(key);
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
if (presence != null) // object is an avatar
try
{
if (parcelManagement != null)
IScenePresence presence = World.GetScenePresence(key);
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
if (presence != null) // object is an avatar
{
if (m_host.OwnerID
== parcelManagement.GetLandObject(
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
return 1;
}
}
else // object is not an avatar
{
ISceneChildEntity obj = World.GetSceneObjectPart(key);
if (obj != null)
if (parcelManagement != null)
{
if (m_host.OwnerID
== parcelManagement.GetLandObject(
obj.AbsolutePosition.X, obj.AbsolutePosition.Y).LandData.OwnerID)
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
return 1;
}
else // object is not an avatar
{
ISceneChildEntity obj = World.GetSceneObjectPart(key);
if (obj != null)
if (parcelManagement != null)
{
if (m_host.OwnerID == parcelManagement.GetLandObject(obj.AbsolutePosition.X, obj.AbsolutePosition.Y).LandData.OwnerID)
return 1;
}
}
}
}
catch (NullReferenceException)
{
// lots of places to get nulls
// eg, presence.AbsolutePosition
return 0;
}
}

return 0;
}

Expand Down Expand Up @@ -13680,11 +13686,16 @@ public LSL_String llGetAnimationOverride(string anim_state)

public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers)
{
OSD o = OSDParser.DeserializeJson(json);
OSD specVal = JsonGetSpecific(o, specifiers, 0);
if (specVal != null)
try
{
OSD o = OSDParser.DeserializeJson(json);
OSD specVal = JsonGetSpecific(o, specifiers, 0);
return specVal.AsString();
return string.Empty;
}
catch (Exception)
{
return ScriptBaseClass.JSON_INVALID;
}
}

public LSL_List llJson2List(LSL_String json)
Expand Down

0 comments on commit 4aef37f

Please sign in to comment.