aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1269
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs413
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs42
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs54
12 files changed, 980 insertions, 944 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
index 47ed6ba..684138f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
@@ -29,42 +29,43 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net;
32using OpenSim.Region.ScriptEngine.Interfaces; 33using OpenSim.Region.ScriptEngine.Interfaces;
33 34
34namespace OpenSim.Region.ScriptEngine.Shared.Api 35namespace OpenSim.Region.ScriptEngine.Shared.Api
35{ 36{
36 public class ApiManager 37 public class ApiManager
37 { 38 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
38 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); 41 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
39 42
40 public string[] GetApis() 43 public string[] GetApis()
41 { 44 {
42 if (m_Apis.Count > 0) 45 if (m_Apis.Count <= 0)
43 { 46 {
44 List<string> l = new List<string>(m_Apis.Keys); 47 Assembly a = Assembly.GetExecutingAssembly();
45 return l.ToArray();
46 }
47 48
48 Assembly a = Assembly.GetExecutingAssembly(); 49 Type[] types = a.GetExportedTypes();
49 50
50 Type[] types = a.GetExportedTypes(); 51 foreach (Type t in types)
51
52 foreach (Type t in types)
53 {
54 string name = t.ToString();
55 int idx = name.LastIndexOf('.');
56 if (idx != -1)
57 name = name.Substring(idx+1);
58
59 if (name.EndsWith("_Api"))
60 { 52 {
61 name = name.Substring(0, name.Length - 4); 53 string name = t.ToString();
62 m_Apis[name] = t; 54 int idx = name.LastIndexOf('.');
55 if (idx != -1)
56 name = name.Substring(idx+1);
57
58 if (name.EndsWith("_Api"))
59 {
60 name = name.Substring(0, name.Length - 4);
61 m_Apis[name] = t;
62 }
63 } 63 }
64 } 64 }
65 65
66 List<string> ret = new List<string>(m_Apis.Keys); 66// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
67 return ret.ToArray(); 67
68 return new List<string>(m_Apis.Keys).ToArray();
68 } 69 }
69 70
70 public IScriptApi CreateApi(string api) 71 public IScriptApi CreateApi(string api)
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
76 return ret; 77 return ret;
77 } 78 }
78 } 79 }
79} 80} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 489c1c6..b5fa6de 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -59,16 +59,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
59 { 59 {
60 internal IScriptEngine m_ScriptEngine; 60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host; 61 internal SceneObjectPart m_host;
62 internal uint m_localID; 62 internal TaskInventoryItem m_item;
63 internal UUID m_itemID;
64 internal bool m_CMFunctionsEnabled = false; 63 internal bool m_CMFunctionsEnabled = false;
65 64
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
67 { 66 {
68 m_ScriptEngine = ScriptEngine; 67 m_ScriptEngine = ScriptEngine;
69 m_host = host; 68 m_host = host;
70 m_localID = localID; 69 m_item = item;
71 m_itemID = itemID;
72 70
73 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) 71 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
74 m_CMFunctionsEnabled = true; 72 m_CMFunctionsEnabled = true;
@@ -95,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
95 public string cmDetectedCountry(int number) 93 public string cmDetectedCountry(int number)
96 { 94 {
97 m_host.AddScriptLPS(1); 95 m_host.AddScriptLPS(1);
98 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 96 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
99 if (detectedParams == null) 97 if (detectedParams == null)
100 return String.Empty; 98 return String.Empty;
101 return detectedParams.Country; 99 return detectedParams.Country;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ca62bac..e9db5d5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -88,8 +88,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
88 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 88 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
89 protected IScriptEngine m_ScriptEngine; 89 protected IScriptEngine m_ScriptEngine;
90 protected SceneObjectPart m_host; 90 protected SceneObjectPart m_host;
91 protected uint m_localID; 91
92 protected UUID m_itemID; 92 /// <summary>
93 /// The item that hosts this script
94 /// </summary>
95 protected TaskInventoryItem m_item;
96
93 protected bool throwErrorOnNotImplemented = true; 97 protected bool throwErrorOnNotImplemented = true;
94 protected AsyncCommandManager AsyncCommands = null; 98 protected AsyncCommandManager AsyncCommands = null;
95 protected float m_ScriptDelayFactor = 1.0f; 99 protected float m_ScriptDelayFactor = 1.0f;
@@ -107,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
107 protected IUrlModule m_UrlModule = null; 111 protected IUrlModule m_UrlModule = null;
108 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = 112 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
109 new Dictionary<UUID, UserInfoCacheEntry>(); 113 new Dictionary<UUID, UserInfoCacheEntry>();
114 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
110 115
111// protected Timer m_ShoutSayTimer; 116// protected Timer m_ShoutSayTimer;
112 protected int m_SayShoutCount = 0; 117 protected int m_SayShoutCount = 0;
@@ -134,7 +139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
134 {"TURNRIGHT", "Turning Right"} 139 {"TURNRIGHT", "Turning Right"}
135 }; 140 };
136 141
137 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 142 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
138 { 143 {
139/* 144/*
140 m_ShoutSayTimer = new Timer(1000); 145 m_ShoutSayTimer = new Timer(1000);
@@ -146,10 +151,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
146 151
147 m_ScriptEngine = ScriptEngine; 152 m_ScriptEngine = ScriptEngine;
148 m_host = host; 153 m_host = host;
149 m_localID = localID; 154 m_item = item;
150 m_itemID = itemID;
151 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 155 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
152 156
157 LoadLimits(); // read script limits from config.
158
159 m_TransferModule =
160 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
161 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
162
163 AsyncCommands = new AsyncCommandManager(ScriptEngine);
164 }
165
166 /* load configuration items that affect script, object and run-time behavior. */
167 private void LoadLimits()
168 {
153 m_ScriptDelayFactor = 169 m_ScriptDelayFactor =
154 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 170 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
155 m_ScriptDistanceFactor = 171 m_ScriptDistanceFactor =
@@ -162,12 +178,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
162 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); 178 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
163 if (m_notecardLineReadCharsMax > 65535) 179 if (m_notecardLineReadCharsMax > 65535)
164 m_notecardLineReadCharsMax = 65535; 180 m_notecardLineReadCharsMax = 65535;
165 181 // load limits for particular subsystems.
166 m_TransferModule = 182 IConfig SMTPConfig;
167 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); 183 if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
168 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 184 // there's an smtp config, so load in the snooze time.
169 185 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
170 AsyncCommands = new AsyncCommandManager(ScriptEngine); 186 }
171 } 187 }
172 188
173 public override Object InitializeLifetimeService() 189 public override Object InitializeLifetimeService()
@@ -199,7 +215,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
199 [DebuggerNonUserCode] 215 [DebuggerNonUserCode]
200 public void state(string newState) 216 public void state(string newState)
201 { 217 {
202 m_ScriptEngine.SetState(m_itemID, newState); 218 m_ScriptEngine.SetState(m_item.ItemID, newState);
203 } 219 }
204 220
205 /// <summary> 221 /// <summary>
@@ -210,7 +226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
210 public void llResetScript() 226 public void llResetScript()
211 { 227 {
212 m_host.AddScriptLPS(1); 228 m_host.AddScriptLPS(1);
213 m_ScriptEngine.ApiResetScript(m_itemID); 229 m_ScriptEngine.ApiResetScript(m_item.ItemID);
214 } 230 }
215 231
216 public void llResetOtherScript(string name) 232 public void llResetOtherScript(string name)
@@ -219,7 +235,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
219 235
220 m_host.AddScriptLPS(1); 236 m_host.AddScriptLPS(1);
221 237
222 if ((item = ScriptByName(name)) != UUID.Zero) 238 if ((item = GetScriptByName(name)) != UUID.Zero)
223 m_ScriptEngine.ResetScript(item); 239 m_ScriptEngine.ResetScript(item);
224 else 240 else
225 ShoutError("llResetOtherScript: script "+name+" not found"); 241 ShoutError("llResetOtherScript: script "+name+" not found");
@@ -231,7 +247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
231 247
232 m_host.AddScriptLPS(1); 248 m_host.AddScriptLPS(1);
233 249
234 if ((item = ScriptByName(name)) != UUID.Zero) 250 if ((item = GetScriptByName(name)) != UUID.Zero)
235 { 251 {
236 return m_ScriptEngine.GetScriptState(item) ?1:0; 252 return m_ScriptEngine.GetScriptState(item) ?1:0;
237 } 253 }
@@ -253,7 +269,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
253 // These functions are supposed to be robust, 269 // These functions are supposed to be robust,
254 // so get the state one step at a time. 270 // so get the state one step at a time.
255 271
256 if ((item = ScriptByName(name)) != UUID.Zero) 272 if ((item = GetScriptByName(name)) != UUID.Zero)
257 { 273 {
258 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); 274 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true);
259 } 275 }
@@ -362,77 +378,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
362 } 378 }
363 } 379 }
364 380
365 protected UUID InventorySelf()
366 {
367 UUID invItemID = new UUID();
368 bool unlock = false;
369 if (!m_host.TaskInventory.IsReadLockedByMe())
370 {
371 m_host.TaskInventory.LockItemsForRead(true);
372 unlock = true;
373 }
374 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
375 {
376 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
377 {
378 invItemID = inv.Key;
379 break;
380 }
381 }
382 if (unlock)
383 {
384 m_host.TaskInventory.LockItemsForRead(false);
385 }
386 return invItemID;
387 }
388
389 protected UUID InventoryKey(string name, int type) 381 protected UUID InventoryKey(string name, int type)
390 { 382 {
391 m_host.AddScriptLPS(1); 383 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
392 m_host.TaskInventory.LockItemsForRead(true);
393
394 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
395 {
396 if (inv.Value.Name == name)
397 {
398 m_host.TaskInventory.LockItemsForRead(false);
399
400 if (inv.Value.Type != type)
401 {
402 return UUID.Zero;
403 }
404
405 return inv.Value.AssetID;
406 }
407 }
408
409 m_host.TaskInventory.LockItemsForRead(false);
410 return UUID.Zero;
411 }
412
413 protected UUID InventoryKey(string name)
414 {
415 m_host.AddScriptLPS(1);
416
417
418 m_host.TaskInventory.LockItemsForRead(true);
419
420 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
421 {
422 if (inv.Value.Name == name)
423 {
424 m_host.TaskInventory.LockItemsForRead(false);
425 return inv.Value.AssetID;
426 }
427 }
428 384
429 m_host.TaskInventory.LockItemsForRead(false); 385 if (item != null && item.Type == type)
430 386 return item.AssetID;
431 387 else
432 return UUID.Zero; 388 return UUID.Zero;
433 } 389 }
434 390
435
436 /// <summary> 391 /// <summary>
437 /// accepts a valid UUID, -or- a name of an inventory item. 392 /// accepts a valid UUID, -or- a name of an inventory item.
438 /// Returns a valid UUID or UUID.Zero if key invalid and item not found 393 /// Returns a valid UUID or UUID.Zero if key invalid and item not found
@@ -442,19 +397,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
442 /// <returns></returns> 397 /// <returns></returns>
443 protected UUID KeyOrName(string k) 398 protected UUID KeyOrName(string k)
444 { 399 {
445 UUID key = UUID.Zero; 400 UUID key;
446 401
447 // if we can parse the string as a key, use it. 402 // if we can parse the string as a key, use it.
448 if (UUID.TryParse(k, out key))
449 {
450 return key;
451 }
452 // else try to locate the name in inventory of object. found returns key, 403 // else try to locate the name in inventory of object. found returns key,
453 // not found returns UUID.Zero which will translate to the default particle texture 404 // not found returns UUID.Zero
454 else 405 if (!UUID.TryParse(k, out key))
455 { 406 {
456 return InventoryKey(k); 407 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k);
408
409 if (item != null)
410 key = item.AssetID;
411 else
412 key = UUID.Zero;
457 } 413 }
414
415 return key;
458 } 416 }
459 417
460 // convert a LSL_Rotation to a Quaternion 418 // convert a LSL_Rotation to a Quaternion
@@ -1010,7 +968,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1010 UUID.TryParse(ID, out keyID); 968 UUID.TryParse(ID, out keyID);
1011 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 969 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1012 if (wComm != null) 970 if (wComm != null)
1013 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 971 return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
1014 else 972 else
1015 return -1; 973 return -1;
1016 } 974 }
@@ -1020,7 +978,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1020 m_host.AddScriptLPS(1); 978 m_host.AddScriptLPS(1);
1021 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 979 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1022 if (wComm != null) 980 if (wComm != null)
1023 wComm.ListenControl(m_itemID, number, active); 981 wComm.ListenControl(m_item.ItemID, number, active);
1024 } 982 }
1025 983
1026 public void llListenRemove(int number) 984 public void llListenRemove(int number)
@@ -1028,7 +986,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1028 m_host.AddScriptLPS(1); 986 m_host.AddScriptLPS(1);
1029 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 987 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1030 if (wComm != null) 988 if (wComm != null)
1031 wComm.ListenRemove(m_itemID, number); 989 wComm.ListenRemove(m_item.ItemID, number);
1032 } 990 }
1033 991
1034 public void llSensor(string name, string id, int type, double range, double arc) 992 public void llSensor(string name, string id, int type, double range, double arc)
@@ -1037,7 +995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1037 UUID keyID = UUID.Zero; 995 UUID keyID = UUID.Zero;
1038 UUID.TryParse(id, out keyID); 996 UUID.TryParse(id, out keyID);
1039 997
1040 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 998 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host);
1041 } 999 }
1042 1000
1043 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 1001 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -1046,13 +1004,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1046 UUID keyID = UUID.Zero; 1004 UUID keyID = UUID.Zero;
1047 UUID.TryParse(id, out keyID); 1005 UUID.TryParse(id, out keyID);
1048 1006
1049 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 1007 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host);
1050 } 1008 }
1051 1009
1052 public void llSensorRemove() 1010 public void llSensorRemove()
1053 { 1011 {
1054 m_host.AddScriptLPS(1); 1012 m_host.AddScriptLPS(1);
1055 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); 1013 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID);
1056 } 1014 }
1057 1015
1058 public string resolveName(UUID objecUUID) 1016 public string resolveName(UUID objecUUID)
@@ -1093,7 +1051,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1093 public LSL_String llDetectedName(int number) 1051 public LSL_String llDetectedName(int number)
1094 { 1052 {
1095 m_host.AddScriptLPS(1); 1053 m_host.AddScriptLPS(1);
1096 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1054 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1097 if (detectedParams == null) 1055 if (detectedParams == null)
1098 return String.Empty; 1056 return String.Empty;
1099 return detectedParams.Name; 1057 return detectedParams.Name;
@@ -1102,7 +1060,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1102 public LSL_String llDetectedKey(int number) 1060 public LSL_String llDetectedKey(int number)
1103 { 1061 {
1104 m_host.AddScriptLPS(1); 1062 m_host.AddScriptLPS(1);
1105 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1063 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1106 if (detectedParams == null) 1064 if (detectedParams == null)
1107 return String.Empty; 1065 return String.Empty;
1108 return detectedParams.Key.ToString(); 1066 return detectedParams.Key.ToString();
@@ -1111,7 +1069,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1111 public LSL_String llDetectedOwner(int number) 1069 public LSL_String llDetectedOwner(int number)
1112 { 1070 {
1113 m_host.AddScriptLPS(1); 1071 m_host.AddScriptLPS(1);
1114 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1072 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1115 if (detectedParams == null) 1073 if (detectedParams == null)
1116 return String.Empty; 1074 return String.Empty;
1117 return detectedParams.Owner.ToString(); 1075 return detectedParams.Owner.ToString();
@@ -1120,7 +1078,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1120 public LSL_Integer llDetectedType(int number) 1078 public LSL_Integer llDetectedType(int number)
1121 { 1079 {
1122 m_host.AddScriptLPS(1); 1080 m_host.AddScriptLPS(1);
1123 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1081 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1124 if (detectedParams == null) 1082 if (detectedParams == null)
1125 return 0; 1083 return 0;
1126 return new LSL_Integer(detectedParams.Type); 1084 return new LSL_Integer(detectedParams.Type);
@@ -1129,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1129 public LSL_Vector llDetectedPos(int number) 1087 public LSL_Vector llDetectedPos(int number)
1130 { 1088 {
1131 m_host.AddScriptLPS(1); 1089 m_host.AddScriptLPS(1);
1132 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1090 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1133 if (detectedParams == null) 1091 if (detectedParams == null)
1134 return new LSL_Vector(); 1092 return new LSL_Vector();
1135 return detectedParams.Position; 1093 return detectedParams.Position;
@@ -1138,7 +1096,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1138 public LSL_Vector llDetectedVel(int number) 1096 public LSL_Vector llDetectedVel(int number)
1139 { 1097 {
1140 m_host.AddScriptLPS(1); 1098 m_host.AddScriptLPS(1);
1141 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1099 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1142 if (detectedParams == null) 1100 if (detectedParams == null)
1143 return new LSL_Vector(); 1101 return new LSL_Vector();
1144 return detectedParams.Velocity; 1102 return detectedParams.Velocity;
@@ -1147,7 +1105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1147 public LSL_Vector llDetectedGrab(int number) 1105 public LSL_Vector llDetectedGrab(int number)
1148 { 1106 {
1149 m_host.AddScriptLPS(1); 1107 m_host.AddScriptLPS(1);
1150 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1108 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1151 if (parms == null) 1109 if (parms == null)
1152 return new LSL_Vector(0, 0, 0); 1110 return new LSL_Vector(0, 0, 0);
1153 1111
@@ -1157,7 +1115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1157 public LSL_Rotation llDetectedRot(int number) 1115 public LSL_Rotation llDetectedRot(int number)
1158 { 1116 {
1159 m_host.AddScriptLPS(1); 1117 m_host.AddScriptLPS(1);
1160 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1118 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1161 if (detectedParams == null) 1119 if (detectedParams == null)
1162 return new LSL_Rotation(); 1120 return new LSL_Rotation();
1163 return detectedParams.Rotation; 1121 return detectedParams.Rotation;
@@ -1166,7 +1124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1166 public LSL_Integer llDetectedGroup(int number) 1124 public LSL_Integer llDetectedGroup(int number)
1167 { 1125 {
1168 m_host.AddScriptLPS(1); 1126 m_host.AddScriptLPS(1);
1169 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1127 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1170 if (detectedParams == null) 1128 if (detectedParams == null)
1171 return new LSL_Integer(0); 1129 return new LSL_Integer(0);
1172 if (m_host.GroupID == detectedParams.Group) 1130 if (m_host.GroupID == detectedParams.Group)
@@ -1177,7 +1135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1177 public LSL_Integer llDetectedLinkNumber(int number) 1135 public LSL_Integer llDetectedLinkNumber(int number)
1178 { 1136 {
1179 m_host.AddScriptLPS(1); 1137 m_host.AddScriptLPS(1);
1180 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1138 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1181 if (parms == null) 1139 if (parms == null)
1182 return new LSL_Integer(0); 1140 return new LSL_Integer(0);
1183 1141
@@ -1190,7 +1148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1190 public LSL_Vector llDetectedTouchBinormal(int index) 1148 public LSL_Vector llDetectedTouchBinormal(int index)
1191 { 1149 {
1192 m_host.AddScriptLPS(1); 1150 m_host.AddScriptLPS(1);
1193 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1151 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1194 if (detectedParams == null) 1152 if (detectedParams == null)
1195 return new LSL_Vector(); 1153 return new LSL_Vector();
1196 return detectedParams.TouchBinormal; 1154 return detectedParams.TouchBinormal;
@@ -1202,7 +1160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1202 public LSL_Integer llDetectedTouchFace(int index) 1160 public LSL_Integer llDetectedTouchFace(int index)
1203 { 1161 {
1204 m_host.AddScriptLPS(1); 1162 m_host.AddScriptLPS(1);
1205 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1163 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1206 if (detectedParams == null) 1164 if (detectedParams == null)
1207 return new LSL_Integer(-1); 1165 return new LSL_Integer(-1);
1208 return new LSL_Integer(detectedParams.TouchFace); 1166 return new LSL_Integer(detectedParams.TouchFace);
@@ -1214,7 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1214 public LSL_Vector llDetectedTouchNormal(int index) 1172 public LSL_Vector llDetectedTouchNormal(int index)
1215 { 1173 {
1216 m_host.AddScriptLPS(1); 1174 m_host.AddScriptLPS(1);
1217 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1175 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1218 if (detectedParams == null) 1176 if (detectedParams == null)
1219 return new LSL_Vector(); 1177 return new LSL_Vector();
1220 return detectedParams.TouchNormal; 1178 return detectedParams.TouchNormal;
@@ -1226,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1226 public LSL_Vector llDetectedTouchPos(int index) 1184 public LSL_Vector llDetectedTouchPos(int index)
1227 { 1185 {
1228 m_host.AddScriptLPS(1); 1186 m_host.AddScriptLPS(1);
1229 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1187 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1230 if (detectedParams == null) 1188 if (detectedParams == null)
1231 return new LSL_Vector(); 1189 return new LSL_Vector();
1232 return detectedParams.TouchPos; 1190 return detectedParams.TouchPos;
@@ -1238,7 +1196,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1238 public LSL_Vector llDetectedTouchST(int index) 1196 public LSL_Vector llDetectedTouchST(int index)
1239 { 1197 {
1240 m_host.AddScriptLPS(1); 1198 m_host.AddScriptLPS(1);
1241 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1199 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1242 if (detectedParams == null) 1200 if (detectedParams == null)
1243 return new LSL_Vector(-1.0, -1.0, 0.0); 1201 return new LSL_Vector(-1.0, -1.0, 0.0);
1244 return detectedParams.TouchST; 1202 return detectedParams.TouchST;
@@ -1250,7 +1208,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1250 public LSL_Vector llDetectedTouchUV(int index) 1208 public LSL_Vector llDetectedTouchUV(int index)
1251 { 1209 {
1252 m_host.AddScriptLPS(1); 1210 m_host.AddScriptLPS(1);
1253 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1211 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1254 if (detectedParams == null) 1212 if (detectedParams == null)
1255 return new LSL_Vector(-1.0, -1.0, 0.0); 1213 return new LSL_Vector(-1.0, -1.0, 0.0);
1256 return detectedParams.TouchUV; 1214 return detectedParams.TouchUV;
@@ -1962,6 +1920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1962 rgb.x = texcolor.R; 1920 rgb.x = texcolor.R;
1963 rgb.y = texcolor.G; 1921 rgb.y = texcolor.G;
1964 rgb.z = texcolor.B; 1922 rgb.z = texcolor.B;
1923
1965 return rgb; 1924 return rgb;
1966 } 1925 }
1967 else 1926 else
@@ -3039,20 +2998,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3039 2998
3040 public LSL_Integer llGiveMoney(string destination, int amount) 2999 public LSL_Integer llGiveMoney(string destination, int amount)
3041 { 3000 {
3042 UUID invItemID=InventorySelf();
3043 if (invItemID == UUID.Zero)
3044 return 0;
3045
3046 m_host.AddScriptLPS(1); 3001 m_host.AddScriptLPS(1);
3047 3002
3048 m_host.TaskInventory.LockItemsForRead(true); 3003 if (m_item.PermsGranter == UUID.Zero)
3049 TaskInventoryItem item = m_host.TaskInventory[invItemID];
3050 m_host.TaskInventory.LockItemsForRead(false);
3051
3052 if (item.PermsGranter == UUID.Zero)
3053 return 0; 3004 return 0;
3054 3005
3055 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) 3006 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
3056 { 3007 {
3057 LSLError("No permissions to give money"); 3008 LSLError("No permissions to give money");
3058 return 0; 3009 return 0;
@@ -3115,74 +3066,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3115 { 3066 {
3116 m_host.AddScriptLPS(1); 3067 m_host.AddScriptLPS(1);
3117 3068
3118 Util.FireAndForget(delegate (object x) 3069 Util.FireAndForget(x =>
3119 { 3070 {
3120 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) 3071 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
3121 return; 3072 return;
3073
3122 float dist = (float)llVecDist(llGetPos(), pos); 3074 float dist = (float)llVecDist(llGetPos(), pos);
3123 3075
3124 if (dist > m_ScriptDistanceFactor * 10.0f) 3076 if (dist > m_ScriptDistanceFactor * 10.0f)
3125 return; 3077 return;
3126 3078
3127 //Clone is thread-safe 3079 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
3128 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3129 3080
3130 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 3081 if (item == null)
3131 { 3082 {
3132 if (inv.Value.Name == inventory) 3083 llSay(0, "Could not find object " + inventory);
3133 { 3084 return;
3134 // make sure we're an object. 3085 }
3135 if (inv.Value.InvType != (int)InventoryType.Object)
3136 {
3137 llSay(0, "Unable to create requested object. Object is missing from database.");
3138 return;
3139 }
3140 3086
3141 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); 3087 if (item.InvType != (int)InventoryType.Object)
3142 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); 3088 {
3089 llSay(0, "Unable to create requested object. Object is missing from database.");
3090 return;
3091 }
3143 3092
3144 // need the magnitude later 3093 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
3145 // float velmag = (float)Util.GetMagnitude(llvel); 3094 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
3146 3095
3147 SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); 3096 // need the magnitude later
3097 // float velmag = (float)Util.GetMagnitude(llvel);
3148 3098
3149 // If either of these are null, then there was an unknown error. 3099 SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param);
3150 if (new_group == null)
3151 continue;
3152 3100
3153 // objects rezzed with this method are die_at_edge by default. 3101 // If either of these are null, then there was an unknown error.
3154 new_group.RootPart.SetDieAtEdge(true); 3102 if (new_group == null)
3103 return;
3155 3104
3156 new_group.ResumeScripts(); 3105 // objects rezzed with this method are die_at_edge by default.
3106 new_group.RootPart.SetDieAtEdge(true);
3157 3107
3158 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( 3108 new_group.ResumeScripts();
3159 "object_rez", new Object[] {
3160 new LSL_String(
3161 new_group.RootPart.UUID.ToString()) },
3162 new DetectParams[0]));
3163 3109
3164 // do recoil 3110 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
3165 SceneObjectGroup hostgrp = m_host.ParentGroup; 3111 "object_rez", new Object[] {
3166 if (hostgrp == null) 3112 new LSL_String(
3167 return; 3113 new_group.RootPart.UUID.ToString()) },
3114 new DetectParams[0]));
3168 3115
3169 if (hostgrp.IsAttachment) // don't recoil avatars 3116 // do recoil
3170 return; 3117 SceneObjectGroup hostgrp = m_host.ParentGroup;
3118 if (hostgrp == null)
3119 return;
3171 3120
3172 PhysicsActor pa = new_group.RootPart.PhysActor; 3121 if (hostgrp.IsAttachment) // don't recoil avatars
3122 return;
3173 3123
3174 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) 3124 PhysicsActor pa = new_group.RootPart.PhysActor;
3175 { 3125
3176 float groupmass = new_group.GetMass(); 3126 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
3177 llvel *= -groupmass; 3127 {
3178 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); 3128 float groupmass = new_group.GetMass();
3179 } 3129 llvel *= -groupmass;
3180 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3130 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0);
3181 return;
3182 }
3183 } 3131 }
3132 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3133 return;
3184 3134
3185 llSay(0, "Could not find object " + inventory);
3186 }); 3135 });
3187 3136
3188 //ScriptSleep((int)((groupmass * velmag) / 10)); 3137 //ScriptSleep((int)((groupmass * velmag) / 10));
@@ -3246,11 +3195,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3246 sec = m_MinTimerInterval; 3195 sec = m_MinTimerInterval;
3247 m_host.AddScriptLPS(1); 3196 m_host.AddScriptLPS(1);
3248 // Setting timer repeat 3197 // Setting timer repeat
3249 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); 3198 AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec);
3250 } 3199 }
3251 3200
3252 public virtual void llSleep(double sec) 3201 public virtual void llSleep(double sec)
3253 { 3202 {
3203// m_log.Info("llSleep snoozing " + sec + "s.");
3254 m_host.AddScriptLPS(1); 3204 m_host.AddScriptLPS(1);
3255 Thread.Sleep((int)(sec * 1000)); 3205 Thread.Sleep((int)(sec * 1000));
3256 } 3206 }
@@ -3309,29 +3259,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3309 3259
3310 public void llTakeControls(int controls, int accept, int pass_on) 3260 public void llTakeControls(int controls, int accept, int pass_on)
3311 { 3261 {
3312 TaskInventoryItem item; 3262 if (m_item.PermsGranter != UUID.Zero)
3313
3314 m_host.TaskInventory.LockItemsForRead(true);
3315 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3316 {
3317 m_host.TaskInventory.LockItemsForRead(false);
3318 return;
3319 }
3320 else
3321 {
3322 item = m_host.TaskInventory[InventorySelf()];
3323 }
3324 m_host.TaskInventory.LockItemsForRead(false);
3325
3326 if (item.PermsGranter != UUID.Zero)
3327 { 3263 {
3328 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3264 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3329 3265
3330 if (presence != null) 3266 if (presence != null)
3331 { 3267 {
3332 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3268 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3333 { 3269 {
3334 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 3270 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID);
3335 } 3271 }
3336 } 3272 }
3337 } 3273 }
@@ -3341,38 +3277,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3341 3277
3342 public void llReleaseControls() 3278 public void llReleaseControls()
3343 { 3279 {
3344 TaskInventoryItem item;
3345
3346 m_host.TaskInventory.LockItemsForRead(true);
3347 lock (m_host.TaskInventory)
3348 {
3349
3350 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3351 {
3352 m_host.TaskInventory.LockItemsForRead(false);
3353 return;
3354 }
3355 else
3356 {
3357 item = m_host.TaskInventory[InventorySelf()];
3358 }
3359 }
3360 m_host.TaskInventory.LockItemsForRead(false);
3361
3362 m_host.AddScriptLPS(1); 3280 m_host.AddScriptLPS(1);
3363 3281
3364 if (item.PermsGranter != UUID.Zero) 3282 if (m_item.PermsGranter != UUID.Zero)
3365 { 3283 {
3366 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3284 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3367 3285
3368 if (presence != null) 3286 if (presence != null)
3369 { 3287 {
3370 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3288 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3371 { 3289 {
3372 // Unregister controls from Presence 3290 // Unregister controls from Presence
3373 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 3291 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
3374 // Remove Take Control permission. 3292 // Remove Take Control permission.
3375 item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 3293 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
3376 } 3294 }
3377 } 3295 }
3378 } 3296 }
@@ -3385,39 +3303,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3385 m_UrlModule.ReleaseURL(url); 3303 m_UrlModule.ReleaseURL(url);
3386 } 3304 }
3387 3305
3388 public void llAttachToAvatar(int attachment) 3306 /// <summary>
3307 /// Attach the object containing this script to the avatar that owns it.
3308 /// </summary>
3309 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3310 /// <returns>true if the attach suceeded, false if it did not</returns>
3311 public bool AttachToAvatar(int attachmentPoint)
3389 { 3312 {
3390 m_host.AddScriptLPS(1); 3313 SceneObjectGroup grp = m_host.ParentGroup;
3314 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3391 3315
3392 TaskInventoryItem item; 3316 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3393
3394 m_host.TaskInventory.LockItemsForRead(true);
3395 3317
3396 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3318 if (attachmentsModule != null)
3397 { 3319 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true);
3398 m_host.TaskInventory.LockItemsForRead(false);
3399 return;
3400 }
3401 else 3320 else
3321 return false;
3322 }
3323
3324 /// <summary>
3325 /// Detach the object containing this script from the avatar it is attached to.
3326 /// </summary>
3327 /// <remarks>
3328 /// Nothing happens if the object is not attached.
3329 /// </remarks>
3330 public void DetachFromAvatar()
3331 {
3332 Util.FireAndForget(DetachWrapper, m_host);
3333 }
3334
3335 private void DetachWrapper(object o)
3336 {
3337 if (World.AttachmentsModule != null)
3402 { 3338 {
3403 item = m_host.TaskInventory[InventorySelf()]; 3339 SceneObjectPart host = (SceneObjectPart)o;
3340 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3341 World.AttachmentsModule.DetachSingleAttachmentToInv(presence, host.ParentGroup);
3404 } 3342 }
3343 }
3405 3344
3406 m_host.TaskInventory.LockItemsForRead(false); 3345 public void llAttachToAvatar(int attachmentPoint)
3346 {
3347 m_host.AddScriptLPS(1);
3407 3348
3408 if (item.PermsGranter != m_host.OwnerID) 3349 if (m_item.PermsGranter != m_host.OwnerID)
3409 return; 3350 return;
3410 3351
3411 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3352 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3412 { 3353 AttachToAvatar(attachmentPoint);
3413 SceneObjectGroup grp = m_host.ParentGroup;
3414
3415 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3416
3417 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3418 if (attachmentsModule != null)
3419 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false, true);
3420 }
3421 } 3354 }
3422 3355
3423 public void llDetachFromAvatar() 3356 public void llDetachFromAvatar()
@@ -3427,44 +3360,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3427 if (m_host.ParentGroup.AttachmentPoint == 0) 3360 if (m_host.ParentGroup.AttachmentPoint == 0)
3428 return; 3361 return;
3429 3362
3430 TaskInventoryItem item; 3363 if (m_item.PermsGranter != m_host.OwnerID)
3431
3432 m_host.TaskInventory.LockItemsForRead(true);
3433
3434 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3435 {
3436 m_host.TaskInventory.LockItemsForRead(false);
3437 return; 3364 return;
3438 }
3439 else
3440 {
3441 item = m_host.TaskInventory[InventorySelf()];
3442 }
3443 m_host.TaskInventory.LockItemsForRead(false);
3444
3445
3446 if (item.PermsGranter != m_host.OwnerID)
3447 return;
3448
3449 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3450 {
3451 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3452 if (attachmentsModule != null)
3453 Util.FireAndForget(DetachWrapper, m_host);
3454 }
3455 }
3456 3365
3457 private void DetachWrapper(object o) 3366 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3458 { 3367 DetachFromAvatar();
3459 SceneObjectPart host = (SceneObjectPart)o;
3460
3461 SceneObjectGroup grp = host.ParentGroup;
3462 UUID itemID = grp.FromItemID;
3463 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3464
3465 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3466 if (attachmentsModule != null)
3467 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3468 } 3368 }
3469 3369
3470 public void llTakeCamera(string avatar) 3370 public void llTakeCamera(string avatar)
@@ -3585,7 +3485,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3585 } 3485 }
3586 3486
3587 emailModule.SendEmail(m_host.UUID, address, subject, message); 3487 emailModule.SendEmail(m_host.UUID, address, subject, message);
3588 ScriptSleep(15000); 3488 ScriptSleep(EMAIL_PAUSE_TIME * 1000);
3589 } 3489 }
3590 3490
3591 public void llGetNextEmail(string address, string subject) 3491 public void llGetNextEmail(string address, string subject)
@@ -3622,6 +3522,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3622 return m_host.UUID.ToString(); 3522 return m_host.UUID.ToString();
3623 } 3523 }
3624 3524
3525 public LSL_Key llGenerateKey()
3526 {
3527 m_host.AddScriptLPS(1);
3528 return UUID.Random().ToString();
3529 }
3530
3625 public void llSetBuoyancy(double buoyancy) 3531 public void llSetBuoyancy(double buoyancy)
3626 { 3532 {
3627 m_host.AddScriptLPS(1); 3533 m_host.AddScriptLPS(1);
@@ -3668,7 +3574,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3668 m_host.AddScriptLPS(1); 3574 m_host.AddScriptLPS(1);
3669 try 3575 try
3670 { 3576 {
3671 m_ScriptEngine.SetMinEventDelay(m_itemID, delay); 3577 m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay);
3672 } 3578 }
3673 catch (NotImplementedException) 3579 catch (NotImplementedException)
3674 { 3580 {
@@ -3721,29 +3627,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3721 { 3627 {
3722 m_host.AddScriptLPS(1); 3628 m_host.AddScriptLPS(1);
3723 3629
3724 UUID invItemID = InventorySelf(); 3630 if (m_item.PermsGranter == UUID.Zero)
3725 if (invItemID == UUID.Zero)
3726 return; 3631 return;
3727 3632
3728 TaskInventoryItem item; 3633 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3729
3730 m_host.TaskInventory.LockItemsForRead(true);
3731 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3732 {
3733 m_host.TaskInventory.LockItemsForRead(false);
3734 return;
3735 }
3736 else
3737 { 3634 {
3738 item = m_host.TaskInventory[InventorySelf()]; 3635 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3739 }
3740 m_host.TaskInventory.LockItemsForRead(false);
3741 if (item.PermsGranter == UUID.Zero)
3742 return;
3743
3744 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3745 {
3746 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3747 3636
3748 if (presence != null) 3637 if (presence != null)
3749 { 3638 {
@@ -3761,41 +3650,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3761 { 3650 {
3762 m_host.AddScriptLPS(1); 3651 m_host.AddScriptLPS(1);
3763 3652
3764 UUID invItemID=InventorySelf(); 3653 if (m_item.PermsGranter == UUID.Zero)
3765 if (invItemID == UUID.Zero)
3766 return;
3767
3768 TaskInventoryItem item;
3769
3770 m_host.TaskInventory.LockItemsForRead(true);
3771 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3772 {
3773 m_host.TaskInventory.LockItemsForRead(false);
3774 return;
3775 }
3776 else
3777 {
3778 item = m_host.TaskInventory[InventorySelf()];
3779 }
3780 m_host.TaskInventory.LockItemsForRead(false);
3781
3782
3783 if (item.PermsGranter == UUID.Zero)
3784 return; 3654 return;
3785 3655
3786 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3656 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3787 { 3657 {
3788 UUID animID = new UUID(); 3658 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3789
3790 if (!UUID.TryParse(anim, out animID))
3791 {
3792 animID=InventoryKey(anim);
3793 }
3794
3795 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3796 3659
3797 if (presence != null) 3660 if (presence != null)
3798 { 3661 {
3662 UUID animID = KeyOrName(anim);
3663
3799 if (animID == UUID.Zero) 3664 if (animID == UUID.Zero)
3800 presence.Animator.RemoveAnimation(anim); 3665 presence.Animator.RemoveAnimation(anim);
3801 else 3666 else
@@ -3829,44 +3694,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3829 public LSL_Integer llGetStartParameter() 3694 public LSL_Integer llGetStartParameter()
3830 { 3695 {
3831 m_host.AddScriptLPS(1); 3696 m_host.AddScriptLPS(1);
3832 return m_ScriptEngine.GetStartParameter(m_itemID); 3697 return m_ScriptEngine.GetStartParameter(m_item.ItemID);
3833 } 3698 }
3834 3699
3835 public void llRequestPermissions(string agent, int perm) 3700 public void llRequestPermissions(string agent, int perm)
3836 { 3701 {
3837 UUID agentID = new UUID(); 3702 UUID agentID;
3838 3703
3839 if (!UUID.TryParse(agent, out agentID)) 3704 if (!UUID.TryParse(agent, out agentID))
3840 return; 3705 return;
3841 3706
3842 UUID invItemID = InventorySelf();
3843
3844 if (invItemID == UUID.Zero)
3845 return; // Not in a prim? How??
3846
3847 TaskInventoryItem item;
3848
3849
3850 m_host.TaskInventory.LockItemsForRead(true);
3851 if (!m_host.TaskInventory.ContainsKey(invItemID))
3852 {
3853 m_host.TaskInventory.LockItemsForRead(false);
3854 return;
3855 }
3856 else
3857 {
3858 item = m_host.TaskInventory[invItemID];
3859 }
3860 m_host.TaskInventory.LockItemsForRead(false);
3861
3862 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3707 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3863 { 3708 {
3864 llReleaseControls(); 3709 llReleaseControls();
3865 3710
3866 item.PermsGranter = UUID.Zero; 3711 m_item.PermsGranter = UUID.Zero;
3867 item.PermsMask = 0; 3712 m_item.PermsMask = 0;
3868 3713
3869 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3714 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3870 "run_time_permissions", new Object[] { 3715 "run_time_permissions", new Object[] {
3871 new LSL_Integer(0) }, 3716 new LSL_Integer(0) },
3872 new DetectParams[0])); 3717 new DetectParams[0]));
@@ -3874,7 +3719,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3874 return; 3719 return;
3875 } 3720 }
3876 3721
3877 if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3722 if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3878 llReleaseControls(); 3723 llReleaseControls();
3879 3724
3880 m_host.AddScriptLPS(1); 3725 m_host.AddScriptLPS(1);
@@ -3891,11 +3736,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3891 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3736 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3892 { 3737 {
3893 m_host.TaskInventory.LockItemsForWrite(true); 3738 m_host.TaskInventory.LockItemsForWrite(true);
3894 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3739 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3895 m_host.TaskInventory[invItemID].PermsMask = perm; 3740 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3896 m_host.TaskInventory.LockItemsForWrite(false); 3741 m_host.TaskInventory.LockItemsForWrite(false);
3897 3742
3898 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3743 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3899 "run_time_permissions", new Object[] { 3744 "run_time_permissions", new Object[] {
3900 new LSL_Integer(perm) }, 3745 new LSL_Integer(perm) },
3901 new DetectParams[0])); 3746 new DetectParams[0]));
@@ -3930,11 +3775,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3930 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3775 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3931 { 3776 {
3932 m_host.TaskInventory.LockItemsForWrite(true); 3777 m_host.TaskInventory.LockItemsForWrite(true);
3933 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3778 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3934 m_host.TaskInventory[invItemID].PermsMask = perm; 3779 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3935 m_host.TaskInventory.LockItemsForWrite(false); 3780 m_host.TaskInventory.LockItemsForWrite(false);
3936 3781
3937 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3782 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3938 "run_time_permissions", new Object[] { 3783 "run_time_permissions", new Object[] {
3939 new LSL_Integer(perm) }, 3784 new LSL_Integer(perm) },
3940 new DetectParams[0])); 3785 new DetectParams[0]));
@@ -3945,9 +3790,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3945 } 3790 }
3946 3791
3947 ScenePresence presence = World.GetScenePresence(agentID); 3792 ScenePresence presence = World.GetScenePresence(agentID);
3948
3949 if (presence != null) 3793 if (presence != null)
3950 { 3794 {
3795 // If permissions are being requested from an NPC and were not implicitly granted above then
3796 // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner
3797 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
3798 if (npcModule != null && npcModule.IsNPC(agentID, World))
3799 {
3800 if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID)
3801 {
3802 lock (m_host.TaskInventory)
3803 {
3804 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3805 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3806 }
3807
3808 m_ScriptEngine.PostScriptEvent(
3809 m_item.ItemID,
3810 new EventParams(
3811 "run_time_permissions", new Object[] { new LSL_Integer(perm) }, new DetectParams[0]));
3812 }
3813
3814 // it is an NPC, exit even if the permissions werent granted above, they are not going to answer
3815 // the question!
3816 return;
3817 }
3818
3951 string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); 3819 string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID);
3952 if (ownerName == String.Empty) 3820 if (ownerName == String.Empty)
3953 ownerName = "(hippos)"; 3821 ownerName = "(hippos)";
@@ -3955,8 +3823,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3955 if (!m_waitingForScriptAnswer) 3823 if (!m_waitingForScriptAnswer)
3956 { 3824 {
3957 m_host.TaskInventory.LockItemsForWrite(true); 3825 m_host.TaskInventory.LockItemsForWrite(true);
3958 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3826 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3959 m_host.TaskInventory[invItemID].PermsMask = 0; 3827 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3960 m_host.TaskInventory.LockItemsForWrite(false); 3828 m_host.TaskInventory.LockItemsForWrite(false);
3961 3829
3962 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3830 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3964,16 +3832,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3964 } 3832 }
3965 3833
3966 presence.ControllingClient.SendScriptQuestion( 3834 presence.ControllingClient.SendScriptQuestion(
3967 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3835 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm);
3968 3836
3969 return; 3837 return;
3970 } 3838 }
3971 3839
3972 // Requested agent is not in range, refuse perms 3840 // Requested agent is not in range, refuse perms
3973 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3841 m_ScriptEngine.PostScriptEvent(
3974 "run_time_permissions", new Object[] { 3842 m_item.ItemID,
3975 new LSL_Integer(0) }, 3843 new EventParams("run_time_permissions", new Object[] { new LSL_Integer(0) }, new DetectParams[0]));
3976 new DetectParams[0]));
3977 } 3844 }
3978 3845
3979 void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) 3846 void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer)
@@ -3981,24 +3848,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3981 if (taskID != m_host.UUID) 3848 if (taskID != m_host.UUID)
3982 return; 3849 return;
3983 3850
3984 UUID invItemID = InventorySelf(); 3851 client.OnScriptAnswer -= handleScriptAnswer;
3985 3852 m_waitingForScriptAnswer = false;
3986 if (invItemID == UUID.Zero)
3987 return;
3988
3989 client.OnScriptAnswer-=handleScriptAnswer;
3990 m_waitingForScriptAnswer=false;
3991 3853
3992 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3854 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3993 llReleaseControls(); 3855 llReleaseControls();
3994 3856
3995
3996 m_host.TaskInventory.LockItemsForWrite(true); 3857 m_host.TaskInventory.LockItemsForWrite(true);
3997 m_host.TaskInventory[invItemID].PermsMask = answer; 3858 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
3998 m_host.TaskInventory.LockItemsForWrite(false); 3859 m_host.TaskInventory.LockItemsForWrite(false);
3999 3860
4000 3861 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
4001 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
4002 "run_time_permissions", new Object[] { 3862 "run_time_permissions", new Object[] {
4003 new LSL_Integer(answer) }, 3863 new LSL_Integer(answer) },
4004 new DetectParams[0])); 3864 new DetectParams[0]));
@@ -4008,41 +3868,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4008 { 3868 {
4009 m_host.AddScriptLPS(1); 3869 m_host.AddScriptLPS(1);
4010 3870
4011 m_host.TaskInventory.LockItemsForRead(true); 3871 return m_item.PermsGranter.ToString();
4012
4013 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4014 {
4015 if (item.Type == 10 && item.ItemID == m_itemID)
4016 {
4017 m_host.TaskInventory.LockItemsForRead(false);
4018 return item.PermsGranter.ToString();
4019 }
4020 }
4021 m_host.TaskInventory.LockItemsForRead(false);
4022
4023 return UUID.Zero.ToString();
4024 } 3872 }
4025 3873
4026 public LSL_Integer llGetPermissions() 3874 public LSL_Integer llGetPermissions()
4027 { 3875 {
4028 m_host.AddScriptLPS(1); 3876 m_host.AddScriptLPS(1);
4029 3877
4030 m_host.TaskInventory.LockItemsForRead(true); 3878 int perms = m_item.PermsMask;
4031 3879
4032 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3880 if (m_automaticLinkPermission)
4033 { 3881 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
4034 if (item.Type == 10 && item.ItemID == m_itemID)
4035 {
4036 int perms = item.PermsMask;
4037 if (m_automaticLinkPermission)
4038 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
4039 m_host.TaskInventory.LockItemsForRead(false);
4040 return perms;
4041 }
4042 }
4043 m_host.TaskInventory.LockItemsForRead(false);
4044 3882
4045 return 0; 3883 return perms;
4046 } 3884 }
4047 3885
4048 public LSL_Integer llGetLinkNumber() 3886 public LSL_Integer llGetLinkNumber()
@@ -4080,18 +3918,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4080 public void llCreateLink(string target, int parent) 3918 public void llCreateLink(string target, int parent)
4081 { 3919 {
4082 m_host.AddScriptLPS(1); 3920 m_host.AddScriptLPS(1);
4083 UUID invItemID = InventorySelf(); 3921
4084 UUID targetID; 3922 UUID targetID;
4085 3923
4086 if (!UUID.TryParse(target, out targetID)) 3924 if (!UUID.TryParse(target, out targetID))
4087 return; 3925 return;
4088 3926
4089 TaskInventoryItem item; 3927 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4090 m_host.TaskInventory.LockItemsForRead(true);
4091 item = m_host.TaskInventory[invItemID];
4092 m_host.TaskInventory.LockItemsForRead(false);
4093
4094 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4095 && !m_automaticLinkPermission) 3928 && !m_automaticLinkPermission)
4096 { 3929 {
4097 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3930 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -4099,7 +3932,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4099 } 3932 }
4100 3933
4101 IClientAPI client = null; 3934 IClientAPI client = null;
4102 ScenePresence sp = World.GetScenePresence(item.PermsGranter); 3935 ScenePresence sp = World.GetScenePresence(m_item.PermsGranter);
4103 if (sp != null) 3936 if (sp != null)
4104 client = sp.ControllingClient; 3937 client = sp.ControllingClient;
4105 3938
@@ -4145,18 +3978,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4145 public void llBreakLink(int linknum) 3978 public void llBreakLink(int linknum)
4146 { 3979 {
4147 m_host.AddScriptLPS(1); 3980 m_host.AddScriptLPS(1);
4148 UUID invItemID = InventorySelf();
4149 3981
4150 m_host.TaskInventory.LockItemsForRead(true); 3982 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4151 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3983 && !m_automaticLinkPermission)
4152 && !m_automaticLinkPermission) 3984 {
4153 { 3985 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4154 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3986 return;
4155 m_host.TaskInventory.LockItemsForRead(false); 3987 }
4156 return; 3988
4157 }
4158 m_host.TaskInventory.LockItemsForRead(false);
4159
4160 if (linknum < ScriptBaseClass.LINK_THIS) 3989 if (linknum < ScriptBaseClass.LINK_THIS)
4161 return; 3990 return;
4162 3991
@@ -4255,12 +4084,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4255 { 4084 {
4256 m_host.AddScriptLPS(1); 4085 m_host.AddScriptLPS(1);
4257 4086
4258 UUID invItemID = InventorySelf(); 4087 TaskInventoryItem item = m_item;
4259
4260 TaskInventoryItem item;
4261 m_host.TaskInventory.LockItemsForRead(true);
4262 item = m_host.TaskInventory[invItemID];
4263 m_host.TaskInventory.LockItemsForRead(false);
4264 4088
4265 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 4089 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4266 && !m_automaticLinkPermission) 4090 && !m_automaticLinkPermission)
@@ -4457,11 +4281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4457 public void llGiveInventory(string destination, string inventory) 4281 public void llGiveInventory(string destination, string inventory)
4458 { 4282 {
4459 m_host.AddScriptLPS(1); 4283 m_host.AddScriptLPS(1);
4460 bool found = false; 4284
4461 UUID destId = UUID.Zero; 4285 UUID destId = UUID.Zero;
4462 UUID objId = UUID.Zero;
4463 int assetType = 0;
4464 string objName = String.Empty;
4465 4286
4466 if (!UUID.TryParse(destination, out destId)) 4287 if (!UUID.TryParse(destination, out destId))
4467 { 4288 {
@@ -4469,28 +4290,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4469 return; 4290 return;
4470 } 4291 }
4471 4292
4472 // move the first object found with this inventory name 4293 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
4473 m_host.TaskInventory.LockItemsForRead(true);
4474 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4475 {
4476 if (inv.Value.Name == inventory)
4477 {
4478 found = true;
4479 objId = inv.Key;
4480 assetType = inv.Value.Type;
4481 objName = inv.Value.Name;
4482 break;
4483 }
4484 }
4485 m_host.TaskInventory.LockItemsForRead(false);
4486 4294
4487 if (!found) 4295 if (item == null)
4488 { 4296 {
4489 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4297 llSay(0, String.Format("Could not find object '{0}'", inventory));
4490 return; 4298 return;
4491// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4299// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4492 } 4300 }
4493 4301
4302 UUID objId = item.ItemID;
4303
4494 // check if destination is an object 4304 // check if destination is an object
4495 if (World.GetSceneObjectPart(destId) != null) 4305 if (World.GetSceneObjectPart(destId) != null)
4496 { 4306 {
@@ -4522,14 +4332,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4522 return; 4332 return;
4523 4333
4524 byte[] bucket = new byte[1]; 4334 byte[] bucket = new byte[1];
4525 bucket[0] = (byte)assetType; 4335 bucket[0] = (byte)item.Type;
4526 //byte[] objBytes = agentItem.ID.GetBytes(); 4336 //byte[] objBytes = agentItem.ID.GetBytes();
4527 //Array.Copy(objBytes, 0, bucket, 1, 16); 4337 //Array.Copy(objBytes, 0, bucket, 1, 16);
4528 4338
4529 GridInstantMessage msg = new GridInstantMessage(World, 4339 GridInstantMessage msg = new GridInstantMessage(World,
4530 m_host.OwnerID, m_host.Name, destId, 4340 m_host.OwnerID, m_host.Name, destId,
4531 (byte)InstantMessageDialog.TaskInventoryOffered, 4341 (byte)InstantMessageDialog.TaskInventoryOffered,
4532 false, objName+". "+m_host.Name+" is located at "+ 4342 false, item.Name+". "+m_host.Name+" is located at "+
4533 World.RegionInfo.RegionName+" "+ 4343 World.RegionInfo.RegionName+" "+
4534 m_host.AbsolutePosition.ToString(), 4344 m_host.AbsolutePosition.ToString(),
4535 agentItem.ID, true, m_host.AbsolutePosition, 4345 agentItem.ID, true, m_host.AbsolutePosition,
@@ -4557,27 +4367,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4557 { 4367 {
4558 m_host.AddScriptLPS(1); 4368 m_host.AddScriptLPS(1);
4559 4369
4560 List<TaskInventoryItem> inv; 4370 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
4561 try 4371
4562 { 4372 if (item == null)
4563 m_host.TaskInventory.LockItemsForRead(true); 4373 return;
4564 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); 4374
4565 } 4375 if (item.ItemID == m_item.ItemID)
4566 finally 4376 throw new ScriptDeleteException();
4567 { 4377 else
4568 m_host.TaskInventory.LockItemsForRead(false); 4378 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4569 }
4570 foreach (TaskInventoryItem item in inv)
4571 {
4572 if (item.Name == name)
4573 {
4574 if (item.ItemID == m_itemID)
4575 throw new ScriptDeleteException();
4576 else
4577 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4578 return;
4579 }
4580 }
4581 } 4379 }
4582 4380
4583 public void llSetText(string text, LSL_Vector color, double alpha) 4381 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -4705,8 +4503,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4705 UUID rq = UUID.Random(); 4503 UUID rq = UUID.Random();
4706 4504
4707 UUID tid = AsyncCommands. 4505 UUID tid = AsyncCommands.
4708 DataserverPlugin.RegisterRequest(m_localID, 4506 DataserverPlugin.RegisterRequest(m_host.LocalId,
4709 m_itemID, rq.ToString()); 4507 m_item.ItemID, rq.ToString());
4710 4508
4711 AsyncCommands. 4509 AsyncCommands.
4712 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4510 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -4725,16 +4523,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4725 { 4523 {
4726 m_host.AddScriptLPS(1); 4524 m_host.AddScriptLPS(1);
4727 4525
4728 //Clone is thread safe 4526 foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems())
4729 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4730
4731 foreach (TaskInventoryItem item in itemDictionary.Values)
4732 { 4527 {
4733 if (item.Type == 3 && item.Name == name) 4528 if (item.Type == 3 && item.Name == name)
4734 { 4529 {
4735 UUID tid = AsyncCommands. 4530 UUID tid = AsyncCommands.
4736 DataserverPlugin.RegisterRequest(m_localID, 4531 DataserverPlugin.RegisterRequest(m_host.LocalId,
4737 m_itemID, item.AssetID.ToString()); 4532 m_item.ItemID, item.AssetID.ToString());
4738 4533
4739 Vector3 region = new Vector3( 4534 Vector3 region = new Vector3(
4740 World.RegionInfo.RegionLocX * Constants.RegionSize, 4535 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -4760,6 +4555,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4760 return tid.ToString(); 4555 return tid.ToString();
4761 } 4556 }
4762 } 4557 }
4558
4763 ScriptSleep(1000); 4559 ScriptSleep(1000);
4764 return String.Empty; 4560 return String.Empty;
4765 } 4561 }
@@ -4952,19 +4748,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4952 UUID soundId = UUID.Zero; 4748 UUID soundId = UUID.Zero;
4953 if (!UUID.TryParse(impact_sound, out soundId)) 4749 if (!UUID.TryParse(impact_sound, out soundId))
4954 { 4750 {
4955 m_host.TaskInventory.LockItemsForRead(true); 4751 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound);
4956 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4752
4957 { 4753 if (item != null && item.Type == (int)AssetType.Sound)
4958 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4754 soundId = item.AssetID;
4959 {
4960 soundId = item.AssetID;
4961 break;
4962 }
4963 }
4964 m_host.TaskInventory.LockItemsForRead(false);
4965 } 4755 }
4966 m_host.CollisionSoundVolume = (float)impact_volume; 4756
4967 m_host.CollisionSound = soundId; 4757 m_host.CollisionSound = soundId;
4758 m_host.CollisionSoundVolume = (float)impact_volume;
4968 m_host.CollisionSoundType = 1; 4759 m_host.CollisionSoundType = 1;
4969 } 4760 }
4970 4761
@@ -5006,10 +4797,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5006 UUID partItemID; 4797 UUID partItemID;
5007 foreach (SceneObjectPart part in parts) 4798 foreach (SceneObjectPart part in parts)
5008 { 4799 {
5009 //Clone is thread safe 4800 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems())
5010 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
5011
5012 foreach (TaskInventoryItem item in itemsDictionary.Values)
5013 { 4801 {
5014 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT) 4802 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT)
5015 { 4803 {
@@ -5207,22 +4995,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5207 4995
5208 public LSL_String llGetScriptName() 4996 public LSL_String llGetScriptName()
5209 { 4997 {
5210 string result = String.Empty;
5211
5212 m_host.AddScriptLPS(1); 4998 m_host.AddScriptLPS(1);
5213 4999
5214 m_host.TaskInventory.LockItemsForRead(true); 5000 return m_item.Name != null ? m_item.Name : String.Empty;
5215 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
5216 {
5217 if (item.Type == 10 && item.ItemID == m_itemID)
5218 {
5219 result = item.Name!=null?item.Name:String.Empty;
5220 break;
5221 }
5222 }
5223 m_host.TaskInventory.LockItemsForRead(false);
5224
5225 return result;
5226 } 5001 }
5227 5002
5228 public LSL_Integer llGetLinkNumberOfSides(int link) 5003 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -5393,22 +5168,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5393 { 5168 {
5394 m_host.AddScriptLPS(1); 5169 m_host.AddScriptLPS(1);
5395 5170
5396 m_host.TaskInventory.LockItemsForRead(true); 5171 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
5397 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 5172
5173 if (item == null)
5174 return UUID.Zero.ToString();
5175
5176 if ((item.CurrentPermissions
5177 & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5178 == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5398 { 5179 {
5399 if (inv.Value.Name == name) 5180 return item.AssetID.ToString();
5400 {
5401 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5402 {
5403 m_host.TaskInventory.LockItemsForRead(false);
5404 return inv.Value.AssetID.ToString();
5405 }
5406 else
5407 {
5408 m_host.TaskInventory.LockItemsForRead(false);
5409 return UUID.Zero.ToString();
5410 }
5411 }
5412 } 5181 }
5413 m_host.TaskInventory.LockItemsForRead(false); 5182 m_host.TaskInventory.LockItemsForRead(false);
5414 5183
@@ -6356,7 +6125,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6356 } 6125 }
6357 } 6126 }
6358 } 6127 }
6359 List<UUID> presenceIds = new List<UUID>();
6360 6128
6361 World.ForEachRootScenePresence( 6129 World.ForEachRootScenePresence(
6362 delegate (ScenePresence ssp) 6130 delegate (ScenePresence ssp)
@@ -6507,7 +6275,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6507 if (m_host.OwnerID == land.LandData.OwnerID) 6275 if (m_host.OwnerID == land.LandData.OwnerID)
6508 { 6276 {
6509 Vector3 pos = World.GetNearestAllowedPosition(presence, land); 6277 Vector3 pos = World.GetNearestAllowedPosition(presence, land);
6510 presence.TeleportWithMomentum(pos); 6278 presence.TeleportWithMomentum(pos, null);
6511 presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); 6279 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
6512 } 6280 }
6513 } 6281 }
@@ -7032,22 +6800,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7032 } 6800 }
7033 } 6801 }
7034 6802
7035 protected UUID GetTaskInventoryItem(string name)
7036 {
7037 m_host.TaskInventory.LockItemsForRead(true);
7038 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
7039 {
7040 if (inv.Value.Name == name)
7041 {
7042 m_host.TaskInventory.LockItemsForRead(false);
7043 return inv.Key;
7044 }
7045 }
7046 m_host.TaskInventory.LockItemsForRead(false);
7047
7048 return UUID.Zero;
7049 }
7050
7051 public void llGiveInventoryList(string destination, string category, LSL_List inventory) 6803 public void llGiveInventoryList(string destination, string category, LSL_List inventory)
7052 { 6804 {
7053 m_host.AddScriptLPS(1); 6805 m_host.AddScriptLPS(1);
@@ -7060,16 +6812,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7060 6812
7061 foreach (Object item in inventory.Data) 6813 foreach (Object item in inventory.Data)
7062 { 6814 {
6815 string rawItemString = item.ToString();
6816
7063 UUID itemID; 6817 UUID itemID;
7064 if (UUID.TryParse(item.ToString(), out itemID)) 6818 if (UUID.TryParse(rawItemString, out itemID))
7065 { 6819 {
7066 itemList.Add(itemID); 6820 itemList.Add(itemID);
7067 } 6821 }
7068 else 6822 else
7069 { 6823 {
7070 itemID = GetTaskInventoryItem(item.ToString()); 6824 TaskInventoryItem taskItem = m_host.Inventory.GetInventoryItem(rawItemString);
7071 if (itemID != UUID.Zero) 6825
7072 itemList.Add(itemID); 6826 if (taskItem != null)
6827 itemList.Add(taskItem.ItemID);
7073 } 6828 }
7074 } 6829 }
7075 6830
@@ -7391,9 +7146,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7391 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) 7146 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
7392 { 7147 {
7393 m_host.AddScriptLPS(1); 7148 m_host.AddScriptLPS(1);
7394 bool found = false; 7149
7395 UUID destId = UUID.Zero; 7150 UUID destId = UUID.Zero;
7396 UUID srcId = UUID.Zero;
7397 7151
7398 if (!UUID.TryParse(target, out destId)) 7152 if (!UUID.TryParse(target, out destId))
7399 { 7153 {
@@ -7408,25 +7162,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7408 } 7162 }
7409 7163
7410 // copy the first script found with this inventory name 7164 // copy the first script found with this inventory name
7411 TaskInventoryItem scriptItem = null; 7165 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
7412 m_host.TaskInventory.LockItemsForRead(true);
7413 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
7414 {
7415 if (inv.Value.Name == name)
7416 {
7417 // make sure the object is a script
7418 if (10 == inv.Value.Type)
7419 {
7420 found = true;
7421 srcId = inv.Key;
7422 scriptItem = inv.Value;
7423 break;
7424 }
7425 }
7426 }
7427 m_host.TaskInventory.LockItemsForRead(false);
7428 7166
7429 if (!found) 7167 // make sure the object is a script
7168 if (item == null || item.Type != 10)
7430 { 7169 {
7431 llSay(0, "Could not find script " + name); 7170 llSay(0, "Could not find script " + name);
7432 return; 7171 return;
@@ -7435,13 +7174,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7435 SceneObjectPart dest = World.GetSceneObjectPart(destId); 7174 SceneObjectPart dest = World.GetSceneObjectPart(destId);
7436 if (dest != null) 7175 if (dest != null)
7437 { 7176 {
7438 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) 7177 if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
7439 { 7178 {
7440 // the rest of the permission checks are done in RezScript, so check the pin there as well 7179 // the rest of the permission checks are done in RezScript, so check the pin there as well
7441 World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); 7180 World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param);
7442 7181
7443 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0) 7182 if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0)
7444 m_host.Inventory.RemoveInventoryItem(srcId); 7183 m_host.Inventory.RemoveInventoryItem(item.ItemID);
7445 } 7184 }
7446 } 7185 }
7447 // this will cause the delay even if the script pin or permissions were wrong - seems ok 7186 // this will cause the delay even if the script pin or permissions were wrong - seems ok
@@ -7454,14 +7193,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7454 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7193 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7455 if (xmlrpcMod.IsEnabled()) 7194 if (xmlrpcMod.IsEnabled())
7456 { 7195 {
7457 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); 7196 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero);
7458 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); 7197 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
7459 if (xmlRpcRouter != null) 7198 if (xmlRpcRouter != null)
7460 { 7199 {
7461 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; 7200 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName;
7462 7201
7463 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, 7202 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID,
7464 m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, 7203 m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName,
7465 xmlrpcMod.Port.ToString())); 7204 xmlrpcMod.Port.ToString()));
7466 } 7205 }
7467 object[] resobj = new object[] 7206 object[] resobj = new object[]
@@ -7473,7 +7212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7473 new LSL_Integer(0), 7212 new LSL_Integer(0),
7474 new LSL_String(String.Empty) 7213 new LSL_String(String.Empty)
7475 }; 7214 };
7476 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, 7215 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj,
7477 new DetectParams[0])); 7216 new DetectParams[0]));
7478 } 7217 }
7479 ScriptSleep(1000); 7218 ScriptSleep(1000);
@@ -7484,7 +7223,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7484 m_host.AddScriptLPS(1); 7223 m_host.AddScriptLPS(1);
7485 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7224 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7486 ScriptSleep(3000); 7225 ScriptSleep(3000);
7487 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); 7226 return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString();
7488 } 7227 }
7489 7228
7490 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) 7229 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@@ -8488,7 +8227,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8488 return; 8227 return;
8489 face = (int)rules.GetLSLIntegerItem(idx++); 8228 face = (int)rules.GetLSLIntegerItem(idx++);
8490 int shiny = (int)rules.GetLSLIntegerItem(idx++); 8229 int shiny = (int)rules.GetLSLIntegerItem(idx++);
8491 Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); 8230 Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++);
8492 8231
8493 SetShiny(part, face, shiny, bump); 8232 SetShiny(part, face, shiny, bump);
8494 8233
@@ -10330,7 +10069,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10330 public LSL_String llGetSimulatorHostname() 10069 public LSL_String llGetSimulatorHostname()
10331 { 10070 {
10332 m_host.AddScriptLPS(1); 10071 m_host.AddScriptLPS(1);
10333 return System.Environment.MachineName; 10072 IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>();
10073 return UrlModule.ExternalHostNameForLSL;
10334 } 10074 }
10335 10075
10336 // <summary> 10076 // <summary>
@@ -10567,92 +10307,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10567 } 10307 }
10568 } 10308 }
10569 10309
10570 public LSL_Integer llGetInventoryPermMask(string item, int mask) 10310 public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
10571 { 10311 {
10572 m_host.AddScriptLPS(1); 10312 m_host.AddScriptLPS(1);
10573 10313
10574 m_host.TaskInventory.LockItemsForRead(true); 10314 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10575 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10315
10316 if (item == null)
10317 return -1;
10318
10319 switch (mask)
10576 { 10320 {
10577 if (inv.Value.Name == item) 10321 case 0:
10578 { 10322 return (int)item.BasePermissions;
10579 m_host.TaskInventory.LockItemsForRead(false); 10323 case 1:
10580 switch (mask) 10324 return (int)item.CurrentPermissions;
10581 { 10325 case 2:
10582 case 0: 10326 return (int)item.GroupPermissions;
10583 return (int)inv.Value.BasePermissions; 10327 case 3:
10584 case 1: 10328 return (int)item.EveryonePermissions;
10585 return (int)inv.Value.CurrentPermissions; 10329 case 4:
10586 case 2: 10330 return (int)item.NextPermissions;
10587 return (int)inv.Value.GroupPermissions;
10588 case 3:
10589 return (int)inv.Value.EveryonePermissions;
10590 case 4:
10591 return (int)inv.Value.NextPermissions;
10592 }
10593 }
10594 } 10331 }
10595 m_host.TaskInventory.LockItemsForRead(false); 10332 m_host.TaskInventory.LockItemsForRead(false);
10596 10333
10597 return -1; 10334 return -1;
10598 } 10335 }
10599 10336
10600 public void llSetInventoryPermMask(string item, int mask, int value) 10337 public void llSetInventoryPermMask(string itemName, int mask, int value)
10601 { 10338 {
10602 m_host.AddScriptLPS(1); 10339 m_host.AddScriptLPS(1);
10340
10603 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) 10341 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
10604 { 10342 {
10605 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 10343 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
10606 { 10344 {
10607 lock (m_host.TaskInventory) 10345 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10346
10347 if (item != null)
10608 { 10348 {
10609 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10349 switch (mask)
10610 { 10350 {
10611 if (inv.Value.Name == item) 10351 case 0:
10612 { 10352 item.BasePermissions = (uint)value;
10613 switch (mask) 10353 break;
10614 { 10354 case 1:
10615 case 0: 10355 item.CurrentPermissions = (uint)value;
10616 inv.Value.BasePermissions = (uint)value; 10356 break;
10617 break; 10357 case 2:
10618 case 1: 10358 item.GroupPermissions = (uint)value;
10619 inv.Value.CurrentPermissions = (uint)value; 10359 break;
10620 break; 10360 case 3:
10621 case 2: 10361 item.EveryonePermissions = (uint)value;
10622 inv.Value.GroupPermissions = (uint)value; 10362 break;
10623 break; 10363 case 4:
10624 case 3: 10364 item.NextPermissions = (uint)value;
10625 inv.Value.EveryonePermissions = (uint)value; 10365 break;
10626 break;
10627 case 4:
10628 inv.Value.NextPermissions = (uint)value;
10629 break;
10630 }
10631 }
10632 } 10366 }
10633 } 10367 }
10634 } 10368 }
10635 } 10369 }
10636 } 10370 }
10637 10371
10638 public LSL_String llGetInventoryCreator(string item) 10372 public LSL_String llGetInventoryCreator(string itemName)
10639 { 10373 {
10640 m_host.AddScriptLPS(1); 10374 m_host.AddScriptLPS(1);
10641 10375
10642 m_host.TaskInventory.LockItemsForRead(true); 10376 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10643 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10377
10378 if (item == null)
10644 { 10379 {
10645 if (inv.Value.Name == item) 10380 llSay(0, "No item name '" + item + "'");
10646 {
10647 m_host.TaskInventory.LockItemsForRead(false);
10648 return inv.Value.CreatorID.ToString();
10649 }
10650 }
10651 m_host.TaskInventory.LockItemsForRead(false);
10652 10381
10653 llSay(0, "No item name '" + item + "'"); 10382 return String.Empty;
10383 }
10654 10384
10655 return String.Empty; 10385 return item.CreatorID.ToString();
10656 } 10386 }
10657 10387
10658 public void llOwnerSay(string msg) 10388 public void llOwnerSay(string msg)
@@ -10669,13 +10399,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10669 { 10399 {
10670 m_host.AddScriptLPS(1); 10400 m_host.AddScriptLPS(1);
10671 if (m_UrlModule != null) 10401 if (m_UrlModule != null)
10672 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 10402 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
10673 return UUID.Zero.ToString(); 10403 return UUID.Zero.ToString();
10674 } 10404 }
10675 10405
10676 public LSL_String llRequestSimulatorData(string simulator, int data) 10406 public LSL_String llRequestSimulatorData(string simulator, int data)
10677 { 10407 {
10678 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 10408 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
10679 10409
10680 try 10410 try
10681 { 10411 {
@@ -10685,7 +10415,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10685 10415
10686 GridRegion info; 10416 GridRegion info;
10687 10417
10688 if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) 10418 if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator?
10419
10689 info = new GridRegion(m_ScriptEngine.World.RegionInfo); 10420 info = new GridRegion(m_ScriptEngine.World.RegionInfo);
10690 else 10421 else
10691 info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); 10422 info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator);
@@ -10698,10 +10429,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10698 ScriptSleep(1000); 10429 ScriptSleep(1000);
10699 return UUID.Zero.ToString(); 10430 return UUID.Zero.ToString();
10700 } 10431 }
10701 reply = new LSL_Vector( 10432 if (m_ScriptEngine.World.RegionInfo.RegionName != simulator)
10702 info.RegionLocX, 10433 {
10703 info.RegionLocY, 10434 //Hypergrid Region co-ordinates
10704 0).ToString(); 10435 uint rx = 0, ry = 0;
10436 Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry);
10437
10438 reply = new LSL_Vector(
10439 rx,
10440 ry,
10441 0).ToString();
10442 }
10443 else
10444 {
10445 //Local-cooridnates
10446 reply = new LSL_Vector(
10447 info.RegionLocX,
10448 info.RegionLocY,
10449 0).ToString();
10450 }
10705 break; 10451 break;
10706 case ScriptBaseClass.DATA_SIM_STATUS: 10452 case ScriptBaseClass.DATA_SIM_STATUS:
10707 if (info != null) 10453 if (info != null)
@@ -10737,7 +10483,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10737 UUID rq = UUID.Random(); 10483 UUID rq = UUID.Random();
10738 10484
10739 UUID tid = AsyncCommands. 10485 UUID tid = AsyncCommands.
10740 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 10486 DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
10741 10487
10742 AsyncCommands. 10488 AsyncCommands.
10743 DataserverPlugin.DataserverReply(rq.ToString(), reply); 10489 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -10756,7 +10502,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10756 m_host.AddScriptLPS(1); 10502 m_host.AddScriptLPS(1);
10757 10503
10758 if (m_UrlModule != null) 10504 if (m_UrlModule != null)
10759 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 10505 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
10760 return UUID.Zero.ToString(); 10506 return UUID.Zero.ToString();
10761 } 10507 }
10762 10508
@@ -10792,7 +10538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10792 // child agents have a mass of 1.0 10538 // child agents have a mass of 1.0
10793 return 1; 10539 return 1;
10794 else 10540 else
10795 return avatar.GetMass(); 10541 return (double)avatar.GetMass();
10796 } 10542 }
10797 catch (KeyNotFoundException) 10543 catch (KeyNotFoundException)
10798 { 10544 {
@@ -11196,18 +10942,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11196 { 10942 {
11197 m_host.AddScriptLPS(1); 10943 m_host.AddScriptLPS(1);
11198 10944
11199 m_host.TaskInventory.LockItemsForRead(true); 10945 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
11200 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
11201 {
11202 if (inv.Value.Name == name)
11203 {
11204 m_host.TaskInventory.LockItemsForRead(false);
11205 return inv.Value.Type;
11206 }
11207 }
11208 m_host.TaskInventory.LockItemsForRead(false);
11209 10946
11210 return -1; 10947 if (item == null)
10948 return -1;
10949
10950 return item.Type;
11211 } 10951 }
11212 10952
11213 public void llSetPayPrice(int price, LSL_List quick_pay_buttons) 10953 public void llSetPayPrice(int price, LSL_List quick_pay_buttons)
@@ -11235,32 +10975,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11235 public LSL_Vector llGetCameraPos() 10975 public LSL_Vector llGetCameraPos()
11236 { 10976 {
11237 m_host.AddScriptLPS(1); 10977 m_host.AddScriptLPS(1);
11238 UUID invItemID = InventorySelf();
11239
11240 if (invItemID == UUID.Zero)
11241 return new LSL_Vector();
11242
11243 m_host.TaskInventory.LockItemsForRead(true);
11244 10978
11245 UUID agentID = m_host.TaskInventory[invItemID].PermsGranter; 10979 if (m_item.PermsGranter == UUID.Zero)
10980 return new LSL_Vector();
11246 10981
11247// if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10982 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11248 if (agentID == UUID.Zero)
11249 {
11250 m_host.TaskInventory.LockItemsForRead(false);
11251 return new LSL_Vector();
11252 }
11253
11254 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11255 { 10983 {
11256 ShoutError("No permissions to track the camera"); 10984 ShoutError("No permissions to track the camera");
11257 m_host.TaskInventory.LockItemsForRead(false);
11258 return new LSL_Vector(); 10985 return new LSL_Vector();
11259 } 10986 }
11260 m_host.TaskInventory.LockItemsForRead(false);
11261 10987
11262// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 10988// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11263 ScenePresence presence = World.GetScenePresence(agentID); 10989 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
11264 if (presence != null) 10990 if (presence != null)
11265 { 10991 {
11266 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); 10992 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z);
@@ -11272,30 +10998,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11272 public LSL_Rotation llGetCameraRot() 10998 public LSL_Rotation llGetCameraRot()
11273 { 10999 {
11274 m_host.AddScriptLPS(1); 11000 m_host.AddScriptLPS(1);
11275 UUID invItemID = InventorySelf();
11276 if (invItemID == UUID.Zero)
11277 return new LSL_Rotation();
11278 11001
11279 m_host.TaskInventory.LockItemsForRead(true); 11002 if (m_item.PermsGranter == UUID.Zero)
11280 11003 return new LSL_Rotation();
11281 UUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
11282 11004
11283// if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 11005 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11284 if (agentID == UUID.Zero)
11285 {
11286 m_host.TaskInventory.LockItemsForRead(false);
11287 return new LSL_Rotation();
11288 }
11289 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11290 { 11006 {
11291 ShoutError("No permissions to track the camera"); 11007 ShoutError("No permissions to track the camera");
11292 m_host.TaskInventory.LockItemsForRead(false);
11293 return new LSL_Rotation(); 11008 return new LSL_Rotation();
11294 } 11009 }
11295 m_host.TaskInventory.LockItemsForRead(false);
11296 11010
11297// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 11011// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11298 ScenePresence presence = World.GetScenePresence(agentID); 11012 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
11299 if (presence != null) 11013 if (presence != null)
11300 { 11014 {
11301 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); 11015 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W);
@@ -11354,7 +11068,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11354 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) 11068 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
11355 { 11069 {
11356 m_host.AddScriptLPS(1); 11070 m_host.AddScriptLPS(1);
11357 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 11071 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
11358 if (detectedParams == null) 11072 if (detectedParams == null)
11359 { 11073 {
11360 if (m_host.ParentGroup.IsAttachment == true) 11074 if (m_host.ParentGroup.IsAttachment == true)
@@ -11478,30 +11192,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11478 { 11192 {
11479 m_host.AddScriptLPS(1); 11193 m_host.AddScriptLPS(1);
11480 11194
11481 // our key in the object we are in
11482 UUID invItemID = InventorySelf();
11483 if (invItemID == UUID.Zero) return;
11484
11485 // the object we are in 11195 // the object we are in
11486 UUID objectID = m_host.ParentUUID; 11196 UUID objectID = m_host.ParentUUID;
11487 if (objectID == UUID.Zero) return; 11197 if (objectID == UUID.Zero)
11198 return;
11488 11199
11489 UUID agentID;
11490 m_host.TaskInventory.LockItemsForRead(true);
11491 // we need the permission first, to know which avatar we want to set the camera for 11200 // we need the permission first, to know which avatar we want to set the camera for
11492 agentID = m_host.TaskInventory[invItemID].PermsGranter; 11201 UUID agentID = m_item.PermsGranter;
11493 11202
11494 if (agentID == UUID.Zero) 11203 if (agentID == UUID.Zero)
11495 {
11496 m_host.TaskInventory.LockItemsForRead(false);
11497 return; 11204 return;
11498 } 11205
11499 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 11206 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
11500 {
11501 m_host.TaskInventory.LockItemsForRead(false);
11502 return; 11207 return;
11503 }
11504 m_host.TaskInventory.LockItemsForRead(false);
11505 11208
11506 ScenePresence presence = World.GetScenePresence(agentID); 11209 ScenePresence presence = World.GetScenePresence(agentID);
11507 11210
@@ -11543,34 +11246,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11543 { 11246 {
11544 m_host.AddScriptLPS(1); 11247 m_host.AddScriptLPS(1);
11545 11248
11546 // our key in the object we are in
11547 UUID invItemID=InventorySelf();
11548 if (invItemID == UUID.Zero) return;
11549
11550 // the object we are in 11249 // the object we are in
11551 UUID objectID = m_host.ParentUUID; 11250 UUID objectID = m_host.ParentUUID;
11552 if (objectID == UUID.Zero) return; 11251 if (objectID == UUID.Zero)
11252 return;
11553 11253
11554 // we need the permission first, to know which avatar we want to clear the camera for 11254 // we need the permission first, to know which avatar we want to clear the camera for
11555 UUID agentID; 11255 UUID agentID = m_item.PermsGranter;
11556 m_host.TaskInventory.LockItemsForRead(true); 11256
11557 agentID = m_host.TaskInventory[invItemID].PermsGranter;
11558 if (agentID == UUID.Zero) 11257 if (agentID == UUID.Zero)
11559 {
11560 m_host.TaskInventory.LockItemsForRead(false);
11561 return; 11258 return;
11562 } 11259
11563 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 11260 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
11564 {
11565 m_host.TaskInventory.LockItemsForRead(false);
11566 return; 11261 return;
11567 }
11568 m_host.TaskInventory.LockItemsForRead(false);
11569 11262
11570 ScenePresence presence = World.GetScenePresence(agentID); 11263 ScenePresence presence = World.GetScenePresence(agentID);
11571 11264
11572 // we are not interested in child-agents 11265 // we are not interested in child-agents
11573 if (presence.IsChildAgent) return; 11266 if (presence.IsChildAgent)
11267 return;
11574 11268
11575 presence.ControllingClient.SendClearFollowCamProperties(objectID); 11269 presence.ControllingClient.SendClearFollowCamProperties(objectID);
11576 } 11270 }
@@ -11761,8 +11455,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11761 } 11455 }
11762 } 11456 }
11763 11457
11764 UUID reqID = httpScriptMod. 11458 UUID reqID
11765 StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); 11459 = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body);
11766 11460
11767 if (reqID != UUID.Zero) 11461 if (reqID != UUID.Zero)
11768 return reqID.ToString(); 11462 return reqID.ToString();
@@ -12016,19 +11710,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12016 break; 11710 break;
12017 // For the following 8 see the Object version below 11711 // For the following 8 see the Object version below
12018 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11712 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
12019 ret.Add(new LSL_Integer(0)); 11713 ret.Add(new LSL_Integer(av.RunningScriptCount()));
12020 break; 11714 break;
12021 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11715 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
12022 ret.Add(new LSL_Integer(0)); 11716 ret.Add(new LSL_Integer(av.ScriptCount()));
12023 break; 11717 break;
12024 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11718 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
12025 ret.Add(new LSL_Integer(0)); 11719 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
12026 break; 11720 break;
12027 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11721 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
12028 ret.Add(new LSL_Float(0)); 11722 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
12029 break; 11723 break;
12030 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11724 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
12031 ret.Add(new LSL_Integer(0)); 11725 ret.Add(new LSL_Integer(1));
12032 break; 11726 break;
12033 case ScriptBaseClass.OBJECT_SERVER_COST: 11727 case ScriptBaseClass.OBJECT_SERVER_COST:
12034 ret.Add(new LSL_Float(0)); 11728 ret.Add(new LSL_Float(0));
@@ -12086,37 +11780,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12086 case ScriptBaseClass.OBJECT_CREATOR: 11780 case ScriptBaseClass.OBJECT_CREATOR:
12087 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11781 ret.Add(new LSL_String(obj.CreatorID.ToString()));
12088 break; 11782 break;
12089 // The following 8 I have intentionaly coded to return zero. They are part of
12090 // "Land Impact" calculations. These calculations are probably not applicable
12091 // to OpenSim, required figures (cpu/memory usage) are not currently tracked
12092 // I have intentionally left these all at zero rather than return possibly
12093 // missleading numbers
12094 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11783 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
12095 // in SL this currently includes crashed scripts 11784 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
12096 ret.Add(new LSL_Integer(0));
12097 break; 11785 break;
12098 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11786 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
12099 ret.Add(new LSL_Integer(0)); 11787 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
12100 break; 11788 break;
12101 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11789 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
12102 // The value returned in SL for mono scripts is 65536 * number of active scripts 11790 // The value returned in SL for mono scripts is 65536 * number of active scripts
12103 ret.Add(new LSL_Integer(0)); 11791 // and 16384 * number of active scripts for LSO. since llGetFreememory
11792 // is coded to give the LSO value use it here
11793 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
12104 break; 11794 break;
12105 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11795 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
12106 // Average cpu time per simulator frame expended on all scripts in the objetc 11796 // Average cpu time in seconds per simulator frame expended on all scripts in the object
12107 ret.Add(new LSL_Float(0)); 11797 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
12108 break; 11798 break;
12109 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11799 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
12110 // according to the SL wiki A prim or linkset will have prim 11800 // according to the SL wiki A prim or linkset will have prim
12111 // equivalent of the number of prims in a linkset if it does not 11801 // equivalent of the number of prims in a linkset if it does not
12112 // contain a mesh anywhere in the link set or is not a normal prim 11802 // contain a mesh anywhere in the link set or is not a normal prim
12113 // The value returned in SL for normal prims is prim count 11803 // The value returned in SL for normal prims is prim count
12114 ret.Add(new LSL_Integer(0)); 11804 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
12115 break; 11805 break;
12116 11806
12117 // costs below may need to be diferent for root parts, need to check 11807 // costs below may need to be diferent for root parts, need to check
12118 case ScriptBaseClass.OBJECT_SERVER_COST: 11808 case ScriptBaseClass.OBJECT_SERVER_COST:
12119 // The value returned in SL for normal prims is prim count 11809 // The linden calculation is here
11810 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11811 // The value returned in SL for normal prims looks like the prim count
12120 ret.Add(new LSL_Float(0)); 11812 ret.Add(new LSL_Float(0));
12121 break; 11813 break;
12122 case ScriptBaseClass.OBJECT_STREAMING_COST: 11814 case ScriptBaseClass.OBJECT_STREAMING_COST:
@@ -12141,22 +11833,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12141 return new LSL_List(); 11833 return new LSL_List();
12142 } 11834 }
12143 11835
12144 internal UUID ScriptByName(string name) 11836 internal UUID GetScriptByName(string name)
12145 { 11837 {
12146 m_host.TaskInventory.LockItemsForRead(true); 11838 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12147
12148 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
12149 {
12150 if (item.Type == 10 && item.Name == name)
12151 {
12152 m_host.TaskInventory.LockItemsForRead(false);
12153 return item.ItemID;
12154 }
12155 }
12156 11839
12157 m_host.TaskInventory.LockItemsForRead(false); 11840 if (item == null || item.Type != 10)
11841 return UUID.Zero;
12158 11842
12159 return UUID.Zero; 11843 return item.ItemID;
12160 } 11844 }
12161 11845
12162 internal void ShoutError(string msg) 11846 internal void ShoutError(string msg)
@@ -12196,21 +11880,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12196 { 11880 {
12197 m_host.AddScriptLPS(1); 11881 m_host.AddScriptLPS(1);
12198 11882
12199 //Clone is thread safe
12200 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
12201
12202 UUID assetID = UUID.Zero; 11883 UUID assetID = UUID.Zero;
12203 11884
12204 if (!UUID.TryParse(name, out assetID)) 11885 if (!UUID.TryParse(name, out assetID))
12205 { 11886 {
12206 foreach (TaskInventoryItem item in itemsDictionary.Values) 11887 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12207 { 11888
12208 if (item.Type == 7 && item.Name == name) 11889 if (item != null && item.Type == 7)
12209 { 11890 assetID = item.AssetID;
12210 assetID = item.AssetID;
12211 break;
12212 }
12213 }
12214 } 11891 }
12215 11892
12216 if (assetID == UUID.Zero) 11893 if (assetID == UUID.Zero)
@@ -12222,7 +11899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12222 } 11899 }
12223 11900
12224 // was: UUID tid = tid = AsyncCommands. 11901 // was: UUID tid = tid = AsyncCommands.
12225 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11902 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
12226 11903
12227 if (NotecardCache.IsCached(assetID)) 11904 if (NotecardCache.IsCached(assetID))
12228 { 11905 {
@@ -12259,21 +11936,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12259 { 11936 {
12260 m_host.AddScriptLPS(1); 11937 m_host.AddScriptLPS(1);
12261 11938
12262 //Clone is thread safe
12263 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
12264
12265 UUID assetID = UUID.Zero; 11939 UUID assetID = UUID.Zero;
12266 11940
12267 if (!UUID.TryParse(name, out assetID)) 11941 if (!UUID.TryParse(name, out assetID))
12268 { 11942 {
12269 foreach (TaskInventoryItem item in itemsDictionary.Values) 11943 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12270 { 11944
12271 if (item.Type == 7 && item.Name == name) 11945 if (item != null && item.Type == 7)
12272 { 11946 assetID = item.AssetID;
12273 assetID = item.AssetID;
12274 break;
12275 }
12276 }
12277 } 11947 }
12278 11948
12279 if (assetID == UUID.Zero) 11949 if (assetID == UUID.Zero)
@@ -12285,7 +11955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12285 } 11955 }
12286 11956
12287 // was: UUID tid = tid = AsyncCommands. 11957 // was: UUID tid = tid = AsyncCommands.
12288 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11958 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
12289 11959
12290 if (NotecardCache.IsCached(assetID)) 11960 if (NotecardCache.IsCached(assetID))
12291 { 11961 {
@@ -12369,7 +12039,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12369 { 12039 {
12370 UUID rq = UUID.Random(); 12040 UUID rq = UUID.Random();
12371 12041
12372 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 12042 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
12373 12043
12374 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); 12044 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
12375 12045
@@ -12385,7 +12055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12385 { 12055 {
12386 UUID rq = UUID.Random(); 12056 UUID rq = UUID.Random();
12387 12057
12388 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 12058 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
12389 12059
12390 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); 12060 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
12391 12061
@@ -12587,7 +12257,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12587 { 12257 {
12588 Tri t1 = new Tri(); 12258 Tri t1 = new Tri();
12589 Tri t2 = new Tri(); 12259 Tri t2 = new Tri();
12590 12260
12591 Vector3 p1 = new Vector3(x-1, y-1, (float)heightfield[x-1, y-1]); 12261 Vector3 p1 = new Vector3(x-1, y-1, (float)heightfield[x-1, y-1]);
12592 Vector3 p2 = new Vector3(x, y-1, (float)heightfield[x, y-1]); 12262 Vector3 p2 = new Vector3(x, y-1, (float)heightfield[x, y-1]);
12593 Vector3 p3 = new Vector3(x, y, (float)heightfield[x, y]); 12263 Vector3 p3 = new Vector3(x, y, (float)heightfield[x, y]);
@@ -12628,7 +12298,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12628 // sometimes 12298 // sometimes
12629 if (Math.Abs(b) < 0.000001) 12299 if (Math.Abs(b) < 0.000001)
12630 continue; 12300 continue;
12631 12301
12632 double r = a / b; 12302 double r = a / b;
12633 12303
12634 // ray points away from plane 12304 // ray points away from plane
@@ -12888,7 +12558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12888 bool isAccount = false; 12558 bool isAccount = false;
12889 bool isGroup = false; 12559 bool isGroup = false;
12890 12560
12891 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) 12561 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
12892 return 0; 12562 return 0;
12893 12563
12894 UUID id = new UUID(); 12564 UUID id = new UUID();
@@ -12950,35 +12620,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12950 return 1; 12620 return 1;
12951 } 12621 }
12952 12622
12953 #region Not Implemented 12623 public LSL_Integer llGetMemoryLimit()
12954 // 12624 {
12955 // Listing the unimplemented lsl functions here, please move 12625 m_host.AddScriptLPS(1);
12956 // them from this region as they are completed 12626 // The value returned for LSO scripts in SL
12957 // 12627 return 16384;
12628 }
12958 12629
12959 public void llGetEnv(LSL_String name) 12630 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
12960 { 12631 {
12961 m_host.AddScriptLPS(1); 12632 m_host.AddScriptLPS(1);
12962 NotImplemented("llGetEnv"); 12633 // Treat as an LSO script
12634 return ScriptBaseClass.FALSE;
12963 } 12635 }
12964 12636
12965 public void llGetSPMaxMemory() 12637 public LSL_Integer llGetSPMaxMemory()
12966 { 12638 {
12967 m_host.AddScriptLPS(1); 12639 m_host.AddScriptLPS(1);
12968 NotImplemented("llGetSPMaxMemory"); 12640 // The value returned for LSO scripts in SL
12641 return 16384;
12969 } 12642 }
12970 12643
12971 public virtual LSL_Integer llGetUsedMemory() 12644 public virtual LSL_Integer llGetUsedMemory()
12972 { 12645 {
12973 m_host.AddScriptLPS(1); 12646 m_host.AddScriptLPS(1);
12974 NotImplemented("llGetUsedMemory"); 12647 // The value returned for LSO scripts in SL
12975 return 0; 12648 return 16384;
12976 } 12649 }
12977 12650
12978 public void llScriptProfiler(LSL_Integer flags) 12651 public void llScriptProfiler(LSL_Integer flags)
12979 { 12652 {
12980 m_host.AddScriptLPS(1); 12653 m_host.AddScriptLPS(1);
12981 //NotImplemented("llScriptProfiler"); 12654 // This does nothing for LSO scripts in SL
12655 }
12656
12657 #region Not Implemented
12658 //
12659 // Listing the unimplemented lsl functions here, please move
12660 // them from this region as they are completed
12661 //
12662
12663 public void llGetEnv(LSL_String name)
12664 {
12665 m_host.AddScriptLPS(1);
12666 NotImplemented("llGetEnv");
12982 } 12667 }
12983 12668
12984 public void llSetSoundQueueing(int queue) 12669 public void llSetSoundQueueing(int queue)
@@ -13058,8 +12743,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13058 12743
13059 try 12744 try
13060 { 12745 {
13061 UUID invItemID=InventorySelf(); 12746 TaskInventoryItem item = m_item;
13062 if (invItemID == UUID.Zero) 12747 if (item == null)
13063 { 12748 {
13064 replydata = "SERVICE_ERROR"; 12749 replydata = "SERVICE_ERROR";
13065 return; 12750 return;
@@ -13067,10 +12752,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13067 12752
13068 m_host.AddScriptLPS(1); 12753 m_host.AddScriptLPS(1);
13069 12754
13070 m_host.TaskInventory.LockItemsForRead(true);
13071 TaskInventoryItem item = m_host.TaskInventory[invItemID];
13072 m_host.TaskInventory.LockItemsForRead(false);
13073
13074 if (item.PermsGranter == UUID.Zero) 12755 if (item.PermsGranter == UUID.Zero)
13075 { 12756 {
13076 replydata = "MISSING_PERMISSION_DEBIT"; 12757 replydata = "MISSING_PERMISSION_DEBIT";
@@ -13112,7 +12793,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13112 } 12793 }
13113 finally 12794 finally
13114 { 12795 {
13115 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 12796 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
13116 "transaction_result", new Object[] { 12797 "transaction_result", new Object[] {
13117 new LSL_String(txn.ToString()), 12798 new LSL_String(txn.ToString()),
13118 new LSL_Integer(replycode), 12799 new LSL_Integer(replycode),
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 77a784d..795de80 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -58,17 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
58 { 58 {
59 internal IScriptEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
60 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
61 internal uint m_localID;
62 internal UUID m_itemID;
63 internal bool m_LSFunctionsEnabled = false; 61 internal bool m_LSFunctionsEnabled = false;
64 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
65 63
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
67 { 65 {
68 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
69 m_host = host; 67 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72 68
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 69 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 70 m_LSFunctionsEnabled = true;
@@ -449,7 +445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
449 LSShoutError("LightShare functions are not enabled."); 445 LSShoutError("LightShare functions are not enabled.");
450 return 0; 446 return 0;
451 } 447 }
452 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 448 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
453 { 449 {
454 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 450 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
455 return 0; 451 return 0;
@@ -477,7 +473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
477 LSShoutError("LightShare functions are not enabled."); 473 LSShoutError("LightShare functions are not enabled.");
478 return; 474 return;
479 } 475 }
480 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 476 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
481 { 477 {
482 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 478 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
483 return; 479 return;
@@ -500,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
500 LSShoutError("LightShare functions are not enabled."); 496 LSShoutError("LightShare functions are not enabled.");
501 return 0; 497 return 0;
502 } 498 }
503 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 499 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
504 { 500 {
505 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 501 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
506 return 0; 502 return 0;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7c07e15..4bd3dff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -57,17 +57,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
57 { 57 {
58 internal IScriptEngine m_ScriptEngine; 58 internal IScriptEngine m_ScriptEngine;
59 internal SceneObjectPart m_host; 59 internal SceneObjectPart m_host;
60 internal uint m_localID; 60 internal TaskInventoryItem m_item;
61 internal UUID m_itemID;
62 internal bool m_MODFunctionsEnabled = false; 61 internal bool m_MODFunctionsEnabled = false;
63 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
64 63
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
66 { 65 {
67 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
68 m_host = host; 67 m_host = host;
69 m_localID = localID; 68 m_item = item;
70 m_itemID = itemID;
71 69
72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) 70 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
73 m_MODFunctionsEnabled = true; 71 m_MODFunctionsEnabled = true;
@@ -252,7 +250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
252 // non-null but don't trust it completely 250 // non-null but don't trust it completely
253 try 251 try
254 { 252 {
255 object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); 253 object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms);
256 if (result != null) 254 if (result != null)
257 return result; 255 return result;
258 256
@@ -279,7 +277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
279 277
280 UUID req = UUID.Random(); 278 UUID req = UUID.Random();
281 279
282 m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); 280 m_comms.RaiseEvent(m_item.ItemID, req.ToString(), module, command, k);
283 281
284 return req.ToString(); 282 return req.ToString();
285 } 283 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0dc2aa2..b639d36 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -126,13 +126,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
126 [Serializable] 126 [Serializable]
127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi 127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
128 { 128 {
129// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 129 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
130
131 public const string GridInfoServiceConfigSectionName = "GridInfoService";
130 132
131 internal IScriptEngine m_ScriptEngine; 133 internal IScriptEngine m_ScriptEngine;
132 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there 134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
133 internal SceneObjectPart m_host; 135 internal SceneObjectPart m_host;
134 internal uint m_localID; 136 internal TaskInventoryItem m_item;
135 internal UUID m_itemID;
136 internal bool m_OSFunctionsEnabled = false; 137 internal bool m_OSFunctionsEnabled = false;
137 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
138 internal float m_ScriptDelayFactor = 1.0f; 139 internal float m_ScriptDelayFactor = 1.0f;
@@ -140,12 +141,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
140 internal bool m_debuggerSafe = false; 141 internal bool m_debuggerSafe = false;
141 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
142 143
143 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
144 { 145 {
145 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
146 m_host = host; 147 m_host = host;
147 m_localID = localID; 148 m_item = item;
148 m_itemID = itemID;
149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
150 150
151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
@@ -218,12 +218,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
218 } 218 }
219 } 219 }
220 220
221 /// <summary>
222 /// Initialize the LSL interface.
223 /// </summary>
224 /// <remarks>
225 /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
226 /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
227 /// ScriptInstance.
228 /// </remarks>
221 private void InitLSL() 229 private void InitLSL()
222 { 230 {
223 if (m_LSL_Api != null) 231 if (m_LSL_Api != null)
224 return; 232 return;
225 233
226 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL"); 234 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
227 } 235 }
228 236
229 // 237 //
@@ -342,22 +350,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
342 return; 350 return;
343 } 351 }
344 352
345 TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID); 353 UUID ownerID = m_item.OwnerID;
346 if (ti == null)
347 {
348 OSSLError(
349 String.Format("{0} permission error. Can't find script in prim inventory.",
350 function));
351 }
352
353 UUID ownerID = ti.OwnerID;
354 354
355 //OSSL only may be used if objet is in the same group as the parcel 355 //OSSL only may be used if object is in the same group as the parcel
356 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) 356 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
357 { 357 {
358 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 358 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
359 359
360 if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) 360 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
361 { 361 {
362 return; 362 return;
363 } 363 }
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) 378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
379 { 379 {
380 //Only Estate Managers may use the function 380 //Only Estate Managers may use the function
381 if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) 381 if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
382 { 382 {
383 return; 383 return;
384 } 384 }
@@ -393,13 +393,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
393 } 393 }
394 } 394 }
395 395
396 if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) 396 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
397 OSSLError( 397 OSSLError(
398 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", 398 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
399 function)); 399 function));
400 if (ti.CreatorID != ownerID) 400
401 if (m_item.CreatorID != ownerID)
401 { 402 {
402 if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) 403 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
403 OSSLError( 404 OSSLError(
404 String.Format("{0} permission denied. Script permissions error.", 405 String.Format("{0} permission denied. Script permissions error.",
405 function)); 406 function));
@@ -730,11 +731,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
730 731
731 m_host.AddScriptLPS(1); 732 m_host.AddScriptLPS(1);
732 733
734 // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions
733 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 735 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
734 { 736 {
735 MainConsole.Instance.RunCommand(command); 737 MainConsole.Instance.RunCommand(command);
736 return true; 738 return true;
737 } 739 }
740
738 return false; 741 return false;
739 } 742 }
740 743
@@ -957,21 +960,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
957 UUID avatarID = (UUID)avatar; 960 UUID avatarID = (UUID)avatar;
958 961
959 m_host.AddScriptLPS(1); 962 m_host.AddScriptLPS(1);
963
964 // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common
965 // method (though see that doesn't do the is animation check, which is probably a bug) and have both
966 // these functions call that common code. However, this does mean navigating the brain-dead requirement
967 // of calling InitLSL()
960 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) 968 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
961 { 969 {
962 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 970 ScenePresence target = (ScenePresence)World.Entities[avatarID];
963 if (target != null) 971 if (target != null)
964 { 972 {
965 UUID animID = UUID.Zero; 973 UUID animID;
966 m_host.TaskInventory.LockItemsForRead(true); 974
967 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 975 if (!UUID.TryParse(animation, out animID))
968 { 976 {
969 if (inv.Value.Name == animation) 977 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
970 { 978 if (item != null && item.Type == (int)AssetType.Animation)
971 if (inv.Value.Type == (int)AssetType.Animation) 979 animID = item.AssetID;
972 animID = inv.Value.AssetID; 980 else
973 continue; 981 animID = UUID.Zero;
974 }
975 } 982 }
976 m_host.TaskInventory.LockItemsForRead(false); 983 m_host.TaskInventory.LockItemsForRead(false);
977 984
@@ -1178,7 +1185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1178 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); 1185 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
1179 m_host.AddScriptLPS(1); 1186 m_host.AddScriptLPS(1);
1180 1187
1181 m_host.SetScriptEvents(m_itemID, events); 1188 m_host.SetScriptEvents(m_item.ItemID, events);
1182 } 1189 }
1183 1190
1184 public void osSetRegionWaterHeight(double height) 1191 public void osSetRegionWaterHeight(double height)
@@ -1186,12 +1193,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1186 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); 1193 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
1187 1194
1188 m_host.AddScriptLPS(1); 1195 m_host.AddScriptLPS(1);
1189 //Check to make sure that the script's owner is the estate manager/master 1196
1190 //World.Permissions.GenericEstatePermission( 1197 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1191 if (World.Permissions.IsGod(m_host.OwnerID))
1192 {
1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1194 }
1195 } 1198 }
1196 1199
1197 /// <summary> 1200 /// <summary>
@@ -1202,27 +1205,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1202 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1205 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1203 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) 1206 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
1204 { 1207 {
1205 CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); 1208 CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings");
1206 1209
1207 m_host.AddScriptLPS(1); 1210 m_host.AddScriptLPS(1);
1208 //Check to make sure that the script's owner is the estate manager/master
1209 //World.Permissions.GenericEstatePermission(
1210 if (World.Permissions.IsGod(m_host.OwnerID))
1211 {
1212 while (sunHour > 24.0)
1213 sunHour -= 24.0;
1214 1211
1215 while (sunHour < 0) 1212 while (sunHour > 24.0)
1216 sunHour += 24.0; 1213 sunHour -= 24.0;
1217 1214
1215 while (sunHour < 0)
1216 sunHour += 24.0;
1218 1217
1219 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1218 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1220 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1219 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1221 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1220 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1222 World.RegionInfo.RegionSettings.Save(); 1221 World.RegionInfo.RegionSettings.Save();
1223 1222
1224 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); 1223 World.EventManager.TriggerEstateToolsSunUpdate(
1225 } 1224 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1226 } 1225 }
1227 1226
1228 /// <summary> 1227 /// <summary>
@@ -1232,26 +1231,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1232 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1231 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1233 public void osSetEstateSunSettings(bool sunFixed, double sunHour) 1232 public void osSetEstateSunSettings(bool sunFixed, double sunHour)
1234 { 1233 {
1235 CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); 1234 CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings");
1236 1235
1237 m_host.AddScriptLPS(1); 1236 m_host.AddScriptLPS(1);
1238 //Check to make sure that the script's owner is the estate manager/master
1239 //World.Permissions.GenericEstatePermission(
1240 if (World.Permissions.IsGod(m_host.OwnerID))
1241 {
1242 while (sunHour > 24.0)
1243 sunHour -= 24.0;
1244 1237
1245 while (sunHour < 0) 1238 while (sunHour > 24.0)
1246 sunHour += 24.0; 1239 sunHour -= 24.0;
1247 1240
1248 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; 1241 while (sunHour < 0)
1249 World.RegionInfo.EstateSettings.SunPosition = sunHour; 1242 sunHour += 24.0;
1250 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1251 World.RegionInfo.EstateSettings.Save();
1252 1243
1253 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); 1244 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
1254 } 1245 World.RegionInfo.EstateSettings.SunPosition = sunHour;
1246 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1247 World.RegionInfo.EstateSettings.Save();
1248
1249 World.EventManager.TriggerEstateToolsSunUpdate(
1250 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1255 } 1251 }
1256 1252
1257 /// <summary> 1253 /// <summary>
@@ -1627,7 +1623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1627 1623
1628 public Object osParseJSONNew(string JSON) 1624 public Object osParseJSONNew(string JSON)
1629 { 1625 {
1630 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1626 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1631 1627
1632 m_host.AddScriptLPS(1); 1628 m_host.AddScriptLPS(1);
1633 1629
@@ -1980,7 +1976,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1980 { 1976 {
1981 string retval = String.Empty; 1977 string retval = String.Empty;
1982 IConfigSource config = m_ScriptEngine.ConfigSource; 1978 IConfigSource config = m_ScriptEngine.ConfigSource;
1983 string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); 1979 string url = null;
1980
1981 IConfig gridInfoConfig = config.Configs["GridInfo"];
1982
1983 if (gridInfoConfig != null)
1984 url = gridInfoConfig.GetString("GridInfoURI", String.Empty);
1984 1985
1985 if (String.IsNullOrEmpty(url)) 1986 if (String.IsNullOrEmpty(url))
1986 return "Configuration Error!"; 1987 return "Configuration Error!";
@@ -2042,8 +2043,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2042 string nick = String.Empty; 2043 string nick = String.Empty;
2043 IConfigSource config = m_ScriptEngine.ConfigSource; 2044 IConfigSource config = m_ScriptEngine.ConfigSource;
2044 2045
2045 if (config.Configs["GridInfo"] != null) 2046 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2046 nick = config.Configs["GridInfo"].GetString("gridnick", nick); 2047 nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick);
2047 2048
2048 if (String.IsNullOrEmpty(nick)) 2049 if (String.IsNullOrEmpty(nick))
2049 nick = GridUserInfo(InfoType.Nick); 2050 nick = GridUserInfo(InfoType.Nick);
@@ -2059,8 +2060,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2059 string name = String.Empty; 2060 string name = String.Empty;
2060 IConfigSource config = m_ScriptEngine.ConfigSource; 2061 IConfigSource config = m_ScriptEngine.ConfigSource;
2061 2062
2062 if (config.Configs["GridInfo"] != null) 2063 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2063 name = config.Configs["GridInfo"].GetString("gridname", name); 2064 name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name);
2064 2065
2065 if (String.IsNullOrEmpty(name)) 2066 if (String.IsNullOrEmpty(name))
2066 name = GridUserInfo(InfoType.Name); 2067 name = GridUserInfo(InfoType.Name);
@@ -2076,8 +2077,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2076 string loginURI = String.Empty; 2077 string loginURI = String.Empty;
2077 IConfigSource config = m_ScriptEngine.ConfigSource; 2078 IConfigSource config = m_ScriptEngine.ConfigSource;
2078 2079
2079 if (config.Configs["GridInfo"] != null) 2080 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2080 loginURI = config.Configs["GridInfo"].GetString("login", loginURI); 2081 loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI);
2081 2082
2082 if (String.IsNullOrEmpty(loginURI)) 2083 if (String.IsNullOrEmpty(loginURI))
2083 loginURI = GridUserInfo(InfoType.Login); 2084 loginURI = GridUserInfo(InfoType.Login);
@@ -2124,8 +2125,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2124 string retval = String.Empty; 2125 string retval = String.Empty;
2125 IConfigSource config = m_ScriptEngine.ConfigSource; 2126 IConfigSource config = m_ScriptEngine.ConfigSource;
2126 2127
2127 if (config.Configs["GridInfo"] != null) 2128 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2128 retval = config.Configs["GridInfo"].GetString(key, retval); 2129 retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval);
2129 2130
2130 if (String.IsNullOrEmpty(retval)) 2131 if (String.IsNullOrEmpty(retval))
2131 retval = GridUserInfo(InfoType.Custom, key); 2132 retval = GridUserInfo(InfoType.Custom, key);
@@ -2135,7 +2136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2135 2136
2136 public LSL_String osFormatString(string str, LSL_List strings) 2137 public LSL_String osFormatString(string str, LSL_List strings)
2137 { 2138 {
2138 CheckThreatLevel(ThreatLevel.Low, "osFormatString"); 2139 CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString");
2139 m_host.AddScriptLPS(1); 2140 m_host.AddScriptLPS(1);
2140 2141
2141 return String.Format(str, strings.Data); 2142 return String.Format(str, strings.Data);
@@ -2143,7 +2144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2143 2144
2144 public LSL_List osMatchString(string src, string pattern, int start) 2145 public LSL_List osMatchString(string src, string pattern, int start)
2145 { 2146 {
2146 CheckThreatLevel(ThreatLevel.High, "osMatchString"); 2147 CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString");
2147 m_host.AddScriptLPS(1); 2148 m_host.AddScriptLPS(1);
2148 2149
2149 LSL_List result = new LSL_List(); 2150 LSL_List result = new LSL_List();
@@ -2185,7 +2186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2185 2186
2186 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) 2187 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
2187 { 2188 {
2188 CheckThreatLevel(ThreatLevel.High, "osReplaceString"); 2189 CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString");
2189 m_host.AddScriptLPS(1); 2190 m_host.AddScriptLPS(1);
2190 2191
2191 // Normalize indices (if negative). 2192 // Normalize indices (if negative).
@@ -2480,7 +2481,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2480 return; 2481 return;
2481 2482
2482 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); 2483 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2483 module.MoveToTarget(npcId, World, pos, false, true); 2484 module.MoveToTarget(npcId, World, pos, false, true, false);
2484 } 2485 }
2485 } 2486 }
2486 2487
@@ -2505,7 +2506,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2505 World, 2506 World,
2506 pos, 2507 pos,
2507 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, 2508 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2508 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); 2509 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
2510 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
2509 } 2511 }
2510 } 2512 }
2511 2513
@@ -2555,7 +2557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 2557
2556 public void osNpcStopMoveToTarget(LSL_Key npc) 2558 public void osNpcStopMoveToTarget(LSL_Key npc)
2557 { 2559 {
2558 CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); 2560 CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget");
2559 m_host.AddScriptLPS(1); 2561 m_host.AddScriptLPS(1);
2560 2562
2561 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2563 INPCModule module = World.RequestModuleInterface<INPCModule>();
@@ -2572,6 +2574,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2572 2574
2573 public void osNpcSay(LSL_Key npc, string message) 2575 public void osNpcSay(LSL_Key npc, string message)
2574 { 2576 {
2577 osNpcSay(npc, 0, message);
2578 }
2579
2580 public void osNpcSay(LSL_Key npc, int channel, string message)
2581 {
2575 CheckThreatLevel(ThreatLevel.High, "osNpcSay"); 2582 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
2576 m_host.AddScriptLPS(1); 2583 m_host.AddScriptLPS(1);
2577 2584
@@ -2583,7 +2590,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2583 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2590 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2584 return; 2591 return;
2585 2592
2586 module.Say(npcId, World, message); 2593 module.Say(npcId, World, message, channel);
2594 }
2595 }
2596
2597 public void osNpcShout(LSL_Key npc, int channel, string message)
2598 {
2599 CheckThreatLevel(ThreatLevel.High, "osNpcShout");
2600 m_host.AddScriptLPS(1);
2601
2602 INPCModule module = World.RequestModuleInterface<INPCModule>();
2603 if (module != null)
2604 {
2605 UUID npcId = new UUID(npc.m_string);
2606
2607 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2608 return;
2609
2610 module.Shout(npcId, World, message, channel);
2587 } 2611 }
2588 } 2612 }
2589 2613
@@ -2684,6 +2708,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2684 } 2708 }
2685 } 2709 }
2686 2710
2711 public void osNpcWhisper(LSL_Key npc, int channel, string message)
2712 {
2713 CheckThreatLevel(ThreatLevel.High, "osNpcWhisper");
2714 m_host.AddScriptLPS(1);
2715
2716 INPCModule module = World.RequestModuleInterface<INPCModule>();
2717 if (module != null)
2718 {
2719 UUID npcId = new UUID(npc.m_string);
2720
2721 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2722 return;
2723
2724 module.Whisper(npcId, World, message, channel);
2725 }
2726 }
2727
2728 public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
2729 {
2730 CheckThreatLevel(ThreatLevel.High, "osNpcTouch");
2731 m_host.AddScriptLPS(1);
2732 INPCModule module = World.RequestModuleInterface<INPCModule>();
2733 int linkNum = link_num.value;
2734 if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
2735 {
2736 UUID npcId;
2737 if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
2738 return;
2739 SceneObjectPart part = null;
2740 UUID objectId;
2741 if (UUID.TryParse(LSL_String.ToString(object_key), out objectId))
2742 part = World.GetSceneObjectPart(objectId);
2743 if (part == null)
2744 return;
2745 if (linkNum != ScriptBaseClass.LINK_THIS)
2746 {
2747 if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT)
2748 { // 0 and 1 are treated as root, find the root if the current part isnt it
2749 if (!part.IsRoot)
2750 part = part.ParentGroup.RootPart;
2751 }
2752 else
2753 { // Find the prim with the given link number if not found then fail silently
2754 part = part.ParentGroup.GetLinkNumPart(linkNum);
2755 if (part == null)
2756 return;
2757 }
2758 }
2759 module.Touch(npcId, part.UUID);
2760 }
2761 }
2762
2687 /// <summary> 2763 /// <summary>
2688 /// Save the current appearance of the script owner permanently to the named notecard. 2764 /// Save the current appearance of the script owner permanently to the named notecard.
2689 /// </summary> 2765 /// </summary>
@@ -2835,21 +2911,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2835 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 2911 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
2836 m_host.AddScriptLPS(1); 2912 m_host.AddScriptLPS(1);
2837 2913
2838 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 2914 World.ForEachRootScenePresence(delegate(ScenePresence sp)
2839 { 2915 {
2840 World.ForEachRootScenePresence(delegate(ScenePresence sp) 2916 if (sp.Firstname == FirstName && sp.Lastname == SurName)
2841 { 2917 {
2842 if (sp.Firstname == FirstName && sp.Lastname == SurName) 2918 // kick client...
2843 { 2919 if (alert != null)
2844 // kick client... 2920 sp.ControllingClient.Kick(alert);
2845 if (alert != null)
2846 sp.ControllingClient.Kick(alert);
2847 2921
2848 // ...and close on our side 2922 // ...and close on our side
2849 sp.Scene.IncomingCloseAgent(sp.UUID); 2923 sp.Scene.IncomingCloseAgent(sp.UUID);
2850 } 2924 }
2851 }); 2925 });
2852 }
2853 } 2926 }
2854 2927
2855 public void osCauseDamage(string avatar, double damage) 2928 public void osCauseDamage(string avatar, double damage)
@@ -3095,5 +3168,151 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3168
3096 return ScriptBaseClass.TRUE; 3169 return ScriptBaseClass.TRUE;
3097 } 3170 }
3171
3172 /// <summary>
3173 /// Sets terrain estate texture
3174 /// </summary>
3175 /// <param name="level"></param>
3176 /// <param name="texture"></param>
3177 /// <returns></returns>
3178 public void osSetTerrainTexture(int level, LSL_Key texture)
3179 {
3180 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3181
3182 m_host.AddScriptLPS(1);
3183 //Check to make sure that the script's owner is the estate manager/master
3184 //World.Permissions.GenericEstatePermission(
3185 if (World.Permissions.IsGod(m_host.OwnerID))
3186 {
3187 if (level < 0 || level > 3)
3188 return;
3189
3190 UUID textureID = new UUID();
3191 if (!UUID.TryParse(texture, out textureID))
3192 return;
3193
3194 // estate module is required
3195 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3196 if (estate != null)
3197 estate.setEstateTerrainBaseTexture(level, textureID);
3198 }
3199 }
3200
3201 /// <summary>
3202 /// Sets terrain heights of estate
3203 /// </summary>
3204 /// <param name="corner"></param>
3205 /// <param name="low"></param>
3206 /// <param name="high"></param>
3207 /// <returns></returns>
3208 public void osSetTerrainTextureHeight(int corner, double low, double high)
3209 {
3210 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3211
3212 m_host.AddScriptLPS(1);
3213 //Check to make sure that the script's owner is the estate manager/master
3214 //World.Permissions.GenericEstatePermission(
3215 if (World.Permissions.IsGod(m_host.OwnerID))
3216 {
3217 if (corner < 0 || corner > 3)
3218 return;
3219
3220 // estate module is required
3221 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3222 if (estate != null)
3223 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3224 }
3225 }
3226
3227 public void osForceAttachToAvatar(int attachmentPoint)
3228 {
3229 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3230
3231 m_host.AddScriptLPS(1);
3232
3233 InitLSL();
3234 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3235 }
3236
3237 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
3238 {
3239 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
3240
3241 m_host.AddScriptLPS(1);
3242
3243 ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint);
3244 }
3245
3246 public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
3247 {
3248 CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory");
3249
3250 m_host.AddScriptLPS(1);
3251
3252 UUID avatarId;
3253
3254 if (!UUID.TryParse(rawAvatarId, out avatarId))
3255 return;
3256
3257 ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint);
3258 }
3259
3260 public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint)
3261 {
3262 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3263
3264 if (attachmentsModule == null)
3265 return;
3266
3267 InitLSL();
3268
3269 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
3270
3271 if (item == null)
3272 {
3273 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName));
3274 throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName));
3275 }
3276
3277 if (item.InvType != (int)InventoryType.Object)
3278 {
3279 // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set
3280 // up the api reference.
3281 if (m_LSL_Api != null)
3282 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
3283
3284 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
3285
3286 return;
3287 }
3288
3289 ScenePresence sp = World.GetScenePresence(avatarId);
3290
3291 if (sp == null)
3292 return;
3293
3294 InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID);
3295
3296 if (newItem == null)
3297 {
3298 m_log.ErrorFormat(
3299 "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}",
3300 itemName, m_host.Name, attachmentPoint, World.Name);
3301
3302 return;
3303 }
3304
3305 attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
3306 }
3307
3308 public void osForceDetachFromAvatar()
3309 {
3310 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3311
3312 m_host.AddScriptLPS(1);
3313
3314 InitLSL();
3315 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3316 }
3098 } 3317 }
3099} 3318}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 1373971..19f3ce1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
308 } 308 }
309 SceneObjectPart SensePoint = ts.host; 309 SceneObjectPart SensePoint = ts.host;
310 310
311 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 311 Vector3 fromRegionPos = SensePoint.GetWorldPosition();
312 312
313 // pre define some things to avoid repeated definitions in the loop body 313 // pre define some things to avoid repeated definitions in the loop body
314 Vector3 toRegionPos; 314 Vector3 toRegionPos;
@@ -323,13 +323,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
323 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! 323 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation!
324 if (SensePoint.ParentGroup.IsAttachment) 324 if (SensePoint.ParentGroup.IsAttachment)
325 { 325 {
326 // In attachments, the sensor cone always orients with the 326 // In attachments, rotate the sensor cone with the
327 // avatar rotation. This may include a nonzero elevation if 327 // avatar rotation. This may include a nonzero elevation if
328 // in mouselook. 328 // in mouselook.
329 // This will not include the rotation and position of the
330 // attachment point (e.g. your head when a sensor is in your
331 // hair attached to your scull. Your hair will turn with
332 // your head but the sensor will stay with your (global)
333 // avatar rotation and position.
334 // Position of a sensor in a child prim attached to an avatar
335 // will be still wrong.
329 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 336 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
330 fromRegionPos = avatar.AbsolutePosition; 337 fromRegionPos = avatar.AbsolutePosition;
331 q = avatar.Rotation; 338 q = avatar.Rotation;
332 } 339 }
340
333 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 341 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
334 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 342 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
335 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 343 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
@@ -441,14 +449,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
441 return sensedEntities; 449 return sensedEntities;
442 450
443 SceneObjectPart SensePoint = ts.host; 451 SceneObjectPart SensePoint = ts.host;
444 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 452 Vector3 fromRegionPos = SensePoint.GetWorldPosition();
445 453
446 Quaternion q = SensePoint.RotationOffset; 454 Quaternion q = SensePoint.GetWorldRotation();
447 if (SensePoint.ParentGroup.IsAttachment) 455 if (SensePoint.ParentGroup.IsAttachment)
448 { 456 {
449 // In attachments, the sensor cone always orients with the 457 // In attachments, rotate the sensor cone with the
450 // avatar rotation. This may include a nonzero elevation if 458 // avatar rotation. This may include a nonzero elevation if
451 // in mouselook. 459 // in mouselook.
460 // This will not include the rotation and position of the
461 // attachment point (e.g. your head when a sensor is in your
462 // hair attached to your scull. Your hair will turn with
463 // your head but the sensor will stay with your (global)
464 // avatar rotation and position.
465 // Position of a sensor in a child prim attached to an avatar
466 // will be still wrong.
452 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 467 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
453 if (avatar == null) 468 if (avatar == null)
454 return sensedEntities; 469 return sensedEntities;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 40ae495..af35258 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
105 LSL_Integer llFloor(double f); 105 LSL_Integer llFloor(double f);
106 void llForceMouselook(int mouselook); 106 void llForceMouselook(int mouselook);
107 LSL_Float llFrand(double mag); 107 LSL_Float llFrand(double mag);
108 LSL_Key llGenerateKey();
108 LSL_Vector llGetAccel(); 109 LSL_Vector llGetAccel();
109 LSL_Integer llGetAgentInfo(string id); 110 LSL_Integer llGetAgentInfo(string id);
110 LSL_String llGetAgentLanguage(string id); 111 LSL_String llGetAgentLanguage(string id);
@@ -150,7 +151,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
150 LSL_Rotation llGetLocalRot(); 151 LSL_Rotation llGetLocalRot();
151 LSL_Float llGetMass(); 152 LSL_Float llGetMass();
152 LSL_Float llGetMassMKS(); 153 LSL_Float llGetMassMKS();
153 void llGetNextEmail(string address, string subject); 154 LSL_Integer llGetMemoryLimit();
155 void llGetNextEmail(string address, string subject);
154 LSL_String llGetNotecardLine(string name, int line); 156 LSL_String llGetNotecardLine(string name, int line);
155 LSL_Key llGetNumberOfNotecardLines(string name); 157 LSL_Key llGetNumberOfNotecardLines(string name);
156 LSL_Integer llGetNumberOfPrims(); 158 LSL_Integer llGetNumberOfPrims();
@@ -188,6 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
188 LSL_String llGetScriptName(); 190 LSL_String llGetScriptName();
189 LSL_Integer llGetScriptState(string name); 191 LSL_Integer llGetScriptState(string name);
190 LSL_String llGetSimulatorHostname(); 192 LSL_String llGetSimulatorHostname();
193 LSL_Integer llGetSPMaxMemory();
191 LSL_Integer llGetStartParameter(); 194 LSL_Integer llGetStartParameter();
192 LSL_Integer llGetStatus(int status); 195 LSL_Integer llGetStatus(int status);
193 LSL_String llGetSubString(string src, int start, int end); 196 LSL_String llGetSubString(string src, int start, int end);
@@ -323,6 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
323 void llSay(int channelID, string text); 326 void llSay(int channelID, string text);
324 void llScaleTexture(double u, double v, int face); 327 void llScaleTexture(double u, double v, int face);
325 LSL_Integer llScriptDanger(LSL_Vector pos); 328 LSL_Integer llScriptDanger(LSL_Vector pos);
329 void llScriptProfiler(LSL_Integer flag);
326 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); 330 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata);
327 void llSensor(string name, string id, int type, double range, double arc); 331 void llSensor(string name, string id, int type, double range, double arc);
328 void llSensorRemove(); 332 void llSensorRemove();
@@ -347,6 +351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
347 void llSetLinkTexture(int linknumber, string texture, int face); 351 void llSetLinkTexture(int linknumber, string texture, int face);
348 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); 352 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate);
349 void llSetLocalRot(LSL_Rotation rot); 353 void llSetLocalRot(LSL_Rotation rot);
354 LSL_Integer llSetMemoryLimit(LSL_Integer limit);
350 void llSetObjectDesc(string desc); 355 void llSetObjectDesc(string desc);
351 void llSetObjectName(string name); 356 void llSetObjectName(string name);
352 void llSetObjectPermMask(int mask, int value); 357 void llSetObjectPermMask(int mask, int value);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 444a681..1facc96 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 98 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 99 void osAvatarStopAnimation(string avatar, string animation);
100 100
101 // Attachment commands
102
103 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
105 /// </summary>
106 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
107 void osForceAttachToAvatar(int attachment);
108
109 /// <summary>
110 /// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
111 /// </summary>
112 /// <remarks>
113 /// Nothing happens if the owner is not in the region.
114 /// </remarks>
115 /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
116 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
117 void osForceAttachToAvatarFromInventory(string itemName, int attachment);
118
119 /// <summary>
120 /// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH
121 /// </summary>
122 /// <remarks>
123 /// Nothing happens if the avatar is not in the region.
124 /// </remarks>
125 /// <param name='rawAvatarId'>The UUID of the avatar to which to attach. Nothing happens if this is not a UUID</para>
126 /// <param name='itemName'>The name of the item. If this is not found then a warning is said to the owner</param>
127 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
128 void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint);
129
130 /// <summary>
131 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
132 /// </summary>
133 /// <remarks>Nothing happens if the object is not attached.</remarks>
134 void osForceDetachFromAvatar();
135
101 //texture draw functions 136 //texture draw functions
102 string osMovePen(string drawList, int x, int y); 137 string osMovePen(string drawList, int x, int y);
103 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 138 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
@@ -203,11 +238,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
203 void osNpcSetRot(LSL_Key npc, rotation rot); 238 void osNpcSetRot(LSL_Key npc, rotation rot);
204 void osNpcStopMoveToTarget(LSL_Key npc); 239 void osNpcStopMoveToTarget(LSL_Key npc);
205 void osNpcSay(key npc, string message); 240 void osNpcSay(key npc, string message);
241 void osNpcSay(key npc, int channel, string message);
242 void osNpcShout(key npc, int channel, string message);
206 void osNpcSit(key npc, key target, int options); 243 void osNpcSit(key npc, key target, int options);
207 void osNpcStand(LSL_Key npc); 244 void osNpcStand(LSL_Key npc);
208 void osNpcRemove(key npc); 245 void osNpcRemove(key npc);
209 void osNpcPlayAnimation(LSL_Key npc, string animation); 246 void osNpcPlayAnimation(LSL_Key npc, string animation);
210 void osNpcStopAnimation(LSL_Key npc, string animation); 247 void osNpcStopAnimation(LSL_Key npc, string animation);
248 void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
249 void osNpcWhisper(key npc, int channel, string message);
211 250
212 LSL_Key osOwnerSaveAppearance(string notecard); 251 LSL_Key osOwnerSaveAppearance(string notecard);
213 LSL_Key osAgentSaveAppearance(key agentId, string notecard); 252 LSL_Key osAgentSaveAppearance(key agentId, string notecard);
@@ -234,5 +273,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
234 273
235 LSL_Integer osInviteToGroup(LSL_Key agentId); 274 LSL_Integer osInviteToGroup(LSL_Key agentId);
236 LSL_Integer osEjectFromGroup(LSL_Key agentId); 275 LSL_Integer osEjectFromGroup(LSL_Key agentId);
276
277 void osSetTerrainTexture(int level, LSL_Key texture);
278 void osSetTerrainTextureHeight(int corner, double low, double high);
237 } 279 }
238} 280}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index ad4f70c..a08cc42 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
383 public const int PRIM_SCULPT_FLAG_INVERT = 64; 383 public const int PRIM_SCULPT_FLAG_INVERT = 64;
384 public const int PRIM_SCULPT_FLAG_MIRROR = 128; 384 public const int PRIM_SCULPT_FLAG_MIRROR = 128;
385 385
386 public const int PROFILE_NONE = 0;
387 public const int PROFILE_SCRIPT_MEMORY = 1;
388
386 public const int MASK_BASE = 0; 389 public const int MASK_BASE = 0;
387 public const int MASK_OWNER = 1; 390 public const int MASK_OWNER = 1;
388 public const int MASK_GROUP = 2; 391 public const int MASK_GROUP = 2;
@@ -641,6 +644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
641 public const int OS_NPC_FLY = 0; 644 public const int OS_NPC_FLY = 0;
642 public const int OS_NPC_NO_FLY = 1; 645 public const int OS_NPC_NO_FLY = 1;
643 public const int OS_NPC_LAND_AT_TARGET = 2; 646 public const int OS_NPC_LAND_AT_TARGET = 2;
647 public const int OS_NPC_RUNNING = 4;
644 648
645 public const int OS_NPC_SIT_NOW = 0; 649 public const int OS_NPC_SIT_NOW = 0;
646 650
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 2f8e169..89b6eff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -165,11 +165,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
165 m_LSL_Functions.llBreakLink(linknum); 165 m_LSL_Functions.llBreakLink(linknum);
166 } 166 }
167 167
168 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
169 {
170 return m_LSL_Functions.llCastRay(start, end, options);
171 }
172
173 public LSL_Integer llCeil(double f) 168 public LSL_Integer llCeil(double f)
174 { 169 {
175 return m_LSL_Functions.llCeil(f); 170 return m_LSL_Functions.llCeil(f);
@@ -376,6 +371,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
376 return m_LSL_Functions.llFrand(mag); 371 return m_LSL_Functions.llFrand(mag);
377 } 372 }
378 373
374 public LSL_Key llGenerateKey()
375 {
376 return m_LSL_Functions.llGenerateKey();
377 }
378
379 public LSL_Vector llGetAccel() 379 public LSL_Vector llGetAccel()
380 { 380 {
381 return m_LSL_Functions.llGetAccel(); 381 return m_LSL_Functions.llGetAccel();
@@ -591,6 +591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
591 return m_LSL_Functions.llGetMassMKS(); 591 return m_LSL_Functions.llGetMassMKS();
592 } 592 }
593 593
594 public LSL_Integer llGetMemoryLimit()
595 {
596 return m_LSL_Functions.llGetMemoryLimit();
597 }
598
594 public void llGetNextEmail(string address, string subject) 599 public void llGetNextEmail(string address, string subject)
595 { 600 {
596 m_LSL_Functions.llGetNextEmail(address, subject); 601 m_LSL_Functions.llGetNextEmail(address, subject);
@@ -781,6 +786,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
781 return m_LSL_Functions.llGetSimulatorHostname(); 786 return m_LSL_Functions.llGetSimulatorHostname();
782 } 787 }
783 788
789 public LSL_Integer llGetSPMaxMemory()
790 {
791 return m_LSL_Functions.llGetSPMaxMemory();
792 }
793
784 public LSL_Integer llGetStartParameter() 794 public LSL_Integer llGetStartParameter()
785 { 795 {
786 return m_LSL_Functions.llGetStartParameter(); 796 return m_LSL_Functions.llGetStartParameter();
@@ -956,6 +966,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
956 return m_LSL_Functions.llRequestDisplayName(id); 966 return m_LSL_Functions.llRequestDisplayName(id);
957 } 967 }
958 968
969 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
970 {
971 return m_LSL_Functions.llCastRay(start, end, options);
972 }
973
959 public void llLinkParticleSystem(int linknum, LSL_List rules) 974 public void llLinkParticleSystem(int linknum, LSL_List rules)
960 { 975 {
961 m_LSL_Functions.llLinkParticleSystem(linknum, rules); 976 m_LSL_Functions.llLinkParticleSystem(linknum, rules);
@@ -1450,6 +1465,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1450 return m_LSL_Functions.llScriptDanger(pos); 1465 return m_LSL_Functions.llScriptDanger(pos);
1451 } 1466 }
1452 1467
1468 public void llScriptProfiler(LSL_Integer flags)
1469 {
1470 m_LSL_Functions.llScriptProfiler(flags);
1471 }
1472
1453 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) 1473 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata)
1454 { 1474 {
1455 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); 1475 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
@@ -1565,6 +1585,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1565 m_LSL_Functions.llSetLocalRot(rot); 1585 m_LSL_Functions.llSetLocalRot(rot);
1566 } 1586 }
1567 1587
1588 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
1589 {
1590 return m_LSL_Functions.llSetMemoryLimit(limit);
1591 }
1592
1568 public void llSetObjectDesc(string desc) 1593 public void llSetObjectDesc(string desc)
1569 { 1594 {
1570 m_LSL_Functions.llSetObjectDesc(desc); 1595 m_LSL_Functions.llSetObjectDesc(desc);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 680cefb4..b40bdf0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,8 +289,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions
292 293
293 //Texture Draw functions 294 public void osForceAttachToAvatar(int attachmentPoint)
295 {
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 }
298
299 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
300 {
301 m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint);
302 }
303
304 public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
305 {
306 m_OSSL_Functions.osForceAttachToOtherAvatarFromInventory(rawAvatarId, itemName, attachmentPoint);
307 }
308
309 public void osForceDetachFromAvatar()
310 {
311 m_OSSL_Functions.osForceDetachFromAvatar();
312 }
313
314 // Texture Draw functions
294 315
295 public string osMovePen(string drawList, int x, int y) 316 public string osMovePen(string drawList, int x, int y)
296 { 317 {
@@ -569,6 +590,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
569 m_OSSL_Functions.osNpcSay(npc, message); 590 m_OSSL_Functions.osNpcSay(npc, message);
570 } 591 }
571 592
593 public void osNpcSay(key npc, int channel, string message)
594 {
595 m_OSSL_Functions.osNpcSay(npc, channel, message);
596 }
597
598
599 public void osNpcShout(key npc, int channel, string message)
600 {
601 m_OSSL_Functions.osNpcShout(npc, channel, message);
602 }
603
572 public void osNpcSit(LSL_Key npc, LSL_Key target, int options) 604 public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
573 { 605 {
574 m_OSSL_Functions.osNpcSit(npc, target, options); 606 m_OSSL_Functions.osNpcSit(npc, target, options);
@@ -594,6 +626,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
594 m_OSSL_Functions.osNpcStopAnimation(npc, animation); 626 m_OSSL_Functions.osNpcStopAnimation(npc, animation);
595 } 627 }
596 628
629 public void osNpcWhisper(key npc, int channel, string message)
630 {
631 m_OSSL_Functions.osNpcWhisper(npc, channel, message);
632 }
633
634 public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
635 {
636 m_OSSL_Functions.osNpcTouch(npcLSL_Key, object_key, link_num);
637 }
638
597 public LSL_Key osOwnerSaveAppearance(string notecard) 639 public LSL_Key osOwnerSaveAppearance(string notecard)
598 { 640 {
599 return m_OSSL_Functions.osOwnerSaveAppearance(notecard); 641 return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
@@ -878,5 +920,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
878 { 920 {
879 return m_OSSL_Functions.osEjectFromGroup(agentId); 921 return m_OSSL_Functions.osEjectFromGroup(agentId);
880 } 922 }
923
924 public void osSetTerrainTexture(int level, LSL_Key texture)
925 {
926 m_OSSL_Functions.osSetTerrainTexture(level, texture);
927 }
928
929 public void osSetTerrainTextureHeight(int corner, double low, double high)
930 {
931 m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high);
932 }
881 } 933 }
882} 934}