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(). --- .../Common/BuiltIn_Commands_BaseClass.cs | 14 +++++- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 2 +- .../ScriptEngine/Common/OSSL_BuilIn_Commands.cs | 30 ++++++++++++- .../Common/OSSL_BuilIn_Commands_Interface.cs | 4 ++ .../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 ++++++ 8 files changed, 114 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 1b7cc48..cfc8e94 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs @@ -37,7 +37,7 @@ using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion; namespace OpenSim.Region.ScriptEngine.Common { - public class BuiltIn_Commands_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript + public class BuiltIn_Commands_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, OSSL_BuilIn_Commands_Interface, IScript { // // Included as base for any LSL-script that is compiled. @@ -1942,6 +1942,18 @@ namespace OpenSim.Region.ScriptEngine.Common m_LSL_Functions.osSetPrimFloatOnWater(floatYN); } + // Teleport Functions + + public void osTeleportAgent(string agent, string regionName, vector position, vector lookat) + { + m_LSL_Functions.osTeleportAgent(agent, regionName, position, lookat); + } + + public void osTeleportAgent(string agent, vector position, vector lookat) + { + m_LSL_Functions.osTeleportAgent(agent, position, lookat); + } + // Animation Functions public void osAvatarPlayAnimation(string avatar, string animation) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 39502b6..5d6cd37 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.ScriptEngine.Common private float m_distanceFactor = 1.0f; - private void ScriptSleep(int delay) + protected void ScriptSleep(int delay) { delay = (int)((float)delay * m_delayFactor); if (delay == 0) diff --git a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs index c6ded79..264a586 100644 --- a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs @@ -32,7 +32,7 @@ using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; - +using TPFlags = OpenSim.Framework.Constants.TeleportFlags; //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; namespace OpenSim.Region.ScriptEngine.Common @@ -436,6 +436,34 @@ namespace OpenSim.Region.ScriptEngine.Common } } + // 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/Common/OSSL_BuilIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands_Interface.cs index 7daef7d..9c1587d 100644 --- a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands_Interface.cs @@ -44,6 +44,10 @@ namespace OpenSim.Region.ScriptEngine.Common 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/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