avoid a possible null ref; cosmetics

This commit is contained in:
UbitUmarov
2022-02-09 23:08:58 +00:00
parent 38d3346a6a
commit 9d390564a9
3 changed files with 28 additions and 41 deletions

View File

@@ -491,7 +491,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
foreach (Scene scene in m_Scenes)
{
ScenePresence presence = scene.GetScenePresence(agentID);
if (presence != null && !presence.IsChildAgent)
if (presence != null && !presence.IsDeleted && !presence.IsChildAgent)
return presence.ControllingClient;
}
}
@@ -627,8 +627,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message);
return true;
if(region != null)
{
m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message);
return true;
}
}
}
// If the prospective friend is not online, he'll get the message upon login.

View File

@@ -776,7 +776,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!m_uMan.IsLocalGridUser(friendID))
{
string friendsURL = m_uMan.GetUserServerURL(friendID, "FriendsServerURI");
if (friendsURL != string.Empty)
if (!string.IsNullOrEmpty(friendsURL))
{
m_log.DebugFormat("[HGFRIENDS MODULE]: Forwading friendship from {0} to {1} @ {2}", agentID, friendID, friendsURL);
GridRegion region = new GridRegion();