aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
diff options
context:
space:
mode:
authorDiva Canto2010-06-04 10:59:59 -0700
committerDiva Canto2010-06-04 10:59:59 -0700
commit952029380a6a038e382dd3b2c312b3e16ff08625 (patch)
tree400586c159859d0ff437685d4c37179e8cba89f1 /OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.zip
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.gz
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.bz2
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.xz
Fixed a couple of buglets in Friendship offers / acceptance / decline when avies are in different sims.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs56
1 files changed, 33 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0c81f44..0050653 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -111,10 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
111 111
112 protected IGridService GridService 112 protected IGridService GridService
113 { 113 {
114 get 114 get { return m_Scenes[0].GridService; }
115 { 115 }
116 return m_Scenes[0].GridService; 116
117 } 117 public IUserAccountService UserAccountService
118 {
119 get { return m_Scenes[0].UserAccountService; }
118 } 120 }
119 121
120 public IScene Scene 122 public IScene Scene
@@ -220,33 +222,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
220 222
221 client.OnLogout += OnLogout; 223 client.OnLogout += OnLogout;
222 224
223 if (m_Friends.ContainsKey(client.AgentId)) 225 lock (m_Friends)
224 { 226 {
225 m_Friends[client.AgentId].Refcount++; 227 if (m_Friends.ContainsKey(client.AgentId))
226 return; 228 {
227 } 229 m_Friends[client.AgentId].Refcount++;
230 return;
231 }
228 232
229 UserFriendData newFriends = new UserFriendData(); 233 UserFriendData newFriends = new UserFriendData();
230 234
231 newFriends.PrincipalID = client.AgentId; 235 newFriends.PrincipalID = client.AgentId;
232 newFriends.Friends = m_FriendsService.GetFriends(client.AgentId); 236 newFriends.Friends = m_FriendsService.GetFriends(client.AgentId);
233 newFriends.Refcount = 1; 237 newFriends.Refcount = 1;
234 newFriends.RegionID = UUID.Zero; 238 newFriends.RegionID = UUID.Zero;
235 239
236 m_Friends.Add(client.AgentId, newFriends); 240 m_Friends.Add(client.AgentId, newFriends);
241 }
237 242
238 //StatusChange(client.AgentId, true); 243 //StatusChange(client.AgentId, true);
239 } 244 }
240 245
241 private void OnClientClosed(UUID agentID, Scene scene) 246 private void OnClientClosed(UUID agentID, Scene scene)
242 { 247 {
243 if (m_Friends.ContainsKey(agentID)) 248 lock (m_Friends)
244 { 249 if (m_Friends.ContainsKey(agentID))
245 if (m_Friends[agentID].Refcount == 1) 250 {
246 m_Friends.Remove(agentID); 251 if (m_Friends[agentID].Refcount == 1)
247 else 252 m_Friends.Remove(agentID);
248 m_Friends[agentID].Refcount--; 253 else
249 } 254 m_Friends[agentID].Refcount--;
255 }
250 } 256 }
251 257
252 private void OnLogout(IClientAPI client) 258 private void OnLogout(IClientAPI client)
@@ -518,12 +524,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
518 524
519 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 525 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
520 { 526 {
527 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
528
521 FriendsService.StoreFriend(agentID, friendID.ToString(), 1); 529 FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
522 FriendsService.StoreFriend(friendID, agentID.ToString(), 1); 530 FriendsService.StoreFriend(friendID, agentID.ToString(), 1);
523 // update the local cache 531 // update the local cache
524 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); 532 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID);
525 533
526 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
527 534
528 // 535 //
529 // Notify the friend 536 // Notify the friend
@@ -572,7 +579,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
572 if (friendSession != null) 579 if (friendSession != null)
573 { 580 {
574 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 581 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
575 m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); 582 if (region != null)
583 m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID);
584 else
585 m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID);
576 } 586 }
577 } 587 }
578 } 588 }