diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index db8e9b5712..1744e038c1 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -554,9 +554,9 @@ namespace OpenSim.Framework internal void ReplaceAttachment(AvatarAttachment attach) { - //m_log.DebugFormat( - // "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}", - // attach.ItemID, attach.AssetID, attach.AttachPoint); + //m_log.DebugFormat( + // "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}", + // attach.ItemID, attach.AssetID, attach.AttachPoint); lock (m_attachments) { diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index d1fbd1874f..e565e01202 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -130,8 +130,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected bool m_Enabled = false; - public Scene Scene { get; private set; } + protected Scene m_scene; + public Scene Scene + { + get + { + return m_scene; + } + } + protected string m_sceneName; + protected RegionInfo m_sceneRegionInfo; + protected ulong m_sceneRegionHandler; /// /// Handles recording and manipulation of state for entities that are in transfer within or between regions /// (cross or teleport). @@ -277,7 +287,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!m_Enabled) return; - Scene = scene; + m_scene = scene; + m_sceneName = scene.Name; + m_sceneRegionInfo = scene.RegionInfo; + m_sceneRegionHandler = m_sceneRegionInfo.RegionHandle; m_thisGridInfo = scene.SceneGridInfo; m_interRegionTeleportAttempts = @@ -288,7 +301,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer + "You can get successfully teleports by subtracting aborts, cancels and teleport failures from this figure.", "", "entitytransfer", - Scene.Name, + m_sceneName, StatType.Push, null, StatVerbosity.Debug); @@ -300,7 +313,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "The chief action is simultaneous logout whilst teleporting.", "", "entitytransfer", - Scene.Name, + m_sceneName, StatType.Push, null, StatVerbosity.Debug); @@ -312,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer null, "", "entitytransfer", - Scene.Name, + m_sceneName, StatType.Push, null, StatVerbosity.Debug); @@ -324,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "This number may not be very helpful in open-grid/hg situations as the network connectivity/quality of destinations is uncontrollable.", "", "entitytransfer", - Scene.Name, + m_sceneName, StatType.Push, null, StatVerbosity.Debug); @@ -372,7 +385,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!m_Enabled) return; - m_eqModule = Scene.RequestModuleInterface(); + m_eqModule = m_scene.RequestModuleInterface(); } #endregion @@ -385,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport request from {0} in {1} due to simultaneous logout", - client.Name, Scene.Name); + client.Name, m_sceneName); } } @@ -394,49 +407,49 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_entityTransferStateMachine.UpdateInTransit(client.AgentId, AgentTransferState.Cancelling); m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, Scene.Name); + "[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, m_sceneName); } // Attempt to teleport the ScenePresence to the specified position in the specified region (spec'ed by its handle). public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { - if (sp.Scene.Permissions.IsGridGod(sp.UUID)) + UUID spUUID = sp.UUID; + if (m_scene.Permissions.IsGridGod(spUUID)) { // This user will be a God in the destination scene, too teleportFlags |= (uint)TeleportFlags.Godlike; } - else if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) + else if (!m_scene.Permissions.CanTeleport(spUUID)) return; string destinationRegionName = "(not found)"; // Record that this agent is in transit so that we can prevent simultaneous requests and do later detection // of whether the destination region completes the teleport. - if (!m_entityTransferStateMachine.SetInTransit(sp.UUID)) + if (!m_entityTransferStateMachine.SetInTransit(spUUID)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2}@{3} - agent is already in transit.", - sp.Name, sp.UUID, position, regionHandle); + sp.Name, spUUID, position, regionHandle); sp.ControllingClient.SendTeleportFailed("Previous teleport process incomplete. Please retry shortly."); return; } - RegionInfo spRi = sp.Scene.RegionInfo; try { - if (Util.CompareRegionHandles(regionHandle, position, spRi, out Vector3 roffset)) + if (Util.CompareRegionHandles(regionHandle, position, m_sceneRegionInfo, out Vector3 roffset)) { if(!sp.AllowMovement) { sp.ControllingClient.SendTeleportFailed("You are frozen"); - m_entityTransferStateMachine.ResetFromTransit(sp.UUID); + m_entityTransferStateMachine.ResetFromTransit(spUUID); return; } - destinationRegionName = spRi.RegionName; + destinationRegionName = m_sceneName; TeleportAgentWithinRegion(sp, roffset, lookAt, teleportFlags); } else // Another region possibly in another simulator @@ -444,8 +457,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer GridRegion finalDestination = null; try { - TeleportAgentToDifferentRegion( - sp, regionHandle, position, lookAt, teleportFlags, out finalDestination); + TeleportAgentToDifferentRegion(sp, regionHandle, position, lookAt, teleportFlags, out finalDestination); } finally { @@ -459,14 +471,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.ErrorFormat( "[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}", - sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName, + sp.Name, sp.AbsolutePosition, m_sceneName, position, destinationRegionName, e.Message, e.StackTrace); if(sp != null && sp.ControllingClient != null && !sp.IsDeleted) sp.ControllingClient.SendTeleportFailed("Internal error"); } finally { - m_entityTransferStateMachine.ResetFromTransit(sp.UUID); + m_entityTransferStateMachine.ResetFromTransit(spUUID); } } @@ -481,23 +493,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}", - sp.Name, position, sp.Scene.RegionInfo.RegionName); + sp.Name, position, m_sceneName); // Teleport within the same region - if (!sp.Scene.PositionIsInCurrentRegion(position) || position.Z < 0) + if (!m_scene.PositionIsInCurrentRegion(position) || position.Z < 0) { Vector3 emergencyPos = new Vector3(128, 128, 128); m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2} in {3}. Substituting {4}", - position, sp.Name, sp.UUID, Scene.Name, emergencyPos); + position, sp.Name, sp.UUID, m_sceneName, emergencyPos); position = emergencyPos; } // Check Default Location (Also See ScenePresence.CompleteMovement) if (position.X == 128f && position.Y == 128f && position.Z == 22.5f) - position = sp.Scene.RegionInfo.DefaultLandingPoint; + position = m_sceneRegionInfo.DefaultLandingPoint; // TODO: Get proper AVG Height float localHalfAVHeight = 0.8f; @@ -507,7 +519,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer float posZLimit = 22; // TODO: Check other Scene HeightField - posZLimit = sp.Scene.Heightmap[(int)position.X, (int)position.Y]; + posZLimit = m_scene.Heightmap[(int)position.X, (int)position.Y]; posZLimit += localHalfAVHeight + 0.1f; @@ -525,7 +537,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.Flying) teleportFlags |= (uint)TeleportFlags.IsFlying; - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); + UUID spUUID = sp.UUID; + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.Transferring); sp.ControllingClient.SendTeleportStart(teleportFlags); lookAt.Z = 0f; @@ -542,15 +555,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Velocity = Vector3.Zero; sp.Teleport(position); - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.ReceivedAtDestination); + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.ReceivedAtDestination); foreach (SceneObjectGroup grp in sp.GetAttachments()) { if ((grp.ScriptEvents & scriptEvents.changed) != 0) - sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); + m_scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); } - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.CleaningUp); } /// @@ -568,7 +581,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { // Get destination region taking into account that the address could be an offset // region inside a varregion. - GridRegion reg = GetTeleportDestinationRegion(sp.Scene.GridService, sp.Scene.RegionInfo.ScopeID, regionHandle, ref position); + GridRegion reg = GetTeleportDestinationRegion(m_scene.GridService, m_sceneRegionInfo.ScopeID, regionHandle, ref position); if( reg == null) { @@ -593,7 +606,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - string homeURI = Scene.GetAgentHomeURI(sp.ControllingClient.AgentId); + string homeURI = m_scene.GetAgentHomeURI(sp.ControllingClient.AgentId); string reason = String.Empty; finalDestination = GetFinalDestination(reg, sp.ControllingClient.AgentId, homeURI, out reason); @@ -687,7 +700,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_log.ErrorFormat( "[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}", - sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, finalDestination.RegionName, + sp.Name, sp.AbsolutePosition, m_sceneName, position, finalDestination.RegionName, e.Message, e.StackTrace); sp.ControllingClient.SendTeleportFailed("Internal error"); @@ -712,18 +725,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - string homeURI = Scene.GetAgentHomeURI(sp.ControllingClient.AgentId); + string homeURI = m_scene.GetAgentHomeURI(sp.ControllingClient.AgentId); m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}", - sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName, + sp.Name, sp.UUID, m_sceneName, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); - RegionInfo sourceRegion = sp.Scene.RegionInfo; - ulong destinationHandle = finalDestination.RegionHandle; - if(destinationHandle == sourceRegion.RegionHandle) + if(destinationHandle == m_sceneRegionHandler) { sp.ControllingClient.SendTeleportFailed("Can't teleport to a region on same map position. Try going to another region first, then retry from there"); return; @@ -747,8 +758,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason; EntityTransferContext ctx = new EntityTransferContext(); - if (!Scene.SimulationService.QueryAccess( - finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, sp.Scene.GetFormatsOffered(), ctx, out reason)) + if (!m_scene.SimulationService.QueryAccess( + finalDestination, sp.UUID, homeURI, true, position, m_scene.GetFormatsOffered(), ctx, out reason)) { sp.ControllingClient.SendTeleportFailed(reason); @@ -815,22 +826,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agentCircuit.Id0 = currentAgentCircuit.Id0; } - uint newRegionX, newRegionY, oldRegionX, oldRegionY; + uint newRegionX, newRegionY; Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY); - Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY); - int oldSizeX = (int)sourceRegion.RegionSizeX; - int oldSizeY = (int)sourceRegion.RegionSizeY; + int oldSizeX = (int)m_sceneRegionInfo.RegionSizeX; + int oldSizeY = (int)m_sceneRegionInfo.RegionSizeY; int newSizeX = finalDestination.RegionSizeX; int newSizeY = finalDestination.RegionSizeY; - bool OutSideViewRange = !sp.IsInLocalTransit || NeedsNewAgent(sp.RegionViewDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, + bool OutSideViewRange = !sp.IsInLocalTransit || NeedsNewAgent(sp.RegionViewDistance, + m_sceneRegionInfo.RegionLocX, newRegionX, m_sceneRegionInfo.RegionLocY, newRegionY, oldSizeX, oldSizeY, newSizeX, newSizeY); if (OutSideViewRange) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} size {3},{4} needs new child agent for agent {5} from {6}", - finalDestination.RegionName, newRegionX, newRegionY,newSizeX, newSizeY, sp.Name, Scene.Name); + finalDestination.RegionName, newRegionX, newRegionY,newSizeX, newSizeY, sp.Name, m_sceneName); //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); @@ -857,7 +868,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Using TP V1 for {0} going from {1} to {2}", - sp.Name, Scene.Name, finalDestination.RegionName); + sp.Name, m_sceneName, finalDestination.RegionName); string capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); List childRegionsToClose = sp.GetChildAgentsToClose(destinationHandle, finalDestination.RegionSizeX, finalDestination.RegionSizeY); @@ -885,29 +896,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling) + UUID spUUID = sp.UUID; + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Cancelling) { m_interRegionTeleportCancels.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } - else if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) + else if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Aborting) { m_interRegionTeleportAborts.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after CreateAgent due to previous client close.", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } // Past this point we have to attempt clean up if the teleport fails, so update transfer state. - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.Transferring); // OK, it got this agent. Let's close some child agents @@ -918,7 +930,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // The EnableSimulator message makes the client establish a connection with the destination // simulator by sending the initial UseCircuitCode UDP packet to the destination containing the // correct circuit code. - m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID, + m_eqModule.EnableSimulator(destinationHandle, endPoint, spUUID, finalDestination.RegionSizeX, finalDestination.RegionSizeY); m_log.DebugFormat("{0} Sent EnableSimulator. regName={1}, size=<{2},{3}>", LogHeader, finalDestination.RegionName, finalDestination.RegionSizeX, finalDestination.RegionSizeY); @@ -931,7 +943,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // unnecessary - teleport will succeed and SEED caps will be requested without it (though possibly // only on TeleportFinish). This is untested for region teleport between different simulators // though this probably also works. - m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, finalDestination.RegionHandle, + m_eqModule.EstablishAgentCommunication(spUUID, endPoint, capsPath, finalDestination.RegionHandle, finalDestination.RegionSizeX, finalDestination.RegionSizeY); } else @@ -952,17 +964,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; agent.Position = agentCircuit.startpos; - SetCallbackURL(agent, sp.Scene.RegionInfo); + SetCallbackURL(agent); // We will check for an abort before UpdateAgent since UpdateAgent will require an active viewer to // establish th econnection to the destination which makes it return true. - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Aborting) { m_interRegionTeleportAborts.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} before UpdateAgent", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } @@ -973,33 +985,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // there's a further 10 second wait whilst we attempt to tell the destination to delete the agent in Fail(). if (!UpdateAgent(reg, finalDestination, agent, sp, ctx)) { - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Aborting) { m_interRegionTeleportAborts.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after UpdateAgent due to previous client close.", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Keeping avatar in {2}", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); sp.IsInTransit = false; return; } - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling) + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Cancelling) { m_interRegionTeleportCancels.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination); sp.IsInTransit = false; @@ -1008,7 +1020,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", - capsPath, sp.Scene.RegionInfo.RegionName, sp.Name); + capsPath, m_sceneName, sp.Name); // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator, // where that neighbour simulator could otherwise request a child agent create on the source which then @@ -1018,7 +1030,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // OK, send TPFinish to the client, so that it starts the process of contacting the destination region if (m_eqModule != null) { - m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID, + m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, spUUID, finalDestination.RegionSizeX, finalDestination.RegionSizeY); } else @@ -1030,29 +1042,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation // that the client contacted the destination before we close things here. - if (!m_entityTransferStateMachine.WaitForAgentArrivedAtDestination(sp.UUID)) + if (!m_entityTransferStateMachine.WaitForAgentArrivedAtDestination(spUUID)) { - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Aborting) { m_interRegionTeleportAborts.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after WaitForAgentArrivedAtDestination due to previous client close.", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", - sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); + sp.Name, finalDestination.RegionName, m_sceneName); Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion."); sp.IsInTransit = false; return; } - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.CleaningUp); if(logout) sp.closeAllChildAgents(); @@ -1064,8 +1076,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.HasMovedAway(!(OutSideViewRange || logout)); -// ulong sourceRegionHandle = sp.RegionHandle; - // Now let's make it officially a child agent sp.MakeChildAgent(destinationHandle); @@ -1073,7 +1083,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (NeedsClosing(reg, OutSideViewRange)) { - if (!sp.Scene.IncomingPreCloseClient(sp)) + if (!m_scene.IncomingPreCloseClient(sp)) return; // We need to delay here because Imprudence viewers, unlike v1 or v3, have a short (<200ms, <500ms) delay before @@ -1083,7 +1093,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // This sleep can be increased if necessary. However, whilst it's active, // an agent cannot teleport back to this region if it has teleported away. Thread.Sleep(2000); - sp.Scene.CloseAgent(sp.UUID, false); + m_scene.CloseAgent(sp.UUID, false); } sp.IsInTransit = false; } @@ -1130,31 +1140,32 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling) + UUID spUUID = sp.UUID; + if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Cancelling) { m_interRegionTeleportCancels.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } - else if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) + else if (m_entityTransferStateMachine.GetAgentTransferState(spUUID) == AgentTransferState.Aborting) { m_interRegionTeleportAborts.Value++; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after CreateAgent due to previous client close.", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } // Past this point we have to attempt clean up if the teleport fails, so update transfer state. - m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); + m_entityTransferStateMachine.UpdateInTransit(spUUID, AgentTransferState.Transferring); // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator, // where that neighbour simulator could otherwise request a child agent create on the source which then @@ -1171,7 +1182,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", - capsPath, sp.Scene.RegionInfo.RegionName, sp.Name); + capsPath, m_sceneName, sp.Name); // Let's send a full update of the agent. AgentData agent = new AgentData(); @@ -1185,7 +1196,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.SenderWantsToWaitForRoot = true; if(OutSideViewRange) - SetNewCallbackURL(agent, sp.Scene.RegionInfo); + SetNewCallbackURL(agent); // Reset the do not close flag. This must be done before the destination opens child connections (here // triggered by UpdateAgent) to avoid race conditions. However, we also want to reset it as late as possible @@ -1209,14 +1220,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after UpdateAgent due to previous client close.", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); sp.IsInTransit = false; return; } m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Keeping avatar in {2}", - sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.Name, finalDestination.RegionName, m_sceneName); Fail(sp, finalDestination, logout, agentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); sp.IsInTransit = false; @@ -1224,7 +1235,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } //shut this up for now - m_entityTransferStateMachine.ResetFromTransit(sp.UUID); + m_entityTransferStateMachine.ResetFromTransit(spUUID); //m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); @@ -1261,8 +1272,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!sp.IsDeleted) { m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Closing agent {0} in {1} after teleport {2}", sp.Name, Scene.Name, sp.IsInTransit?"timeout":""); - sp.Scene.CloseAgent(sp.UUID, false); + "[ENTITY TRANSFER MODULE]: Closing agent {0} in {1} after teleport {2}", sp.Name, m_sceneName, sp.IsInTransit?"timeout":""); + m_scene.CloseAgent(spUUID, false); } return; } @@ -1317,11 +1328,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, EntityTransferContext ctx, out string reason, out bool logout) { - GridRegion source = new GridRegion(Scene.RegionInfo); + GridRegion source = new GridRegion(m_sceneRegionInfo); source.RawServerURI = m_thisGridInfo.GateKeeperURL; logout = false; - bool success = Scene.SimulationService.CreateAgent(source, finalDestination, agentCircuit, teleportFlags, ctx, out reason); + bool success = m_scene.SimulationService.CreateAgent(source, finalDestination, agentCircuit, teleportFlags, ctx, out reason); if (success) sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); @@ -1331,25 +1342,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent, ScenePresence sp, EntityTransferContext ctx) { - return Scene.SimulationService.UpdateAgent(finalDestination, agent, ctx); + return m_scene.SimulationService.UpdateAgent(finalDestination, agent, ctx); } - protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) + protected virtual void SetCallbackURL(AgentData agent) { - agent.CallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; + agent.CallbackURI = m_sceneRegionInfo.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + m_sceneRegionInfo.RegionID.ToString() + "/release/"; //m_log.DebugFormat( // "[ENTITY TRANSFER MODULE]: Set release callback URL to {0} in {1}", // agent.CallbackURI, region.RegionName); } - protected virtual void SetNewCallbackURL(AgentData agent, RegionInfo region) + protected virtual void SetNewCallbackURL(AgentData agent) { - agent.NewCallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; + agent.NewCallbackURI = m_sceneRegionInfo.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + m_sceneRegionInfo.RegionID.ToString() + "/release/"; m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Set release callback URL to {0} in {1}", - agent.NewCallbackURI, region.RegionName); + agent.NewCallbackURI, m_sceneName); } /// @@ -1414,11 +1425,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (lm == null || lm.Data == null || lm.Data.Length == 0) return; - ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId); + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp == null || sp.IsDeleted || sp.IsInTransit || sp.IsChildAgent || sp.IsNPC) return; - GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); + GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); if (info == null) { // can't find the region: Tell viewer and abort @@ -1428,11 +1439,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //check if region on same position and fix local offset if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, info.RegionLocX, info.RegionLocY, info.RegionSizeX, info.RegionSizeY, out Vector3 offset)) { - Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset, + m_scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } else //region may had move to other grid slot. assume the lm position is good - Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, + m_scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } @@ -1455,7 +1466,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - if (id == client.AgentId) + if (id.Equals(client.AgentId)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, id); @@ -1488,7 +1499,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } //OpenSim.Services.Interfaces.PresenceInfo pinfo = Scene.PresenceService.GetAgent(client.SessionId); - GridUserInfo uinfo = Scene.GridUserService.GetGridUserInfo(id.ToString()); + GridUserInfo uinfo = m_scene.GridUserService.GetGridUserInfo(id.ToString()); if(uinfo == null) { m_log.ErrorFormat("[ENTITY TRANSFER MODULE] Griduser info not found for {1}. Cannot send home.", id); @@ -1508,7 +1519,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return false; } - GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); + GridRegion regionInfo = m_scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); if (regionInfo == null) { // can't find the Home region: Tell viewer and abort @@ -1533,22 +1544,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public bool checkAgentAccessToRegion(ScenePresence agent, GridRegion destiny, Vector3 position, EntityTransferContext ctx, out string reason) { - reason = String.Empty; + reason = string.Empty; UUID agentID = agent.UUID; ulong destinyHandle = destiny.RegionHandle; if (m_bannedRegionCache.IfBanned(destinyHandle, agentID)) - { return false; - } - Scene ascene = agent.Scene; - string homeURI = ascene.GetAgentHomeURI(agentID); - - - if (!ascene.SimulationService.QueryAccess(destiny, agentID, homeURI, false, position, - agent.Scene.GetFormatsOffered(), ctx, out reason)) + string homeURI = m_scene.GetAgentHomeURI(agentID); + if (!m_scene.SimulationService.QueryAccess(destiny, agentID, homeURI, false, position, + m_scene.GetFormatsOffered(), ctx, out reason)) { m_bannedRegionCache.Add(destinyHandle, agentID, 60.0); return false; @@ -1570,7 +1576,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // else also returns new target position in the new region local coords // now only works for crossings - public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, + public GridRegion GetDestination(UUID agentID, Vector3 pos, EntityTransferContext ctx, out Vector3 newpos, out string failureReason) { newpos = pos; @@ -1580,12 +1586,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); // Compute world location of the agent's position - double presenceWorldX = (double)scene.RegionInfo.WorldLocX + pos.X; - double presenceWorldY = (double)scene.RegionInfo.WorldLocY + pos.Y; + double presenceWorldX = (double)m_sceneRegionInfo.WorldLocX + pos.X; + double presenceWorldY = (double)m_sceneRegionInfo.WorldLocY + pos.Y; // Call the grid service to lookup the region containing the new position. GridRegion neighbourRegion = GetRegionContainingWorldLocation( - scene.GridService, scene.RegionInfo.ScopeID, + m_scene.GridService, m_sceneRegionInfo.ScopeID, presenceWorldX, presenceWorldY); if (neighbourRegion == null) @@ -1604,11 +1610,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer (float)(presenceWorldY - neighbourRegion.RegionLocY), pos.Z); - string homeURI = scene.GetAgentHomeURI(agentID); + string homeURI = m_scene.GetAgentHomeURI(agentID); - if (!scene.SimulationService.QueryAccess( + if (!m_scene.SimulationService.QueryAccess( neighbourRegion, agentID, homeURI, false, newpos, - scene.GetFormatsOffered(), ctx, out failureReason)) + m_scene.GetFormatsOffered(), ctx, out failureReason)) { // remember the fail m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID, 60); @@ -1656,7 +1662,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 pos = agent.AbsolutePosition + agent.Velocity * 0.2f; - GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos, + GridRegion neighbourRegion = GetDestination(agent.UUID, pos, ctx, out newpos, out failureReason); if (neighbourRegion == null) { @@ -1680,16 +1686,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public bool CrossAgentCreateFarChild(ScenePresence agent, GridRegion neighbourRegion, Vector3 pos, EntityTransferContext ctx) { ulong regionhandler = neighbourRegion.RegionHandle; - if(agent.knowsNeighbourRegion(regionhandler)) return true; string reason; - ulong currentRegionHandler = agent.Scene.RegionInfo.RegionHandle; - GridRegion source = new GridRegion(agent.Scene.RegionInfo); - + GridRegion source = new GridRegion(m_sceneRegionInfo); AgentCircuitData currentAgentCircuit = - agent.Scene.AuthenticateHandler.GetAgentCircuitData(agent.ControllingClient.CircuitCode); + m_scene.AuthenticateHandler.GetAgentCircuitData(agent.ControllingClient.CircuitCode); AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo(); agentCircuit.startpos = pos; agentCircuit.child = true; @@ -1716,7 +1719,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat("CrossAgentCreateFarChild failed to resolve neighbour address {0}", neighbourRegion.ExternalHostName); return false; } - if (!Scene.SimulationService.CreateAgent(source, neighbourRegion, agentCircuit, (int)TeleportFlags.Default, ctx, out reason)) + if (!m_scene.SimulationService.CreateAgent(source, neighbourRegion, agentCircuit, (int)TeleportFlags.Default, ctx, out reason)) { agent.RemoveNeighbourRegion(regionhandler); return false; @@ -1794,6 +1797,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer bool sucess = true; string reason = String.Empty; List childRegionsToClose = null; + UUID agentUUID = agent.UUID; try { AgentData cAgent = new AgentData(); @@ -1819,9 +1823,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer cAgent.CallbackURI = String.Empty; // Beyond this point, extra cleanup is needed beyond removing transit state - m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); + m_entityTransferStateMachine.UpdateInTransit(agentUUID, AgentTransferState.Transferring); - if (sucess && !agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx)) + if (sucess && !m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent, ctx)) { sucess = false; reason = "agent update failed"; @@ -1830,7 +1834,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if(!sucess) { // region doesn't take it - m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); + m_entityTransferStateMachine.UpdateInTransit(agentUUID, AgentTransferState.CleaningUp); m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: agent {0} crossing to {1} failed: {2}", @@ -1851,7 +1855,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_log.ErrorFormat( "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", - agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); + agent.Name, neighbourRegion.RegionName, m_sceneName, e.Message, e.StackTrace); // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. return false; @@ -1881,7 +1885,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_eqModule.CrossRegion( neighbourRegion.RegionHandle, pos, vel2 /* agent.Velocity */, - endpoint, capsPath, agent.UUID, agent.ControllingClient.SessionId, + endpoint, capsPath, agentUUID, agent.ControllingClient.SessionId, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY); } else @@ -1892,10 +1896,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // SUCCESS! - m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); + m_entityTransferStateMachine.UpdateInTransit(agentUUID, AgentTransferState.ReceivedAtDestination); // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. - m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); + m_entityTransferStateMachine.UpdateInTransit(agentUUID, AgentTransferState.CleaningUp); if(childRegionsToClose != null) agent.CloseChildAgents(childRegionsToClose); @@ -1909,7 +1913,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // FIXME: Possibly this should occur lower down after other commands to close other agents, // but not sure yet what the side effects would be. - m_entityTransferStateMachine.ResetFromTransit(agent.UUID); + m_entityTransferStateMachine.ResetFromTransit(agentUUID); return true; } @@ -1947,28 +1951,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if(viewrange == 0) return; - Vector3 pos = sp.AbsolutePosition; - RegionInfo curregion = sp.Scene.RegionInfo; + ICapabilitiesModule capsModule = m_scene.CapsModule; + if (capsModule == null) + return; - int rtmp = region.RegionLocX - (int)Util.RegionToWorldLoc(curregion.RegionLocX) - (int)pos.X; + Vector3 pos = sp.AbsolutePosition; + + int rtmp = region.RegionLocX - (int)m_sceneRegionInfo.WorldLocX - (int)pos.X; if ( rtmp > viewrange || rtmp < -(viewrange + region.RegionSizeX)) return; - rtmp = region.RegionLocY - (int)Util.RegionToWorldLoc(curregion.RegionLocY) - (int)pos.Y; + rtmp = region.RegionLocY - (int)m_sceneRegionInfo.WorldLocY - (int)pos.Y; if (rtmp > viewrange || rtmp < -(viewrange + region.RegionSizeY)) return; m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); - ulong currentRegionHandler = curregion.RegionHandle; ulong regionhandler = region.RegionHandle; - Dictionary seeds = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); + Dictionary seeds = new Dictionary(capsModule.GetChildrenSeeds(sp.UUID)); if (seeds.ContainsKey(regionhandler)) seeds.Remove(regionhandler); - if (!seeds.ContainsKey(currentRegionHandler)) - seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath); + if (!seeds.ContainsKey(m_sceneRegionHandler)) + seeds.Add(m_sceneRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath); AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); @@ -1984,14 +1990,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer seeds.Add(regionhandler, agent.CapsPath); -// agent.ChildrenCapSeeds = new Dictionary(seeds); agent.ChildrenCapSeeds = null; - if (sp.Scene.CapsModule != null) - { - sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); - } - + capsModule.SetChildrenSeed(sp.UUID, seeds); sp.KnownRegions = seeds; sp.AddNeighbourRegionSizeInfo(region); @@ -2058,7 +2059,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return ret; } - List RegionsInSPView(ScenePresence sp, RegionInfo curregion) + List RegionsInSPView(ScenePresence sp) { int viewrange = (int)sp.RegionViewDistance; if (viewrange == 0) @@ -2069,10 +2070,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return new List(); Vector3 pos = sp.AbsolutePosition; - int itmp = (int)curregion.WorldLocX + (int)pos.X; + int itmp = (int)m_sceneRegionInfo.WorldLocX + (int)pos.X; int minX = itmp - viewrange; int maxX = itmp + viewrange; - itmp = (int)curregion.WorldLocY + (int)pos.Y; + itmp = (int)m_sceneRegionInfo.WorldLocY + (int)pos.Y; int minY = itmp - viewrange; int maxY = itmp + viewrange; @@ -2109,39 +2110,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public void EnableChildAgents(ScenePresence sp) { // assumes that out of view range regions are disconnected by the previous region - - Scene spScene = sp.Scene; - RegionInfo regionInfo = spScene.RegionInfo; - - if (regionInfo == null) + ICapabilitiesModule capsModule = m_scene.CapsModule; + if (capsModule == null) return; - ulong currentRegionHandler = regionInfo.RegionHandle; - - List neighbours = RegionsInSPView(sp, regionInfo); + List neighbours = RegionsInSPView(sp); LinkedList previousRegionNeighbourHandles; Dictionary seeds; - ICapabilitiesModule capsModule = spScene.CapsModule; - if (capsModule != null) - { - seeds = new Dictionary(capsModule.GetChildrenSeeds(sp.UUID)); - previousRegionNeighbourHandles = new LinkedList(seeds.Keys); - } - else - { - seeds = new Dictionary(); - previousRegionNeighbourHandles = new LinkedList(); - } + seeds = new Dictionary(capsModule.GetChildrenSeeds(sp.UUID)); + previousRegionNeighbourHandles = new LinkedList(seeds.Keys); IClientAPI spClient = sp.ControllingClient; // This will fail if the user aborts login try { - if (!seeds.ContainsKey(currentRegionHandler)) - seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); + if (!seeds.ContainsKey(m_sceneRegionHandler)) + seeds.Add(m_sceneRegionHandler, spClient.RequestClientInfo().CapsPath); } catch { @@ -2149,7 +2136,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } AgentCircuitData currentAgentCircuit = - spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + m_scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); List cagents = new List(); List newneighbours = new List(); @@ -2165,7 +2152,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer continue; } - if (handler == currentRegionHandler) + if (handler == m_sceneRegionHandler) continue; // a new region to add @@ -2199,8 +2186,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // previousRegionNeighbourHandles now contains regions to forget if (previousRegionNeighbourHandles.Count > 0) { - if (previousRegionNeighbourHandles.Contains(currentRegionHandler)) - previousRegionNeighbourHandles.Remove(currentRegionHandler); + if (previousRegionNeighbourHandles.Contains(m_sceneRegionHandler)) + previousRegionNeighbourHandles.Remove(m_sceneRegionHandler); foreach (ulong handler in previousRegionNeighbourHandles) seeds.Remove(handler); @@ -2229,7 +2216,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agentpos.Far = sp.DrawDistance; agentpos.Position = sp.AbsolutePosition; agentpos.Velocity = sp.Velocity; - agentpos.RegionHandle = currentRegionHandler; + agentpos.RegionHandle = m_sceneRegionHandler; //agentpos.GodLevel = sp.GodLevel; agentpos.GodData = sp.GodController.State(); agentpos.Throttles = spClient.GetThrottlesPacked(1); @@ -2261,7 +2248,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else if (!previousRegionNeighbourHandles.Contains(handler)) { - spScene.SimulationService.UpdateAgent(neighbour, agentpos); + m_scene.SimulationService.UpdateAgent(neighbour, agentpos); } if (sp.IsDeleted) return; @@ -2283,40 +2270,28 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public void CheckChildAgents(ScenePresence sp) { - // assumes that out of view range regions are disconnected by the previous region + List neighbours = RegionsInSPView(sp); - Scene spScene = sp.Scene; - RegionInfo regionInfo = spScene.RegionInfo; - - if (regionInfo == null) - return; - - ulong currentRegionHandler = regionInfo.RegionHandle; - - List neighbours = RegionsInSPView(sp, regionInfo); - - LinkedList previousRegionNeighbourHandles = new LinkedList(sp.KnownRegions.Keys); + Dictionary previousRegionNeighbour = sp.KnownRegions; + previousRegionNeighbour.Remove(m_sceneRegionHandler); IClientAPI spClient = sp.ControllingClient; + AgentCircuitData currentAgentCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(spClient.CircuitCode); - AgentCircuitData currentAgentCircuit = - spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - - List cagents = new List(); - List newneighbours = new List(); + List cagents = new List(neighbours.Count); + List newneighbours = new List(neighbours.Count); foreach (GridRegion neighbour in neighbours) { ulong handler = neighbour.RegionHandle; - if (previousRegionNeighbourHandles.Contains(handler)) + if (previousRegionNeighbour.Remove(handler)) { // agent already knows this region - previousRegionNeighbourHandles.Remove(handler); continue; } - if (handler == currentRegionHandler) + if (handler == m_sceneRegionHandler) continue; // a new region to add @@ -2346,28 +2321,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer cagents.Add(agent); } - List toclose; // previousRegionNeighbourHandles now contains regions to forget - if (previousRegionNeighbourHandles.Count > 0) + if (previousRegionNeighbour.Count > 0) { - if (previousRegionNeighbourHandles.Contains(currentRegionHandler)) - previousRegionNeighbourHandles.Remove(currentRegionHandler); - - foreach (ulong handler in previousRegionNeighbourHandles) - sp.KnownRegions.Remove(handler); - - toclose = new List(previousRegionNeighbourHandles); + List toclose = new List(previousRegionNeighbour.Keys); + sp.CloseChildAgents(toclose); } - else - toclose = new List(); - ICapabilitiesModule capsModule = spScene.CapsModule; + ICapabilitiesModule capsModule = m_scene.CapsModule; if (capsModule != null) capsModule.SetChildrenSeed(sp.UUID, sp.KnownRegions); - if (toclose.Count > 0) - sp.CloseChildAgents(toclose); - if (newneighbours.Count > 0) { int count = 0; @@ -2404,51 +2368,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public void CloseOldChildAgents(ScenePresence sp) { - Scene spScene = sp.Scene; - RegionInfo regionInfo = spScene.RegionInfo; - if (regionInfo == null ) - return; - ICapabilitiesModule capsModule = spScene.CapsModule; - if (capsModule == null) - return; - - Dictionary seeds = new Dictionary(capsModule.GetChildrenSeeds(sp.UUID)); + Dictionary seeds = sp.KnownRegions; if (seeds.Count == 0) return; - ulong currentRegionHandler = regionInfo.RegionHandle; - seeds.Remove(currentRegionHandler); + seeds.Remove(m_sceneRegionHandler); if (seeds.Count == 0) return; - List neighbours = RegionsInSPView(sp, regionInfo); + List neighbours = RegionsInSPView(sp); + sp.SetNeighbourRegionSizeInfo(neighbours); foreach (GridRegion neighbour in neighbours) - { seeds.Remove(neighbour.RegionHandle); - } // seeds now contains regions to forget if (seeds.Count == 0) return; List toclose = new List(seeds.Keys); - - IClientAPI spClient = sp.ControllingClient; - // This will fail if the user aborts login - try - { - if (!seeds.ContainsKey(currentRegionHandler)) - seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); - } - catch - { - return; - } - - capsModule.SetChildrenSeed(sp.UUID, seeds); - sp.KnownRegions = seeds; - sp.SetNeighbourRegionSizeInfo(neighbours); - Util.FireAndForget(delegate { sp.CloseChildAgents(toclose); @@ -2697,7 +2634,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public void AgentArrivedAtDestination(UUID id) { - ScenePresence sp = Scene.GetScenePresence(id); + ScenePresence sp = m_scene.GetScenePresence(id); if(sp == null || sp.IsDeleted || !sp.IsInTransit) return; @@ -2774,22 +2711,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (destination != null) { - //string objectState = grp.GetStateSnapshot(); - - //successYN - // = m_sceneGridService.PrimCrossToNeighboringRegion( - // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); - //if (successYN && (objectState != "") && m_allowScriptCrossings) - //{ - // successYN = m_sceneGridService.PrimCrossToNeighboringRegion( - // newRegionHandle, grp.UUID, objectState, 100); - //} - - //// And the new channel... - //if (m_interregionCommsOut != null) - // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); - if (Scene.SimulationService != null) - successYN = Scene.SimulationService.CreateObject(destination, newPosition, grp, true); + if (m_scene.SimulationService != null) + successYN = m_scene.SimulationService.CreateObject(destination, newPosition, grp, true); if (successYN) { @@ -2893,11 +2816,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // If the user is banned, we won't let any of their objects // enter. Period. // - if (Scene.RegionInfo.EstateSettings.IsBanned(so.OwnerID)) + if (m_sceneRegionInfo.EstateSettings.IsBanned(so.OwnerID)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Denied prim crossing of {0} {1} into {2} for banned avatar {3}", - so.Name, so.UUID, Scene.Name, so.OwnerID); + so.Name, so.UUID, m_sceneName, so.OwnerID); return false; } @@ -2905,11 +2828,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!newPosition.IsZero()) so.RootPart.GroupPosition = newPosition; - if (!Scene.AddSceneObject(so)) + if (!m_scene.AddSceneObject(so)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Problem adding scene object {0} {1} into {2} ", - so.Name, so.UUID, Scene.Name); + so.Name, so.UUID, m_sceneName); return false; } @@ -2918,21 +2841,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { // FIXME: It would be better to never add the scene object at all rather than add it and then delete // it - if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition)) + if (!m_scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition)) { // Deny non attachments based on parcel settings // m_log.Info("[ENTITY TRANSFER MODULE]: Denied prim crossing because of parcel settings"); - Scene.DeleteSceneObject(so, false); + m_scene.DeleteSceneObject(so, false); return false; } // For attachments, we need to wait until the agent is root // before we restart the scripts, or else some functions won't work. - so.RootPart.ParentGroup.CreateScriptInstances( - 0, false, Scene.DefaultScriptEngine, GetStateSource(so)); + so.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource(so)); so.ResumeScripts(); @@ -2946,7 +2868,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer private int GetStateSource(SceneObjectGroup sog) { - ScenePresence sp = Scene.GetScenePresence(sog.OwnerID); + ScenePresence sp = m_scene.GetScenePresence(sog.OwnerID); if (sp != null) return sp.GetStateSource(); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b16f4ae826..c8b2779f79 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -84,19 +84,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", name); return null; } - UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); + UserAccount account = m_scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); if (account == null) { m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName); return null; } - AvatarAppearance a = Scene.AvatarService.GetAppearance(account.PrincipalID); + AvatarAppearance a = m_scene.AvatarService.GetAppearance(account.PrincipalID); if (a != null) m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", name); foreach (AvatarAttachment att in a.GetAttachments()) { - InventoryItemBase item = Scene.InventoryService.GetItem(account.PrincipalID, att.ItemID); + InventoryItemBase item = m_scene.InventoryService.GetItem(account.PrincipalID, att.ItemID); if (item != null) a.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); else @@ -214,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override GridRegion GetFinalDestination(GridRegion region, UUID agentID, string agentHomeURI, out string message) { - int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); + int flags = m_scene.GridService.GetRegionFlags(m_sceneRegionInfo.ScopeID, region.RegionID); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionName, flags); message = null; @@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (OutViewRange) return true; - int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); + int flags = m_scene.GridService.GetRegionFlags(m_sceneRegionInfo.ScopeID, reg.RegionID); if (flags == -1 || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) return true; @@ -250,9 +250,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (logout) { // Log them out of this grid - Scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); - string userId = Scene.UserManagementModule.GetUserUUI(sp.UUID); - Scene.GridUserService.LoggedOut(userId, UUID.Zero, Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + m_scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); + string userId = m_scene.UserManagementModule.GetUserUUI(sp.UUID); + m_scene.GridUserService.LoggedOut(userId, UUID.Zero, m_sceneRegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); } } @@ -261,12 +261,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); reason = string.Empty; logout = false; - int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); + int flags = Scene.GridService.GetRegionFlags(m_sceneRegionInfo.ScopeID, reg.RegionID); if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) { // this user is going to another grid // for local users, check if HyperGrid teleport is allowed, based on user level - bool isLocal = Scene.UserManagementModule.IsLocalGridUser(sp.UUID); + bool isLocal = m_scene.UserManagementModule.IsLocalGridUser(sp.UUID); if (isLocal && sp.GodController.UserLevel < m_levelHGTeleport) { m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); @@ -284,7 +284,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer else connector = new UserAgentServiceConnector(userAgentDriver); - GridRegion source = new GridRegion(Scene.RegionInfo) + GridRegion source = new GridRegion(m_sceneRegionInfo) { RawServerURI = m_thisGridInfo.GateKeeperURL }; @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer logout = success; // flag for later logout from this grid; this is an HG TP if (success) - Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); + m_scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); return success; } @@ -320,11 +320,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // The rest is only needed for controlling appearance - int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); + int flags = m_scene.GridService.GetRegionFlags(m_sceneRegionInfo.ScopeID, reg.RegionID); if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) { // this user is going to another grid - if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID)) + if (m_scene.UserManagementModule.IsLocalGridUser(sp.UUID)) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Checking generic appearance"); @@ -434,7 +434,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public override bool TeleportHome(UUID id, IClientAPI client) { // Let's find out if this is a foreign user or a local user - IUserManagement uMan = Scene.RequestModuleInterface(); + IUserManagement uMan = m_scene.RequestModuleInterface(); if (uMan != null && uMan.IsLocalGridUser(id)) { // local grid user @@ -549,7 +549,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", (string.IsNullOrEmpty(lm.Gatekeeper)) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); - ScenePresence sp = Scene.GetScenePresence(remoteClient.AgentId); + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp == null || sp.IsDeleted || sp.IsInTransit || sp.IsChildAgent || sp.IsNPC) return; @@ -557,7 +557,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (m_thisGridInfo.IsLocalGrid(gatekeeperHost) != 0) { // Local region? - GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); + GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); if (info == null) { remoteClient.SendTeleportFailed("Landmark region not found"); @@ -567,11 +567,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //check if region on same position and fix local offset if (Util.CompareRegionHandles(lm.RegionHandle, lm.Position, info.RegionLocX, info.RegionLocY, info.RegionSizeX, info.RegionSizeY, out Vector3 offset)) { - Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset, + m_scene.RequestTeleportLocation(remoteClient, info.RegionHandle, offset, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } else //region may had move to other grid slot. assume the lm position is good - Scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, + m_scene.RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); return; } @@ -593,7 +593,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer RegionFlags = OpenSim.Framework.RegionFlags.Hyperlink }; - string homeURI = Scene.GetAgentHomeURI(remoteClient.AgentId); + string homeURI = m_scene.GetAgentHomeURI(remoteClient.AgentId); GatekeeperServiceConnector gConn = new GatekeeperServiceConnector(); GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, lm.RegionID, remoteClient.AgentId, homeURI, out string message); @@ -648,11 +648,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public override bool HandleIncomingSceneObject(SceneObjectGroup so, Vector3 newPosition) { UUID OwnerID = so.OwnerID; - if (Scene.RegionInfo.EstateSettings.IsBanned(OwnerID)) + if (m_sceneRegionInfo.EstateSettings.IsBanned(OwnerID)) { m_log.DebugFormat( "[HG TRANSFER MODULE]: Denied prim crossing of {0} {1} into {2} for banned avatar {3}", - so.Name, so.UUID, Scene.Name, so.OwnerID); + so.Name, so.UUID, m_sceneName, so.OwnerID); return false; } @@ -662,11 +662,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return base.HandleIncomingSceneObject(so, newPosition); // Equally, we can't use so.AttachedAvatar here. - if (OwnerID.IsZero() || Scene.UserManagementModule.IsLocalGridUser(OwnerID)) + if (OwnerID.IsZero() || m_scene.UserManagementModule.IsLocalGridUser(OwnerID)) return base.HandleIncomingSceneObject(so, newPosition); // foreign user - AgentCircuitData aCircuit = Scene.AuthenticateHandler.GetAgentCircuitData(OwnerID); + AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(OwnerID); if (aCircuit != null) { if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) == 0) @@ -689,7 +689,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // so.Name, so.AttachedAvatar, url); IDictionary ids = new Dictionary(); - HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url, ids); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, url, ids); uuidGatherer.AddForInspection(defso); while (!uuidGatherer.Complete) @@ -783,7 +783,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; // Let's find out if this is a foreign user or a local user - IUserManagement uMan = Scene.RequestModuleInterface(); + IUserManagement uMan = m_scene.RequestModuleInterface(); // UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, obj.AgentId); if (uMan != null && uMan.IsLocalGridUser(obj.AgentId))