From bd6d1a24448dafea5be7ddbcd591b352040e4412 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 07:46:07 -0800 Subject: [PATCH] Moved prim crossing to EntityTransferModule. Not complete yet. --- .../EntityTransfer/EntityTransferModule.cs | 421 ++++++++++++++++-- .../Resources/CoreModulePlugin.addin.xml | 2 +- .../Interfaces/IEntityTransferModule.cs | 2 + OpenSim/Region/Framework/Scenes/Scene.cs | 339 +++++++------- .../Region/Framework/Scenes/ScenePresence.cs | 4 + OpenSim/Services/Interfaces/IGridService.cs | 4 +- bin/config-include/Grid.ini | 2 +- bin/config-include/GridHypergrid.ini | 2 +- bin/config-include/Standalone.ini | 2 +- bin/config-include/StandaloneHypergrid.ini | 2 +- 10 files changed, 557 insertions(+), 223 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index af004b09f3..44d3858a93 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -46,15 +46,16 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { - public class AgentTransferModule : ISharedRegionModule, IEntityTransferModule + public class EntityTransferModule : ISharedRegionModule, IEntityTransferModule { - #region ISharedRegionModule - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; protected Scene m_aScene; protected List m_agentsInTransit; + #region ISharedRegionModule + public Type ReplaceableInterface { get { return null; } @@ -62,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public string Name { - get { return "AgentTransferModule"; } + get { return "BasicEntityTransferModule"; } } public virtual void Initialise(IConfigSource source) @@ -70,12 +71,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer IConfig moduleConfig = source.Configs["Modules"]; if (moduleConfig != null) { - string name = moduleConfig.GetString("AgentTransferModule", ""); + string name = moduleConfig.GetString("EntityTransferModule", ""); if (name == Name) { m_agentsInTransit = new List(); m_Enabled = true; - m_log.Info("[AGENT TRANSFER MODULE]: Enabled."); + m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} nabled.", Name); } } } @@ -120,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion - #region Teleports + #region Agent Teleports public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { @@ -137,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (regionHandle == sp.Scene.RegionInfo.RegionHandle) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", position, sp.Scene.RegionInfo.RegionName); // Teleport within the same region @@ -146,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 emergencyPos = new Vector3(128, 128, 128); m_log.WarnFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", position, sp.Name, sp.UUID, emergencyPos); position = emergencyPos; } @@ -183,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (reg != null) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", position, reg.RegionName); uint newRegionX = (uint)(reg.RegionHandle >> 40); @@ -338,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_aScene.SimulationService.UpdateAgent(reg, agent); m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); + "[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); if (eq != null) @@ -377,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - sp.CrossAttachmentsIntoNewRegion(reg, true); + CrossAttachmentsIntoNewRegion(reg, sp, true); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone @@ -396,7 +397,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.Scene.NeedSceneCacheClear(sp.UUID)) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", sp.UUID); } } @@ -470,28 +471,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion - #region Enable Child Agent - /// - /// This informs a single neighboring region about agent "avatar". - /// Calls an asynchronous method to do so.. so it doesn't lag the sim. - /// - public void EnableChildAgent(ScenePresence sp, GridRegion region) - { - AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = new Vector3(128, 128, 70); - agent.child = true; - agent.Appearance = sp.Appearance; - - InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; - d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, - InformClientOfNeighbourCompleted, - d); - } - #endregion - - #region Crossings + #region Agent Crossings public void Cross(ScenePresence agent, bool isFlying) { @@ -700,7 +680,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer new Byte[0]); im.SendInstantMessage(m, delegate(bool success) { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); }); } @@ -721,7 +701,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); Scene m_scene = agent.Scene; ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); @@ -756,7 +736,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string agentcaps; if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) { - m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", + m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", neighbourRegion.RegionHandle); return agent; } @@ -765,7 +745,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface(); if (eq != null) @@ -781,7 +761,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!WaitForCallback(agent.UUID)) { - m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent"); + m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); ResetFromTransit(agent.UUID); // Yikes! We should just have a ref to scene here. @@ -795,7 +775,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); - agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); + CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); // m_scene.SendKillObject(m_localId); @@ -806,7 +786,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (agent.Scene.NeedSceneCacheClear(agent.UUID)) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID); + "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); } } @@ -830,11 +810,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // In any case agent.NotInTransit(); - //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + //m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } #endregion + #region Enable Child Agent + /// + /// This informs a single neighboring region about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgent(ScenePresence sp, GridRegion region) + { + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, + InformClientOfNeighbourCompleted, + d); + } + #endregion #region Enable Child Agents @@ -856,7 +856,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); + m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); } /// We need to find the difference between the new regions where there are no child agents @@ -963,7 +963,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer catch (ArgumentOutOfRangeException) { m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", + "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", neighbour.ExternalHostName, neighbour.RegionHandle, neighbour.RegionLocX, @@ -972,7 +972,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer catch (Exception e) { m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", + "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", neighbour.ExternalHostName, neighbour.RegionHandle, neighbour.RegionLocX, @@ -1021,7 +1021,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Utils.LongToUInts(reg.RegionHandle, out x, out y); x = x / Constants.RegionSize; y = y / Constants.RegionSize; - m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); + m_log.Info("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + a.CapsPath + "0000/"; @@ -1046,7 +1046,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}", + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1} in region {2}", capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); } else @@ -1055,7 +1055,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // TODO: make Event Queue disablable! } - m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); + m_log.Info("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); } @@ -1154,6 +1154,329 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion + #region Object Crossings + /// + /// Move the given scene object into a new region depending on which region its absolute position has moved + /// into. + /// + /// This method locates the new region handle and offsets the prim position for the new region + /// + /// the attempted out of region position of the scene object + /// the scene object that we're crossing + public void Cross(SceneObjectGroup grp, Vector3 attemptedPosition, bool silent) + { + if (grp == null) + return; + if (grp.IsDeleted) + return; + + Scene scene = grp.Scene; + if (scene == null) + return; + + if (grp.RootPart.DIE_AT_EDGE) + { + // We remove the object here + try + { + scene.DeleteSceneObject(grp, false); + } + catch (Exception) + { + m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); + } + return; + } + + int thisx = (int)scene.RegionInfo.RegionLocX; + int thisy = (int)scene.RegionInfo.RegionLocY; + Vector3 EastCross = new Vector3(0.1f, 0, 0); + Vector3 WestCross = new Vector3(-0.1f, 0, 0); + Vector3 NorthCross = new Vector3(0, 0.1f, 0); + Vector3 SouthCross = new Vector3(0, -0.1f, 0); + + + // use this if no borders were crossed! + ulong newRegionHandle + = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), + (uint)((thisy) * Constants.RegionSize)); + + Vector3 pos = attemptedPosition; + + int changeX = 1; + int changeY = 1; + + if (scene.TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) + { + if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); + // x - 1 + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); + // x - 1 + // y + 1 + } + else + { + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)(thisy * Constants.RegionSize)); + // x - 1 + } + } + else if (scene.TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) + { + if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + + pos.X = ((pos.X - Constants.RegionSize)); + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); + // x + 1 + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + pos.X = ((pos.X - Constants.RegionSize)); + pos.Y = ((pos.Y - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); + // x + 1 + // y + 1 + } + else + { + pos.X = ((pos.X - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)(thisy * Constants.RegionSize)); + // x + 1 + } + } + else if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + + pos.Y = ((pos.Y - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); + // y + 1 + } + + // Offset the positions for the new region across the border + Vector3 oldGroupPosition = grp.RootPart.GroupPosition; + grp.OffsetForNewRegion(pos); + + // If we fail to cross the border, then reset the position of the scene object on that border. + uint x = 0, y = 0; + Utils.LongToUInts(newRegionHandle, out x, out y); + GridRegion destination = scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent)) + { + grp.OffsetForNewRegion(oldGroupPosition); + grp.ScheduleGroupForFullUpdate(); + } + } + + + /// + /// Move the given scene object into a new region + /// + /// + /// Scene Object Group that we're crossing + /// + /// true if the crossing itself was successful, false on failure + /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region + /// + protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) + { + //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); + + bool successYN = false; + grp.RootPart.UpdateFlag = 0; + //int primcrossingXMLmethod = 0; + + 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 (m_aScene.SimulationService != null) + successYN = m_aScene.SimulationService.CreateObject(destination, grp, true); + + if (successYN) + { + // We remove the object here + try + { + grp.Scene.DeleteSceneObject(grp, silent); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}", + grp, e); + } + } + else + { + if (!grp.IsDeleted) + { + if (grp.RootPart.PhysActor != null) + { + grp.RootPart.PhysActor.CrossingFailure(); + } + } + + m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); + } + } + else + { + m_log.Error("[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()"); + } + + return successYN; + } + + protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) + { + List m_attachments = sp.Attachments; + lock (m_attachments) + { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj == null || gobj.IsDeleted) + return false; + } + + foreach (SceneObjectGroup gobj in m_attachments) + { + // If the prim group is null then something must have happened to it! + if (gobj != null && gobj.RootPart != null) + { + // Set the parent localID to 0 so it transfers over properly. + gobj.RootPart.SetParentLocalId(0); + gobj.AbsolutePosition = gobj.RootPart.AttachedPos; + gobj.RootPart.IsAttachment = false; + //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); + CrossPrimGroupIntoNewRegion(destination, gobj, silent); + } + } + m_attachments.Clear(); + + return true; + } + } + + #endregion #region Misc diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 106e87c88a..68cf060160 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -8,7 +8,7 @@ - + diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 96884b3161..a0505df0e7 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs @@ -46,5 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces void EnableChildAgents(ScenePresence agent); void EnableChildAgent(ScenePresence agent, GridRegion region); + + void Cross(SceneObjectGroup sog, Vector3 position, bool silent); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7b582a95be..bd753cca00 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1655,7 +1655,9 @@ namespace OpenSim.Region.Framework.Scenes GridRegion region = new GridRegion(RegionInfo); string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); if (error != String.Empty) + { throw new Exception(error); + } m_sceneGridService.SetScene(this); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo); @@ -2049,202 +2051,205 @@ namespace OpenSim.Region.Framework.Scenes if (grp.IsDeleted) return; - if (grp.RootPart.DIE_AT_EDGE) - { - // We remove the object here - try - { - DeleteSceneObject(grp, false); - } - catch (Exception) - { - m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); - } - return; - } + if (m_teleportModule != null) + m_teleportModule.Cross(grp, attemptedPosition, silent); - int thisx = (int)RegionInfo.RegionLocX; - int thisy = (int)RegionInfo.RegionLocY; - Vector3 EastCross = new Vector3(0.1f,0,0); - Vector3 WestCross = new Vector3(-0.1f, 0, 0); - Vector3 NorthCross = new Vector3(0, 0.1f, 0); - Vector3 SouthCross = new Vector3(0, -0.1f, 0); + //if (grp.RootPart.DIE_AT_EDGE) + //{ + // // We remove the object here + // try + // { + // DeleteSceneObject(grp, false); + // } + // catch (Exception) + // { + // m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); + // } + // return; + //} + + //int thisx = (int)RegionInfo.RegionLocX; + //int thisy = (int)RegionInfo.RegionLocY; + //Vector3 EastCross = new Vector3(0.1f,0,0); + //Vector3 WestCross = new Vector3(-0.1f, 0, 0); + //Vector3 NorthCross = new Vector3(0, 0.1f, 0); + //Vector3 SouthCross = new Vector3(0, -0.1f, 0); - // use this if no borders were crossed! - ulong newRegionHandle - = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), - (uint)((thisy) * Constants.RegionSize)); + //// use this if no borders were crossed! + //ulong newRegionHandle + // = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), + // (uint)((thisy) * Constants.RegionSize)); - Vector3 pos = attemptedPosition; + //Vector3 pos = attemptedPosition; - int changeX = 1; - int changeY = 1; + //int changeX = 1; + //int changeY = 1; - if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) - { - if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) - { + //if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) + //{ + // if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + // { - Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + // Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); - if (crossedBorderx.BorderLine.Z > 0) - { - pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); - changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize); - } - else - pos.X = ((pos.X + Constants.RegionSize)); + // if (crossedBorderx.BorderLine.Z > 0) + // { + // pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + // changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize); + // } + // else + // pos.X = ((pos.X + Constants.RegionSize)); - Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); - //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + // Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + // //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) - if (crossedBordery.BorderLine.Z > 0) - { - pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); - changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.Y = ((pos.Y + Constants.RegionSize)); + // if (crossedBordery.BorderLine.Z > 0) + // { + // pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + // changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.Y = ((pos.Y + Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), - (uint)((thisy - changeY) * Constants.RegionSize)); - // x - 1 - // y - 1 - } - else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) - { - Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + // (uint)((thisy - changeY) * Constants.RegionSize)); + // // x - 1 + // // y - 1 + // } + // else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + // { + // Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); - if (crossedBorderx.BorderLine.Z > 0) - { - pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); - changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.X = ((pos.X + Constants.RegionSize)); + // if (crossedBorderx.BorderLine.Z > 0) + // { + // pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + // changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.X = ((pos.X + Constants.RegionSize)); - Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); - //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + // Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + // //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) - if (crossedBordery.BorderLine.Z > 0) - { - pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); - changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.Y = ((pos.Y + Constants.RegionSize)); + // if (crossedBordery.BorderLine.Z > 0) + // { + // pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + // changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.Y = ((pos.Y + Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), - (uint)((thisy + changeY) * Constants.RegionSize)); - // x - 1 - // y + 1 - } - else - { - Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + // (uint)((thisy + changeY) * Constants.RegionSize)); + // // x - 1 + // // y + 1 + // } + // else + // { + // Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); - if (crossedBorderx.BorderLine.Z > 0) - { - pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); - changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.X = ((pos.X + Constants.RegionSize)); + // if (crossedBorderx.BorderLine.Z > 0) + // { + // pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + // changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.X = ((pos.X + Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), - (uint) (thisy*Constants.RegionSize)); - // x - 1 - } - } - else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) - { - if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) - { + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + // (uint) (thisy*Constants.RegionSize)); + // // x - 1 + // } + //} + //else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) + //{ + // if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + // { - pos.X = ((pos.X - Constants.RegionSize)); - Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); - //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + // pos.X = ((pos.X - Constants.RegionSize)); + // Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + // //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) - if (crossedBordery.BorderLine.Z > 0) - { - pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); - changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.Y = ((pos.Y + Constants.RegionSize)); + // if (crossedBordery.BorderLine.Z > 0) + // { + // pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + // changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.Y = ((pos.Y + Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), - (uint)((thisy - changeY) * Constants.RegionSize)); - // x + 1 - // y - 1 - } - else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) - { - pos.X = ((pos.X - Constants.RegionSize)); - pos.Y = ((pos.Y - Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), - (uint)((thisy + changeY) * Constants.RegionSize)); - // x + 1 - // y + 1 - } - else - { - pos.X = ((pos.X - Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), - (uint) (thisy*Constants.RegionSize)); - // x + 1 - } - } - else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) - { - Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); - //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + // (uint)((thisy - changeY) * Constants.RegionSize)); + // // x + 1 + // // y - 1 + // } + // else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + // { + // pos.X = ((pos.X - Constants.RegionSize)); + // pos.Y = ((pos.Y - Constants.RegionSize)); + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + // (uint)((thisy + changeY) * Constants.RegionSize)); + // // x + 1 + // // y + 1 + // } + // else + // { + // pos.X = ((pos.X - Constants.RegionSize)); + // newRegionHandle + // = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + // (uint) (thisy*Constants.RegionSize)); + // // x + 1 + // } + //} + //else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + //{ + // Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + // //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) - if (crossedBordery.BorderLine.Z > 0) - { - pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); - changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); - } - else - pos.Y = ((pos.Y + Constants.RegionSize)); + // if (crossedBordery.BorderLine.Z > 0) + // { + // pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + // changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + // } + // else + // pos.Y = ((pos.Y + Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); - // y - 1 - } - else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) - { + // newRegionHandle + // = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); + // // y - 1 + //} + //else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + //{ - pos.Y = ((pos.Y - Constants.RegionSize)); - newRegionHandle - = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); - // y + 1 - } + // pos.Y = ((pos.Y - Constants.RegionSize)); + // newRegionHandle + // = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); + // // y + 1 + //} - // Offset the positions for the new region across the border - Vector3 oldGroupPosition = grp.RootPart.GroupPosition; - grp.OffsetForNewRegion(pos); + //// Offset the positions for the new region across the border + //Vector3 oldGroupPosition = grp.RootPart.GroupPosition; + //grp.OffsetForNewRegion(pos); - // If we fail to cross the border, then reset the position of the scene object on that border. - uint x = 0, y = 0; - Utils.LongToUInts(newRegionHandle, out x, out y); - GridRegion destination = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent)) - { - grp.OffsetForNewRegion(oldGroupPosition); - grp.ScheduleGroupForFullUpdate(); - } + //// If we fail to cross the border, then reset the position of the scene object on that border. + //uint x = 0, y = 0; + //Utils.LongToUInts(newRegionHandle, out x, out y); + //GridRegion destination = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + //if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent)) + //{ + // grp.OffsetForNewRegion(oldGroupPosition); + // grp.ScheduleGroupForFullUpdate(); + //} } public Border GetCrossedBorder(Vector3 position, Cardinals gridline) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2c8c6750a3..d185fba7b1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -218,6 +218,10 @@ namespace OpenSim.Region.Framework.Scenes protected AvatarAppearance m_appearance; protected List m_attachments = new List(); + public List Attachments + { + get { return m_attachments; } + } // neighbouring regions we have enabled a child agent in // holds the seed cap for the child agent in that region diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 6186d80f2d..6a83f65a5d 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -158,8 +158,8 @@ namespace OpenSim.Services.Interfaces public UUID TerrainImage = UUID.Zero; public byte Access; public int Maturity; - public string RegionSecret; - public string Token; + public string RegionSecret = string.Empty; + public string Token = string.Empty; public GridRegion() { diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 1a9ac72d46..5aae1bc3ef 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini @@ -17,7 +17,7 @@ PresenceServices = "RemotePresenceServicesConnector" UserAccountServices = "RemoteUserAccountServicesConnector" SimulationServices = "RemoteSimulationConnectorModule" - AgentTransferModule = "AgentTransferModule" + EntityTransferModule = "BasicEntityTransferModule" LandServiceInConnector = true NeighbourServiceInConnector = true SimulationServiceInConnector = true diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 1275a603aa..4b6bc17797 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -20,7 +20,7 @@ PresenceServices = "RemotePresenceServicesConnector" UserAccountServices = "RemoteUserAccountServicesConnector" SimulationServices = "RemoteSimulationConnectorModule" - AgentTransferModule = "AgentTransferModule" + EntityTransferModule = "BasicEntityTransferModule" LandServiceInConnector = true NeighbourServiceInConnector = true HypergridServiceInConnector = true diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index c9d483bfa0..452b9e943b 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -16,7 +16,7 @@ PresenceServices = "LocalPresenceServicesConnector" UserAccountServices = "LocalUserAccountServicesConnector" SimulationServices = "LocalSimulationConnectorModule" - AgentTransferModule = "AgentTransferModule" + EntityTransferModule = "BasicEntityTransferModule" LibraryModule = true LLLoginServiceInConnector = true diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 20c5d102e6..7f44bb77bc 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -20,7 +20,7 @@ UserAccountServices = "LocalUserAccountServicesConnector" SimulationServices = "RemoteSimulationConnectorModule" AvatarServices = "LocalAvatarServicesConnector" - AgentTransferModule = "AgentTransferModule" + EntityTransferModule = "BasicEntityTransferModule" InventoryServiceInConnector = true AssetServiceInConnector = true HGAuthServiceInConnector = true