/Aurora/AuroraDotNetEngine/APIs/OSSL_Api.cs
C# | 2846 lines | 2135 code | 432 blank | 279 comment | 490 complexity | 5007e9acdc0569cdeca3a8afef972619 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (c) Contributors, http://aurora-sim.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Aurora-Sim Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Globalization;
- using System.Linq;
- using System.Net;
- using System.Runtime.Remoting.Lifetime;
- using System.Text;
- using System.Text.RegularExpressions;
- using Aurora.Framework;
- using Aurora.Framework.ClientInterfaces;
- using Aurora.Framework.ConsoleFramework;
- using Aurora.Framework.Modules;
- using Aurora.Framework.PresenceInfo;
- using Aurora.Framework.SceneInfo;
- using Aurora.Framework.SceneInfo.Entities;
- using Aurora.Framework.Servers;
- using Aurora.Framework.Services;
- using Aurora.Framework.Services.ClassHelpers.Assets;
- using Aurora.Framework.Utilities;
- using Aurora.ScriptEngine.AuroraDotNetEngine.APIs.Interfaces;
- using Aurora.ScriptEngine.AuroraDotNetEngine.Runtime;
- using Nini.Config;
- using OpenMetaverse;
- using OpenMetaverse.StructuredData;
- using GridRegion = Aurora.Framework.Services.GridRegion;
- using Group = System.Text.RegularExpressions.Group;
- using LSL_Float = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLFloat;
- using LSL_Integer = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLInteger;
- using LSL_Key = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLString;
- using LSL_List = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.list;
- using LSL_Rotation = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Quaternion;
- using LSL_String = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLString;
- using LSL_Vector = Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3;
-
- namespace Aurora.ScriptEngine.AuroraDotNetEngine.APIs
- {
- [Serializable]
- public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
- {
- internal ScriptProtectionModule ScriptProtection;
- internal ILSL_Api m_LSL_Api; // get a reference to the LSL API so we can call methods housed there
- internal bool m_OSFunctionsEnabled;
- internal float m_ScriptDelayFactor = 1.0f;
- internal float m_ScriptDistanceFactor = 1.0f;
- internal IScriptModulePlugin m_ScriptEngine;
- internal ISceneChildEntity m_host;
- internal UUID m_itemID;
- internal uint m_localID;
-
- public IScene World
- {
- get { return m_host.ParentEntity.Scene; }
- }
-
- //
- // OpenSim functions
- //
-
- #region IOSSL_Api Members
-
- public LSL_Integer osSetTerrainHeight(int x, int y, double val)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight", m_host, "OSSL", m_itemID))
- return new LSL_Integer();
-
- if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
- OSSLError("osTerrainSetHeight: Coordinate out of bounds");
-
- if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
- {
- ITerrainChannel heightmap = World.RequestModuleInterface<ITerrainChannel>();
- heightmap[x, y] = (float) val;
- ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>();
- if (terrainModule != null) terrainModule.TaintTerrain();
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- public LSL_Float osGetTerrainHeight(int x, int y)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight", m_host, "OSSL", m_itemID))
- return new LSL_Float();
-
-
- if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
- OSSLError("osTerrainGetHeight: Coordinate out of bounds");
-
- ITerrainChannel heightmap = World.RequestModuleInterface<ITerrainChannel>();
- return heightmap[x, y];
- }
-
- public void osTerrainFlush()
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush", m_host, "OSSL", m_itemID))
- return;
-
- ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>();
- if (terrainModule != null) terrainModule.TaintTerrain();
- }
-
- public int osRegionRestart(double seconds)
- {
- // This is High here because region restart is not reliable
- // it may result in the region staying down or becoming
- // unstable. This should be changed to Low or VeryLow once
- // The underlying functionality is fixed, since the security
- // as such is sound
- //
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osRegionRestart", m_host, "OSSL", m_itemID))
- return new int();
-
- IRestartModule restartModule = World.RequestModuleInterface<IRestartModule>();
- if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null))
- {
- if (seconds < 15)
- {
- restartModule.AbortRestart("Restart aborted");
- return 1;
- }
-
- List<int> times = new List<int>();
- while (seconds > 0)
- {
- times.Add((int) seconds);
- if (seconds > 300)
- seconds -= 120;
- else if (seconds > 30)
- seconds -= 30;
- else
- seconds -= 15;
- }
-
- restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- public void osShutDown()
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osShutDown", m_host, "OSSL", m_itemID)) return;
-
- if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
- {
- MainConsole.Instance.RunCommand("shutdown");
- }
- }
-
- public void osReturnObjects(LSL_Float Parameter)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osReturnObjects", m_host, "OSSL", m_itemID))
- return;
-
- Dictionary<UUID, List<ISceneEntity>> returns =
- new Dictionary<UUID, List<ISceneEntity>>();
- IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
- if (parcelManagement != null)
- {
- ILandObject LO = parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
- IPrimCountModule primCountModule = World.RequestModuleInterface<IPrimCountModule>();
- IPrimCounts primCounts = primCountModule.GetPrimCounts(LO.LandData.GlobalID);
- if (Parameter == 0) // Owner objects
- {
- foreach (ISceneEntity obj in primCounts.Objects.Where(obj => obj.OwnerID == LO.LandData.OwnerID))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List<ISceneEntity>();
-
- returns[obj.OwnerID].Add(obj);
- }
- }
- if (Parameter == 1) //Everyone elses
- {
- foreach (ISceneEntity obj in primCounts.Objects.Where(obj => obj.OwnerID != LO.LandData.OwnerID &&
- (obj.GroupID != LO.LandData.GroupID ||
- LO.LandData.GroupID == UUID.Zero)))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List<ISceneEntity>();
-
- returns[obj.OwnerID].Add(obj);
- }
- }
- if (Parameter == 2) // Group
- {
- foreach (ISceneEntity obj in primCounts.Objects.Where(obj => obj.GroupID == LO.LandData.GroupID))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List<ISceneEntity>();
-
- returns[obj.OwnerID].Add(obj);
- }
- }
-
- foreach (List<ISceneEntity> ol in returns.Values)
- {
- if (World.Permissions.CanReturnObjects(LO, m_host.OwnerID, ol))
- {
- ILLClientInventory inventoryModule = World.RequestModuleInterface<ILLClientInventory>();
- if (inventoryModule != null)
- inventoryModule.ReturnObjects(ol.ToArray(), m_host.OwnerID);
- }
- }
- }
- }
-
- public void osReturnObject(LSL_Key userID)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osReturnObjects", m_host, "OSSL", m_itemID))
- return;
-
- Dictionary<UUID, List<ISceneEntity>> returns =
- new Dictionary<UUID, List<ISceneEntity>>();
- IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
- if (parcelManagement != null)
- {
- ILandObject LO = parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
-
- IPrimCountModule primCountModule = World.RequestModuleInterface<IPrimCountModule>();
- IPrimCounts primCounts = primCountModule.GetPrimCounts(LO.LandData.GlobalID);
-
- foreach (ISceneEntity obj in primCounts.Objects.Where(obj => obj.OwnerID == new UUID(userID.m_string)))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List<ISceneEntity>();
-
- returns[obj.OwnerID].Add(obj);
- }
-
- foreach (List<ISceneEntity> ol in returns.Values)
- {
- if (World.Permissions.CanReturnObjects(LO, m_host.OwnerID, ol))
- {
- ILLClientInventory inventoryModule = World.RequestModuleInterface<ILLClientInventory>();
- if (inventoryModule != null)
- inventoryModule.ReturnObjects(ol.ToArray(), m_host.OwnerID);
- }
- }
- }
- }
-
- public void osRegionNotice(string msg)
- {
- // This implementation provides absolutely no security
- // It's high griefing potential makes this classification
- // necessary
- //
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice", m_host, "OSSL", m_itemID))
- return;
-
-
- IDialogModule dm = World.RequestModuleInterface<IDialogModule>();
-
- if (dm != null)
- dm.SendGeneralAlert(msg);
- }
-
- public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
- int timer)
- {
- // This may be upgraded depending on the griefing or DOS
- // potential, or guarded with a delay
- //
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL", m_host, "OSSL",
- m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero, contentType,
- url,
- extraParams, timer);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, oldAssetID, contentType,
- url,
- extraParams, timer);
- return createdTexture.ToString();
- }
- }
-
- public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
- int timer, int alpha)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend", m_host, "OSSL",
- m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero, contentType,
- url,
- extraParams, timer, true, (byte) alpha);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, oldAssetID, contentType,
- url,
- extraParams, timer, true, (byte) alpha);
- return createdTexture.ToString();
- }
- }
-
- public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url,
- string extraParams,
- bool blend, int disp, int timer, int alpha, int face)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace", m_host,
- "OSSL", m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero, contentType,
- url,
- extraParams, timer, blend, disp, (byte) alpha, face);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, oldAssetID, contentType,
- url,
- extraParams, timer, blend, disp, (byte) alpha, face);
- return createdTexture.ToString();
- }
- }
-
- public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
- int timer)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData", m_host, "OSSL",
- m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (textureManager != null)
- {
- if (extraParams == String.Empty)
- {
- extraParams = "256";
- }
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero,
- contentType, data,
- extraParams, timer);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, oldAssetID,
- contentType, data,
- extraParams, timer);
- return createdTexture.ToString();
- }
- }
-
- return UUID.Zero.ToString();
- }
-
- public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
- int timer, int alpha)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend", m_host, "OSSL",
- m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (textureManager != null)
- {
- if (extraParams == String.Empty)
- {
- extraParams = "256";
- }
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero,
- contentType, data,
- extraParams, timer, true, (byte) alpha);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, oldAssetID,
- contentType, data,
- extraParams, timer, true, (byte) alpha);
- return createdTexture.ToString();
- }
- }
-
- return UUID.Zero.ToString();
- }
-
- private enum InfoType
- {
- Nick,
- Name,
- Login,
- Home,
- Custom
- };
-
- private string GridUserInfo(InfoType type)
- {
- return GridUserInfo(type, "");
- }
-
- private string GridUserInfo(InfoType type, string key)
- {
- string retval = String.Empty;
- IConfigSource config = m_ScriptEngine.ConfigSource;
- string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty);
-
- if (String.IsNullOrEmpty(url))
- return "Configuration Error!";
-
- string verb = "/json_grid_info";
- OSDMap json = new OSDMap();
-
- OSDMap info = (OSDMap) Util.CombineParams(new[] {String.Format("{0}{1}", url, verb)}, 3000);
-
- if (info["Success"] != true)
- return "Get GridInfo Failed!";
-
- json = (OSDMap) OSDParser.DeserializeJson(info["_RawResult"].AsString());
-
- switch (type)
- {
- case InfoType.Nick:
- retval = json["gridnick"];
- break;
-
- case InfoType.Name:
- retval = json["gridname"];
- break;
-
- case InfoType.Login:
- retval = json["login"];
- break;
-
- case InfoType.Home:
- retval = json["home"];
- break;
-
- case InfoType.Custom:
- retval = json[key];
- break;
-
- default:
- retval = "error";
- break;
- }
-
- return retval;
- }
-
- public string osGetGridHomeURI() //patched from OpenSim, you can remove this comment after pull
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetGridHomeURI", m_host, "OSSL",
- m_itemID)) return "";
-
- string HomeURI = String.Empty;
-
- if (m_ScriptEngine.Config.GetString("GridInfoService") != null)
- HomeURI = MainServer.Instance.ServerURI + "/";
-
- return HomeURI;
- }
-
- public string osGetGridCustom(string key) //patched from OpenSim, you can remove this comment after pull
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetGridCustom", m_host, "OSSL",
- m_itemID)) return "";
-
- string retval = String.Empty;
-
- if (m_ScriptEngine.Config.GetString("GridInfoService") != null)
- retval = m_ScriptEngine.Config.GetString("gridnick", retval);
-
- return retval;
- }
-
- public string osGetThreatLevel(string key)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetThreatLevel", m_host, "OSSL",
- m_itemID)) return "";
-
- string retval = String.Empty;
-
- if (m_ScriptEngine.Config.GetString("AllowedAPIs").Contains("os"))
- retval = m_ScriptEngine.Config.GetString("FunctionThreatLevel", retval);
-
- return retval;
- }
-
- public string osGetGridGatekeeperURI() //patched from OpenSim, you can remove this comment after pull
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetGridGatekeeperURI", m_host, "OSSL", m_itemID))
- return "";
- string gatekeeperURI = String.Empty;
- IConfigSource config = m_ScriptEngine.ConfigSource;
- if (config.Configs["GridService"] != null)
- gatekeeperURI = MainServer.Instance.ServerURI + "/";
- return gatekeeperURI;
- }
-
- public void osForceAttachToAvatar(int attachmentPoint)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar", m_host, "OSSL", m_itemID))
- return;
- InitLSL();
- ((LSL_Api) m_LSL_Api).AttachToAvatar(attachmentPoint, false);
- }
-
- public void osForceDetachFromAvatar()
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar", m_host, "OSSL", m_itemID))
- return;
- InitLSL();
- ((LSL_Api) m_LSL_Api).DetachFromAvatar();
- }
-
- public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data,
- string extraParams,
- bool blend, int disp, int timer, int alpha, int face)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlendFace", m_host,
- "OSSL", m_itemID)) return "";
-
-
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (textureManager != null)
- {
- if (extraParams == String.Empty)
- {
- extraParams = "256";
- }
- if (dynamicID == String.Empty)
- {
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, UUID.Zero,
- contentType, data,
- extraParams, timer, blend, disp, (byte) alpha, face);
- return createdTexture.ToString();
- }
- else
- {
- UUID oldAssetID = UUID.Parse(dynamicID);
- UUID createdTexture =
- textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, oldAssetID,
- contentType, data,
- extraParams, timer, blend, disp, (byte) alpha, face);
- return createdTexture.ToString();
- }
- }
-
- return UUID.Zero.ToString();
- }
-
- public bool osConsoleCommand(string command)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand", m_host, "OSSL", m_itemID))
- return false;
-
-
- if (m_ScriptEngine.Config.GetBoolean("AllowosConsoleCommand", false))
- {
- if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
- {
- MainConsole.Instance.RunCommand(command);
- return true;
- }
- }
- return false;
- }
-
- public void osSetPrimFloatOnWater(int floatYN)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater", m_host, "OSSL",
- m_itemID)) return;
-
- if (m_host.ParentEntity != null)
- {
- if (m_host.ParentEntity.RootChild != null)
- {
- m_host.ParentEntity.RootChild.SetFloatOnWater(floatYN);
- }
- }
- }
-
- public DateTime osTeleportOwner(string regionName, LSL_Vector position, LSL_Vector lookat)
- {
- // Threat level None because this is what can already be done with the World Map in the viewer
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osTeleportOwner", m_host, "OSSL", m_itemID))
- return DateTime.Now;
-
- List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.AllScopeIDs, regionName, 0, 1);
- // Try to link the region
- if (regions != null && regions.Count > 0)
- {
- GridRegion regInfo = regions[0];
-
- ulong regionHandle = regInfo.RegionHandle;
- return TeleportAgent(m_host.OwnerID, regionHandle,
- new Vector3((float) position.x, (float) position.y, (float) position.z),
- new Vector3((float) lookat.x, (float) lookat.y, (float) lookat.z));
- }
- return DateTime.Now;
- }
-
- public DateTime osTeleportOwner(LSL_Vector position, LSL_Vector lookat)
- {
- return osTeleportOwner(World.RegionInfo.RegionName, position, lookat);
- }
-
- public DateTime osTeleportOwner(int regionX, int regionY, LSL_Vector position, LSL_Vector lookat)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osTeleportOwner", m_host, "OSSL", m_itemID))
- return DateTime.Now;
-
- GridRegion regInfo = World.GridService.GetRegionByPosition(World.RegionInfo.AllScopeIDs,
- (regionX*Constants.RegionSize),
- (regionY*Constants.RegionSize));
- // Try to link the region
- if (regInfo != null)
- {
- ulong regionHandle = regInfo.RegionHandle;
- return TeleportAgent(m_host.OwnerID, regionHandle,
- new Vector3((float) position.x, (float) position.y, (float) position.z),
- new Vector3((float) lookat.x, (float) lookat.y, (float) lookat.z));
- }
- return DateTime.Now;
- }
-
- // Teleport functions
- public DateTime osTeleportAgent(string agent, string regionName, LSL_Vector position, LSL_Vector lookat)
- {
- // High because there is no security check. High griefer potential
- //
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osTeleportAgent", m_host, "OSSL", m_itemID))
- return DateTime.Now;
-
- UUID AgentID;
- if (UUID.TryParse(agent, out AgentID))
- {
- List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.AllScopeIDs, regionName,
- 0, 1);
- // Try to link the region
- if (regions != null && regions.Count > 0)
- {
- GridRegion regInfo = regions[0];
-
- ulong regionHandle = regInfo.RegionHandle;
- return TeleportAgent(AgentID, regionHandle,
- position.ToVector3(),
- lookat.ToVector3());
- }
- }
- return DateTime.Now;
- }
-
- // Teleport functions
- public DateTime osTeleportAgent(string agent, int regionX, int regionY, LSL_Vector position, LSL_Vector lookat)
- {
- // High because there is no security check. High griefer potential
- //
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osTeleportAgent", m_host, "OSSL", m_itemID))
- return DateTime.Now;
-
- ulong regionHandle = Utils.UIntsToLong(((uint) regionX*Constants.RegionSize),
- ((uint) regionY*Constants.RegionSize));
-
-
- UUID agentId = new UUID();
- if (UUID.TryParse(agent, out agentId))
- {
- return TeleportAgent(agentId, regionHandle,
- position.ToVector3(),
- lookat.ToVector3());
- }
- return DateTime.Now;
- }
-
- public DateTime osTeleportAgent(string agent, LSL_Vector position, LSL_Vector lookat)
- {
- return osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
- }
-
- // Functions that get information from the agent itself.
- //
- // osGetAgentIP - this is used to determine the IP address of
- //the client. This is needed to help configure other in world
- //resources based on the IP address of the clients connected.
- //I think High is a good risk level for this, as it is an
- //information leak.
- public LSL_String osGetAgentIP(string agent)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetAgentIP", m_host, "OSSL", m_itemID))
- return new LSL_String();
-
- UUID avatarID = (UUID) agent;
-
- IScenePresence target;
- if (World.TryGetScenePresence(avatarID, out target))
- {
- EndPoint ep = target.ControllingClient.GetClientEP();
- if (ep is IPEndPoint)
- {
- IPEndPoint ip = (IPEndPoint) ep;
- return new LSL_String(ip.Address.ToString());
- }
- }
- // fall through case, just return nothing
- return new LSL_String("");
- }
-
- // Get a list of all the avatars/agents in the region
- public LSL_List osGetAgents()
- {
- // threat level is None as we could get this information with an
- // in-world script as well, just not as efficient
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osGetAgents", m_host, "OSSL", m_itemID))
- return new LSL_List();
-
- LSL_List result = new LSL_List();
- World.ForEachScenePresence(delegate(IScenePresence sp)
- {
- if (!sp.IsChildAgent)
- result.Add(new LSL_String(sp.Name));
- });
- return result;
- }
-
- // Adam's super super custom animation functions
- public void osAvatarPlayAnimation(string avatar, string animation)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation", m_host, "OSSL",
- m_itemID)) return;
-
- UUID avatarID = (UUID) avatar;
-
-
- IScenePresence target;
- if (World.TryGetScenePresence(avatarID, out target))
- {
- if (target != null)
- {
- UUID animID = new UUID();
- if (!UUID.TryParse(animation, out animID))
- {
- animID = UUID.Zero;
- lock (m_host.TaskInventory)
- {
- foreach (
- KeyValuePair<UUID, TaskInventoryItem> inv in
- m_host.TaskInventory.Where(inv => inv.Value.Name == animation))
- {
- if (inv.Value.Type == (int) AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
- }
- }
-
- if (animID == UUID.Zero)
- target.Animator.AddAnimation(animation, m_host.UUID);
- else
- target.Animator.AddAnimation(animID, m_host.UUID);
- }
- }
- }
-
- public void osAvatarStopAnimation(string avatar, string animation)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation", m_host, "OSSL",
- m_itemID)) return;
-
- UUID avatarID = (UUID) avatar;
-
-
- IScenePresence target;
- if (World.TryGetScenePresence(avatarID, out target))
- {
- if (target != null)
- {
- UUID animID = UUID.Zero;
- lock (m_host.TaskInventory)
- {
- foreach (
- KeyValuePair<UUID, TaskInventoryItem> inv in
- m_host.TaskInventory.Where(inv => inv.Value.Name == animation))
- {
- if (inv.Value.Type == (int) AssetType.Animation)
- animID = inv.Value.AssetID;
- continue;
- }
- }
-
- if (animID == UUID.Zero)
- target.Animator.RemoveAnimation(animation);
- else
- target.Animator.RemoveAnimation(animID);
- }
- }
- }
-
- //Texture draw functions
- public string osMovePen(string drawList, int x, int y)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osMovePen", m_host, "OSSL", m_itemID)) return "";
-
-
- drawList += "MoveTo " + x + "," + y + ";";
- return new LSL_String(drawList);
- }
-
- public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawLine", m_host, "OSSL", m_itemID)) return "";
-
-
- drawList += "MoveTo " + startX + "," + startY + "; LineTo " + endX + "," + endY + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawLine(string drawList, int endX, int endY)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawLine", m_host, "OSSL", m_itemID)) return "";
-
-
- drawList += "LineTo " + endX + "," + endY + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawText(string drawList, string text)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawText", m_host, "OSSL", m_itemID)) return "";
-
-
- drawList += "Text " + text + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawEllipse(string drawList, int width, int height)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawEllipse", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "Ellipse " + width + "," + height + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawRectangle(string drawList, int width, int height)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawRectangle", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "Rectangle " + width + "," + height + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawFilledRectangle(string drawList, int width, int height)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawFilledRectangle", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "FillRectangle " + width + "," + height + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon", m_host, "OSSL", m_itemID))
- return "";
-
-
- if (x.Length != y.Length || x.Length < 3)
- {
- return new LSL_String("");
- }
- drawList += "FillPolygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
- for (int i = 1; i < x.Length; i++)
- {
- drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
- }
- drawList += "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawPolygon(string drawList, LSL_List x, LSL_List y)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon", m_host, "OSSL", m_itemID))
- return "";
-
-
- if (x.Length != y.Length || x.Length < 3)
- {
- return new LSL_String("");
- }
- drawList += "Polygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
- for (int i = 1; i < x.Length; i++)
- {
- drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
- }
- drawList += "; ";
- return new LSL_String(drawList);
- }
-
- public string osSetFontSize(string drawList, int fontSize)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osSetFontSize", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "FontSize " + fontSize + "; ";
- return drawList;
- }
-
- public string osSetFontName(string drawList, string fontName)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osSetFontName", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "FontName " + fontName + "; ";
- return new LSL_String(drawList);
- }
-
- public string osSetPenSize(string drawList, int penSize)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osSetPenSize", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "PenSize " + penSize + "; ";
- return new LSL_String(drawList);
- }
-
- public string osSetPenColor(string drawList, string colour)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osSetPenColor", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "PenColour " + colour + "; ";
- return new LSL_String(drawList);
- }
-
- public string osSetPenCap(string drawList, string direction, string type)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osSetPenColor", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "PenCap " + direction + "," + type + "; ";
- return new LSL_String(drawList);
- }
-
- public string osDrawImage(string drawList, int width, int height, string imageUrl)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osDrawImage", m_host, "OSSL", m_itemID))
- return "";
-
-
- drawList += "Image " + width + "," + height + "," + imageUrl + "; ";
- return new LSL_String(drawList);
- }
-
- public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize", m_host, "OSSL", m_itemID))
- return new LSL_Vector();
-
-
- LSL_Vector vec = new LSL_Vector(0, 0, 0);
- IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
- if (textureManager != null)
- {
- double xSize, ySize;
- textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
- out xSize, out ySize);
- vec.x = xSize;
- vec.y = ySize;
- }
- return vec;
- }
-
- public void osSetRegionWaterHeight(double height)
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight", m_host, "OSSL", m_itemID))
- return;
-
-
- //Check to make sure that the script's owner is the estate manager/master
- //World.Permissions.GenericEstatePermission(
- if (World.Permissions.IsGod(m_host.OwnerID))
- {
- World.EventManager.TriggerRequestChangeWaterHeight((float) height);
- }
- }
-
- /// <summary>
- /// Changes the Region Sun Settings, then Triggers a Sun Update
- /// </summary>
- /// <param name="useEstateSun">True to use Estate Sun instead of Region Sun</param>
- /// <param name="sunFixed">True to keep the sun stationary</param>
- /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
- public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings", m_host, "OSSL",
- m_itemID)) return;
-
-
- //Check to make sure that the script's owner is the estate manager/master
- //World.Permissions.GenericEstatePermission(
- if (World.Permissions.IsGod(m_host.OwnerID))
- {
- while (sunHour > 24.0)
- sunHour -= 24.0;
-
- while (sunHour < 0)
- sunHour += 24.0;
-
-
- World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
- World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
- World.RegionInfo.RegionSettings.FixedSun = sunFixed;
-
- World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun,
- (float) sunHour);
- }
- }
-
- /// <summary>
- /// Changes the Estate Sun Settings, then Triggers a Sun Update
- /// </summary>
- /// <param name="sunFixed">True to keep the sun stationary, false to use global time</param>
- /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
- public void osSetEstateSunSettings(bool sunFixed, double sunHour)
- {
- if (
- !ScriptProtection.CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings", m_host, "OSSL",
- m_itemID)) return;
-
-
- //Check to make sure that the script's owner is the estate manager/master
- //World.Permissions.GenericEstatePermission(
- if (World.Permissions.IsGod(m_host.OwnerID))
- {
- while (sunHour > 24.0)
- sunHour -= 24.0;
-
- while (sunHour < 0)
- sunHour += 24.0;
-
- World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
- World.RegionInfo.EstateSettings.SunPosition = sunHour;
- World.RegionInfo.EstateSettings.FixedSun = sunFixed;
- World.RegionInfo.EstateSettings.Save();
-
- World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed,
- World.RegionInfo.RegionSettings.UseEstateSun,
- (float) sunHour);
- }
- }
-
- /// <summary>
- /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise
- /// </summary>
- /// <returns></returns>
- public double osGetCurrentSunHour()
- {
- if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour", m_host, "OSSL", m_itemID))
- return 0;
-
-
- // Must adjust for the fact that Region Sun Settings are still LL offset
- double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6;
-
- // See if the sun module has registered itself, if so it's authoritative
- ISunModule module = World.RequestModuleInterface<ISunModule>();
- if (module != null)
- {
- sunHour = module.G…
Large files files are truncated, but you can click here to view the full file