From 4241cdc9291eb5beeaa3120bf3079541b6452410 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sun, 13 Sep 2009 07:20:18 -0400 Subject: * More comments in the RegionCombinerModule * Changed the Destination ID to 0 in the TeleportFinish Event (why did we have it as 3?) * Added border based trigger teleports * Fix MakeRootAgent border cross tests for ensuring that the position is inside the region to use the borders to figure out if it's outside the Region --- .../Framework/Scenes/SceneCommunicationService.cs | 124 +++++++++++++++++++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 ++++- 2 files changed, 135 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 1c71a99..b38148b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1074,7 +1074,7 @@ namespace OpenSim.Region.Framework.Scenes if (eq != null) { eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint, - 4, teleportFlags, capsPath, avatar.UUID); + 0, teleportFlags, capsPath, avatar.UUID); } else { @@ -1269,16 +1269,53 @@ namespace OpenSim.Region.Framework.Scenes if (scene.TestBorderCross(pos + northCross, Cardinals.N)) { Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); - neighboury += (uint)(int)(b.BorderLine.Z/(int)Constants.RegionSize); + neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); } else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } } - neighbourx--; - newpos.X = Constants.RegionSize - enterDistance; + Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighbourx--; + newpos.X = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + + + return; + } } else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) @@ -1289,8 +1326,24 @@ namespace OpenSim.Region.Framework.Scenes if (scene.TestBorderCross(pos + southCross, Cardinals.S)) { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; + Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } } else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) { @@ -1298,16 +1351,33 @@ namespace OpenSim.Region.Framework.Scenes neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); newpos.Y = enterDistance; } - + } else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } } else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) { + Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); newpos.Y = enterDistance; @@ -1342,6 +1412,38 @@ namespace OpenSim.Region.Framework.Scenes d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); } + public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) + { + Util.FireAndForget(delegate + { + Thread.Sleep(10000); + IMessageTransferModule im = initiatingScene.RequestModuleInterface(); + if (im != null) + { + UUID gotoLocation = Util.BuildFakeParcelID( + Util.UIntsToLong( + (regionX * + (uint)Constants.RegionSize), + (regionY * + (uint)Constants.RegionSize)), + (uint)(int)position.X, + (uint)(int)position.Y, + (uint)(int)position.Z); + GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero, + "Region", agent.UUID, + (byte)InstantMessageDialog.GodLikeRequestTeleport, false, + "", gotoLocation, false, new Vector3(127, 0, 0), + new Byte[0]); + im.SendInstantMessage(m, delegate(bool success) + { + m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success); + }); + + } + + }); + } + public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1024857..23fe2d3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -776,8 +776,20 @@ namespace OpenSim.Region.Framework.Scenes // before the inventory is processed in MakeRootAgent. This fixes a race condition // related to the handling of attachments //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + if (m_scene.TestBorderCross(pos, Cardinals.E)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); + pos.X = crossedBorder.BorderLine.Z - 1; + } + + if (m_scene.TestBorderCross(pos, Cardinals.N)) + { + Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); + pos.Y = crossedBorder.BorderLine.Z - 1; + } + - if (pos.X < 0 || pos.X >= (int)Constants.RegionSize || pos.Y < 0 || pos.Y >= (int)Constants.RegionSize || pos.Z < 0) + if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) { Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); @@ -795,7 +807,11 @@ namespace OpenSim.Region.Framework.Scenes localAVHeight = m_avHeight; } - float posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; + float posZLimit = 0; + + if (pos.X = (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) { @@ -877,6 +893,7 @@ namespace OpenSim.Region.Framework.Scenes m_isChildAgent = true; m_scene.SwapRootAgentCount(true); RemoveFromPhysicalScene(); + m_scene.EventManager.TriggerOnMakeChildAgent(this); } @@ -904,7 +921,7 @@ namespace OpenSim.Region.Framework.Scenes bool isFlying = false; if (m_physicsActor != null) isFlying = m_physicsActor.Flying; - + RemoveFromPhysicalScene(); Velocity = new Vector3(0, 0, 0); AbsolutePosition = pos; @@ -2412,7 +2429,8 @@ namespace OpenSim.Region.Framework.Scenes } // followed suggestion from mic bowman. reversed the two lines below. - CheckForBorderCrossing(); + if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something + CheckForBorderCrossing(); CheckForSignificantMovement(); // sends update to the modules. } } -- cgit v1.1