From e5cdba1cb49346308fb0e9699c3a6386b487d97b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 15:09:35 +0000 Subject: Fix region crossings and access to inventory after changing regions within the same simulator --- .../Modules/Avatar/Inventory/InventoryModule.cs | 28 +++++++++++++++++++--- OpenSim/Region/Environment/Scenes/Scene.cs | 17 +++++++++++++ .../Scenes/SceneCommunicationService.cs | 5 ++-- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 7 ++++-- 4 files changed, 50 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs index 03bbaf3..5f0d83d 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory private IDictionary m_pendingOffers = new Dictionary(); private List m_Scenelist = new List(); + private Dictionary m_AgentRegions = new Dictionary(); #region IRegionModule Members @@ -61,6 +62,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory scene.RegisterModuleInterface(this); scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnClientClosed += ClientLoggedOut; } } @@ -223,8 +225,28 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory } } -// public void TestFunction() -// { -// } + public void SetRootAgentScene(LLUUID agentID, Scene scene) + { + m_AgentRegions[agentID] = scene; + } + + public bool NeedSceneCacheClear(LLUUID agentID, Scene scene) + { + if (!m_AgentRegions.ContainsKey(agentID)) + return true; + + if(m_AgentRegions[agentID] == scene) + { + m_AgentRegions.Remove(agentID); + return true; + } + return false; + } + + public void ClientLoggedOut(LLUUID agentID) + { + if (m_AgentRegions.ContainsKey(agentID)) + m_AgentRegions.Remove(agentID); + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 4564cf1..7d55f7e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -3860,5 +3860,22 @@ namespace OpenSim.Region.Environment.Scenes client.SendLayerData(patchX, patchY, Heightmap.GetFloatsSerialised()); } + public void SetRootAgentScene(LLUUID agentID) + { + IInventoryModule inv = RequestModuleInterface(); + if(inv == null) + return; + + inv.SetRootAgentScene(agentID, this); + } + + public bool NeedSceneCacheClear(LLUUID agentID) + { + IInventoryModule inv = RequestModuleInterface(); + if(inv == null) + return true; + + return inv.NeedSceneCacheClear(agentID, this); + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index adad7d3..f1af15f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -653,9 +653,10 @@ namespace OpenSim.Region.Environment.Scenes SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList()); } // if (teleport success) // seems to be always success here - // the user may change thier profile information in other region, + // the user may change their profile information in other region, // so the userinfo in UserProfileCache is not reliable any more, delete it - m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); + if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) + m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); m_log.InfoFormat("User {0} is going to another region, profile cache removed", avatar.UUID); } else diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 8059a78..706fd61 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -606,6 +606,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void MakeRootAgent(LLVector3 pos, bool isFlying) { + m_scene.SetRootAgentScene(m_uuid); + IAvatarFactory ava = m_scene.RequestModuleInterface(); if (ava != null) { @@ -2010,9 +2012,10 @@ namespace OpenSim.Region.Environment.Scenes m_scene.SendKillObject(m_localId); m_scene.NotifyMyCoarseLocationChange(); - // the user may change thier profile information in other region, + // the user may change their profile information in other region, // so the userinfo in UserProfileCache is not reliable any more, delete it - m_scene.CommsManager.UserProfileCacheService.RemoveUser(UUID); + if(m_scene.NeedSceneCacheClear(UUID)) + m_scene.CommsManager.UserProfileCacheService.RemoveUser(UUID); m_log.InfoFormat("User {0} is going to another region, profile cache removed", UUID); } else -- cgit v1.1