From 94e48838d5b1f0bf0c5b0e40b7bc9a6f1be156e9 Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Tue, 22 Nov 2016 15:31:45 +0000 Subject: [PATCH] Include new Region.ini option for DefaultLandingPoint for teleports with no coords specified. This is useful when using a Telehub would be to restrictive as it would block landmarks and map teleports. This location is only ever used when no coordinates are provided. If config value not set, the previous default of 128,128 is used. --- OpenSim/Framework/RegionInfo.cs | 58 +++++++++++++++++++ .../EntityTransfer/EntityTransferModule.cs | 4 ++ .../Region/Framework/Scenes/ScenePresence.cs | 4 ++ bin/Regions/Regions.ini.example | 3 + 4 files changed, 69 insertions(+) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index ac7735248a..b6e9d9f1f4 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -176,6 +176,9 @@ namespace OpenSim.Framework /// public uint RegionSizeZ = Constants.RegionHeight; + // If entering avatar has no specific coords, this is where they land + public Vector3 DefaultLandingPoint = new Vector3(128, 128, 30); + private Dictionary m_extraSettings = new Dictionary(); // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. @@ -712,6 +715,19 @@ namespace OpenSim.Framework m_regionType = config.GetString("RegionType", String.Empty); allKeys.Remove("RegionType"); + // Get Default Landing Location (Defaults to 128,128) + string temp_location = config.GetString("DefaultLanding", "<128, 128, 30>"); + Vector3 temp_vector; + + if (Vector3.TryParse(temp_location, out temp_vector)) + DefaultLandingPoint = temp_vector; + else + m_log.ErrorFormat("[RegionInfo]: Unable to parse DefaultLanding for '{0}'. The value given was '{1}'", RegionName, temp_location); + + allKeys.Remove("DefaultLanding"); + + DoDefaultLandingSanityChecks(); + #region Prim and map stuff m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0); @@ -764,6 +780,48 @@ namespace OpenSim.Framework } } + // Make sure DefaultLanding is within region borders with a buffer zone 5 meters from borders + private void DoDefaultLandingSanityChecks() + { + // Sanity Check Default Landing + float buffer_zone = 5f; + + bool ValuesCapped = false; + + // Minimum Positions + if (DefaultLandingPoint.X < 0f) + { + DefaultLandingPoint.X = buffer_zone; + ValuesCapped = true; + } + + if (DefaultLandingPoint.Y < 0f) + { + DefaultLandingPoint.Y = buffer_zone; + ValuesCapped = true; + } + + // Maximum Positions + if (DefaultLandingPoint.X > RegionSizeX - buffer_zone) + { + DefaultLandingPoint.X = RegionSizeX - buffer_zone; + ValuesCapped = true; + } + + if (DefaultLandingPoint.Y > RegionSizeY - buffer_zone) + { + DefaultLandingPoint.Y = RegionSizeY - buffer_zone; + ValuesCapped = true; + } + + // Height + if (DefaultLandingPoint.Z < 0f) + DefaultLandingPoint.Z = 0f; + + if (ValuesCapped == true) + m_log.WarnFormat("[RegionInfo]: The default landing location for {0} has been capped to {1}", RegionName, DefaultLandingPoint); + } + // Make sure user specified region sizes are sane. // Must be multiples of legacy region size (256). private void DoRegionSizeSanityChecks() diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 1161571016..23cfde5c43 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -455,6 +455,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer position = emergencyPos; } + // Check Default Location (Also See ScenePresence.CompleteMovement) + if (position.X == 128f && position.Y == 128f) + position = sp.Scene.RegionInfo.DefaultLandingPoint; + // TODO: Get proper AVG Height float localHalfAVHeight = 0.8f; if (sp.Appearance != null) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7efd9200ed..2cf0e9d3ac 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2043,6 +2043,10 @@ namespace OpenSim.Region.Framework.Scenes look = new Vector3(0.99f, 0.042f, 0); } + // Check Default Location (Also See EntityTransferModule.TeleportAgentWithinRegion) + if (AbsolutePosition.X == 128f && AbsolutePosition.Y == 128f) + AbsolutePosition = Scene.RegionInfo.DefaultLandingPoint; + if (!MakeRootAgent(AbsolutePosition, flying, ref look)) { m_log.DebugFormat( diff --git a/bin/Regions/Regions.ini.example b/bin/Regions/Regions.ini.example index e20fee609b..97d1c4f628 100644 --- a/bin/Regions/Regions.ini.example +++ b/bin/Regions/Regions.ini.example @@ -31,6 +31,9 @@ ExternalHostName = SYSTEMIP ; SizeX = 512 ; SizeY = 512 +; * Default region landing point used when no teleport coords are specified +; DefaultLanding = <128,128,30> + ; * ; * Prim data ; * This allows limiting the sizes of prims and the region prim count