From 5164fa24110b0197c2d18dc824351d384b1b8582 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 15 Sep 2008 14:32:02 +0000 Subject: Mantis#2197. Thank you kindly, Tyre, for a patch that: adds the new function osTeleportAgent(). --- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- .../Shared/Api/Implementation/OSSL_Api.cs | 50 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 4 ++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 12 ++++++ 4 files changed, 67 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 00f843f..a5ff42d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; } - private void ScriptSleep(int delay) + protected void ScriptSleep(int delay) { delay = (int)((float)delay * m_ScriptDelayFactor); if (delay == 0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5d69673..5293a26 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -36,6 +36,7 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; +using TPFlags = OpenSim.Framework.Constants.TeleportFlags; namespace OpenSim.Region.ScriptEngine.Shared.Api { @@ -46,6 +47,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal SceneObjectPart m_host; internal uint m_localID; internal UUID m_itemID; + internal AsyncCommandManager AsyncCommands = null; + internal float m_ScriptDelayFactor = 1.0f; + internal float m_ScriptDistanceFactor = 1.0f; public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) { @@ -53,6 +57,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host = host; m_localID = localID; m_itemID = itemID; + + IConfigSource config = new IniConfigSource(Application.iniFilePath); + if (config.Configs["XEngine"] == null) + config.AddConfig("XEngine"); + + m_ScriptDelayFactor = config.Configs["XEngine"]. + GetFloat("ScriptDelayFactor", 1.0f); + m_ScriptDistanceFactor = config.Configs["XEngine"]. + GetFloat("ScriptDistanceLimitFactor", 1.0f); + + AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; } // @@ -69,6 +84,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return lease; } + protected void ScriptSleep(int delay) + { + delay = (int)((float)delay * m_ScriptDelayFactor); + if (delay == 0) + return; + System.Threading.Thread.Sleep(delay); + } + // // OpenSim functions // @@ -312,6 +335,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + // Teleport functions + public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + { + m_host.AddScriptLPS(1); + UUID agentId = new UUID(); + if (UUID.TryParse(agent, out agentId)) + { + ScenePresence presence = World.GetScenePresence(agentId); + if (presence != null) + { + // agent must be over owners land to avoid abuse + if (m_host.OwnerID == World.GetLandOwner(presence.AbsolutePosition.X, presence.AbsolutePosition.Y)) + { + World.RequestTeleportLocation(presence.ControllingClient, regionName, + new Vector3((float)position.x, (float)position.y, (float)position.z), + new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); + // ScriptSleep(5000); + } + } + } + } + + public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + { + osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat); + } + // Adam's super super custom animation functions public void osAvatarPlayAnimation(string avatar, string animation) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 87b3ef4..d4bb8c3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -44,6 +44,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetParcelMediaURL(string url); void osSetPrimFloatOnWater(int floatYN); + // Teleport commands + void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); + void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); + // Animation commands void osAvatarPlayAnimation(string avatar, string animation); void osAvatarStopAnimation(string avatar, string animation); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 9d0c337..3a7c14e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -122,6 +122,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osSetPrimFloatOnWater(floatYN); } + // Teleport Functions + + public void osTeleportAgent(string agent, string regionName, vector position, vector lookat) + { + m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat); + } + + public void osTeleportAgent(string agent, vector position, vector lookat) + { + m_OSSL_Functions.osTeleportAgent(agent, position, lookat); + } + // Animation Functions public void osAvatarPlayAnimation(string avatar, string animation) -- cgit v1.1