OSSL_Api.cs 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Runtime.Remoting.Lifetime;
  31. using System.Text;
  32. using System.Net;
  33. using System.Threading;
  34. using OpenMetaverse;
  35. using Nini.Config;
  36. using OpenSim;
  37. using OpenSim.Framework;
  38. using OpenSim.Framework.Communications.Cache;
  39. using OpenSim.Framework.Console;
  40. using OpenSim.Region.CoreModules.Avatar.NPC;
  41. using OpenSim.Region.Framework.Interfaces;
  42. using OpenSim.Region.Framework.Scenes;
  43. using OpenSim.Region.Framework.Scenes.Hypergrid;
  44. using OpenSim.Region.ScriptEngine.Shared;
  45. using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
  46. using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
  47. using OpenSim.Region.ScriptEngine.Interfaces;
  48. using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
  49. using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
  50. using OpenSim.Services.Interfaces;
  51. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  52. using System.Text.RegularExpressions;
  53. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  54. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  55. using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  56. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  57. using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  58. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  59. using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  60. namespace OpenSim.Region.ScriptEngine.Shared.Api
  61. {
  62. //////////////////////////////////////////////////////////////
  63. //
  64. // Level description
  65. //
  66. // None - Function is no threat at all. It doesn't constitute
  67. // an threat to either users or the system and has no
  68. // known side effects
  69. //
  70. // Nuisance - Abuse of this command can cause a nuisance to the
  71. // region operator, such as log message spew
  72. //
  73. // VeryLow - Extreme levels ob abuse of this function can cause
  74. // impaired functioning of the region, or very gullible
  75. // users can be tricked into experiencing harmless effects
  76. //
  77. // Low - Intentional abuse can cause crashes or malfunction
  78. // under certain circumstances, which can easily be rectified,
  79. // or certain users can be tricked into certain situations
  80. // in an avoidable manner.
  81. //
  82. // Moderate - Intentional abuse can cause denial of service and crashes
  83. // with potential of data or state loss, or trusting users
  84. // can be tricked into embarrassing or uncomfortable
  85. // situationsa.
  86. //
  87. // High - Casual abuse can cause impaired functionality or temporary
  88. // denial of service conditions. Intentional abuse can easily
  89. // cause crashes with potential data loss, or can be used to
  90. // trick experienced and cautious users into unwanted situations,
  91. // or changes global data permanently and without undo ability
  92. // Malicious scripting can allow theft of content
  93. //
  94. // VeryHigh - Even normal use may, depending on the number of instances,
  95. // or frequency of use, result in severe service impairment
  96. // or crash with loss of data, or can be used to cause
  97. // unwanted or harmful effects on users without giving the
  98. // user a means to avoid it.
  99. //
  100. // Severe - Even casual use is a danger to region stability, or function
  101. // allows console or OS command execution, or function allows
  102. // taking money without consent, or allows deletion or
  103. // modification of user data, or allows the compromise of
  104. // sensitive data by design.
  105. [Serializable]
  106. public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
  107. {
  108. internal IScriptEngine m_ScriptEngine;
  109. internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
  110. internal SceneObjectPart m_host;
  111. internal uint m_localID;
  112. internal UUID m_itemID;
  113. internal bool m_OSFunctionsEnabled = false;
  114. internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
  115. internal float m_ScriptDelayFactor = 1.0f;
  116. internal float m_ScriptDistanceFactor = 1.0f;
  117. internal Dictionary<string, List<UUID> > m_FunctionPerms = new Dictionary<string, List<UUID> >();
  118. public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
  119. {
  120. m_ScriptEngine = ScriptEngine;
  121. m_host = host;
  122. m_localID = localID;
  123. m_itemID = itemID;
  124. if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
  125. m_OSFunctionsEnabled = true;
  126. m_ScriptDelayFactor =
  127. m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
  128. m_ScriptDistanceFactor =
  129. m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);
  130. string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
  131. switch (risk)
  132. {
  133. case "None":
  134. m_MaxThreatLevel = ThreatLevel.None;
  135. break;
  136. case "VeryLow":
  137. m_MaxThreatLevel = ThreatLevel.VeryLow;
  138. break;
  139. case "Low":
  140. m_MaxThreatLevel = ThreatLevel.Low;
  141. break;
  142. case "Moderate":
  143. m_MaxThreatLevel = ThreatLevel.Moderate;
  144. break;
  145. case "High":
  146. m_MaxThreatLevel = ThreatLevel.High;
  147. break;
  148. case "VeryHigh":
  149. m_MaxThreatLevel = ThreatLevel.VeryHigh;
  150. break;
  151. case "Severe":
  152. m_MaxThreatLevel = ThreatLevel.Severe;
  153. break;
  154. default:
  155. break;
  156. }
  157. }
  158. public override Object InitializeLifetimeService()
  159. {
  160. ILease lease = (ILease)base.InitializeLifetimeService();
  161. if (lease.CurrentState == LeaseState.Initial)
  162. {
  163. lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
  164. // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
  165. // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
  166. }
  167. return lease;
  168. }
  169. public Scene World
  170. {
  171. get { return m_ScriptEngine.World; }
  172. }
  173. internal void OSSLError(string msg)
  174. {
  175. throw new Exception("OSSL Runtime Error: " + msg);
  176. }
  177. private void InitLSL()
  178. {
  179. if (m_LSL_Api != null)
  180. return;
  181. m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL");
  182. }
  183. //
  184. //Dumps an error message on the debug console.
  185. //
  186. internal void OSSLShoutError(string message)
  187. {
  188. if (message.Length > 1023)
  189. message = message.Substring(0, 1023);
  190. World.SimChat(Utils.StringToBytes(message),
  191. ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
  192. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  193. wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
  194. }
  195. public void CheckThreatLevel(ThreatLevel level, string function)
  196. {
  197. if (!m_OSFunctionsEnabled)
  198. OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws
  199. if (!m_FunctionPerms.ContainsKey(function))
  200. {
  201. string perm = m_ScriptEngine.Config.GetString("Allow_" + function, "");
  202. if (perm == "")
  203. {
  204. m_FunctionPerms[function] = null; // a null value is default
  205. }
  206. else
  207. {
  208. bool allowed;
  209. if (bool.TryParse(perm, out allowed))
  210. {
  211. // Boolean given
  212. if (allowed)
  213. {
  214. m_FunctionPerms[function] = new List<UUID>();
  215. m_FunctionPerms[function].Add(UUID.Zero);
  216. }
  217. else
  218. m_FunctionPerms[function] = new List<UUID>(); // Empty list = none
  219. }
  220. else
  221. {
  222. m_FunctionPerms[function] = new List<UUID>();
  223. string[] ids = perm.Split(new char[] {','});
  224. foreach (string id in ids)
  225. {
  226. string current = id.Trim();
  227. UUID uuid;
  228. if (UUID.TryParse(current, out uuid))
  229. {
  230. if (uuid != UUID.Zero)
  231. m_FunctionPerms[function].Add(uuid);
  232. }
  233. }
  234. }
  235. }
  236. }
  237. // If the list is null, then the value was true / undefined
  238. // Threat level governs permissions in this case
  239. //
  240. // If the list is non-null, then it is a list of UUIDs allowed
  241. // to use that particular function. False causes an empty
  242. // list and therefore means "no one"
  243. //
  244. // To allow use by anyone, the list contains UUID.Zero
  245. //
  246. if (m_FunctionPerms[function] == null) // No list = true
  247. {
  248. if (level > m_MaxThreatLevel)
  249. OSSLError(
  250. String.Format(
  251. "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.",
  252. function, m_MaxThreatLevel, level));
  253. }
  254. else
  255. {
  256. if (!m_FunctionPerms[function].Contains(UUID.Zero))
  257. {
  258. if (!m_FunctionPerms[function].Contains(m_host.OwnerID))
  259. OSSLError(
  260. String.Format("{0} permission denied. Prim owner is not in the list of users allowed to execute this function.",
  261. function));
  262. }
  263. }
  264. }
  265. protected void ScriptSleep(int delay)
  266. {
  267. delay = (int)((float)delay * m_ScriptDelayFactor);
  268. if (delay == 0)
  269. return;
  270. System.Threading.Thread.Sleep(delay);
  271. }
  272. //
  273. // OpenSim functions
  274. //
  275. public LSL_Integer osTerrainSetHeight(int x, int y, double val)
  276. {
  277. CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
  278. m_host.AddScriptLPS(1);
  279. if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
  280. OSSLError("osTerrainSetHeight: Coordinate out of bounds");
  281. if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
  282. {
  283. World.Heightmap[x, y] = val;
  284. return 1;
  285. }
  286. else
  287. {
  288. return 0;
  289. }
  290. }
  291. public LSL_Float osTerrainGetHeight(int x, int y)
  292. {
  293. CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
  294. m_host.AddScriptLPS(1);
  295. if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
  296. OSSLError("osTerrainGetHeight: Coordinate out of bounds");
  297. return World.Heightmap[x, y];
  298. }
  299. public void osTerrainFlush()
  300. {
  301. CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush");
  302. ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>();
  303. if (terrainModule != null) terrainModule.TaintTerrain();
  304. }
  305. public int osRegionRestart(double seconds)
  306. {
  307. // This is High here because region restart is not reliable
  308. // it may result in the region staying down or becoming
  309. // unstable. This should be changed to Low or VeryLow once
  310. // The underlying functionality is fixed, since the security
  311. // as such is sound
  312. //
  313. CheckThreatLevel(ThreatLevel.High, "osRegionRestart");
  314. m_host.AddScriptLPS(1);
  315. if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
  316. {
  317. World.Restart((float)seconds);
  318. return 1;
  319. }
  320. else
  321. {
  322. return 0;
  323. }
  324. }
  325. public void osRegionNotice(string msg)
  326. {
  327. // This implementation provides absolutely no security
  328. // It's high griefing potential makes this classification
  329. // necessary
  330. //
  331. CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice");
  332. m_host.AddScriptLPS(1);
  333. IDialogModule dm = World.RequestModuleInterface<IDialogModule>();
  334. if (dm != null)
  335. dm.SendGeneralAlert(msg);
  336. }
  337. public void osSetRot(UUID target, Quaternion rotation)
  338. {
  339. // This function has no security. It can be used to destroy
  340. // arbitrary builds the user would normally have no rights to
  341. //
  342. CheckThreatLevel(ThreatLevel.VeryHigh, "osSetRot");
  343. m_host.AddScriptLPS(1);
  344. if (World.Entities.ContainsKey(target))
  345. {
  346. World.Entities[target].Rotation = rotation;
  347. }
  348. else
  349. {
  350. OSSLError("osSetRot: Invalid target");
  351. }
  352. }
  353. public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
  354. int timer)
  355. {
  356. // This may be upgraded depending on the griefing or DOS
  357. // potential, or guarded with a delay
  358. //
  359. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURL");
  360. m_host.AddScriptLPS(1);
  361. if (dynamicID == String.Empty)
  362. {
  363. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  364. UUID createdTexture =
  365. textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
  366. extraParams, timer);
  367. return createdTexture.ToString();
  368. }
  369. else
  370. {
  371. //TODO update existing dynamic textures
  372. }
  373. return UUID.Zero.ToString();
  374. }
  375. public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  376. int timer, int alpha)
  377. {
  378. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlend");
  379. m_host.AddScriptLPS(1);
  380. if (dynamicID == String.Empty)
  381. {
  382. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  383. UUID createdTexture =
  384. textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
  385. extraParams, timer, true, (byte) alpha);
  386. return createdTexture.ToString();
  387. }
  388. else
  389. {
  390. //TODO update existing dynamic textures
  391. }
  392. return UUID.Zero.ToString();
  393. }
  394. public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams,
  395. bool blend, int disp, int timer, int alpha, int face)
  396. {
  397. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace");
  398. m_host.AddScriptLPS(1);
  399. if (dynamicID == String.Empty)
  400. {
  401. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  402. UUID createdTexture =
  403. textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
  404. extraParams, timer, blend, disp, (byte) alpha, face);
  405. return createdTexture.ToString();
  406. }
  407. else
  408. {
  409. //TODO update existing dynamic textures
  410. }
  411. return UUID.Zero.ToString();
  412. }
  413. public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
  414. int timer)
  415. {
  416. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureData");
  417. m_host.AddScriptLPS(1);
  418. if (dynamicID == String.Empty)
  419. {
  420. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  421. if (textureManager != null)
  422. {
  423. if (extraParams == String.Empty)
  424. {
  425. extraParams = "256";
  426. }
  427. UUID createdTexture =
  428. textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
  429. extraParams, timer);
  430. return createdTexture.ToString();
  431. }
  432. }
  433. else
  434. {
  435. //TODO update existing dynamic textures
  436. }
  437. return UUID.Zero.ToString();
  438. }
  439. public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  440. int timer, int alpha)
  441. {
  442. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlend");
  443. m_host.AddScriptLPS(1);
  444. if (dynamicID == String.Empty)
  445. {
  446. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  447. if (textureManager != null)
  448. {
  449. if (extraParams == String.Empty)
  450. {
  451. extraParams = "256";
  452. }
  453. UUID createdTexture =
  454. textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
  455. extraParams, timer, true, (byte) alpha);
  456. return createdTexture.ToString();
  457. }
  458. }
  459. else
  460. {
  461. //TODO update existing dynamic textures
  462. }
  463. return UUID.Zero.ToString();
  464. }
  465. public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
  466. bool blend, int disp, int timer, int alpha, int face)
  467. {
  468. CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlendFace");
  469. m_host.AddScriptLPS(1);
  470. if (dynamicID == String.Empty)
  471. {
  472. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  473. if (textureManager != null)
  474. {
  475. if (extraParams == String.Empty)
  476. {
  477. extraParams = "256";
  478. }
  479. UUID createdTexture =
  480. textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
  481. extraParams, timer, blend, disp, (byte) alpha, face);
  482. return createdTexture.ToString();
  483. }
  484. }
  485. else
  486. {
  487. //TODO update existing dynamic textures
  488. }
  489. return UUID.Zero.ToString();
  490. }
  491. public bool osConsoleCommand(string command)
  492. {
  493. CheckThreatLevel(ThreatLevel.Severe, "osConsoleCommand");
  494. m_host.AddScriptLPS(1);
  495. if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
  496. {
  497. MainConsole.Instance.RunCommand(command);
  498. return true;
  499. }
  500. return false;
  501. }
  502. public void osSetPrimFloatOnWater(int floatYN)
  503. {
  504. CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater");
  505. m_host.AddScriptLPS(1);
  506. if (m_host.ParentGroup != null)
  507. {
  508. if (m_host.ParentGroup.RootPart != null)
  509. {
  510. m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
  511. }
  512. }
  513. }
  514. // Teleport functions
  515. public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
  516. {
  517. // High because there is no security check. High griefer potential
  518. //
  519. CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
  520. m_host.AddScriptLPS(1);
  521. UUID agentId = new UUID();
  522. if (UUID.TryParse(agent, out agentId))
  523. {
  524. ScenePresence presence = World.GetScenePresence(agentId);
  525. if (presence != null)
  526. {
  527. // agent must be over owners land to avoid abuse
  528. if (m_host.OwnerID
  529. == World.LandChannel.GetLandObject(
  530. presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
  531. {
  532. // Check for hostname , attempt to make a hglink
  533. // and convert the regionName to the target region
  534. if (regionName.Contains(".") && regionName.Contains(":"))
  535. {
  536. // Try to link the region
  537. IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>();
  538. if (hyperService != null)
  539. {
  540. GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
  541. regionName);
  542. // Get the region name
  543. if (regInfo != null)
  544. {
  545. regionName = regInfo.RegionName;
  546. }
  547. else
  548. {
  549. // Might need to ping the client here in case of failure??
  550. }
  551. }
  552. }
  553. presence.ControllingClient.SendTeleportLocationStart();
  554. World.RequestTeleportLocation(presence.ControllingClient, regionName,
  555. new Vector3((float)position.x, (float)position.y, (float)position.z),
  556. new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
  557. ScriptSleep(5000);
  558. }
  559. }
  560. }
  561. }
  562. // Teleport functions
  563. public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
  564. {
  565. // High because there is no security check. High griefer potential
  566. //
  567. CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
  568. ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize));
  569. m_host.AddScriptLPS(1);
  570. UUID agentId = new UUID();
  571. if (UUID.TryParse(agent, out agentId))
  572. {
  573. ScenePresence presence = World.GetScenePresence(agentId);
  574. if (presence != null)
  575. {
  576. // agent must be over owners land to avoid abuse
  577. if (m_host.OwnerID
  578. == World.LandChannel.GetLandObject(
  579. presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
  580. {
  581. presence.ControllingClient.SendTeleportLocationStart();
  582. World.RequestTeleportLocation(presence.ControllingClient, regionHandle,
  583. new Vector3((float)position.x, (float)position.y, (float)position.z),
  584. new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
  585. ScriptSleep(5000);
  586. }
  587. }
  588. }
  589. }
  590. public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
  591. {
  592. osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
  593. }
  594. // Functions that get information from the agent itself.
  595. //
  596. // osGetAgentIP - this is used to determine the IP address of
  597. //the client. This is needed to help configure other in world
  598. //resources based on the IP address of the clients connected.
  599. //I think High is a good risk level for this, as it is an
  600. //information leak.
  601. public string osGetAgentIP(string agent)
  602. {
  603. CheckThreatLevel(ThreatLevel.High, "osGetAgentIP");
  604. UUID avatarID = (UUID)agent;
  605. m_host.AddScriptLPS(1);
  606. if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence)
  607. {
  608. ScenePresence target = (ScenePresence)World.Entities[avatarID];
  609. EndPoint ep = target.ControllingClient.GetClientEP();
  610. if (ep is IPEndPoint)
  611. {
  612. IPEndPoint ip = (IPEndPoint)ep;
  613. return ip.Address.ToString();
  614. }
  615. }
  616. // fall through case, just return nothing
  617. return "";
  618. }
  619. // Get a list of all the avatars/agents in the region
  620. public LSL_List osGetAgents()
  621. {
  622. // threat level is None as we could get this information with an
  623. // in-world script as well, just not as efficient
  624. CheckThreatLevel(ThreatLevel.None, "osGetAgents");
  625. LSL_List result = new LSL_List();
  626. foreach (ScenePresence avatar in World.GetAvatars())
  627. {
  628. result.Add(avatar.Name);
  629. }
  630. return result;
  631. }
  632. // Adam's super super custom animation functions
  633. public void osAvatarPlayAnimation(string avatar, string animation)
  634. {
  635. CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation");
  636. UUID avatarID = (UUID)avatar;
  637. m_host.AddScriptLPS(1);
  638. if (World.Entities.ContainsKey((UUID)avatar) && World.Entities[avatarID] is ScenePresence)
  639. {
  640. ScenePresence target = (ScenePresence)World.Entities[avatarID];
  641. if (target != null)
  642. {
  643. UUID animID=UUID.Zero;
  644. lock (m_host.TaskInventory)
  645. {
  646. foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
  647. {
  648. if (inv.Value.Name == animation)
  649. {
  650. if (inv.Value.Type == (int)AssetType.Animation)
  651. animID = inv.Value.AssetID;
  652. continue;
  653. }
  654. }
  655. }
  656. if (animID == UUID.Zero)
  657. target.AddAnimation(animation, m_host.UUID);
  658. else
  659. target.AddAnimation(animID, m_host.UUID);
  660. }
  661. }
  662. }
  663. public void osAvatarStopAnimation(string avatar, string animation)
  664. {
  665. CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation");
  666. UUID avatarID = (UUID)avatar;
  667. m_host.AddScriptLPS(1);
  668. if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
  669. {
  670. ScenePresence target = (ScenePresence)World.Entities[avatarID];
  671. if (target != null)
  672. {
  673. UUID animID=UUID.Zero;
  674. lock (m_host.TaskInventory)
  675. {
  676. foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
  677. {
  678. if (inv.Value.Name == animation)
  679. {
  680. if (inv.Value.Type == (int)AssetType.Animation)
  681. animID = inv.Value.AssetID;
  682. continue;
  683. }
  684. }
  685. }
  686. if (animID == UUID.Zero)
  687. target.RemoveAnimation(animation);
  688. else
  689. target.RemoveAnimation(animID);
  690. }
  691. }
  692. }
  693. //Texture draw functions
  694. public string osMovePen(string drawList, int x, int y)
  695. {
  696. CheckThreatLevel(ThreatLevel.None, "osMovePen");
  697. m_host.AddScriptLPS(1);
  698. drawList += "MoveTo " + x + "," + y + ";";
  699. return drawList;
  700. }
  701. public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
  702. {
  703. CheckThreatLevel(ThreatLevel.None, "osDrawLine");
  704. m_host.AddScriptLPS(1);
  705. drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
  706. return drawList;
  707. }
  708. public string osDrawLine(string drawList, int endX, int endY)
  709. {
  710. CheckThreatLevel(ThreatLevel.None, "osDrawLine");
  711. m_host.AddScriptLPS(1);
  712. drawList += "LineTo " + endX + "," + endY + "; ";
  713. return drawList;
  714. }
  715. public string osDrawText(string drawList, string text)
  716. {
  717. CheckThreatLevel(ThreatLevel.None, "osDrawText");
  718. m_host.AddScriptLPS(1);
  719. drawList += "Text " + text + "; ";
  720. return drawList;
  721. }
  722. public string osDrawEllipse(string drawList, int width, int height)
  723. {
  724. CheckThreatLevel(ThreatLevel.None, "osDrawEllipse");
  725. m_host.AddScriptLPS(1);
  726. drawList += "Ellipse " + width + "," + height + "; ";
  727. return drawList;
  728. }
  729. public string osDrawRectangle(string drawList, int width, int height)
  730. {
  731. CheckThreatLevel(ThreatLevel.None, "osDrawRectangle");
  732. m_host.AddScriptLPS(1);
  733. drawList += "Rectangle " + width + "," + height + "; ";
  734. return drawList;
  735. }
  736. public string osDrawFilledRectangle(string drawList, int width, int height)
  737. {
  738. CheckThreatLevel(ThreatLevel.None, "osDrawFilledRectangle");
  739. m_host.AddScriptLPS(1);
  740. drawList += "FillRectangle " + width + "," + height + "; ";
  741. return drawList;
  742. }
  743. public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
  744. {
  745. CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon");
  746. m_host.AddScriptLPS(1);
  747. if (x.Length != y.Length || x.Length < 3)
  748. {
  749. return "";
  750. }
  751. drawList += "FillPolygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
  752. for (int i = 1; i < x.Length; i++)
  753. {
  754. drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
  755. }
  756. drawList += "; ";
  757. return drawList;
  758. }
  759. public string osDrawPolygon(string drawList, LSL_List x, LSL_List y)
  760. {
  761. CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon");
  762. m_host.AddScriptLPS(1);
  763. if (x.Length != y.Length || x.Length < 3)
  764. {
  765. return "";
  766. }
  767. drawList += "Polygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
  768. for (int i = 1; i < x.Length; i++)
  769. {
  770. drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
  771. }
  772. drawList += "; ";
  773. return drawList;
  774. }
  775. public string osSetFontSize(string drawList, int fontSize)
  776. {
  777. CheckThreatLevel(ThreatLevel.None, "osSetFontSize");
  778. m_host.AddScriptLPS(1);
  779. drawList += "FontSize "+ fontSize +"; ";
  780. return drawList;
  781. }
  782. public string osSetFontName(string drawList, string fontName)
  783. {
  784. CheckThreatLevel(ThreatLevel.None, "osSetFontName");
  785. m_host.AddScriptLPS(1);
  786. drawList += "FontName "+ fontName +"; ";
  787. return drawList;
  788. }
  789. public string osSetPenSize(string drawList, int penSize)
  790. {
  791. CheckThreatLevel(ThreatLevel.None, "osSetPenSize");
  792. m_host.AddScriptLPS(1);
  793. drawList += "PenSize " + penSize + "; ";
  794. return drawList;
  795. }
  796. public string osSetPenColour(string drawList, string colour)
  797. {
  798. CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
  799. m_host.AddScriptLPS(1);
  800. drawList += "PenColour " + colour + "; ";
  801. return drawList;
  802. }
  803. public string osSetPenCap(string drawList, string direction, string type)
  804. {
  805. CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
  806. m_host.AddScriptLPS(1);
  807. drawList += "PenCap " + direction + "," + type + "; ";
  808. return drawList;
  809. }
  810. public string osDrawImage(string drawList, int width, int height, string imageUrl)
  811. {
  812. CheckThreatLevel(ThreatLevel.None, "osDrawImage");
  813. m_host.AddScriptLPS(1);
  814. drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
  815. return drawList;
  816. }
  817. public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
  818. {
  819. CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize");
  820. m_host.AddScriptLPS(1);
  821. LSL_Vector vec = new LSL_Vector(0,0,0);
  822. IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
  823. if (textureManager != null)
  824. {
  825. double xSize, ySize;
  826. textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
  827. out xSize, out ySize);
  828. vec.x = xSize;
  829. vec.y = ySize;
  830. }
  831. return vec;
  832. }
  833. public void osSetStateEvents(int events)
  834. {
  835. // This function is a hack. There is no reason for it's existence
  836. // anymore, since state events now work properly.
  837. // It was probably added as a crutch or debugging aid, and
  838. // should be removed
  839. //
  840. CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
  841. m_host.SetScriptEvents(m_itemID, events);
  842. }
  843. public void osSetRegionWaterHeight(double height)
  844. {
  845. CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
  846. m_host.AddScriptLPS(1);
  847. //Check to make sure that the script's owner is the estate manager/master
  848. //World.Permissions.GenericEstatePermission(
  849. if (World.Permissions.IsGod(m_host.OwnerID))
  850. {
  851. World.EventManager.TriggerRequestChangeWaterHeight((float)height);
  852. }
  853. }
  854. /// <summary>
  855. /// Changes the Region Sun Settings, then Triggers a Sun Update
  856. /// </summary>
  857. /// <param name="useEstateSun">True to use Estate Sun instead of Region Sun</param>
  858. /// <param name="sunFixed">True to keep the sun stationary</param>
  859. /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
  860. public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
  861. {
  862. CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings");
  863. m_host.AddScriptLPS(1);
  864. //Check to make sure that the script's owner is the estate manager/master
  865. //World.Permissions.GenericEstatePermission(
  866. if (World.Permissions.IsGod(m_host.OwnerID))
  867. {
  868. while (sunHour > 24.0)
  869. sunHour -= 24.0;
  870. while (sunHour < 0)
  871. sunHour += 24.0;
  872. World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
  873. World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
  874. World.RegionInfo.RegionSettings.FixedSun = sunFixed;
  875. World.RegionInfo.RegionSettings.Save();
  876. World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
  877. }
  878. }
  879. /// <summary>
  880. /// Changes the Estate Sun Settings, then Triggers a Sun Update
  881. /// </summary>
  882. /// <param name="sunFixed">True to keep the sun stationary, false to use global time</param>
  883. /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
  884. public void osSetEstateSunSettings(bool sunFixed, double sunHour)
  885. {
  886. CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings");
  887. m_host.AddScriptLPS(1);
  888. //Check to make sure that the script's owner is the estate manager/master
  889. //World.Permissions.GenericEstatePermission(
  890. if (World.Permissions.IsGod(m_host.OwnerID))
  891. {
  892. while (sunHour > 24.0)
  893. sunHour -= 24.0;
  894. while (sunHour < 0)
  895. sunHour += 24.0;
  896. World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
  897. World.RegionInfo.EstateSettings.SunPosition = sunHour;
  898. World.RegionInfo.EstateSettings.FixedSun = sunFixed;
  899. World.RegionInfo.EstateSettings.Save();
  900. World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
  901. }
  902. }
  903. /// <summary>
  904. /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise
  905. /// </summary>
  906. /// <returns></returns>
  907. public double osGetCurrentSunHour()
  908. {
  909. CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour");
  910. m_host.AddScriptLPS(1);
  911. // Must adjust for the fact that Region Sun Settings are still LL offset
  912. double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6;
  913. // See if the sun module has registered itself, if so it's authoritative
  914. ISunModule module = World.RequestModuleInterface<ISunModule>();
  915. if (module != null)
  916. {
  917. sunHour = module.GetCurrentSunHour();
  918. }
  919. return sunHour;
  920. }
  921. public double osSunGetParam(string param)
  922. {
  923. CheckThreatLevel(ThreatLevel.None, "osSunGetParam");
  924. m_host.AddScriptLPS(1);
  925. double value = 0.0;
  926. ISunModule module = World.RequestModuleInterface<ISunModule>();
  927. if (module != null)
  928. {
  929. value = module.GetSunParameter(param);
  930. }
  931. return value;
  932. }
  933. public void osSunSetParam(string param, double value)
  934. {
  935. CheckThreatLevel(ThreatLevel.None, "osSunSetParam");
  936. m_host.AddScriptLPS(1);
  937. ISunModule module = World.RequestModuleInterface<ISunModule>();
  938. if (module != null)
  939. {
  940. module.SetSunParameter(param, value);
  941. }
  942. }
  943. public string osWindActiveModelPluginName()
  944. {
  945. CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
  946. m_host.AddScriptLPS(1);
  947. IWindModule module = World.RequestModuleInterface<IWindModule>();
  948. if (module != null)
  949. {
  950. return module.WindActiveModelPluginName;
  951. }
  952. return String.Empty;
  953. }
  954. public void osWindParamSet(string plugin, string param, float value)
  955. {
  956. CheckThreatLevel(ThreatLevel.VeryLow, "osWindParamSet");
  957. m_host.AddScriptLPS(1);
  958. IWindModule module = World.RequestModuleInterface<IWindModule>();
  959. if (module != null)
  960. {
  961. try
  962. {
  963. module.WindParamSet(plugin, param, value);
  964. }
  965. catch (Exception) { }
  966. }
  967. }
  968. public float osWindParamGet(string plugin, string param)
  969. {
  970. CheckThreatLevel(ThreatLevel.VeryLow, "osWindParamGet");
  971. m_host.AddScriptLPS(1);
  972. IWindModule module = World.RequestModuleInterface<IWindModule>();
  973. if (module != null)
  974. {
  975. return module.WindParamGet(plugin, param);
  976. }
  977. return 0.0f;
  978. }
  979. public double osList2Double(LSL_Types.list src, int index)
  980. {
  981. // There is really no double type in OSSL. C# and other
  982. // have one, but the current implementation of LSL_Types.list
  983. // is not allowed to contain any.
  984. // This really should be removed.
  985. //
  986. CheckThreatLevel(ThreatLevel.None, "osList2Double");
  987. m_host.AddScriptLPS(1);
  988. if (index < 0)
  989. {
  990. index = src.Length + index;
  991. }
  992. if (index >= src.Length)
  993. {
  994. return 0.0;
  995. }
  996. return Convert.ToDouble(src.Data[index]);
  997. }
  998. public void osSetParcelMediaURL(string url)
  999. {
  1000. // What actually is the difference to the LL function?
  1001. //
  1002. CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
  1003. m_host.AddScriptLPS(1);
  1004. ILandObject land
  1005. = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
  1006. if (land.LandData.OwnerID != m_host.OwnerID)
  1007. return;
  1008. land.SetMediaUrl(url);
  1009. }
  1010. public void osSetParcelSIPAddress(string SIPAddress)
  1011. {
  1012. // What actually is the difference to the LL function?
  1013. //
  1014. CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
  1015. m_host.AddScriptLPS(1);
  1016. ILandObject land
  1017. = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
  1018. if (land.LandData.OwnerID != m_host.OwnerID)
  1019. {
  1020. OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function");
  1021. return;
  1022. }
  1023. // get the voice module
  1024. IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>();
  1025. if (voiceModule != null)
  1026. voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
  1027. else
  1028. OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
  1029. }
  1030. public string osGetScriptEngineName()
  1031. {
  1032. // This gets a "high" because knowing the engine may be used
  1033. // to exploit engine-specific bugs or induce usage patterns
  1034. // that trigger engine-specific failures.
  1035. // Besides, public grid users aren't supposed to know.
  1036. //
  1037. CheckThreatLevel(ThreatLevel.High, "osGetScriptEngineName");
  1038. m_host.AddScriptLPS(1);
  1039. int scriptEngineNameIndex = 0;
  1040. if (!String.IsNullOrEmpty(m_ScriptEngine.ScriptEngineName))
  1041. {
  1042. // parse off the "ScriptEngine."
  1043. scriptEngineNameIndex = m_ScriptEngine.ScriptEngineName.IndexOf(".", scriptEngineNameIndex);
  1044. scriptEngineNameIndex++; // get past delimiter
  1045. int scriptEngineNameLength = m_ScriptEngine.ScriptEngineName.Length - scriptEngineNameIndex;
  1046. // create char array then a string that is only the script engine name
  1047. Char[] scriptEngineNameCharArray = m_ScriptEngine.ScriptEngineName.ToCharArray(scriptEngineNameIndex, scriptEngineNameLength);
  1048. String scriptEngineName = new String(scriptEngineNameCharArray);
  1049. return scriptEngineName;
  1050. }
  1051. else
  1052. {
  1053. return String.Empty;
  1054. }
  1055. }
  1056. public string osGetSimulatorVersion()
  1057. {
  1058. // High because it can be used to target attacks to known weaknesses
  1059. // This would allow a new class of griefer scripts that don't even
  1060. // require their user to know what they are doing (see script
  1061. // kiddie)
  1062. //
  1063. CheckThreatLevel(ThreatLevel.High,"osGetSimulatorVersion");
  1064. m_host.AddScriptLPS(1);
  1065. return m_ScriptEngine.World.GetSimulatorVersion();
  1066. }
  1067. public Hashtable osParseJSON(string JSON)
  1068. {
  1069. CheckThreatLevel(ThreatLevel.None, "osParseJSON");
  1070. m_host.AddScriptLPS(1);
  1071. // see http://www.json.org/ for more details on JSON
  1072. string currentKey = null;
  1073. Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
  1074. Hashtable jsondata = new Hashtable(); // the hashtable to be returned
  1075. int i = 0;
  1076. try
  1077. {
  1078. // iterate through the serialised stream of tokens and store at the right depth in the hashtable
  1079. // the top level hashtable may contain more nested hashtables within it each containing an objects representation
  1080. for (i = 0; i < JSON.Length; i++)
  1081. {
  1082. // m_log.Debug(""+JSON[i]);
  1083. switch (JSON[i])
  1084. {
  1085. case '{':
  1086. // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON
  1087. Hashtable currentObject = new Hashtable();
  1088. if (objectStack.Count == 0) // the stack should only be empty for the first outer object
  1089. {
  1090. objectStack.Push(jsondata);
  1091. }
  1092. else if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1093. {
  1094. // add it to the parent array
  1095. ((ArrayList)objectStack.Peek()).Add(currentObject);
  1096. objectStack.Push(currentObject);
  1097. }
  1098. else
  1099. {
  1100. // add it to the parent hashtable
  1101. ((Hashtable)objectStack.Peek()).Add(currentKey,currentObject);
  1102. objectStack.Push(currentObject);
  1103. }
  1104. // clear the key
  1105. currentKey = null;
  1106. break;
  1107. case '}':
  1108. // pop the hashtable off the stack
  1109. objectStack.Pop();
  1110. break;
  1111. case '"':// string boundary
  1112. string tokenValue = "";
  1113. i++; // move to next char
  1114. // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \
  1115. while (JSON[i] != '"')
  1116. {
  1117. tokenValue += JSON[i];
  1118. // handle escaped double quotes \"
  1119. if (JSON[i] == '\\' && JSON[i+1] == '"')
  1120. {
  1121. tokenValue += JSON[i+1];
  1122. i++;
  1123. }
  1124. i++;
  1125. }
  1126. // ok we've got a string, if we've got an array on the top of the stack then we store it
  1127. if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1128. {
  1129. ((ArrayList)objectStack.Peek()).Add(tokenValue);
  1130. }
  1131. else if (currentKey == null) // no key stored and its not an array this must be a key so store it
  1132. {
  1133. currentKey = tokenValue;
  1134. }
  1135. else
  1136. {
  1137. // we have a key so lets store this value
  1138. ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue);
  1139. // now lets clear the key, we're done with it and moving on
  1140. currentKey = null;
  1141. }
  1142. break;
  1143. case ':':// key : value separator
  1144. // just ignore
  1145. break;
  1146. case ' ':// spaces
  1147. // just ignore
  1148. break;
  1149. case '[': // array start
  1150. ArrayList currentArray = new ArrayList();
  1151. if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1152. {
  1153. ((ArrayList)objectStack.Peek()).Add(currentArray);
  1154. }
  1155. else
  1156. {
  1157. ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray);
  1158. // clear the key
  1159. currentKey = null;
  1160. }
  1161. objectStack.Push(currentArray);
  1162. break;
  1163. case ',':// seperator
  1164. // just ignore
  1165. break;
  1166. case ']'://Array end
  1167. // pop the array off the stack
  1168. objectStack.Pop();
  1169. break;
  1170. case 't': // we've found a character start not in quotes, it must be a boolean true
  1171. if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1172. {
  1173. ((ArrayList)objectStack.Peek()).Add(true);
  1174. }
  1175. else
  1176. {
  1177. ((Hashtable)objectStack.Peek()).Add(currentKey,true);
  1178. currentKey = null;
  1179. }
  1180. //advance the counter to the letter 'e'
  1181. i = i + 3;
  1182. break;
  1183. case 'f': // we've found a character start not in quotes, it must be a boolean false
  1184. if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1185. {
  1186. ((ArrayList)objectStack.Peek()).Add(false);
  1187. }
  1188. else
  1189. {
  1190. ((Hashtable)objectStack.Peek()).Add(currentKey,false);
  1191. currentKey = null;
  1192. }
  1193. //advance the counter to the letter 'e'
  1194. i = i + 4;
  1195. break;
  1196. case '\n':// carriage return
  1197. // just ignore
  1198. break;
  1199. case '\r':// carriage return
  1200. // just ignore
  1201. break;
  1202. default:
  1203. // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
  1204. // but for now we'll just do them as strings
  1205. string numberValue = "";
  1206. // just loop through until the next known marker quote mark storing the string
  1207. while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ')
  1208. {
  1209. numberValue += "" + JSON[i++];
  1210. }
  1211. i--; // we want to process this caracter that marked the end of this string in the main loop
  1212. // ok we've got a string, if we've got an array on the top of the stack then we store it
  1213. if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
  1214. {
  1215. ((ArrayList)objectStack.Peek()).Add(numberValue);
  1216. }
  1217. else
  1218. {
  1219. // we have a key so lets store this value
  1220. ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue);
  1221. // now lets clear the key, we're done with it and moving on
  1222. currentKey = null;
  1223. }
  1224. break;
  1225. }
  1226. }
  1227. }
  1228. catch(Exception)
  1229. {
  1230. OSSLError("osParseJSON: The JSON string is not valid " + JSON) ;
  1231. }
  1232. return jsondata;
  1233. }
  1234. // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function
  1235. // the dataserver function is passed the ID of the calling function and a string message
  1236. public void osMessageObject(LSL_Key objectUUID, string message)
  1237. {
  1238. CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
  1239. m_host.AddScriptLPS(1);
  1240. object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
  1241. SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID));
  1242. m_ScriptEngine.PostObjectEvent(
  1243. sceneOP.LocalId, new EventParams(
  1244. "dataserver", resobj, new DetectParams[0]));
  1245. }
  1246. // This needs ThreatLevel high. It is an excellent griefer tool,
  1247. // In a loop, it can cause asset bloat and DOS levels of asset
  1248. // writes.
  1249. //
  1250. public void osMakeNotecard(string notecardName, LSL_Types.list contents)
  1251. {
  1252. CheckThreatLevel(ThreatLevel.High, "osMakeNotecard");
  1253. m_host.AddScriptLPS(1);
  1254. // Create new asset
  1255. AssetBase asset = new AssetBase();
  1256. asset.Name = notecardName;
  1257. asset.Description = "Script Generated Notecard";
  1258. asset.Type = 7;
  1259. asset.FullID = UUID.Random();
  1260. string notecardData = "";
  1261. for (int i = 0; i < contents.Length; i++) {
  1262. notecardData += contents.GetLSLStringItem(i) + "\n";
  1263. }
  1264. int textLength = notecardData.Length;
  1265. notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
  1266. + textLength.ToString() + "\n" + notecardData + "}\n";
  1267. asset.Data = Util.UTF8.GetBytes(notecardData);
  1268. World.AssetService.Store(asset);
  1269. // Create Task Entry
  1270. TaskInventoryItem taskItem=new TaskInventoryItem();
  1271. taskItem.ResetIDs(m_host.UUID);
  1272. taskItem.ParentID = m_host.UUID;
  1273. taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
  1274. taskItem.Name = asset.Name;
  1275. taskItem.Description = asset.Description;
  1276. taskItem.Type = (int)AssetType.Notecard;
  1277. taskItem.InvType = (int)InventoryType.Notecard;
  1278. taskItem.OwnerID = m_host.OwnerID;
  1279. taskItem.CreatorID = m_host.OwnerID;
  1280. taskItem.BasePermissions = (uint)PermissionMask.All;
  1281. taskItem.CurrentPermissions = (uint)PermissionMask.All;
  1282. taskItem.EveryonePermissions = 0;
  1283. taskItem.NextPermissions = (uint)PermissionMask.All;
  1284. taskItem.GroupID = m_host.GroupID;
  1285. taskItem.GroupPermissions = 0;
  1286. taskItem.Flags = 0;
  1287. taskItem.PermsGranter = UUID.Zero;
  1288. taskItem.PermsMask = 0;
  1289. taskItem.AssetID = asset.FullID;
  1290. m_host.Inventory.AddInventoryItem(taskItem, false);
  1291. }
  1292. /*Instead of using the LSL Dataserver event to pull notecard data,
  1293. this will simply read the requested line and return its data as a string.
  1294. Warning - due to the synchronous method this function uses to fetch assets, its use
  1295. may be dangerous and unreliable while running in grid mode.
  1296. */
  1297. public string osGetNotecardLine(string name, int line)
  1298. {
  1299. CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
  1300. m_host.AddScriptLPS(1);
  1301. UUID assetID = UUID.Zero;
  1302. if (!UUID.TryParse(name, out assetID))
  1303. {
  1304. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  1305. {
  1306. if (item.Type == 7 && item.Name == name)
  1307. {
  1308. assetID = item.AssetID;
  1309. }
  1310. }
  1311. }
  1312. if (assetID == UUID.Zero)
  1313. {
  1314. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1315. return "ERROR!";
  1316. }
  1317. if (!NotecardCache.IsCached(assetID))
  1318. {
  1319. AssetBase a = World.AssetService.Get(assetID.ToString());
  1320. if (a != null)
  1321. {
  1322. System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
  1323. string data = enc.GetString(a.Data);
  1324. NotecardCache.Cache(assetID, data);
  1325. }
  1326. else
  1327. {
  1328. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1329. return "ERROR!";
  1330. }
  1331. };
  1332. return NotecardCache.GetLine(assetID, line, 255);
  1333. }
  1334. /*Instead of using the LSL Dataserver event to pull notecard data line by line,
  1335. this will simply read the entire notecard and return its data as a string.
  1336. Warning - due to the synchronous method this function uses to fetch assets, its use
  1337. may be dangerous and unreliable while running in grid mode.
  1338. */
  1339. public string osGetNotecard(string name)
  1340. {
  1341. CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
  1342. m_host.AddScriptLPS(1);
  1343. UUID assetID = UUID.Zero;
  1344. string NotecardData = "";
  1345. if (!UUID.TryParse(name, out assetID))
  1346. {
  1347. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  1348. {
  1349. if (item.Type == 7 && item.Name == name)
  1350. {
  1351. assetID = item.AssetID;
  1352. }
  1353. }
  1354. }
  1355. if (assetID == UUID.Zero)
  1356. {
  1357. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1358. return "ERROR!";
  1359. }
  1360. if (!NotecardCache.IsCached(assetID))
  1361. {
  1362. AssetBase a = World.AssetService.Get(assetID.ToString());
  1363. if (a != null)
  1364. {
  1365. System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
  1366. string data = enc.GetString(a.Data);
  1367. NotecardCache.Cache(assetID, data);
  1368. }
  1369. else
  1370. {
  1371. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1372. return "ERROR!";
  1373. }
  1374. };
  1375. for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
  1376. {
  1377. NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n";
  1378. }
  1379. return NotecardData;
  1380. }
  1381. /*Instead of using the LSL Dataserver event to pull notecard data,
  1382. this will simply read the number of note card lines and return this data as an integer.
  1383. Warning - due to the synchronous method this function uses to fetch assets, its use
  1384. may be dangerous and unreliable while running in grid mode.
  1385. */
  1386. public int osGetNumberOfNotecardLines(string name)
  1387. {
  1388. CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
  1389. m_host.AddScriptLPS(1);
  1390. UUID assetID = UUID.Zero;
  1391. if (!UUID.TryParse(name, out assetID))
  1392. {
  1393. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  1394. {
  1395. if (item.Type == 7 && item.Name == name)
  1396. {
  1397. assetID = item.AssetID;
  1398. }
  1399. }
  1400. }
  1401. if (assetID == UUID.Zero)
  1402. {
  1403. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1404. return -1;
  1405. }
  1406. if (!NotecardCache.IsCached(assetID))
  1407. {
  1408. AssetBase a = World.AssetService.Get(assetID.ToString());
  1409. if (a != null)
  1410. {
  1411. System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
  1412. string data = enc.GetString(a.Data);
  1413. NotecardCache.Cache(assetID, data);
  1414. }
  1415. else
  1416. {
  1417. OSSLShoutError("Notecard '" + name + "' could not be found.");
  1418. return -1;
  1419. }
  1420. };
  1421. return NotecardCache.GetLines(assetID);
  1422. }
  1423. public string osAvatarName2Key(string firstname, string lastname)
  1424. {
  1425. CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
  1426. CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
  1427. if (null == userInfo)
  1428. {
  1429. return UUID.Zero.ToString();
  1430. }
  1431. else
  1432. {
  1433. return userInfo.UserProfile.ID.ToString();
  1434. }
  1435. }
  1436. public string osKey2Name(string id)
  1437. {
  1438. CheckThreatLevel(ThreatLevel.Low, "osKey2Name");
  1439. UUID key = new UUID();
  1440. if (UUID.TryParse(id, out key))
  1441. {
  1442. CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(key);
  1443. if (null == userInfo)
  1444. {
  1445. return "";
  1446. }
  1447. else
  1448. {
  1449. return userInfo.UserProfile.Name;
  1450. }
  1451. }
  1452. else
  1453. {
  1454. return "";
  1455. }
  1456. }
  1457. /// Threat level is Moderate because intentional abuse, for instance
  1458. /// scripts that are written to be malicious only on one grid,
  1459. /// for instance in a HG scenario, are a distinct possibility.
  1460. ///
  1461. /// Use value from the config file and return it.
  1462. ///
  1463. public string osGetGridNick()
  1464. {
  1465. CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
  1466. m_host.AddScriptLPS(1);
  1467. string nick = "hippogrid";
  1468. IConfigSource config = new IniConfigSource(Application.iniFilePath);
  1469. if (config.Configs["GridInfo"] != null)
  1470. nick = config.Configs["GridInfo"].GetString("gridnick", nick);
  1471. return nick;
  1472. }
  1473. public string osGetGridName()
  1474. {
  1475. CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName");
  1476. m_host.AddScriptLPS(1);
  1477. string name = "the lost continent of hippo";
  1478. IConfigSource config = new IniConfigSource(Application.iniFilePath);
  1479. if (config.Configs["GridInfo"] != null)
  1480. name = config.Configs["GridInfo"].GetString("gridname", name);
  1481. return name;
  1482. }
  1483. public string osGetGridLoginURI()
  1484. {
  1485. CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI");
  1486. m_host.AddScriptLPS(1);
  1487. string loginURI = "http://127.0.0.1:9000/";
  1488. IConfigSource config = new IniConfigSource(Application.iniFilePath);
  1489. if (config.Configs["GridInfo"] != null)
  1490. loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
  1491. return loginURI;
  1492. }
  1493. public LSL_String osFormatString(string str, LSL_List strings)
  1494. {
  1495. CheckThreatLevel(ThreatLevel.Low, "osFormatString");
  1496. m_host.AddScriptLPS(1);
  1497. return String.Format(str, strings.Data);
  1498. }
  1499. public LSL_List osMatchString(string src, string pattern, int start)
  1500. {
  1501. CheckThreatLevel(ThreatLevel.High, "osMatchString");
  1502. m_host.AddScriptLPS(1);
  1503. LSL_List result = new LSL_List();
  1504. // Normalize indices (if negative).
  1505. // After normlaization they may still be
  1506. // negative, but that is now relative to
  1507. // the start, rather than the end, of the
  1508. // sequence.
  1509. if (start < 0)
  1510. {
  1511. start = src.Length + start;
  1512. }
  1513. if (start < 0 || start >= src.Length)
  1514. {
  1515. return result; // empty list
  1516. }
  1517. // Find matches beginning at start position
  1518. Regex matcher = new Regex(pattern);
  1519. Match match = matcher.Match(src, start);
  1520. if (match.Success)
  1521. {
  1522. foreach (System.Text.RegularExpressions.Group g in match.Groups)
  1523. {
  1524. if (g.Success)
  1525. {
  1526. result.Add(g.Value);
  1527. result.Add(g.Index);
  1528. }
  1529. }
  1530. }
  1531. return result;
  1532. }
  1533. public string osLoadedCreationDate()
  1534. {
  1535. CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationDate");
  1536. m_host.AddScriptLPS(1);
  1537. return World.RegionInfo.RegionSettings.LoadedCreationDate;
  1538. }
  1539. public string osLoadedCreationTime()
  1540. {
  1541. CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationTime");
  1542. m_host.AddScriptLPS(1);
  1543. return World.RegionInfo.RegionSettings.LoadedCreationTime;
  1544. }
  1545. public string osLoadedCreationID()
  1546. {
  1547. CheckThreatLevel(ThreatLevel.Low, "osLoadedCreationID");
  1548. m_host.AddScriptLPS(1);
  1549. return World.RegionInfo.RegionSettings.LoadedCreationID;
  1550. }
  1551. // Threat level is 'Low' because certain users could possibly be tricked into
  1552. // dropping an unverified script into one of their own objects, which could
  1553. // then gather the physical construction details of the object and transmit it
  1554. // to an unscrupulous third party, thus permitting unauthorized duplication of
  1555. // the object's form.
  1556. //
  1557. public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
  1558. {
  1559. CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
  1560. m_host.AddScriptLPS(1);
  1561. InitLSL();
  1562. LSL_List retVal = new LSL_List();
  1563. List<SceneObjectPart> parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber);
  1564. foreach (SceneObjectPart part in parts)
  1565. {
  1566. retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams(part, rules);
  1567. }
  1568. return retVal;
  1569. }
  1570. public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
  1571. {
  1572. CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
  1573. //QueueUserWorkItem
  1574. INPCModule module = World.RequestModuleInterface<INPCModule>();
  1575. if (module != null)
  1576. {
  1577. UUID x = module.CreateNPC(firstname,
  1578. lastname,
  1579. new Vector3((float) position.x, (float) position.y, (float) position.z),
  1580. World,
  1581. new UUID(cloneFrom));
  1582. return new LSL_Key(x.ToString());
  1583. }
  1584. return new LSL_Key(UUID.Zero.ToString());
  1585. }
  1586. public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
  1587. {
  1588. CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
  1589. INPCModule module = World.RequestModuleInterface<INPCModule>();
  1590. if (module != null)
  1591. {
  1592. Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
  1593. module.Autopilot(new UUID(npc.m_string), World, pos);
  1594. }
  1595. }
  1596. public void osNpcSay(LSL_Key npc, string message)
  1597. {
  1598. CheckThreatLevel(ThreatLevel.High, "osNpcSay");
  1599. INPCModule module = World.RequestModuleInterface<INPCModule>();
  1600. if (module != null)
  1601. {
  1602. module.Say(new UUID(npc.m_string), World, message);
  1603. }
  1604. }
  1605. public void osNpcRemove(LSL_Key npc)
  1606. {
  1607. CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
  1608. INPCModule module = World.RequestModuleInterface<INPCModule>();
  1609. if (module != null)
  1610. {
  1611. module.DeleteNPC(new UUID(npc.m_string), World);
  1612. }
  1613. }
  1614. }
  1615. }