From 43b2ff1d112174c36bb18caf353945afc6390840 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 1 Aug 2008 18:49:48 +0000 Subject: * Drop cached inventory from the local region when a user crosses out into a remote region * May resolves inventory problems that occur when the user moves between two regions` * e.g. if the user moves to a second region, adds an inventory item, moves back to the original region then tries to manipulate that item * Not yet implemented for teleport --- OpenSim/Region/Environment/Scenes/Scene.cs | 7 ++-- .../Scenes/SceneCommunicationService.cs | 2 ++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 39 +++++++++++++++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index c4078c9..f81248b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1976,7 +1976,7 @@ namespace OpenSim.Region.Environment.Scenes #region Add/Remove Avatar Methods /// - /// + /// Register the new client with the scene /// /// @@ -1991,7 +1991,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_restorePresences.ContainsKey(client.AgentId)) { - m_log.Info("[REGION]: Restore Scene Presence"); + m_log.Info("[REGION]: Restoring Scene Presence"); presence = m_restorePresences[client.AgentId]; m_restorePresences.Remove(client.AgentId); @@ -2015,9 +2015,8 @@ namespace OpenSim.Region.Environment.Scenes } else { - m_log.Info("[REGION]: Add New Scene Presence"); + m_log.Info("[REGION]: Adding New Scene Presence"); - //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); CommsManager.UserProfileCacheService.AddNewUser(client); CreateAndAddScenePresence(client, child); diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index b9bf42b..b35e60f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -557,8 +557,10 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 lookAt, uint flags) { bool destRegionUp = false; + if (regionHandle == m_regionInfo.RegionHandle) { + // Teleport within the same region avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); avatar.Teleport(position); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 221da0e..bb3d953 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -35,6 +35,7 @@ using libsecondlife; using libsecondlife.Packets; using log4net; using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; @@ -646,7 +647,7 @@ namespace OpenSim.Region.Environment.Scenes /// when an agent departs this region for a neighbor, this gets called. /// /// It doesn't get called for a teleport. Reason being, an agent that - /// teleports out may not be anywhere near this region + /// teleports out may not end up anywhere near this region /// public void MakeChildAgent() { @@ -1877,6 +1878,7 @@ namespace OpenSim.Region.Environment.Scenes { if (IsChildAgent) return; + LLVector3 pos2 = AbsolutePosition; LLVector3 vel = Velocity; @@ -1947,10 +1949,30 @@ namespace OpenSim.Region.Environment.Scenes // in case both scenes are being hosted on the same region server. Messy m_scene.RemoveCapsHandler(UUID); newpos = newpos + (vel); - bool res = + + bool crossingToRemoteRegion = neighbourRegion.ExternalHostName != m_scene.RegionInfo.ExternalHostName; + if (crossingToRemoteRegion) + { + m_scene.CommsManager.UserProfileCacheService.RemoveUser(UUID); + } + else + { + CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(UUID); + + if (userInfo != null) + { + userInfo.DropInventory(); + } + else + { + m_log.WarnFormat("[SCENE PRESENCE]: No cached user info found for {0} {1} on leaving region", Name, UUID); + } + } + + bool crossingSuccessful = m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos, - m_physicsActor.Flying); - if (res) + m_physicsActor.Flying); + if (crossingSuccessful) { AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); @@ -1965,12 +1987,19 @@ namespace OpenSim.Region.Environment.Scenes m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, capsPath); MakeChildAgent(); - CrossAttachmentsIntoNewRegion(neighbourHandle); + CrossAttachmentsIntoNewRegion(neighbourHandle); + m_scene.SendKillObject(m_localId); m_scene.NotifyMyCoarseLocationChange(); } else { + // Restore the user structures that we needed to delete before asking the receiving region to complete the crossing + if (crossingToRemoteRegion) + m_scene.CommsManager.UserProfileCacheService.AddNewUser(m_controllingClient); + + m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(UUID); + m_scene.AddCapsHandler(UUID); } } -- cgit v1.1