From a3ab4db5fc74724803cea44f6785758a0e2b507a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 15 Sep 2021 21:05:00 +0100 Subject: [PATCH] several changes to llTeleport so it does HG lms --- OpenSim/Framework/IClientAPI.cs | 3 +- .../EntityTransfer/EntityTransferModule.cs | 12 +++++-- .../EntityTransfer/HGEntityTransferModule.cs | 6 ++-- .../Interfaces/IEntityTransferModule.cs | 2 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 36 ++++++++++--------- 6 files changed, 49 insertions(+), 24 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index e938137764..61bef320db 100755 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -85,8 +85,7 @@ namespace OpenSim.Framework public delegate void TeleportLocationRequest( IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags); - public delegate void TeleportLandmarkRequest( - IClientAPI remoteClient, AssetLandmark lm); + public delegate void TeleportLandmarkRequest(IClientAPI remoteClient, AssetLandmark lm); public delegate void TeleportCancel(IClientAPI remoteClient); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 2ce72b693b..880c7deb8c 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1402,7 +1402,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// /// /// - public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) + + public void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) + { + RequestTeleportLandmark(remoteClient, lm, Vector3.Zero); + } + + public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt) { GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); @@ -1413,7 +1419,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, - Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); + lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } #endregion @@ -2568,7 +2574,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(agentCircData.CapsPath); - string reason = String.Empty; + string reason = string.Empty; EntityTransferContext ctx = new EntityTransferContext(); bool regionAccepted = scene.SimulationService.CreateAgent(reg, reg, agentCircData, (uint)TeleportFlags.Default, null, out reason); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 547535c5a0..92d9f2f6a5 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -541,14 +541,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// /// /// - public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) + public override void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); if (lm.Gatekeeper == string.Empty) { - base.RequestTeleportLandmark(remoteClient, lm); + base.RequestTeleportLandmark(remoteClient, lm, lookAt); return; } @@ -594,7 +594,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } DoTeleport( - sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX, + sp, gatekeeper, finalDestination, lm.Position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); } } diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 937756448b..11d7f71dc9 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs @@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Interfaces /// bool TeleportHome(UUID id, IClientAPI client); + void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt); + /// /// Teleport an agent directly to a given region without checking whether the region should be substituted. /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e1d1c1b1b8..bf725accbf 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4996,6 +4996,20 @@ Label_GroupsDone: EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); } + public void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt) + { + if (EntityTransferModule == null) + { + m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); + return; + } + + ScenePresence sp = GetScenePresence(remoteClient.AgentId); + if (sp == null || sp.IsDeleted || sp.IsInTransit) + return; + EntityTransferModule.RequestTeleportLandmark(remoteClient, lm, lookAt); + } + public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) { if (EntityTransferModule != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9de2c8ca78..47f75d9193 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5063,14 +5063,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScenePresence presence = World.GetScenePresence(agentId); if (presence != null && presence.PresenceType != PresenceType.Npc) { - if (destination == String.Empty) - destination = World.RegionInfo.RegionName; + if (presence.ParentID != 0) // Sitting + return; if (m_item.PermsGranter == agentId) { if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) { DoLLTeleport(presence, destination, targetPos, targetLookAt); + return; } } @@ -5078,19 +5079,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) { DoLLTeleport(presence, destination, targetPos, targetLookAt); + return; } - else - { - // agent must not be a god - if (presence.IsViewerUIGod) return; - // agent must be over the owners land - ILandObject agentLand = World.LandChannel.GetLandObject(presence.AbsolutePosition); - ILandObject objectLand = World.LandChannel.GetLandObject(m_host.AbsolutePosition); - if (m_host.OwnerID == objectLand.LandData.OwnerID && m_host.OwnerID == agentLand.LandData.OwnerID) - { - DoLLTeleport(presence, destination, targetPos, targetLookAt); - } + // agent must not be a god + if (presence.IsViewerUIGod) + return; + + // agent must be over the owners land + ILandObject agentLand = World.LandChannel.GetLandObject(presence.AbsolutePosition); + ILandObject objectLand = World.LandChannel.GetLandObject(m_host.AbsolutePosition); + if (m_host.OwnerID == objectLand.LandData.OwnerID && m_host.OwnerID == agentLand.LandData.OwnerID) + { + DoLLTeleport(presence, destination, targetPos, targetLookAt); } } } @@ -5135,11 +5136,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, destination); - // The destinaion is not an asset ID and also doesn't name a landmark. + // The destination is not an asset ID and also doesn't name a landmark. // Use it as a sim name if (assetID == UUID.Zero) { - World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + if(string.IsNullOrEmpty(destination)) + World.RequestTeleportLocation(sp.ControllingClient, World.RegionInfo.RegionName, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + else + World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); return; } @@ -5152,7 +5156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AssetLandmark lm = new AssetLandmark(lma); - World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + World.RequestTeleportLandmark(sp.ControllingClient, lm, targetLookAt); } public void llTextBox(string agent, string message, int chatChannel)