From 71ba85137f6b85db7c617bd6ee8ef2081b9fab61 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Jun 2012 16:45:52 +0100 Subject: Commitig the Avination implementation of llTeleportAgent and llTeleportAgentGlobalCoords. These do NOT use PERMISSION_TELEPORT like their SL counterparts because that permission is not yet understood by TPVs based on v1.x. --- .../Shared/Api/Implementation/LSL_Api.cs | 94 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 10 +++ 3 files changed, 106 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fb0fdc9..89f2068 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4169,6 +4169,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(5000); } + public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) + { + m_host.AddScriptLPS(1); + UUID agentId = new UUID(); + + Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); + + if (UUID.TryParse(agent, out agentId)) + { + ScenePresence presence = World.GetScenePresence(agentId); + if (presence != null && presence.PresenceType != PresenceType.Npc) + { + // agent must not be a god + if (presence.GodLevel >= 200) return; + + if (destination == String.Empty) + destination = World.RegionInfo.RegionName; + + // agent must be over the owners land + if (m_host.OwnerID == World.LandChannel.GetLandObject( + presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) + { + DoLLTeleport(presence, destination, targetPos, targetLookAt); + } + else // or must be wearing the prim + { + if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) + { + DoLLTeleport(presence, destination, targetPos, targetLookAt); + } + } + } + } + } + + public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) + { + m_host.AddScriptLPS(1); + UUID agentId = new UUID(); + + ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); + + Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); + if (UUID.TryParse(agent, out agentId)) + { + ScenePresence presence = World.GetScenePresence(agentId); + if (presence != null && presence.PresenceType != PresenceType.Npc) + { + // agent must not be a god + if (presence.GodLevel >= 200) return; + + // agent must be over the owners land + if (m_host.OwnerID == World.LandChannel.GetLandObject( + presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) + { + World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + } + else // or must be wearing the prim + { + if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) + { + World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + } + } + } + } + } + + private void DoLLTeleport(ScenePresence sp, string destination, Vector3 targetPos, Vector3 targetLookAt) + { + UUID assetID = KeyOrName(destination); + + // The destinaion 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); + return; + } + + AssetBase lma = World.AssetService.Get(assetID.ToString()); + if (lma == null) + return; + + if (lma.Type != (sbyte)AssetType.Landmark) + return; + + AssetLandmark lm = new AssetLandmark(lma); + + World.RequestTeleportLocation(sp.ControllingClient, lm.RegionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); + } + public void llTextBox(string agent, string message, int chatChannel) { IDialogModule dm = World.RequestModuleInterface(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 7f5d1fe..d39b204 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -403,6 +403,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llTargetOmega(LSL_Vector axis, double spinrate, double gain); void llTargetRemove(int number); void llTeleportAgentHome(string agent); + void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt); + void llTeleportAgentGlobalCoords(string agent, LSL_Vector global, LSL_Vector pos, LSL_Vector lookAt); void llTextBox(string avatar, string message, int chat_channel); LSL_String llToLower(string source); LSL_String llToUpper(string source); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index c0bf29c..06f5617 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1833,6 +1833,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llTargetRemove(number); } + public void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt) + { + m_LSL_Functions.llTeleportAgent(agent, simname, pos, lookAt); + } + + public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global, LSL_Vector pos, LSL_Vector lookAt) + { + m_LSL_Functions.llTeleportAgentGlobalCoords(agent, global, pos, lookAt); + } + public void llTeleportAgentHome(string agent) { m_LSL_Functions.llTeleportAgentHome(agent); -- cgit v1.1