From d90b0c53ec747c512b1efccf6f25596dac9c3e41 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Jan 2011 01:37:37 +0100 Subject: Fix bumping into sim borders and check estate bans for walking crossings --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 49 ++++++++++++++++++------ 2 files changed, 42 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dc08b49..4325ab8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3861,14 +3861,16 @@ namespace OpenSim.Region.Framework.Scenes RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); } - public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) + public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) { if (m_teleportModule != null) - m_teleportModule.Cross(agent, isFlying); + return m_teleportModule.Cross(agent, isFlying); else { m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); } + + return false; } public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1c276fa..cd70de8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2725,29 +2725,57 @@ namespace OpenSim.Region.Framework.Scenes // Makes sure avatar does not end up outside region if (neighbor <= 0) { - if (!needsTransit) + if (needsTransit) { if (m_requestedSitTargetUUID == UUID.Zero) { + bool isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + Vector3 pos = AbsolutePosition; if (AbsolutePosition.X < 0) - pos.X += Velocity.X; + pos.X += Velocity.X * 2; else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X; + pos.X -= Velocity.X * 2; if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y; + pos.Y += Velocity.Y * 2; else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y; + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); } } } else if (neighbor > 0) - CrossToNewRegion(); + { + if (!CrossToNewRegion()) + { + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = m_physicsActor.Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + } + } + } } else { - RemoveFromPhysicalScene(); // This constant has been inferred from experimentation // I'm not sure what this value should be, so I tried a few values. timeStep = 0.04f; @@ -2796,16 +2824,15 @@ namespace OpenSim.Region.Framework.Scenes /// If the neighbor accepts, remove the agent's viewable avatar from this scene /// set them to a child agent. /// - protected void CrossToNewRegion() + protected bool CrossToNewRegion() { - InTransit(); try { - m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); + return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); } catch { - m_scene.CrossAgentToNewRegion(this, false); + return m_scene.CrossAgentToNewRegion(this, false); } } -- cgit v1.1