From 7421708ba19581cdd65f38524882a67d4af785a7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 15 Aug 2010 18:10:54 -0700 Subject: [PATCH] Addresses mantis #4929. Agent was being logged off the grid too soon -- things may still fail. --- .../EntityTransfer/EntityTransferModule.cs | 15 +++++++++++++-- .../EntityTransfer/HGEntityTransferModule.cs | 14 ++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ab1cfc352b..2738346ace 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -307,7 +307,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; // Let's create an agent there if one doesn't exist yet. - if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason)) + bool logout = false; + if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) { sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); @@ -434,8 +435,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it CrossAttachmentsIntoNewRegion(finalDestination, sp, true); + // Well, this is it. The agent is over there. + KillEntity(sp.Scene, sp.LocalId); + // May need to logout or other cleanup + AgentHasMovedAway(sp.ControllingClient.SessionId, logout); + // Now let's make it officially a child agent sp.MakeChildAgent(); @@ -483,8 +489,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } - protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) { + logout = false; return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); } @@ -500,6 +507,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } + protected virtual void AgentHasMovedAway(UUID sessionID, bool logout) + { + } + protected void KillEntity(Scene scene, uint localID) { scene.SendKillObject(localID); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 7d26e3ff5f..d49d18db36 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -140,9 +140,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return false; } - protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected override void AgentHasMovedAway(UUID sessionID, bool logout) + { + if (logout) + // Log them out of this grid + m_aScene.PresenceService.LogoutAgent(sessionID); + } + + protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) { reason = string.Empty; + logout = false; int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { @@ -152,9 +160,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); - if (success) - // Log them out of this grid - m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID); + logout = success; return success; }