aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorUbitUmarov2012-07-17 00:54:23 +0100
committerUbitUmarov2012-07-17 00:54:23 +0100
commitd5f4fb7b50fb7c594b018f8241399e22f88fc951 (patch)
tree8f3dab3d170596f02b1d1d836a0bc08a3e6b8ebd /OpenSim/Region/ScriptEngine/Shared/Api
parentUbitOde: remove useless water collider from active code. (diff)
parentMerge branch 'avination' into careminster (diff)
downloadopensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.zip
opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.gz
opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.bz2
opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.xz
Merge branch 'avination' into ubitwork
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/AsyncCommandManager.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1412
-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.cs439
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs8
-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
14 files changed, 1092 insertions, 1024 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/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 3cbdde5..693992a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -233,17 +233,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
233 m_Timer[engine].UnSetTimerEvents(localID, itemID); 233 m_Timer[engine].UnSetTimerEvents(localID, itemID);
234 234
235 // Remove from: HttpRequest 235 // Remove from: HttpRequest
236 IHttpRequestModule iHttpReq = 236 IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>();
237 engine.World.RequestModuleInterface<IHttpRequestModule>(); 237 if (iHttpReq != null)
238 iHttpReq.StopHttpRequest(localID, itemID); 238 iHttpReq.StopHttpRequest(localID, itemID);
239 239
240 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); 240 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
241 if (comms != null) 241 if (comms != null)
242 comms.DeleteListener(itemID); 242 comms.DeleteListener(itemID);
243 243
244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); 244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
245 xmlrpc.DeleteChannels(itemID); 245 if (xmlrpc != null)
246 xmlrpc.CancelSRDRequests(itemID); 246 {
247 xmlrpc.DeleteChannels(itemID);
248 xmlrpc.CancelSRDRequests(itemID);
249 }
247 250
248 // Remove Sensors 251 // Remove Sensors
249 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); 252 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
@@ -325,7 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
325 { 328 {
326 List<Object> data = new List<Object>(); 329 List<Object> data = new List<Object>();
327 330
328 Object[] listeners=m_Listener[engine].GetSerializationData(itemID); 331 Object[] listeners = m_Listener[engine].GetSerializationData(itemID);
329 if (listeners.Length > 0) 332 if (listeners.Length > 0)
330 { 333 {
331 data.Add("listener"); 334 data.Add("listener");
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 595dd8a..6ec3081 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 384
420 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 385 if (item != null && item.Type == type)
421 { 386 return item.AssetID;
422 if (inv.Value.Name == name) 387 else
423 { 388 return UUID.Zero;
424 m_host.TaskInventory.LockItemsForRead(false);
425 return inv.Value.AssetID;
426 }
427 }
428
429 m_host.TaskInventory.LockItemsForRead(false);
430
431
432 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
@@ -559,15 +517,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
559 return LSL_Vector.Norm(v); 517 return LSL_Vector.Norm(v);
560 } 518 }
561 519
562 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b) 520 private double VecDist(LSL_Vector a, LSL_Vector b)
563 { 521 {
564 m_host.AddScriptLPS(1);
565 double dx = a.x - b.x; 522 double dx = a.x - b.x;
566 double dy = a.y - b.y; 523 double dy = a.y - b.y;
567 double dz = a.z - b.z; 524 double dz = a.z - b.z;
568 return Math.Sqrt(dx * dx + dy * dy + dz * dz); 525 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
569 } 526 }
570 527
528 public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b)
529 {
530 m_host.AddScriptLPS(1);
531 return VecDist(a, b);
532 }
533
571 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 534 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
572 535
573 // Utility function for llRot2Euler 536 // Utility function for llRot2Euler
@@ -1010,7 +973,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1010 UUID.TryParse(ID, out keyID); 973 UUID.TryParse(ID, out keyID);
1011 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 974 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1012 if (wComm != null) 975 if (wComm != null)
1013 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 976 return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
1014 else 977 else
1015 return -1; 978 return -1;
1016 } 979 }
@@ -1020,7 +983,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1020 m_host.AddScriptLPS(1); 983 m_host.AddScriptLPS(1);
1021 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 984 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1022 if (wComm != null) 985 if (wComm != null)
1023 wComm.ListenControl(m_itemID, number, active); 986 wComm.ListenControl(m_item.ItemID, number, active);
1024 } 987 }
1025 988
1026 public void llListenRemove(int number) 989 public void llListenRemove(int number)
@@ -1028,7 +991,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1028 m_host.AddScriptLPS(1); 991 m_host.AddScriptLPS(1);
1029 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 992 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
1030 if (wComm != null) 993 if (wComm != null)
1031 wComm.ListenRemove(m_itemID, number); 994 wComm.ListenRemove(m_item.ItemID, number);
1032 } 995 }
1033 996
1034 public void llSensor(string name, string id, int type, double range, double arc) 997 public void llSensor(string name, string id, int type, double range, double arc)
@@ -1037,7 +1000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1037 UUID keyID = UUID.Zero; 1000 UUID keyID = UUID.Zero;
1038 UUID.TryParse(id, out keyID); 1001 UUID.TryParse(id, out keyID);
1039 1002
1040 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 1003 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host);
1041 } 1004 }
1042 1005
1043 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 1006 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -1046,13 +1009,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1046 UUID keyID = UUID.Zero; 1009 UUID keyID = UUID.Zero;
1047 UUID.TryParse(id, out keyID); 1010 UUID.TryParse(id, out keyID);
1048 1011
1049 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 1012 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host);
1050 } 1013 }
1051 1014
1052 public void llSensorRemove() 1015 public void llSensorRemove()
1053 { 1016 {
1054 m_host.AddScriptLPS(1); 1017 m_host.AddScriptLPS(1);
1055 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); 1018 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID);
1056 } 1019 }
1057 1020
1058 public string resolveName(UUID objecUUID) 1021 public string resolveName(UUID objecUUID)
@@ -1093,7 +1056,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1093 public LSL_String llDetectedName(int number) 1056 public LSL_String llDetectedName(int number)
1094 { 1057 {
1095 m_host.AddScriptLPS(1); 1058 m_host.AddScriptLPS(1);
1096 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1059 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1097 if (detectedParams == null) 1060 if (detectedParams == null)
1098 return String.Empty; 1061 return String.Empty;
1099 return detectedParams.Name; 1062 return detectedParams.Name;
@@ -1102,7 +1065,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1102 public LSL_String llDetectedKey(int number) 1065 public LSL_String llDetectedKey(int number)
1103 { 1066 {
1104 m_host.AddScriptLPS(1); 1067 m_host.AddScriptLPS(1);
1105 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1068 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1106 if (detectedParams == null) 1069 if (detectedParams == null)
1107 return String.Empty; 1070 return String.Empty;
1108 return detectedParams.Key.ToString(); 1071 return detectedParams.Key.ToString();
@@ -1111,7 +1074,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1111 public LSL_String llDetectedOwner(int number) 1074 public LSL_String llDetectedOwner(int number)
1112 { 1075 {
1113 m_host.AddScriptLPS(1); 1076 m_host.AddScriptLPS(1);
1114 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1077 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1115 if (detectedParams == null) 1078 if (detectedParams == null)
1116 return String.Empty; 1079 return String.Empty;
1117 return detectedParams.Owner.ToString(); 1080 return detectedParams.Owner.ToString();
@@ -1120,7 +1083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1120 public LSL_Integer llDetectedType(int number) 1083 public LSL_Integer llDetectedType(int number)
1121 { 1084 {
1122 m_host.AddScriptLPS(1); 1085 m_host.AddScriptLPS(1);
1123 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1086 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1124 if (detectedParams == null) 1087 if (detectedParams == null)
1125 return 0; 1088 return 0;
1126 return new LSL_Integer(detectedParams.Type); 1089 return new LSL_Integer(detectedParams.Type);
@@ -1129,7 +1092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1129 public LSL_Vector llDetectedPos(int number) 1092 public LSL_Vector llDetectedPos(int number)
1130 { 1093 {
1131 m_host.AddScriptLPS(1); 1094 m_host.AddScriptLPS(1);
1132 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1095 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1133 if (detectedParams == null) 1096 if (detectedParams == null)
1134 return new LSL_Vector(); 1097 return new LSL_Vector();
1135 return detectedParams.Position; 1098 return detectedParams.Position;
@@ -1138,7 +1101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1138 public LSL_Vector llDetectedVel(int number) 1101 public LSL_Vector llDetectedVel(int number)
1139 { 1102 {
1140 m_host.AddScriptLPS(1); 1103 m_host.AddScriptLPS(1);
1141 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1104 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1142 if (detectedParams == null) 1105 if (detectedParams == null)
1143 return new LSL_Vector(); 1106 return new LSL_Vector();
1144 return detectedParams.Velocity; 1107 return detectedParams.Velocity;
@@ -1147,7 +1110,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1147 public LSL_Vector llDetectedGrab(int number) 1110 public LSL_Vector llDetectedGrab(int number)
1148 { 1111 {
1149 m_host.AddScriptLPS(1); 1112 m_host.AddScriptLPS(1);
1150 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1113 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1151 if (parms == null) 1114 if (parms == null)
1152 return new LSL_Vector(0, 0, 0); 1115 return new LSL_Vector(0, 0, 0);
1153 1116
@@ -1157,7 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1157 public LSL_Rotation llDetectedRot(int number) 1120 public LSL_Rotation llDetectedRot(int number)
1158 { 1121 {
1159 m_host.AddScriptLPS(1); 1122 m_host.AddScriptLPS(1);
1160 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1123 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1161 if (detectedParams == null) 1124 if (detectedParams == null)
1162 return new LSL_Rotation(); 1125 return new LSL_Rotation();
1163 return detectedParams.Rotation; 1126 return detectedParams.Rotation;
@@ -1166,7 +1129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1166 public LSL_Integer llDetectedGroup(int number) 1129 public LSL_Integer llDetectedGroup(int number)
1167 { 1130 {
1168 m_host.AddScriptLPS(1); 1131 m_host.AddScriptLPS(1);
1169 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1132 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1170 if (detectedParams == null) 1133 if (detectedParams == null)
1171 return new LSL_Integer(0); 1134 return new LSL_Integer(0);
1172 if (m_host.GroupID == detectedParams.Group) 1135 if (m_host.GroupID == detectedParams.Group)
@@ -1177,7 +1140,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1177 public LSL_Integer llDetectedLinkNumber(int number) 1140 public LSL_Integer llDetectedLinkNumber(int number)
1178 { 1141 {
1179 m_host.AddScriptLPS(1); 1142 m_host.AddScriptLPS(1);
1180 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1143 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1181 if (parms == null) 1144 if (parms == null)
1182 return new LSL_Integer(0); 1145 return new LSL_Integer(0);
1183 1146
@@ -1190,7 +1153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1190 public LSL_Vector llDetectedTouchBinormal(int index) 1153 public LSL_Vector llDetectedTouchBinormal(int index)
1191 { 1154 {
1192 m_host.AddScriptLPS(1); 1155 m_host.AddScriptLPS(1);
1193 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1156 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1194 if (detectedParams == null) 1157 if (detectedParams == null)
1195 return new LSL_Vector(); 1158 return new LSL_Vector();
1196 return detectedParams.TouchBinormal; 1159 return detectedParams.TouchBinormal;
@@ -1202,7 +1165,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1202 public LSL_Integer llDetectedTouchFace(int index) 1165 public LSL_Integer llDetectedTouchFace(int index)
1203 { 1166 {
1204 m_host.AddScriptLPS(1); 1167 m_host.AddScriptLPS(1);
1205 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1168 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1206 if (detectedParams == null) 1169 if (detectedParams == null)
1207 return new LSL_Integer(-1); 1170 return new LSL_Integer(-1);
1208 return new LSL_Integer(detectedParams.TouchFace); 1171 return new LSL_Integer(detectedParams.TouchFace);
@@ -1214,7 +1177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1214 public LSL_Vector llDetectedTouchNormal(int index) 1177 public LSL_Vector llDetectedTouchNormal(int index)
1215 { 1178 {
1216 m_host.AddScriptLPS(1); 1179 m_host.AddScriptLPS(1);
1217 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1180 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1218 if (detectedParams == null) 1181 if (detectedParams == null)
1219 return new LSL_Vector(); 1182 return new LSL_Vector();
1220 return detectedParams.TouchNormal; 1183 return detectedParams.TouchNormal;
@@ -1226,7 +1189,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1226 public LSL_Vector llDetectedTouchPos(int index) 1189 public LSL_Vector llDetectedTouchPos(int index)
1227 { 1190 {
1228 m_host.AddScriptLPS(1); 1191 m_host.AddScriptLPS(1);
1229 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1192 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1230 if (detectedParams == null) 1193 if (detectedParams == null)
1231 return new LSL_Vector(); 1194 return new LSL_Vector();
1232 return detectedParams.TouchPos; 1195 return detectedParams.TouchPos;
@@ -1238,7 +1201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1238 public LSL_Vector llDetectedTouchST(int index) 1201 public LSL_Vector llDetectedTouchST(int index)
1239 { 1202 {
1240 m_host.AddScriptLPS(1); 1203 m_host.AddScriptLPS(1);
1241 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1204 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1242 if (detectedParams == null) 1205 if (detectedParams == null)
1243 return new LSL_Vector(-1.0, -1.0, 0.0); 1206 return new LSL_Vector(-1.0, -1.0, 0.0);
1244 return detectedParams.TouchST; 1207 return detectedParams.TouchST;
@@ -1250,7 +1213,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1250 public LSL_Vector llDetectedTouchUV(int index) 1213 public LSL_Vector llDetectedTouchUV(int index)
1251 { 1214 {
1252 m_host.AddScriptLPS(1); 1215 m_host.AddScriptLPS(1);
1253 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1216 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1254 if (detectedParams == null) 1217 if (detectedParams == null)
1255 return new LSL_Vector(-1.0, -1.0, 0.0); 1218 return new LSL_Vector(-1.0, -1.0, 0.0);
1256 return detectedParams.TouchUV; 1219 return detectedParams.TouchUV;
@@ -1433,6 +1396,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1433 } 1396 }
1434 } 1397 }
1435 1398
1399 private bool IsPhysical()
1400 {
1401 return ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == (uint)PrimFlags.Physics);
1402 }
1403
1436 public LSL_Integer llGetStatus(int status) 1404 public LSL_Integer llGetStatus(int status)
1437 { 1405 {
1438 m_host.AddScriptLPS(1); 1406 m_host.AddScriptLPS(1);
@@ -1440,11 +1408,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1440 switch (status) 1408 switch (status)
1441 { 1409 {
1442 case ScriptBaseClass.STATUS_PHYSICS: 1410 case ScriptBaseClass.STATUS_PHYSICS:
1443 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == (uint)PrimFlags.Physics) 1411 return IsPhysical() ? 1 : 0;
1444 {
1445 return 1;
1446 }
1447 return 0;
1448 1412
1449 case ScriptBaseClass.STATUS_PHANTOM: 1413 case ScriptBaseClass.STATUS_PHANTOM:
1450 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) == (uint)PrimFlags.Phantom) 1414 if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) == (uint)PrimFlags.Phantom)
@@ -1962,6 +1926,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1962 rgb.x = texcolor.R; 1926 rgb.x = texcolor.R;
1963 rgb.y = texcolor.G; 1927 rgb.y = texcolor.G;
1964 rgb.z = texcolor.B; 1928 rgb.z = texcolor.B;
1929
1965 return rgb; 1930 return rgb;
1966 } 1931 }
1967 else 1932 else
@@ -2196,11 +2161,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2196 { 2161 {
2197 m_host.AddScriptLPS(1); 2162 m_host.AddScriptLPS(1);
2198 2163
2199 SetPos(m_host, pos); 2164 SetPos(m_host, pos, true);
2200 2165
2201 ScriptSleep(200); 2166 ScriptSleep(200);
2202 } 2167 }
2203 2168
2169 /// <summary>
2170 /// Tries to move the entire object so that the root prim is within 0.1m of position. http://wiki.secondlife.com/wiki/LlSetRegionPos
2171 /// Documentation indicates that the use of x/y coordinates up to 10 meters outside the bounds of a region will work but do not specify what happens if there is no adjacent region for the object to move into.
2172 /// Uses the RegionSize constant here rather than hard-coding 266.0 to alert any developer modifying OpenSim to support variable-sized regions that this method will need tweaking.
2173 /// </summary>
2174 /// <param name="pos"></param>
2175 /// <returns>1 if successful, 0 otherwise.</returns>
2176 public LSL_Integer llSetRegionPos(LSL_Vector pos)
2177 {
2178 m_host.AddScriptLPS(1);
2179
2180 // BEGIN WORKAROUND
2181 // IF YOU GET REGION CROSSINGS WORKING WITH THIS FUNCTION, REPLACE THE WORKAROUND.
2182 //
2183 // This workaround is to prevent silent failure of this function.
2184 // According to the specification on the SL Wiki, providing a position outside of the
2185 if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize)
2186 {
2187 return 0;
2188 }
2189 // END WORK AROUND
2190 else if ( // this is not part of the workaround if-block because it's not related to the workaround.
2191 IsPhysical() ||
2192 m_host.ParentGroup.IsAttachment || // return FALSE if attachment
2193 (
2194 pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region.
2195 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
2196 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region.
2197 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
2198 pos.z > 4096 // return FALSE if altitude than 4096m
2199 )
2200 )
2201 {
2202 return 0;
2203 }
2204
2205 // if we reach this point, then the object is not physical, it's not an attachment, and the destination is within the valid range.
2206 // this could possibly be done in the above else-if block, but we're doing the check here to keep the code easier to read.
2207
2208 Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition;
2209 LandData here = World.GetLandData((float)objectPos.X, (float)objectPos.Y);
2210 LandData there = World.GetLandData((float)pos.x, (float)pos.y);
2211
2212 // we're only checking prim limits if it's moving to a different parcel under the assumption that if the object got onto the parcel without exceeding the prim limits.
2213
2214 bool sameParcel = here.GlobalID == there.GlobalID;
2215
2216 if (!sameParcel && !World.Permissions.CanObjectEntry(m_host.UUID, false, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)))
2217 {
2218 return 0;
2219 }
2220
2221 SetPos(m_host.ParentGroup.RootPart, pos, false);
2222
2223 return VecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0;
2224 }
2225
2204 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2226 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
2205 // note linked setpos is capped "differently" 2227 // note linked setpos is capped "differently"
2206 private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end) 2228 private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end)
@@ -2232,55 +2254,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2232 return real_vec; 2254 return real_vec;
2233 } 2255 }
2234 2256
2235 public LSL_Integer llSetRegionPos(LSL_Vector pos) 2257 /// <summary>
2236 { 2258 /// set object position, optionally capping the distance.
2237 return new LSL_Integer(SetRegionPos(m_host, pos)); 2259 /// </summary>
2238 } 2260 /// <param name="part"></param>
2239 2261 /// <param name="targetPos"></param>
2240 protected int SetRegionPos(SceneObjectPart part, LSL_Vector targetPos) 2262 /// <param name="adjust">if TRUE, will cap the distance to 10m.</param>
2241 { 2263 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust)
2242 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2243 return 0;
2244
2245 SceneObjectGroup grp = part.ParentGroup;
2246
2247 if (grp.IsAttachment)
2248 return 0;
2249
2250 if (grp.RootPart.PhysActor != null && grp.RootPart.PhysActor.IsPhysical)
2251 return 0;
2252
2253 if (targetPos.x < -10.0f || targetPos.x >= (float)Constants.RegionSize || targetPos.y < -10.0f || targetPos.y >= (float)Constants.RegionSize || targetPos.z < 0 || targetPos.z >= 4096.0f)
2254 return 0;
2255
2256 float constrainedX = (float)targetPos.x;
2257 float constrainedY = (float)targetPos.y;
2258
2259 if (constrainedX < 0.0f)
2260 constrainedX = 0.0f;
2261 if (constrainedY < 0.0f)
2262 constrainedY = 0.0f;
2263 if (constrainedX >= (float)Constants.RegionSize)
2264 constrainedX = (float)Constants.RegionSize - 0.1f;
2265 if (constrainedY >= (float)Constants.RegionSize)
2266 constrainedY = (float)Constants.RegionSize -0.1f;
2267
2268 float ground = World.GetGroundHeight(constrainedX, constrainedY);
2269
2270 if (targetPos.z < ground)
2271 targetPos.z = ground;
2272
2273 Vector3 dest = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z);
2274
2275 if (!World.Permissions.CanObjectEntry(grp.UUID, false, dest))
2276 return 0;
2277
2278 grp.UpdateGroupPosition(dest);
2279
2280 return 1;
2281 }
2282
2283 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
2284 { 2264 {
2285 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2265 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2286 return; 2266 return;
@@ -3044,20 +3024,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3044 3024
3045 public LSL_Integer llGiveMoney(string destination, int amount) 3025 public LSL_Integer llGiveMoney(string destination, int amount)
3046 { 3026 {
3047 UUID invItemID=InventorySelf();
3048 if (invItemID == UUID.Zero)
3049 return 0;
3050
3051 m_host.AddScriptLPS(1); 3027 m_host.AddScriptLPS(1);
3052 3028
3053 m_host.TaskInventory.LockItemsForRead(true); 3029 if (m_item.PermsGranter == UUID.Zero)
3054 TaskInventoryItem item = m_host.TaskInventory[invItemID];
3055 m_host.TaskInventory.LockItemsForRead(false);
3056
3057 if (item.PermsGranter == UUID.Zero)
3058 return 0; 3030 return 0;
3059 3031
3060 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) 3032 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
3061 { 3033 {
3062 LSLError("No permissions to give money"); 3034 LSLError("No permissions to give money");
3063 return 0; 3035 return 0;
@@ -3120,74 +3092,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3120 { 3092 {
3121 m_host.AddScriptLPS(1); 3093 m_host.AddScriptLPS(1);
3122 3094
3123 Util.FireAndForget(delegate (object x) 3095 Util.FireAndForget(x =>
3124 { 3096 {
3125 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) 3097 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
3126 return; 3098 return;
3099
3127 float dist = (float)llVecDist(llGetPos(), pos); 3100 float dist = (float)llVecDist(llGetPos(), pos);
3128 3101
3129 if (dist > m_ScriptDistanceFactor * 10.0f) 3102 if (dist > m_ScriptDistanceFactor * 10.0f)
3130 return; 3103 return;
3131 3104
3132 //Clone is thread-safe 3105 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
3133 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3134 3106
3135 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 3107 if (item == null)
3136 { 3108 {
3137 if (inv.Value.Name == inventory) 3109 llSay(0, "Could not find object " + inventory);
3138 { 3110 return;
3139 // make sure we're an object. 3111 }
3140 if (inv.Value.InvType != (int)InventoryType.Object)
3141 {
3142 llSay(0, "Unable to create requested object. Object is missing from database.");
3143 return;
3144 }
3145 3112
3146 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); 3113 if (item.InvType != (int)InventoryType.Object)
3147 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); 3114 {
3115 llSay(0, "Unable to create requested object. Object is missing from database.");
3116 return;
3117 }
3148 3118
3149 // need the magnitude later 3119 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
3150 // float velmag = (float)Util.GetMagnitude(llvel); 3120 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
3151 3121
3152 SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); 3122 // need the magnitude later
3123 // float velmag = (float)Util.GetMagnitude(llvel);
3153 3124
3154 // If either of these are null, then there was an unknown error. 3125 SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param);
3155 if (new_group == null)
3156 continue;
3157 3126
3158 // objects rezzed with this method are die_at_edge by default. 3127 // If either of these are null, then there was an unknown error.
3159 new_group.RootPart.SetDieAtEdge(true); 3128 if (new_group == null)
3129 return;
3160 3130
3161 new_group.ResumeScripts(); 3131 // objects rezzed with this method are die_at_edge by default.
3132 new_group.RootPart.SetDieAtEdge(true);
3162 3133
3163 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( 3134 new_group.ResumeScripts();
3164 "object_rez", new Object[] {
3165 new LSL_String(
3166 new_group.RootPart.UUID.ToString()) },
3167 new DetectParams[0]));
3168 3135
3169 // do recoil 3136 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
3170 SceneObjectGroup hostgrp = m_host.ParentGroup; 3137 "object_rez", new Object[] {
3171 if (hostgrp == null) 3138 new LSL_String(
3172 return; 3139 new_group.RootPart.UUID.ToString()) },
3140 new DetectParams[0]));
3141
3142 // do recoil
3143 SceneObjectGroup hostgrp = m_host.ParentGroup;
3144 if (hostgrp == null)
3145 return;
3173 3146
3174 if (hostgrp.IsAttachment) // don't recoil avatars 3147 if (hostgrp.IsAttachment) // don't recoil avatars
3175 return; 3148 return;
3176 3149
3177 PhysicsActor pa = new_group.RootPart.PhysActor; 3150 PhysicsActor pa = new_group.RootPart.PhysActor;
3178 3151
3179 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) 3152 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
3180 { 3153 {
3181 float groupmass = new_group.GetMass(); 3154 float groupmass = new_group.GetMass();
3182 llvel *= -groupmass; 3155 llvel *= -groupmass;
3183 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); 3156 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0);
3184 }
3185 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3186 return;
3187 }
3188 } 3157 }
3158 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3159 return;
3189 3160
3190 llSay(0, "Could not find object " + inventory);
3191 }); 3161 });
3192 3162
3193 //ScriptSleep((int)((groupmass * velmag) / 10)); 3163 //ScriptSleep((int)((groupmass * velmag) / 10));
@@ -3251,11 +3221,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3251 sec = m_MinTimerInterval; 3221 sec = m_MinTimerInterval;
3252 m_host.AddScriptLPS(1); 3222 m_host.AddScriptLPS(1);
3253 // Setting timer repeat 3223 // Setting timer repeat
3254 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); 3224 AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec);
3255 } 3225 }
3256 3226
3257 public virtual void llSleep(double sec) 3227 public virtual void llSleep(double sec)
3258 { 3228 {
3229// m_log.Info("llSleep snoozing " + sec + "s.");
3259 m_host.AddScriptLPS(1); 3230 m_host.AddScriptLPS(1);
3260 Thread.Sleep((int)(sec * 1000)); 3231 Thread.Sleep((int)(sec * 1000));
3261 } 3232 }
@@ -3314,29 +3285,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3314 3285
3315 public void llTakeControls(int controls, int accept, int pass_on) 3286 public void llTakeControls(int controls, int accept, int pass_on)
3316 { 3287 {
3317 TaskInventoryItem item; 3288 if (m_item.PermsGranter != UUID.Zero)
3318
3319 m_host.TaskInventory.LockItemsForRead(true);
3320 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3321 { 3289 {
3322 m_host.TaskInventory.LockItemsForRead(false); 3290 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3323 return;
3324 }
3325 else
3326 {
3327 item = m_host.TaskInventory[InventorySelf()];
3328 }
3329 m_host.TaskInventory.LockItemsForRead(false);
3330
3331 if (item.PermsGranter != UUID.Zero)
3332 {
3333 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3334 3291
3335 if (presence != null) 3292 if (presence != null)
3336 { 3293 {
3337 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3294 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3338 { 3295 {
3339 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 3296 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID);
3340 } 3297 }
3341 } 3298 }
3342 } 3299 }
@@ -3346,38 +3303,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3346 3303
3347 public void llReleaseControls() 3304 public void llReleaseControls()
3348 { 3305 {
3349 TaskInventoryItem item;
3350
3351 m_host.TaskInventory.LockItemsForRead(true);
3352 lock (m_host.TaskInventory)
3353 {
3354
3355 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3356 {
3357 m_host.TaskInventory.LockItemsForRead(false);
3358 return;
3359 }
3360 else
3361 {
3362 item = m_host.TaskInventory[InventorySelf()];
3363 }
3364 }
3365 m_host.TaskInventory.LockItemsForRead(false);
3366
3367 m_host.AddScriptLPS(1); 3306 m_host.AddScriptLPS(1);
3368 3307
3369 if (item.PermsGranter != UUID.Zero) 3308 if (m_item.PermsGranter != UUID.Zero)
3370 { 3309 {
3371 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3310 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3372 3311
3373 if (presence != null) 3312 if (presence != null)
3374 { 3313 {
3375 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3314 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3376 { 3315 {
3377 // Unregister controls from Presence 3316 // Unregister controls from Presence
3378 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 3317 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
3379 // Remove Take Control permission. 3318 // Remove Take Control permission.
3380 item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 3319 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
3381 } 3320 }
3382 } 3321 }
3383 } 3322 }
@@ -3390,86 +3329,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3390 m_UrlModule.ReleaseURL(url); 3329 m_UrlModule.ReleaseURL(url);
3391 } 3330 }
3392 3331
3393 public void llAttachToAvatar(int attachment) 3332 /// <summary>
3333 /// Attach the object containing this script to the avatar that owns it.
3334 /// </summary>
3335 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3336 /// <returns>true if the attach suceeded, false if it did not</returns>
3337 public bool AttachToAvatar(int attachmentPoint)
3394 { 3338 {
3395 m_host.AddScriptLPS(1); 3339 SceneObjectGroup grp = m_host.ParentGroup;
3396 3340 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3397 TaskInventoryItem item;
3398 3341
3399 m_host.TaskInventory.LockItemsForRead(true); 3342 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3400 3343
3401 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3344 if (attachmentsModule != null)
3402 { 3345 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true);
3403 m_host.TaskInventory.LockItemsForRead(false);
3404 return;
3405 }
3406 else 3346 else
3407 { 3347 return false;
3408 item = m_host.TaskInventory[InventorySelf()]; 3348 }
3409 }
3410
3411 m_host.TaskInventory.LockItemsForRead(false);
3412 3349
3413 if (item.PermsGranter != m_host.OwnerID) 3350 /// <summary>
3414 return; 3351 /// Detach the object containing this script from the avatar it is attached to.
3352 /// </summary>
3353 /// <remarks>
3354 /// Nothing happens if the object is not attached.
3355 /// </remarks>
3356 public void DetachFromAvatar()
3357 {
3358 Util.FireAndForget(DetachWrapper, m_host);
3359 }
3415 3360
3416 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3361 private void DetachWrapper(object o)
3362 {
3363 if (World.AttachmentsModule != null)
3417 { 3364 {
3418 SceneObjectGroup grp = m_host.ParentGroup; 3365 SceneObjectPart host = (SceneObjectPart)o;
3419 3366 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3420 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3367 World.AttachmentsModule.DetachSingleAttachmentToInv(presence, host.ParentGroup);
3421
3422 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3423 if (attachmentsModule != null)
3424 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false, true);
3425 } 3368 }
3426 } 3369 }
3427 3370
3428 public void llDetachFromAvatar() 3371 public void llAttachToAvatar(int attachmentPoint)
3429 { 3372 {
3430 m_host.AddScriptLPS(1); 3373 m_host.AddScriptLPS(1);
3431 3374
3432 if (m_host.ParentGroup.AttachmentPoint == 0) 3375 if (m_item.PermsGranter != m_host.OwnerID)
3433 return; 3376 return;
3434 3377
3435 TaskInventoryItem item; 3378 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3379 AttachToAvatar(attachmentPoint);
3380 }
3436 3381
3437 m_host.TaskInventory.LockItemsForRead(true); 3382 public void llDetachFromAvatar()
3383 {
3384 m_host.AddScriptLPS(1);
3438 3385
3439 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3386 if (m_host.ParentGroup.AttachmentPoint == 0)
3440 {
3441 m_host.TaskInventory.LockItemsForRead(false);
3442 return; 3387 return;
3443 }
3444 else
3445 {
3446 item = m_host.TaskInventory[InventorySelf()];
3447 }
3448 m_host.TaskInventory.LockItemsForRead(false);
3449 3388
3450 3389 if (m_item.PermsGranter != m_host.OwnerID)
3451 if (item.PermsGranter != m_host.OwnerID)
3452 return; 3390 return;
3453 3391
3454 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3392 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3455 { 3393 DetachFromAvatar();
3456 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3457 if (attachmentsModule != null)
3458 Util.FireAndForget(DetachWrapper, m_host);
3459 }
3460 }
3461
3462 private void DetachWrapper(object o)
3463 {
3464 SceneObjectPart host = (SceneObjectPart)o;
3465
3466 SceneObjectGroup grp = host.ParentGroup;
3467 UUID itemID = grp.FromItemID;
3468 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3469
3470 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3471 if (attachmentsModule != null)
3472 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3473 } 3394 }
3474 3395
3475 public void llTakeCamera(string avatar) 3396 public void llTakeCamera(string avatar)
@@ -3590,7 +3511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3590 } 3511 }
3591 3512
3592 emailModule.SendEmail(m_host.UUID, address, subject, message); 3513 emailModule.SendEmail(m_host.UUID, address, subject, message);
3593 ScriptSleep(15000); 3514 ScriptSleep(EMAIL_PAUSE_TIME * 1000);
3594 } 3515 }
3595 3516
3596 public void llGetNextEmail(string address, string subject) 3517 public void llGetNextEmail(string address, string subject)
@@ -3627,6 +3548,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3627 return m_host.UUID.ToString(); 3548 return m_host.UUID.ToString();
3628 } 3549 }
3629 3550
3551 public LSL_Key llGenerateKey()
3552 {
3553 m_host.AddScriptLPS(1);
3554 return UUID.Random().ToString();
3555 }
3556
3630 public void llSetBuoyancy(double buoyancy) 3557 public void llSetBuoyancy(double buoyancy)
3631 { 3558 {
3632 m_host.AddScriptLPS(1); 3559 m_host.AddScriptLPS(1);
@@ -3673,7 +3600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3673 m_host.AddScriptLPS(1); 3600 m_host.AddScriptLPS(1);
3674 try 3601 try
3675 { 3602 {
3676 m_ScriptEngine.SetMinEventDelay(m_itemID, delay); 3603 m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay);
3677 } 3604 }
3678 catch (NotImplementedException) 3605 catch (NotImplementedException)
3679 { 3606 {
@@ -3726,29 +3653,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3726 { 3653 {
3727 m_host.AddScriptLPS(1); 3654 m_host.AddScriptLPS(1);
3728 3655
3729 UUID invItemID = InventorySelf(); 3656 if (m_item.PermsGranter == UUID.Zero)
3730 if (invItemID == UUID.Zero)
3731 return; 3657 return;
3732 3658
3733 TaskInventoryItem item; 3659 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3734
3735 m_host.TaskInventory.LockItemsForRead(true);
3736 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3737 { 3660 {
3738 m_host.TaskInventory.LockItemsForRead(false); 3661 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3739 return;
3740 }
3741 else
3742 {
3743 item = m_host.TaskInventory[InventorySelf()];
3744 }
3745 m_host.TaskInventory.LockItemsForRead(false);
3746 if (item.PermsGranter == UUID.Zero)
3747 return;
3748
3749 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3750 {
3751 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3752 3662
3753 if (presence != null) 3663 if (presence != null)
3754 { 3664 {
@@ -3766,41 +3676,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3766 { 3676 {
3767 m_host.AddScriptLPS(1); 3677 m_host.AddScriptLPS(1);
3768 3678
3769 UUID invItemID=InventorySelf(); 3679 if (m_item.PermsGranter == UUID.Zero)
3770 if (invItemID == UUID.Zero)
3771 return;
3772
3773 TaskInventoryItem item;
3774
3775 m_host.TaskInventory.LockItemsForRead(true);
3776 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3777 {
3778 m_host.TaskInventory.LockItemsForRead(false);
3779 return;
3780 }
3781 else
3782 {
3783 item = m_host.TaskInventory[InventorySelf()];
3784 }
3785 m_host.TaskInventory.LockItemsForRead(false);
3786
3787
3788 if (item.PermsGranter == UUID.Zero)
3789 return; 3680 return;
3790 3681
3791 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3682 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3792 { 3683 {
3793 UUID animID = new UUID(); 3684 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3794
3795 if (!UUID.TryParse(anim, out animID))
3796 {
3797 animID=InventoryKey(anim);
3798 }
3799
3800 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
3801 3685
3802 if (presence != null) 3686 if (presence != null)
3803 { 3687 {
3688 UUID animID = KeyOrName(anim);
3689
3804 if (animID == UUID.Zero) 3690 if (animID == UUID.Zero)
3805 presence.Animator.RemoveAnimation(anim); 3691 presence.Animator.RemoveAnimation(anim);
3806 else 3692 else
@@ -3833,44 +3719,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3833 public LSL_Integer llGetStartParameter() 3719 public LSL_Integer llGetStartParameter()
3834 { 3720 {
3835 m_host.AddScriptLPS(1); 3721 m_host.AddScriptLPS(1);
3836 return m_ScriptEngine.GetStartParameter(m_itemID); 3722 return m_ScriptEngine.GetStartParameter(m_item.ItemID);
3837 } 3723 }
3838 3724
3839 public void llRequestPermissions(string agent, int perm) 3725 public void llRequestPermissions(string agent, int perm)
3840 { 3726 {
3841 UUID agentID = new UUID(); 3727 UUID agentID;
3842 3728
3843 if (!UUID.TryParse(agent, out agentID)) 3729 if (!UUID.TryParse(agent, out agentID))
3844 return; 3730 return;
3845 3731
3846 UUID invItemID = InventorySelf();
3847
3848 if (invItemID == UUID.Zero)
3849 return; // Not in a prim? How??
3850
3851 TaskInventoryItem item;
3852
3853
3854 m_host.TaskInventory.LockItemsForRead(true);
3855 if (!m_host.TaskInventory.ContainsKey(invItemID))
3856 {
3857 m_host.TaskInventory.LockItemsForRead(false);
3858 return;
3859 }
3860 else
3861 {
3862 item = m_host.TaskInventory[invItemID];
3863 }
3864 m_host.TaskInventory.LockItemsForRead(false);
3865
3866 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3732 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3867 { 3733 {
3868 llReleaseControls(); 3734 llReleaseControls();
3869 3735
3870 item.PermsGranter = UUID.Zero; 3736 m_item.PermsGranter = UUID.Zero;
3871 item.PermsMask = 0; 3737 m_item.PermsMask = 0;
3872 3738
3873 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3739 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3874 "run_time_permissions", new Object[] { 3740 "run_time_permissions", new Object[] {
3875 new LSL_Integer(0) }, 3741 new LSL_Integer(0) },
3876 new DetectParams[0])); 3742 new DetectParams[0]));
@@ -3878,7 +3744,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3878 return; 3744 return;
3879 } 3745 }
3880 3746
3881 if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3747 if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3882 llReleaseControls(); 3748 llReleaseControls();
3883 3749
3884 m_host.AddScriptLPS(1); 3750 m_host.AddScriptLPS(1);
@@ -3895,11 +3761,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3895 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3761 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3896 { 3762 {
3897 m_host.TaskInventory.LockItemsForWrite(true); 3763 m_host.TaskInventory.LockItemsForWrite(true);
3898 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3764 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3899 m_host.TaskInventory[invItemID].PermsMask = perm; 3765 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3900 m_host.TaskInventory.LockItemsForWrite(false); 3766 m_host.TaskInventory.LockItemsForWrite(false);
3901 3767
3902 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3768 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3903 "run_time_permissions", new Object[] { 3769 "run_time_permissions", new Object[] {
3904 new LSL_Integer(perm) }, 3770 new LSL_Integer(perm) },
3905 new DetectParams[0])); 3771 new DetectParams[0]));
@@ -3934,11 +3800,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3934 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3800 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3935 { 3801 {
3936 m_host.TaskInventory.LockItemsForWrite(true); 3802 m_host.TaskInventory.LockItemsForWrite(true);
3937 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3803 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3938 m_host.TaskInventory[invItemID].PermsMask = perm; 3804 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3939 m_host.TaskInventory.LockItemsForWrite(false); 3805 m_host.TaskInventory.LockItemsForWrite(false);
3940 3806
3941 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3807 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3942 "run_time_permissions", new Object[] { 3808 "run_time_permissions", new Object[] {
3943 new LSL_Integer(perm) }, 3809 new LSL_Integer(perm) },
3944 new DetectParams[0])); 3810 new DetectParams[0]));
@@ -3949,9 +3815,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3949 } 3815 }
3950 3816
3951 ScenePresence presence = World.GetScenePresence(agentID); 3817 ScenePresence presence = World.GetScenePresence(agentID);
3952
3953 if (presence != null) 3818 if (presence != null)
3954 { 3819 {
3820 // If permissions are being requested from an NPC and were not implicitly granted above then
3821 // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner
3822 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
3823 if (npcModule != null && npcModule.IsNPC(agentID, World))
3824 {
3825 if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID)
3826 {
3827 lock (m_host.TaskInventory)
3828 {
3829 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3830 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3831 }
3832
3833 m_ScriptEngine.PostScriptEvent(
3834 m_item.ItemID,
3835 new EventParams(
3836 "run_time_permissions", new Object[] { new LSL_Integer(perm) }, new DetectParams[0]));
3837 }
3838
3839 // it is an NPC, exit even if the permissions werent granted above, they are not going to answer
3840 // the question!
3841 return;
3842 }
3843
3955 string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); 3844 string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID);
3956 if (ownerName == String.Empty) 3845 if (ownerName == String.Empty)
3957 ownerName = "(hippos)"; 3846 ownerName = "(hippos)";
@@ -3959,8 +3848,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3959 if (!m_waitingForScriptAnswer) 3848 if (!m_waitingForScriptAnswer)
3960 { 3849 {
3961 m_host.TaskInventory.LockItemsForWrite(true); 3850 m_host.TaskInventory.LockItemsForWrite(true);
3962 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3851 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3963 m_host.TaskInventory[invItemID].PermsMask = 0; 3852 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3964 m_host.TaskInventory.LockItemsForWrite(false); 3853 m_host.TaskInventory.LockItemsForWrite(false);
3965 3854
3966 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3855 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3968,16 +3857,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3968 } 3857 }
3969 3858
3970 presence.ControllingClient.SendScriptQuestion( 3859 presence.ControllingClient.SendScriptQuestion(
3971 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3860 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm);
3972 3861
3973 return; 3862 return;
3974 } 3863 }
3975 3864
3976 // Requested agent is not in range, refuse perms 3865 // Requested agent is not in range, refuse perms
3977 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3866 m_ScriptEngine.PostScriptEvent(
3978 "run_time_permissions", new Object[] { 3867 m_item.ItemID,
3979 new LSL_Integer(0) }, 3868 new EventParams("run_time_permissions", new Object[] { new LSL_Integer(0) }, new DetectParams[0]));
3980 new DetectParams[0]));
3981 } 3869 }
3982 3870
3983 void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) 3871 void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer)
@@ -3985,24 +3873,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3985 if (taskID != m_host.UUID) 3873 if (taskID != m_host.UUID)
3986 return; 3874 return;
3987 3875
3988 UUID invItemID = InventorySelf(); 3876 client.OnScriptAnswer -= handleScriptAnswer;
3989 3877 m_waitingForScriptAnswer = false;
3990 if (invItemID == UUID.Zero)
3991 return;
3992
3993 client.OnScriptAnswer-=handleScriptAnswer;
3994 m_waitingForScriptAnswer=false;
3995 3878
3996 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3879 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3997 llReleaseControls(); 3880 llReleaseControls();
3998 3881
3999
4000 m_host.TaskInventory.LockItemsForWrite(true); 3882 m_host.TaskInventory.LockItemsForWrite(true);
4001 m_host.TaskInventory[invItemID].PermsMask = answer; 3883 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
4002 m_host.TaskInventory.LockItemsForWrite(false); 3884 m_host.TaskInventory.LockItemsForWrite(false);
4003 3885
4004 3886 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
4005 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
4006 "run_time_permissions", new Object[] { 3887 "run_time_permissions", new Object[] {
4007 new LSL_Integer(answer) }, 3888 new LSL_Integer(answer) },
4008 new DetectParams[0])); 3889 new DetectParams[0]));
@@ -4012,41 +3893,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4012 { 3893 {
4013 m_host.AddScriptLPS(1); 3894 m_host.AddScriptLPS(1);
4014 3895
4015 m_host.TaskInventory.LockItemsForRead(true); 3896 return m_item.PermsGranter.ToString();
4016
4017 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4018 {
4019 if (item.Type == 10 && item.ItemID == m_itemID)
4020 {
4021 m_host.TaskInventory.LockItemsForRead(false);
4022 return item.PermsGranter.ToString();
4023 }
4024 }
4025 m_host.TaskInventory.LockItemsForRead(false);
4026
4027 return UUID.Zero.ToString();
4028 } 3897 }
4029 3898
4030 public LSL_Integer llGetPermissions() 3899 public LSL_Integer llGetPermissions()
4031 { 3900 {
4032 m_host.AddScriptLPS(1); 3901 m_host.AddScriptLPS(1);
4033 3902
4034 m_host.TaskInventory.LockItemsForRead(true); 3903 int perms = m_item.PermsMask;
4035 3904
4036 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3905 if (m_automaticLinkPermission)
4037 { 3906 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
4038 if (item.Type == 10 && item.ItemID == m_itemID)
4039 {
4040 int perms = item.PermsMask;
4041 if (m_automaticLinkPermission)
4042 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
4043 m_host.TaskInventory.LockItemsForRead(false);
4044 return perms;
4045 }
4046 }
4047 m_host.TaskInventory.LockItemsForRead(false);
4048 3907
4049 return 0; 3908 return perms;
4050 } 3909 }
4051 3910
4052 public LSL_Integer llGetLinkNumber() 3911 public LSL_Integer llGetLinkNumber()
@@ -4084,18 +3943,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4084 public void llCreateLink(string target, int parent) 3943 public void llCreateLink(string target, int parent)
4085 { 3944 {
4086 m_host.AddScriptLPS(1); 3945 m_host.AddScriptLPS(1);
4087 UUID invItemID = InventorySelf(); 3946
4088 UUID targetID; 3947 UUID targetID;
4089 3948
4090 if (!UUID.TryParse(target, out targetID)) 3949 if (!UUID.TryParse(target, out targetID))
4091 return; 3950 return;
4092 3951
4093 TaskInventoryItem item; 3952 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4094 m_host.TaskInventory.LockItemsForRead(true);
4095 item = m_host.TaskInventory[invItemID];
4096 m_host.TaskInventory.LockItemsForRead(false);
4097
4098 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4099 && !m_automaticLinkPermission) 3953 && !m_automaticLinkPermission)
4100 { 3954 {
4101 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3955 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -4103,7 +3957,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4103 } 3957 }
4104 3958
4105 IClientAPI client = null; 3959 IClientAPI client = null;
4106 ScenePresence sp = World.GetScenePresence(item.PermsGranter); 3960 ScenePresence sp = World.GetScenePresence(m_item.PermsGranter);
4107 if (sp != null) 3961 if (sp != null)
4108 client = sp.ControllingClient; 3962 client = sp.ControllingClient;
4109 3963
@@ -4149,18 +4003,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4149 public void llBreakLink(int linknum) 4003 public void llBreakLink(int linknum)
4150 { 4004 {
4151 m_host.AddScriptLPS(1); 4005 m_host.AddScriptLPS(1);
4152 UUID invItemID = InventorySelf();
4153 4006
4154 m_host.TaskInventory.LockItemsForRead(true); 4007 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4155 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 4008 && !m_automaticLinkPermission)
4156 && !m_automaticLinkPermission) 4009 {
4157 { 4010 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4158 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 4011 return;
4159 m_host.TaskInventory.LockItemsForRead(false); 4012 }
4160 return; 4013
4161 }
4162 m_host.TaskInventory.LockItemsForRead(false);
4163
4164 if (linknum < ScriptBaseClass.LINK_THIS) 4014 if (linknum < ScriptBaseClass.LINK_THIS)
4165 return; 4015 return;
4166 4016
@@ -4259,12 +4109,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4259 { 4109 {
4260 m_host.AddScriptLPS(1); 4110 m_host.AddScriptLPS(1);
4261 4111
4262 UUID invItemID = InventorySelf(); 4112 TaskInventoryItem item = m_item;
4263
4264 TaskInventoryItem item;
4265 m_host.TaskInventory.LockItemsForRead(true);
4266 item = m_host.TaskInventory[invItemID];
4267 m_host.TaskInventory.LockItemsForRead(false);
4268 4113
4269 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 4114 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4270 && !m_automaticLinkPermission) 4115 && !m_automaticLinkPermission)
@@ -4461,11 +4306,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4461 public void llGiveInventory(string destination, string inventory) 4306 public void llGiveInventory(string destination, string inventory)
4462 { 4307 {
4463 m_host.AddScriptLPS(1); 4308 m_host.AddScriptLPS(1);
4464 bool found = false; 4309
4465 UUID destId = UUID.Zero; 4310 UUID destId = UUID.Zero;
4466 UUID objId = UUID.Zero;
4467 int assetType = 0;
4468 string objName = String.Empty;
4469 4311
4470 if (!UUID.TryParse(destination, out destId)) 4312 if (!UUID.TryParse(destination, out destId))
4471 { 4313 {
@@ -4473,28 +4315,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4473 return; 4315 return;
4474 } 4316 }
4475 4317
4476 // move the first object found with this inventory name 4318 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
4477 m_host.TaskInventory.LockItemsForRead(true);
4478 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4479 {
4480 if (inv.Value.Name == inventory)
4481 {
4482 found = true;
4483 objId = inv.Key;
4484 assetType = inv.Value.Type;
4485 objName = inv.Value.Name;
4486 break;
4487 }
4488 }
4489 m_host.TaskInventory.LockItemsForRead(false);
4490 4319
4491 if (!found) 4320 if (item == null)
4492 { 4321 {
4493 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4322 llSay(0, String.Format("Could not find object '{0}'", inventory));
4494 return; 4323 return;
4495// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4324// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4496 } 4325 }
4497 4326
4327 UUID objId = item.ItemID;
4328
4498 // check if destination is an object 4329 // check if destination is an object
4499 if (World.GetSceneObjectPart(destId) != null) 4330 if (World.GetSceneObjectPart(destId) != null)
4500 { 4331 {
@@ -4526,14 +4357,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4526 return; 4357 return;
4527 4358
4528 byte[] bucket = new byte[1]; 4359 byte[] bucket = new byte[1];
4529 bucket[0] = (byte)assetType; 4360 bucket[0] = (byte)item.Type;
4530 //byte[] objBytes = agentItem.ID.GetBytes(); 4361 //byte[] objBytes = agentItem.ID.GetBytes();
4531 //Array.Copy(objBytes, 0, bucket, 1, 16); 4362 //Array.Copy(objBytes, 0, bucket, 1, 16);
4532 4363
4533 GridInstantMessage msg = new GridInstantMessage(World, 4364 GridInstantMessage msg = new GridInstantMessage(World,
4534 m_host.OwnerID, m_host.Name, destId, 4365 m_host.OwnerID, m_host.Name, destId,
4535 (byte)InstantMessageDialog.TaskInventoryOffered, 4366 (byte)InstantMessageDialog.TaskInventoryOffered,
4536 false, objName+". "+m_host.Name+" is located at "+ 4367 false, item.Name+". "+m_host.Name+" is located at "+
4537 World.RegionInfo.RegionName+" "+ 4368 World.RegionInfo.RegionName+" "+
4538 m_host.AbsolutePosition.ToString(), 4369 m_host.AbsolutePosition.ToString(),
4539 agentItem.ID, true, m_host.AbsolutePosition, 4370 agentItem.ID, true, m_host.AbsolutePosition,
@@ -4561,27 +4392,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4561 { 4392 {
4562 m_host.AddScriptLPS(1); 4393 m_host.AddScriptLPS(1);
4563 4394
4564 List<TaskInventoryItem> inv; 4395 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
4565 try 4396
4566 { 4397 if (item == null)
4567 m_host.TaskInventory.LockItemsForRead(true); 4398 return;
4568 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); 4399
4569 } 4400 if (item.ItemID == m_item.ItemID)
4570 finally 4401 throw new ScriptDeleteException();
4571 { 4402 else
4572 m_host.TaskInventory.LockItemsForRead(false); 4403 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4573 }
4574 foreach (TaskInventoryItem item in inv)
4575 {
4576 if (item.Name == name)
4577 {
4578 if (item.ItemID == m_itemID)
4579 throw new ScriptDeleteException();
4580 else
4581 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4582 return;
4583 }
4584 }
4585 } 4404 }
4586 4405
4587 public void llSetText(string text, LSL_Vector color, double alpha) 4406 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -4709,8 +4528,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4709 UUID rq = UUID.Random(); 4528 UUID rq = UUID.Random();
4710 4529
4711 UUID tid = AsyncCommands. 4530 UUID tid = AsyncCommands.
4712 DataserverPlugin.RegisterRequest(m_localID, 4531 DataserverPlugin.RegisterRequest(m_host.LocalId,
4713 m_itemID, rq.ToString()); 4532 m_item.ItemID, rq.ToString());
4714 4533
4715 AsyncCommands. 4534 AsyncCommands.
4716 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4535 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -4729,16 +4548,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4729 { 4548 {
4730 m_host.AddScriptLPS(1); 4549 m_host.AddScriptLPS(1);
4731 4550
4732 //Clone is thread safe 4551 foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems())
4733 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4734
4735 foreach (TaskInventoryItem item in itemDictionary.Values)
4736 { 4552 {
4737 if (item.Type == 3 && item.Name == name) 4553 if (item.Type == 3 && item.Name == name)
4738 { 4554 {
4739 UUID tid = AsyncCommands. 4555 UUID tid = AsyncCommands.
4740 DataserverPlugin.RegisterRequest(m_localID, 4556 DataserverPlugin.RegisterRequest(m_host.LocalId,
4741 m_itemID, item.AssetID.ToString()); 4557 m_item.ItemID, item.AssetID.ToString());
4742 4558
4743 Vector3 region = new Vector3( 4559 Vector3 region = new Vector3(
4744 World.RegionInfo.RegionLocX * Constants.RegionSize, 4560 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -4764,6 +4580,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4764 return tid.ToString(); 4580 return tid.ToString();
4765 } 4581 }
4766 } 4582 }
4583
4767 ScriptSleep(1000); 4584 ScriptSleep(1000);
4768 return String.Empty; 4585 return String.Empty;
4769 } 4586 }
@@ -4956,19 +4773,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4956 UUID soundId = UUID.Zero; 4773 UUID soundId = UUID.Zero;
4957 if (!UUID.TryParse(impact_sound, out soundId)) 4774 if (!UUID.TryParse(impact_sound, out soundId))
4958 { 4775 {
4959 m_host.TaskInventory.LockItemsForRead(true); 4776 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound);
4960 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4777
4961 { 4778 if (item != null && item.Type == (int)AssetType.Sound)
4962 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4779 soundId = item.AssetID;
4963 {
4964 soundId = item.AssetID;
4965 break;
4966 }
4967 }
4968 m_host.TaskInventory.LockItemsForRead(false);
4969 } 4780 }
4970 m_host.CollisionSoundVolume = (float)impact_volume; 4781
4971 m_host.CollisionSound = soundId; 4782 m_host.CollisionSound = soundId;
4783 m_host.CollisionSoundVolume = (float)impact_volume;
4972 m_host.CollisionSoundType = 1; 4784 m_host.CollisionSoundType = 1;
4973 } 4785 }
4974 4786
@@ -5010,10 +4822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5010 UUID partItemID; 4822 UUID partItemID;
5011 foreach (SceneObjectPart part in parts) 4823 foreach (SceneObjectPart part in parts)
5012 { 4824 {
5013 //Clone is thread safe 4825 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems())
5014 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
5015
5016 foreach (TaskInventoryItem item in itemsDictionary.Values)
5017 { 4826 {
5018 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT) 4827 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT)
5019 { 4828 {
@@ -5211,22 +5020,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5211 5020
5212 public LSL_String llGetScriptName() 5021 public LSL_String llGetScriptName()
5213 { 5022 {
5214 string result = String.Empty;
5215
5216 m_host.AddScriptLPS(1); 5023 m_host.AddScriptLPS(1);
5217 5024
5218 m_host.TaskInventory.LockItemsForRead(true); 5025 return m_item.Name != null ? m_item.Name : String.Empty;
5219 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
5220 {
5221 if (item.Type == 10 && item.ItemID == m_itemID)
5222 {
5223 result = item.Name!=null?item.Name:String.Empty;
5224 break;
5225 }
5226 }
5227 m_host.TaskInventory.LockItemsForRead(false);
5228
5229 return result;
5230 } 5026 }
5231 5027
5232 public LSL_Integer llGetLinkNumberOfSides(int link) 5028 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -5397,22 +5193,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5397 { 5193 {
5398 m_host.AddScriptLPS(1); 5194 m_host.AddScriptLPS(1);
5399 5195
5400 m_host.TaskInventory.LockItemsForRead(true); 5196 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
5401 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 5197
5198 if (item == null)
5199 return UUID.Zero.ToString();
5200
5201 if ((item.CurrentPermissions
5202 & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5203 == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5402 { 5204 {
5403 if (inv.Value.Name == name) 5205 return item.AssetID.ToString();
5404 {
5405 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5406 {
5407 m_host.TaskInventory.LockItemsForRead(false);
5408 return inv.Value.AssetID.ToString();
5409 }
5410 else
5411 {
5412 m_host.TaskInventory.LockItemsForRead(false);
5413 return UUID.Zero.ToString();
5414 }
5415 }
5416 } 5206 }
5417 m_host.TaskInventory.LockItemsForRead(false); 5207 m_host.TaskInventory.LockItemsForRead(false);
5418 5208
@@ -6360,7 +6150,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6360 } 6150 }
6361 } 6151 }
6362 } 6152 }
6363 List<UUID> presenceIds = new List<UUID>();
6364 6153
6365 World.ForEachRootScenePresence( 6154 World.ForEachRootScenePresence(
6366 delegate (ScenePresence ssp) 6155 delegate (ScenePresence ssp)
@@ -6511,7 +6300,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6511 if (m_host.OwnerID == land.LandData.OwnerID) 6300 if (m_host.OwnerID == land.LandData.OwnerID)
6512 { 6301 {
6513 Vector3 pos = World.GetNearestAllowedPosition(presence, land); 6302 Vector3 pos = World.GetNearestAllowedPosition(presence, land);
6514 presence.TeleportWithMomentum(pos); 6303 presence.TeleportWithMomentum(pos, null);
6515 presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); 6304 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
6516 } 6305 }
6517 } 6306 }
@@ -7036,22 +6825,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7036 } 6825 }
7037 } 6826 }
7038 6827
7039 protected UUID GetTaskInventoryItem(string name)
7040 {
7041 m_host.TaskInventory.LockItemsForRead(true);
7042 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
7043 {
7044 if (inv.Value.Name == name)
7045 {
7046 m_host.TaskInventory.LockItemsForRead(false);
7047 return inv.Key;
7048 }
7049 }
7050 m_host.TaskInventory.LockItemsForRead(false);
7051
7052 return UUID.Zero;
7053 }
7054
7055 public void llGiveInventoryList(string destination, string category, LSL_List inventory) 6828 public void llGiveInventoryList(string destination, string category, LSL_List inventory)
7056 { 6829 {
7057 m_host.AddScriptLPS(1); 6830 m_host.AddScriptLPS(1);
@@ -7064,16 +6837,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7064 6837
7065 foreach (Object item in inventory.Data) 6838 foreach (Object item in inventory.Data)
7066 { 6839 {
6840 string rawItemString = item.ToString();
6841
7067 UUID itemID; 6842 UUID itemID;
7068 if (UUID.TryParse(item.ToString(), out itemID)) 6843 if (UUID.TryParse(rawItemString, out itemID))
7069 { 6844 {
7070 itemList.Add(itemID); 6845 itemList.Add(itemID);
7071 } 6846 }
7072 else 6847 else
7073 { 6848 {
7074 itemID = GetTaskInventoryItem(item.ToString()); 6849 TaskInventoryItem taskItem = m_host.Inventory.GetInventoryItem(rawItemString);
7075 if (itemID != UUID.Zero) 6850
7076 itemList.Add(itemID); 6851 if (taskItem != null)
6852 itemList.Add(taskItem.ItemID);
7077 } 6853 }
7078 } 6854 }
7079 6855
@@ -7395,9 +7171,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7395 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) 7171 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
7396 { 7172 {
7397 m_host.AddScriptLPS(1); 7173 m_host.AddScriptLPS(1);
7398 bool found = false; 7174
7399 UUID destId = UUID.Zero; 7175 UUID destId = UUID.Zero;
7400 UUID srcId = UUID.Zero;
7401 7176
7402 if (!UUID.TryParse(target, out destId)) 7177 if (!UUID.TryParse(target, out destId))
7403 { 7178 {
@@ -7412,25 +7187,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7412 } 7187 }
7413 7188
7414 // copy the first script found with this inventory name 7189 // copy the first script found with this inventory name
7415 TaskInventoryItem scriptItem = null; 7190 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
7416 m_host.TaskInventory.LockItemsForRead(true);
7417 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
7418 {
7419 if (inv.Value.Name == name)
7420 {
7421 // make sure the object is a script
7422 if (10 == inv.Value.Type)
7423 {
7424 found = true;
7425 srcId = inv.Key;
7426 scriptItem = inv.Value;
7427 break;
7428 }
7429 }
7430 }
7431 m_host.TaskInventory.LockItemsForRead(false);
7432 7191
7433 if (!found) 7192 // make sure the object is a script
7193 if (item == null || item.Type != 10)
7434 { 7194 {
7435 llSay(0, "Could not find script " + name); 7195 llSay(0, "Could not find script " + name);
7436 return; 7196 return;
@@ -7439,13 +7199,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7439 SceneObjectPart dest = World.GetSceneObjectPart(destId); 7199 SceneObjectPart dest = World.GetSceneObjectPart(destId);
7440 if (dest != null) 7200 if (dest != null)
7441 { 7201 {
7442 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) 7202 if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
7443 { 7203 {
7444 // the rest of the permission checks are done in RezScript, so check the pin there as well 7204 // the rest of the permission checks are done in RezScript, so check the pin there as well
7445 World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); 7205 World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param);
7446 7206
7447 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0) 7207 if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0)
7448 m_host.Inventory.RemoveInventoryItem(srcId); 7208 m_host.Inventory.RemoveInventoryItem(item.ItemID);
7449 } 7209 }
7450 } 7210 }
7451 // this will cause the delay even if the script pin or permissions were wrong - seems ok 7211 // this will cause the delay even if the script pin or permissions were wrong - seems ok
@@ -7458,14 +7218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7458 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7218 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7459 if (xmlrpcMod.IsEnabled()) 7219 if (xmlrpcMod.IsEnabled())
7460 { 7220 {
7461 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); 7221 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero);
7462 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); 7222 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
7463 if (xmlRpcRouter != null) 7223 if (xmlRpcRouter != null)
7464 { 7224 {
7465 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; 7225 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName;
7466 7226
7467 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, 7227 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID,
7468 m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, 7228 m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName,
7469 xmlrpcMod.Port.ToString())); 7229 xmlrpcMod.Port.ToString()));
7470 } 7230 }
7471 object[] resobj = new object[] 7231 object[] resobj = new object[]
@@ -7477,7 +7237,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7477 new LSL_Integer(0), 7237 new LSL_Integer(0),
7478 new LSL_String(String.Empty) 7238 new LSL_String(String.Empty)
7479 }; 7239 };
7480 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, 7240 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj,
7481 new DetectParams[0])); 7241 new DetectParams[0]));
7482 } 7242 }
7483 ScriptSleep(1000); 7243 ScriptSleep(1000);
@@ -7488,7 +7248,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7488 m_host.AddScriptLPS(1); 7248 m_host.AddScriptLPS(1);
7489 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7249 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7490 ScriptSleep(3000); 7250 ScriptSleep(3000);
7491 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); 7251 return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString();
7492 } 7252 }
7493 7253
7494 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) 7254 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@@ -8475,7 +8235,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8475 return; 8235 return;
8476 face = (int)rules.GetLSLIntegerItem(idx++); 8236 face = (int)rules.GetLSLIntegerItem(idx++);
8477 int shiny = (int)rules.GetLSLIntegerItem(idx++); 8237 int shiny = (int)rules.GetLSLIntegerItem(idx++);
8478 Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); 8238 Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++);
8479 8239
8480 SetShiny(part, face, shiny, bump); 8240 SetShiny(part, face, shiny, bump);
8481 8241
@@ -10317,7 +10077,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10317 public LSL_String llGetSimulatorHostname() 10077 public LSL_String llGetSimulatorHostname()
10318 { 10078 {
10319 m_host.AddScriptLPS(1); 10079 m_host.AddScriptLPS(1);
10320 return System.Environment.MachineName; 10080 IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>();
10081 return UrlModule.ExternalHostNameForLSL;
10321 } 10082 }
10322 10083
10323 // <summary> 10084 // <summary>
@@ -10554,92 +10315,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10554 } 10315 }
10555 } 10316 }
10556 10317
10557 public LSL_Integer llGetInventoryPermMask(string item, int mask) 10318 public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
10558 { 10319 {
10559 m_host.AddScriptLPS(1); 10320 m_host.AddScriptLPS(1);
10560 10321
10561 m_host.TaskInventory.LockItemsForRead(true); 10322 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10562 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10323
10324 if (item == null)
10325 return -1;
10326
10327 switch (mask)
10563 { 10328 {
10564 if (inv.Value.Name == item) 10329 case 0:
10565 { 10330 return (int)item.BasePermissions;
10566 m_host.TaskInventory.LockItemsForRead(false); 10331 case 1:
10567 switch (mask) 10332 return (int)item.CurrentPermissions;
10568 { 10333 case 2:
10569 case 0: 10334 return (int)item.GroupPermissions;
10570 return (int)inv.Value.BasePermissions; 10335 case 3:
10571 case 1: 10336 return (int)item.EveryonePermissions;
10572 return (int)inv.Value.CurrentPermissions; 10337 case 4:
10573 case 2: 10338 return (int)item.NextPermissions;
10574 return (int)inv.Value.GroupPermissions;
10575 case 3:
10576 return (int)inv.Value.EveryonePermissions;
10577 case 4:
10578 return (int)inv.Value.NextPermissions;
10579 }
10580 }
10581 } 10339 }
10582 m_host.TaskInventory.LockItemsForRead(false); 10340 m_host.TaskInventory.LockItemsForRead(false);
10583 10341
10584 return -1; 10342 return -1;
10585 } 10343 }
10586 10344
10587 public void llSetInventoryPermMask(string item, int mask, int value) 10345 public void llSetInventoryPermMask(string itemName, int mask, int value)
10588 { 10346 {
10589 m_host.AddScriptLPS(1); 10347 m_host.AddScriptLPS(1);
10348
10590 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) 10349 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
10591 { 10350 {
10592 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 10351 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
10593 { 10352 {
10594 lock (m_host.TaskInventory) 10353 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10354
10355 if (item != null)
10595 { 10356 {
10596 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10357 switch (mask)
10597 { 10358 {
10598 if (inv.Value.Name == item) 10359 case 0:
10599 { 10360 item.BasePermissions = (uint)value;
10600 switch (mask) 10361 break;
10601 { 10362 case 1:
10602 case 0: 10363 item.CurrentPermissions = (uint)value;
10603 inv.Value.BasePermissions = (uint)value; 10364 break;
10604 break; 10365 case 2:
10605 case 1: 10366 item.GroupPermissions = (uint)value;
10606 inv.Value.CurrentPermissions = (uint)value; 10367 break;
10607 break; 10368 case 3:
10608 case 2: 10369 item.EveryonePermissions = (uint)value;
10609 inv.Value.GroupPermissions = (uint)value; 10370 break;
10610 break; 10371 case 4:
10611 case 3: 10372 item.NextPermissions = (uint)value;
10612 inv.Value.EveryonePermissions = (uint)value; 10373 break;
10613 break;
10614 case 4:
10615 inv.Value.NextPermissions = (uint)value;
10616 break;
10617 }
10618 }
10619 } 10374 }
10620 } 10375 }
10621 } 10376 }
10622 } 10377 }
10623 } 10378 }
10624 10379
10625 public LSL_String llGetInventoryCreator(string item) 10380 public LSL_String llGetInventoryCreator(string itemName)
10626 { 10381 {
10627 m_host.AddScriptLPS(1); 10382 m_host.AddScriptLPS(1);
10628 10383
10629 m_host.TaskInventory.LockItemsForRead(true); 10384 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10630 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10385
10386 if (item == null)
10631 { 10387 {
10632 if (inv.Value.Name == item) 10388 llSay(0, "No item name '" + item + "'");
10633 {
10634 m_host.TaskInventory.LockItemsForRead(false);
10635 return inv.Value.CreatorID.ToString();
10636 }
10637 }
10638 m_host.TaskInventory.LockItemsForRead(false);
10639 10389
10640 llSay(0, "No item name '" + item + "'"); 10390 return String.Empty;
10391 }
10641 10392
10642 return String.Empty; 10393 return item.CreatorID.ToString();
10643 } 10394 }
10644 10395
10645 public void llOwnerSay(string msg) 10396 public void llOwnerSay(string msg)
@@ -10656,13 +10407,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10656 { 10407 {
10657 m_host.AddScriptLPS(1); 10408 m_host.AddScriptLPS(1);
10658 if (m_UrlModule != null) 10409 if (m_UrlModule != null)
10659 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 10410 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
10660 return UUID.Zero.ToString(); 10411 return UUID.Zero.ToString();
10661 } 10412 }
10662 10413
10663 public LSL_String llRequestSimulatorData(string simulator, int data) 10414 public LSL_String llRequestSimulatorData(string simulator, int data)
10664 { 10415 {
10665 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 10416 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
10666 10417
10667 try 10418 try
10668 { 10419 {
@@ -10672,7 +10423,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10672 10423
10673 GridRegion info; 10424 GridRegion info;
10674 10425
10675 if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) 10426 if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator?
10427
10676 info = new GridRegion(m_ScriptEngine.World.RegionInfo); 10428 info = new GridRegion(m_ScriptEngine.World.RegionInfo);
10677 else 10429 else
10678 info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); 10430 info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator);
@@ -10685,10 +10437,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10685 ScriptSleep(1000); 10437 ScriptSleep(1000);
10686 return UUID.Zero.ToString(); 10438 return UUID.Zero.ToString();
10687 } 10439 }
10688 reply = new LSL_Vector( 10440 if (m_ScriptEngine.World.RegionInfo.RegionName != simulator)
10689 info.RegionLocX, 10441 {
10690 info.RegionLocY, 10442 //Hypergrid Region co-ordinates
10691 0).ToString(); 10443 uint rx = 0, ry = 0;
10444 Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry);
10445
10446 reply = new LSL_Vector(
10447 rx,
10448 ry,
10449 0).ToString();
10450 }
10451 else
10452 {
10453 //Local-cooridnates
10454 reply = new LSL_Vector(
10455 info.RegionLocX,
10456 info.RegionLocY,
10457 0).ToString();
10458 }
10692 break; 10459 break;
10693 case ScriptBaseClass.DATA_SIM_STATUS: 10460 case ScriptBaseClass.DATA_SIM_STATUS:
10694 if (info != null) 10461 if (info != null)
@@ -10724,7 +10491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10724 UUID rq = UUID.Random(); 10491 UUID rq = UUID.Random();
10725 10492
10726 UUID tid = AsyncCommands. 10493 UUID tid = AsyncCommands.
10727 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 10494 DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
10728 10495
10729 AsyncCommands. 10496 AsyncCommands.
10730 DataserverPlugin.DataserverReply(rq.ToString(), reply); 10497 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -10743,7 +10510,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10743 m_host.AddScriptLPS(1); 10510 m_host.AddScriptLPS(1);
10744 10511
10745 if (m_UrlModule != null) 10512 if (m_UrlModule != null)
10746 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 10513 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
10747 return UUID.Zero.ToString(); 10514 return UUID.Zero.ToString();
10748 } 10515 }
10749 10516
@@ -10779,7 +10546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10779 // child agents have a mass of 1.0 10546 // child agents have a mass of 1.0
10780 return 1; 10547 return 1;
10781 else 10548 else
10782 return avatar.GetMass(); 10549 return (double)avatar.GetMass();
10783 } 10550 }
10784 catch (KeyNotFoundException) 10551 catch (KeyNotFoundException)
10785 { 10552 {
@@ -11183,18 +10950,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11183 { 10950 {
11184 m_host.AddScriptLPS(1); 10951 m_host.AddScriptLPS(1);
11185 10952
11186 m_host.TaskInventory.LockItemsForRead(true); 10953 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
11187 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
11188 {
11189 if (inv.Value.Name == name)
11190 {
11191 m_host.TaskInventory.LockItemsForRead(false);
11192 return inv.Value.Type;
11193 }
11194 }
11195 m_host.TaskInventory.LockItemsForRead(false);
11196 10954
11197 return -1; 10955 if (item == null)
10956 return -1;
10957
10958 return item.Type;
11198 } 10959 }
11199 10960
11200 public void llSetPayPrice(int price, LSL_List quick_pay_buttons) 10961 public void llSetPayPrice(int price, LSL_List quick_pay_buttons)
@@ -11222,32 +10983,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11222 public LSL_Vector llGetCameraPos() 10983 public LSL_Vector llGetCameraPos()
11223 { 10984 {
11224 m_host.AddScriptLPS(1); 10985 m_host.AddScriptLPS(1);
11225 UUID invItemID = InventorySelf();
11226 10986
11227 if (invItemID == UUID.Zero) 10987 if (m_item.PermsGranter == UUID.Zero)
11228 return new LSL_Vector(); 10988 return new LSL_Vector();
11229
11230 m_host.TaskInventory.LockItemsForRead(true);
11231
11232 UUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
11233
11234// if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
11235 if (agentID == UUID.Zero)
11236 {
11237 m_host.TaskInventory.LockItemsForRead(false);
11238 return new LSL_Vector();
11239 }
11240 10989
11241 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10990 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11242 { 10991 {
11243 ShoutError("No permissions to track the camera"); 10992 ShoutError("No permissions to track the camera");
11244 m_host.TaskInventory.LockItemsForRead(false);
11245 return new LSL_Vector(); 10993 return new LSL_Vector();
11246 } 10994 }
11247 m_host.TaskInventory.LockItemsForRead(false);
11248 10995
11249// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 10996// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11250 ScenePresence presence = World.GetScenePresence(agentID); 10997 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
11251 if (presence != null) 10998 if (presence != null)
11252 { 10999 {
11253 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); 11000 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z);
@@ -11259,30 +11006,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11259 public LSL_Rotation llGetCameraRot() 11006 public LSL_Rotation llGetCameraRot()
11260 { 11007 {
11261 m_host.AddScriptLPS(1); 11008 m_host.AddScriptLPS(1);
11262 UUID invItemID = InventorySelf();
11263 if (invItemID == UUID.Zero)
11264 return new LSL_Rotation();
11265
11266 m_host.TaskInventory.LockItemsForRead(true);
11267 11009
11268 UUID agentID = m_host.TaskInventory[invItemID].PermsGranter; 11010 if (m_item.PermsGranter == UUID.Zero)
11011 return new LSL_Rotation();
11269 11012
11270// if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 11013 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11271 if (agentID == UUID.Zero)
11272 {
11273 m_host.TaskInventory.LockItemsForRead(false);
11274 return new LSL_Rotation();
11275 }
11276 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
11277 { 11014 {
11278 ShoutError("No permissions to track the camera"); 11015 ShoutError("No permissions to track the camera");
11279 m_host.TaskInventory.LockItemsForRead(false);
11280 return new LSL_Rotation(); 11016 return new LSL_Rotation();
11281 } 11017 }
11282 m_host.TaskInventory.LockItemsForRead(false);
11283 11018
11284// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 11019// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11285 ScenePresence presence = World.GetScenePresence(agentID); 11020 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
11286 if (presence != null) 11021 if (presence != null)
11287 { 11022 {
11288 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); 11023 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W);
@@ -11341,7 +11076,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11341 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) 11076 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
11342 { 11077 {
11343 m_host.AddScriptLPS(1); 11078 m_host.AddScriptLPS(1);
11344 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 11079 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
11345 if (detectedParams == null) 11080 if (detectedParams == null)
11346 { 11081 {
11347 if (m_host.ParentGroup.IsAttachment == true) 11082 if (m_host.ParentGroup.IsAttachment == true)
@@ -11465,30 +11200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11465 { 11200 {
11466 m_host.AddScriptLPS(1); 11201 m_host.AddScriptLPS(1);
11467 11202
11468 // our key in the object we are in
11469 UUID invItemID = InventorySelf();
11470 if (invItemID == UUID.Zero) return;
11471
11472 // the object we are in 11203 // the object we are in
11473 UUID objectID = m_host.ParentUUID; 11204 UUID objectID = m_host.ParentUUID;
11474 if (objectID == UUID.Zero) return; 11205 if (objectID == UUID.Zero)
11206 return;
11475 11207
11476 UUID agentID;
11477 m_host.TaskInventory.LockItemsForRead(true);
11478 // we need the permission first, to know which avatar we want to set the camera for 11208 // we need the permission first, to know which avatar we want to set the camera for
11479 agentID = m_host.TaskInventory[invItemID].PermsGranter; 11209 UUID agentID = m_item.PermsGranter;
11480 11210
11481 if (agentID == UUID.Zero) 11211 if (agentID == UUID.Zero)
11482 {
11483 m_host.TaskInventory.LockItemsForRead(false);
11484 return; 11212 return;
11485 } 11213
11486 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 11214 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
11487 {
11488 m_host.TaskInventory.LockItemsForRead(false);
11489 return; 11215 return;
11490 }
11491 m_host.TaskInventory.LockItemsForRead(false);
11492 11216
11493 ScenePresence presence = World.GetScenePresence(agentID); 11217 ScenePresence presence = World.GetScenePresence(agentID);
11494 11218
@@ -11530,34 +11254,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11530 { 11254 {
11531 m_host.AddScriptLPS(1); 11255 m_host.AddScriptLPS(1);
11532 11256
11533 // our key in the object we are in
11534 UUID invItemID=InventorySelf();
11535 if (invItemID == UUID.Zero) return;
11536
11537 // the object we are in 11257 // the object we are in
11538 UUID objectID = m_host.ParentUUID; 11258 UUID objectID = m_host.ParentUUID;
11539 if (objectID == UUID.Zero) return; 11259 if (objectID == UUID.Zero)
11260 return;
11540 11261
11541 // we need the permission first, to know which avatar we want to clear the camera for 11262 // we need the permission first, to know which avatar we want to clear the camera for
11542 UUID agentID; 11263 UUID agentID = m_item.PermsGranter;
11543 m_host.TaskInventory.LockItemsForRead(true); 11264
11544 agentID = m_host.TaskInventory[invItemID].PermsGranter;
11545 if (agentID == UUID.Zero) 11265 if (agentID == UUID.Zero)
11546 {
11547 m_host.TaskInventory.LockItemsForRead(false);
11548 return; 11266 return;
11549 } 11267
11550 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 11268 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
11551 {
11552 m_host.TaskInventory.LockItemsForRead(false);
11553 return; 11269 return;
11554 }
11555 m_host.TaskInventory.LockItemsForRead(false);
11556 11270
11557 ScenePresence presence = World.GetScenePresence(agentID); 11271 ScenePresence presence = World.GetScenePresence(agentID);
11558 11272
11559 // we are not interested in child-agents 11273 // we are not interested in child-agents
11560 if (presence.IsChildAgent) return; 11274 if (presence.IsChildAgent)
11275 return;
11561 11276
11562 presence.ControllingClient.SendClearFollowCamProperties(objectID); 11277 presence.ControllingClient.SendClearFollowCamProperties(objectID);
11563 } 11278 }
@@ -11748,8 +11463,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11748 } 11463 }
11749 } 11464 }
11750 11465
11751 UUID reqID = httpScriptMod. 11466 UUID reqID
11752 StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); 11467 = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body);
11753 11468
11754 if (reqID != UUID.Zero) 11469 if (reqID != UUID.Zero)
11755 return reqID.ToString(); 11470 return reqID.ToString();
@@ -12003,19 +11718,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12003 break; 11718 break;
12004 // For the following 8 see the Object version below 11719 // For the following 8 see the Object version below
12005 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11720 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
12006 ret.Add(new LSL_Integer(0)); 11721 ret.Add(new LSL_Integer(av.RunningScriptCount()));
12007 break; 11722 break;
12008 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11723 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
12009 ret.Add(new LSL_Integer(0)); 11724 ret.Add(new LSL_Integer(av.ScriptCount()));
12010 break; 11725 break;
12011 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11726 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
12012 ret.Add(new LSL_Integer(0)); 11727 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
12013 break; 11728 break;
12014 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11729 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
12015 ret.Add(new LSL_Float(0)); 11730 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
12016 break; 11731 break;
12017 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11732 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
12018 ret.Add(new LSL_Integer(0)); 11733 ret.Add(new LSL_Integer(1));
12019 break; 11734 break;
12020 case ScriptBaseClass.OBJECT_SERVER_COST: 11735 case ScriptBaseClass.OBJECT_SERVER_COST:
12021 ret.Add(new LSL_Float(0)); 11736 ret.Add(new LSL_Float(0));
@@ -12073,37 +11788,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12073 case ScriptBaseClass.OBJECT_CREATOR: 11788 case ScriptBaseClass.OBJECT_CREATOR:
12074 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11789 ret.Add(new LSL_String(obj.CreatorID.ToString()));
12075 break; 11790 break;
12076 // The following 8 I have intentionaly coded to return zero. They are part of
12077 // "Land Impact" calculations. These calculations are probably not applicable
12078 // to OpenSim, required figures (cpu/memory usage) are not currently tracked
12079 // I have intentionally left these all at zero rather than return possibly
12080 // missleading numbers
12081 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11791 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
12082 // in SL this currently includes crashed scripts 11792 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
12083 ret.Add(new LSL_Integer(0));
12084 break; 11793 break;
12085 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11794 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
12086 ret.Add(new LSL_Integer(0)); 11795 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
12087 break; 11796 break;
12088 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11797 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
12089 // The value returned in SL for mono scripts is 65536 * number of active scripts 11798 // The value returned in SL for mono scripts is 65536 * number of active scripts
12090 ret.Add(new LSL_Integer(0)); 11799 // and 16384 * number of active scripts for LSO. since llGetFreememory
11800 // is coded to give the LSO value use it here
11801 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
12091 break; 11802 break;
12092 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11803 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
12093 // Average cpu time per simulator frame expended on all scripts in the objetc 11804 // Average cpu time in seconds per simulator frame expended on all scripts in the object
12094 ret.Add(new LSL_Float(0)); 11805 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
12095 break; 11806 break;
12096 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11807 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
12097 // according to the SL wiki A prim or linkset will have prim 11808 // according to the SL wiki A prim or linkset will have prim
12098 // equivalent of the number of prims in a linkset if it does not 11809 // equivalent of the number of prims in a linkset if it does not
12099 // contain a mesh anywhere in the link set or is not a normal prim 11810 // contain a mesh anywhere in the link set or is not a normal prim
12100 // The value returned in SL for normal prims is prim count 11811 // The value returned in SL for normal prims is prim count
12101 ret.Add(new LSL_Integer(0)); 11812 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
12102 break; 11813 break;
12103 11814
12104 // costs below may need to be diferent for root parts, need to check 11815 // costs below may need to be diferent for root parts, need to check
12105 case ScriptBaseClass.OBJECT_SERVER_COST: 11816 case ScriptBaseClass.OBJECT_SERVER_COST:
12106 // The value returned in SL for normal prims is prim count 11817 // The linden calculation is here
11818 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11819 // The value returned in SL for normal prims looks like the prim count
12107 ret.Add(new LSL_Float(0)); 11820 ret.Add(new LSL_Float(0));
12108 break; 11821 break;
12109 case ScriptBaseClass.OBJECT_STREAMING_COST: 11822 case ScriptBaseClass.OBJECT_STREAMING_COST:
@@ -12128,22 +11841,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12128 return new LSL_List(); 11841 return new LSL_List();
12129 } 11842 }
12130 11843
12131 internal UUID ScriptByName(string name) 11844 internal UUID GetScriptByName(string name)
12132 { 11845 {
12133 m_host.TaskInventory.LockItemsForRead(true); 11846 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12134 11847
12135 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 11848 if (item == null || item.Type != 10)
12136 { 11849 return UUID.Zero;
12137 if (item.Type == 10 && item.Name == name)
12138 {
12139 m_host.TaskInventory.LockItemsForRead(false);
12140 return item.ItemID;
12141 }
12142 }
12143
12144 m_host.TaskInventory.LockItemsForRead(false);
12145 11850
12146 return UUID.Zero; 11851 return item.ItemID;
12147 } 11852 }
12148 11853
12149 internal void ShoutError(string msg) 11854 internal void ShoutError(string msg)
@@ -12183,21 +11888,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12183 { 11888 {
12184 m_host.AddScriptLPS(1); 11889 m_host.AddScriptLPS(1);
12185 11890
12186 //Clone is thread safe
12187 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
12188
12189 UUID assetID = UUID.Zero; 11891 UUID assetID = UUID.Zero;
12190 11892
12191 if (!UUID.TryParse(name, out assetID)) 11893 if (!UUID.TryParse(name, out assetID))
12192 { 11894 {
12193 foreach (TaskInventoryItem item in itemsDictionary.Values) 11895 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12194 { 11896
12195 if (item.Type == 7 && item.Name == name) 11897 if (item != null && item.Type == 7)
12196 { 11898 assetID = item.AssetID;
12197 assetID = item.AssetID;
12198 break;
12199 }
12200 }
12201 } 11899 }
12202 11900
12203 if (assetID == UUID.Zero) 11901 if (assetID == UUID.Zero)
@@ -12209,7 +11907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12209 } 11907 }
12210 11908
12211 // was: UUID tid = tid = AsyncCommands. 11909 // was: UUID tid = tid = AsyncCommands.
12212 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11910 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
12213 11911
12214 if (NotecardCache.IsCached(assetID)) 11912 if (NotecardCache.IsCached(assetID))
12215 { 11913 {
@@ -12228,9 +11926,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12228 return; 11926 return;
12229 } 11927 }
12230 11928
12231 System.Text.UTF8Encoding enc = 11929 string data = Encoding.UTF8.GetString(a.Data);
12232 new System.Text.UTF8Encoding();
12233 string data = enc.GetString(a.Data);
12234 //m_log.Debug(data); 11930 //m_log.Debug(data);
12235 NotecardCache.Cache(id, data); 11931 NotecardCache.Cache(id, data);
12236 AsyncCommands. 11932 AsyncCommands.
@@ -12246,21 +11942,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12246 { 11942 {
12247 m_host.AddScriptLPS(1); 11943 m_host.AddScriptLPS(1);
12248 11944
12249 //Clone is thread safe
12250 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
12251
12252 UUID assetID = UUID.Zero; 11945 UUID assetID = UUID.Zero;
12253 11946
12254 if (!UUID.TryParse(name, out assetID)) 11947 if (!UUID.TryParse(name, out assetID))
12255 { 11948 {
12256 foreach (TaskInventoryItem item in itemsDictionary.Values) 11949 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
12257 { 11950
12258 if (item.Type == 7 && item.Name == name) 11951 if (item != null && item.Type == 7)
12259 { 11952 assetID = item.AssetID;
12260 assetID = item.AssetID;
12261 break;
12262 }
12263 }
12264 } 11953 }
12265 11954
12266 if (assetID == UUID.Zero) 11955 if (assetID == UUID.Zero)
@@ -12272,7 +11961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12272 } 11961 }
12273 11962
12274 // was: UUID tid = tid = AsyncCommands. 11963 // was: UUID tid = tid = AsyncCommands.
12275 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11964 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
12276 11965
12277 if (NotecardCache.IsCached(assetID)) 11966 if (NotecardCache.IsCached(assetID))
12278 { 11967 {
@@ -12290,9 +11979,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12290 return; 11979 return;
12291 } 11980 }
12292 11981
12293 System.Text.UTF8Encoding enc = 11982 string data = Encoding.UTF8.GetString(a.Data);
12294 new System.Text.UTF8Encoding();
12295 string data = enc.GetString(a.Data);
12296 //m_log.Debug(data); 11983 //m_log.Debug(data);
12297 NotecardCache.Cache(id, data); 11984 NotecardCache.Cache(id, data);
12298 AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), 11985 AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(),
@@ -12356,7 +12043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12356 { 12043 {
12357 UUID rq = UUID.Random(); 12044 UUID rq = UUID.Random();
12358 12045
12359 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 12046 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
12360 12047
12361 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); 12048 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
12362 12049
@@ -12372,7 +12059,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12372 { 12059 {
12373 UUID rq = UUID.Random(); 12060 UUID rq = UUID.Random();
12374 12061
12375 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 12062 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
12376 12063
12377 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); 12064 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
12378 12065
@@ -12574,7 +12261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12574 { 12261 {
12575 Tri t1 = new Tri(); 12262 Tri t1 = new Tri();
12576 Tri t2 = new Tri(); 12263 Tri t2 = new Tri();
12577 12264
12578 Vector3 p1 = new Vector3(x-1, y-1, (float)heightfield[x-1, y-1]); 12265 Vector3 p1 = new Vector3(x-1, y-1, (float)heightfield[x-1, y-1]);
12579 Vector3 p2 = new Vector3(x, y-1, (float)heightfield[x, y-1]); 12266 Vector3 p2 = new Vector3(x, y-1, (float)heightfield[x, y-1]);
12580 Vector3 p3 = new Vector3(x, y, (float)heightfield[x, y]); 12267 Vector3 p3 = new Vector3(x, y, (float)heightfield[x, y]);
@@ -12615,7 +12302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12615 // sometimes 12302 // sometimes
12616 if (Math.Abs(b) < 0.000001) 12303 if (Math.Abs(b) < 0.000001)
12617 continue; 12304 continue;
12618 12305
12619 double r = a / b; 12306 double r = a / b;
12620 12307
12621 // ray points away from plane 12308 // ray points away from plane
@@ -12875,7 +12562,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12875 bool isAccount = false; 12562 bool isAccount = false;
12876 bool isGroup = false; 12563 bool isGroup = false;
12877 12564
12878 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) 12565 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
12879 return 0; 12566 return 0;
12880 12567
12881 UUID id = new UUID(); 12568 UUID id = new UUID();
@@ -12937,35 +12624,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12937 return 1; 12624 return 1;
12938 } 12625 }
12939 12626
12940 #region Not Implemented 12627 public LSL_Integer llGetMemoryLimit()
12941 // 12628 {
12942 // Listing the unimplemented lsl functions here, please move 12629 m_host.AddScriptLPS(1);
12943 // them from this region as they are completed 12630 // The value returned for LSO scripts in SL
12944 // 12631 return 16384;
12632 }
12945 12633
12946 public void llGetEnv(LSL_String name) 12634 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
12947 { 12635 {
12948 m_host.AddScriptLPS(1); 12636 m_host.AddScriptLPS(1);
12949 NotImplemented("llGetEnv"); 12637 // Treat as an LSO script
12638 return ScriptBaseClass.FALSE;
12950 } 12639 }
12951 12640
12952 public void llGetSPMaxMemory() 12641 public LSL_Integer llGetSPMaxMemory()
12953 { 12642 {
12954 m_host.AddScriptLPS(1); 12643 m_host.AddScriptLPS(1);
12955 NotImplemented("llGetSPMaxMemory"); 12644 // The value returned for LSO scripts in SL
12645 return 16384;
12956 } 12646 }
12957 12647
12958 public virtual LSL_Integer llGetUsedMemory() 12648 public virtual LSL_Integer llGetUsedMemory()
12959 { 12649 {
12960 m_host.AddScriptLPS(1); 12650 m_host.AddScriptLPS(1);
12961 NotImplemented("llGetUsedMemory"); 12651 // The value returned for LSO scripts in SL
12962 return 0; 12652 return 16384;
12963 } 12653 }
12964 12654
12965 public void llScriptProfiler(LSL_Integer flags) 12655 public void llScriptProfiler(LSL_Integer flags)
12966 { 12656 {
12967 m_host.AddScriptLPS(1); 12657 m_host.AddScriptLPS(1);
12968 //NotImplemented("llScriptProfiler"); 12658 // This does nothing for LSO scripts in SL
12659 }
12660
12661 #region Not Implemented
12662 //
12663 // Listing the unimplemented lsl functions here, please move
12664 // them from this region as they are completed
12665 //
12666
12667 public void llGetEnv(LSL_String name)
12668 {
12669 m_host.AddScriptLPS(1);
12670 NotImplemented("llGetEnv");
12969 } 12671 }
12970 12672
12971 public void llSetSoundQueueing(int queue) 12673 public void llSetSoundQueueing(int queue)
@@ -13045,8 +12747,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13045 12747
13046 try 12748 try
13047 { 12749 {
13048 UUID invItemID=InventorySelf(); 12750 TaskInventoryItem item = m_item;
13049 if (invItemID == UUID.Zero) 12751 if (item == null)
13050 { 12752 {
13051 replydata = "SERVICE_ERROR"; 12753 replydata = "SERVICE_ERROR";
13052 return; 12754 return;
@@ -13054,10 +12756,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13054 12756
13055 m_host.AddScriptLPS(1); 12757 m_host.AddScriptLPS(1);
13056 12758
13057 m_host.TaskInventory.LockItemsForRead(true);
13058 TaskInventoryItem item = m_host.TaskInventory[invItemID];
13059 m_host.TaskInventory.LockItemsForRead(false);
13060
13061 if (item.PermsGranter == UUID.Zero) 12759 if (item.PermsGranter == UUID.Zero)
13062 { 12760 {
13063 replydata = "MISSING_PERMISSION_DEBIT"; 12761 replydata = "MISSING_PERMISSION_DEBIT";
@@ -13099,7 +12797,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13099 } 12797 }
13100 finally 12798 finally
13101 { 12799 {
13102 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 12800 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
13103 "transaction_result", new Object[] { 12801 "transaction_result", new Object[] {
13104 new LSL_String(txn.ToString()), 12802 new LSL_String(txn.ToString()),
13105 new LSL_Integer(replycode), 12803 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..29d0342 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
@@ -880,13 +883,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
880 if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) 883 if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence)
881 { 884 {
882 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 885 ScenePresence target = (ScenePresence)World.Entities[avatarID];
883 EndPoint ep = target.ControllingClient.GetClientEP(); 886 return target.ControllingClient.RemoteEndPoint.Address.ToString();
884 if (ep is IPEndPoint)
885 {
886 IPEndPoint ip = (IPEndPoint)ep;
887 return ip.Address.ToString();
888 }
889 } 887 }
888
890 // fall through case, just return nothing 889 // fall through case, just return nothing
891 return ""; 890 return "";
892 } 891 }
@@ -957,21 +956,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
957 UUID avatarID = (UUID)avatar; 956 UUID avatarID = (UUID)avatar;
958 957
959 m_host.AddScriptLPS(1); 958 m_host.AddScriptLPS(1);
959
960 // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common
961 // method (though see that doesn't do the is animation check, which is probably a bug) and have both
962 // these functions call that common code. However, this does mean navigating the brain-dead requirement
963 // of calling InitLSL()
960 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) 964 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
961 { 965 {
962 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 966 ScenePresence target = (ScenePresence)World.Entities[avatarID];
963 if (target != null) 967 if (target != null)
964 { 968 {
965 UUID animID = UUID.Zero; 969 UUID animID;
966 m_host.TaskInventory.LockItemsForRead(true); 970
967 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 971 if (!UUID.TryParse(animation, out animID))
968 { 972 {
969 if (inv.Value.Name == animation) 973 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
970 { 974 if (item != null && item.Type == (int)AssetType.Animation)
971 if (inv.Value.Type == (int)AssetType.Animation) 975 animID = item.AssetID;
972 animID = inv.Value.AssetID; 976 else
973 continue; 977 animID = UUID.Zero;
974 }
975 } 978 }
976 m_host.TaskInventory.LockItemsForRead(false); 979 m_host.TaskInventory.LockItemsForRead(false);
977 980
@@ -1178,7 +1181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1178 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); 1181 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
1179 m_host.AddScriptLPS(1); 1182 m_host.AddScriptLPS(1);
1180 1183
1181 m_host.SetScriptEvents(m_itemID, events); 1184 m_host.SetScriptEvents(m_item.ItemID, events);
1182 } 1185 }
1183 1186
1184 public void osSetRegionWaterHeight(double height) 1187 public void osSetRegionWaterHeight(double height)
@@ -1186,12 +1189,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1186 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); 1189 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
1187 1190
1188 m_host.AddScriptLPS(1); 1191 m_host.AddScriptLPS(1);
1189 //Check to make sure that the script's owner is the estate manager/master 1192
1190 //World.Permissions.GenericEstatePermission( 1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1191 if (World.Permissions.IsGod(m_host.OwnerID))
1192 {
1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1194 }
1195 } 1194 }
1196 1195
1197 /// <summary> 1196 /// <summary>
@@ -1202,27 +1201,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> 1201 /// <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) 1202 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
1204 { 1203 {
1205 CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); 1204 CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings");
1206 1205
1207 m_host.AddScriptLPS(1); 1206 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 1207
1215 while (sunHour < 0) 1208 while (sunHour > 24.0)
1216 sunHour += 24.0; 1209 sunHour -= 24.0;
1217 1210
1211 while (sunHour < 0)
1212 sunHour += 24.0;
1218 1213
1219 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1214 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1220 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1215 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1221 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1216 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1222 World.RegionInfo.RegionSettings.Save(); 1217 World.RegionInfo.RegionSettings.Save();
1223 1218
1224 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); 1219 World.EventManager.TriggerEstateToolsSunUpdate(
1225 } 1220 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1226 } 1221 }
1227 1222
1228 /// <summary> 1223 /// <summary>
@@ -1232,26 +1227,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> 1227 /// <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) 1228 public void osSetEstateSunSettings(bool sunFixed, double sunHour)
1234 { 1229 {
1235 CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); 1230 CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings");
1236 1231
1237 m_host.AddScriptLPS(1); 1232 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 1233
1245 while (sunHour < 0) 1234 while (sunHour > 24.0)
1246 sunHour += 24.0; 1235 sunHour -= 24.0;
1247 1236
1248 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; 1237 while (sunHour < 0)
1249 World.RegionInfo.EstateSettings.SunPosition = sunHour; 1238 sunHour += 24.0;
1250 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1251 World.RegionInfo.EstateSettings.Save();
1252 1239
1253 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); 1240 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
1254 } 1241 World.RegionInfo.EstateSettings.SunPosition = sunHour;
1242 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1243 World.RegionInfo.EstateSettings.Save();
1244
1245 World.EventManager.TriggerEstateToolsSunUpdate(
1246 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1255 } 1247 }
1256 1248
1257 /// <summary> 1249 /// <summary>
@@ -1627,7 +1619,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1627 1619
1628 public Object osParseJSONNew(string JSON) 1620 public Object osParseJSONNew(string JSON)
1629 { 1621 {
1630 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1622 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1631 1623
1632 m_host.AddScriptLPS(1); 1624 m_host.AddScriptLPS(1);
1633 1625
@@ -1681,9 +1673,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1681 CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); 1673 CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
1682 m_host.AddScriptLPS(1); 1674 m_host.AddScriptLPS(1);
1683 1675
1676 UUID objUUID;
1677 if (!UUID.TryParse(objectUUID, out objUUID)) // prior to patching, a thrown exception regarding invalid GUID format would be shouted instead.
1678 {
1679 OSSLShoutError("osMessageObject() cannot send messages to objects with invalid UUIDs");
1680 return;
1681 }
1682
1684 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; 1683 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
1685 1684
1686 SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID)); 1685 SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID);
1686
1687 if (sceneOP == null) // prior to patching, PostObjectEvent() would cause a throw exception to be shouted instead.
1688 {
1689 OSSLShoutError("osMessageObject() cannot send message to " + objUUID.ToString() + ", object was not found in scene.");
1690 return;
1691 }
1687 1692
1688 m_ScriptEngine.PostObjectEvent( 1693 m_ScriptEngine.PostObjectEvent(
1689 sceneOP.LocalId, new EventParams( 1694 sceneOP.LocalId, new EventParams(
@@ -1826,8 +1831,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1826 if (a == null) 1831 if (a == null)
1827 return UUID.Zero; 1832 return UUID.Zero;
1828 1833
1829 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); 1834 string data = Encoding.UTF8.GetString(a.Data);
1830 string data = enc.GetString(a.Data);
1831 NotecardCache.Cache(assetID, data); 1835 NotecardCache.Cache(assetID, data);
1832 }; 1836 };
1833 1837
@@ -1980,7 +1984,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1980 { 1984 {
1981 string retval = String.Empty; 1985 string retval = String.Empty;
1982 IConfigSource config = m_ScriptEngine.ConfigSource; 1986 IConfigSource config = m_ScriptEngine.ConfigSource;
1983 string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); 1987 string url = null;
1988
1989 IConfig gridInfoConfig = config.Configs["GridInfo"];
1990
1991 if (gridInfoConfig != null)
1992 url = gridInfoConfig.GetString("GridInfoURI", String.Empty);
1984 1993
1985 if (String.IsNullOrEmpty(url)) 1994 if (String.IsNullOrEmpty(url))
1986 return "Configuration Error!"; 1995 return "Configuration Error!";
@@ -2042,8 +2051,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2042 string nick = String.Empty; 2051 string nick = String.Empty;
2043 IConfigSource config = m_ScriptEngine.ConfigSource; 2052 IConfigSource config = m_ScriptEngine.ConfigSource;
2044 2053
2045 if (config.Configs["GridInfo"] != null) 2054 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2046 nick = config.Configs["GridInfo"].GetString("gridnick", nick); 2055 nick = config.Configs[GridInfoServiceConfigSectionName].GetString("gridnick", nick);
2047 2056
2048 if (String.IsNullOrEmpty(nick)) 2057 if (String.IsNullOrEmpty(nick))
2049 nick = GridUserInfo(InfoType.Nick); 2058 nick = GridUserInfo(InfoType.Nick);
@@ -2059,8 +2068,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2059 string name = String.Empty; 2068 string name = String.Empty;
2060 IConfigSource config = m_ScriptEngine.ConfigSource; 2069 IConfigSource config = m_ScriptEngine.ConfigSource;
2061 2070
2062 if (config.Configs["GridInfo"] != null) 2071 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2063 name = config.Configs["GridInfo"].GetString("gridname", name); 2072 name = config.Configs[GridInfoServiceConfigSectionName].GetString("gridname", name);
2064 2073
2065 if (String.IsNullOrEmpty(name)) 2074 if (String.IsNullOrEmpty(name))
2066 name = GridUserInfo(InfoType.Name); 2075 name = GridUserInfo(InfoType.Name);
@@ -2076,8 +2085,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2076 string loginURI = String.Empty; 2085 string loginURI = String.Empty;
2077 IConfigSource config = m_ScriptEngine.ConfigSource; 2086 IConfigSource config = m_ScriptEngine.ConfigSource;
2078 2087
2079 if (config.Configs["GridInfo"] != null) 2088 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2080 loginURI = config.Configs["GridInfo"].GetString("login", loginURI); 2089 loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString("login", loginURI);
2081 2090
2082 if (String.IsNullOrEmpty(loginURI)) 2091 if (String.IsNullOrEmpty(loginURI))
2083 loginURI = GridUserInfo(InfoType.Login); 2092 loginURI = GridUserInfo(InfoType.Login);
@@ -2124,8 +2133,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2124 string retval = String.Empty; 2133 string retval = String.Empty;
2125 IConfigSource config = m_ScriptEngine.ConfigSource; 2134 IConfigSource config = m_ScriptEngine.ConfigSource;
2126 2135
2127 if (config.Configs["GridInfo"] != null) 2136 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2128 retval = config.Configs["GridInfo"].GetString(key, retval); 2137 retval = config.Configs[GridInfoServiceConfigSectionName].GetString(key, retval);
2129 2138
2130 if (String.IsNullOrEmpty(retval)) 2139 if (String.IsNullOrEmpty(retval))
2131 retval = GridUserInfo(InfoType.Custom, key); 2140 retval = GridUserInfo(InfoType.Custom, key);
@@ -2135,7 +2144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2135 2144
2136 public LSL_String osFormatString(string str, LSL_List strings) 2145 public LSL_String osFormatString(string str, LSL_List strings)
2137 { 2146 {
2138 CheckThreatLevel(ThreatLevel.Low, "osFormatString"); 2147 CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString");
2139 m_host.AddScriptLPS(1); 2148 m_host.AddScriptLPS(1);
2140 2149
2141 return String.Format(str, strings.Data); 2150 return String.Format(str, strings.Data);
@@ -2143,7 +2152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2143 2152
2144 public LSL_List osMatchString(string src, string pattern, int start) 2153 public LSL_List osMatchString(string src, string pattern, int start)
2145 { 2154 {
2146 CheckThreatLevel(ThreatLevel.High, "osMatchString"); 2155 CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString");
2147 m_host.AddScriptLPS(1); 2156 m_host.AddScriptLPS(1);
2148 2157
2149 LSL_List result = new LSL_List(); 2158 LSL_List result = new LSL_List();
@@ -2185,7 +2194,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2185 2194
2186 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) 2195 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
2187 { 2196 {
2188 CheckThreatLevel(ThreatLevel.High, "osReplaceString"); 2197 CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString");
2189 m_host.AddScriptLPS(1); 2198 m_host.AddScriptLPS(1);
2190 2199
2191 // Normalize indices (if negative). 2200 // Normalize indices (if negative).
@@ -2480,7 +2489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2480 return; 2489 return;
2481 2490
2482 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); 2491 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2483 module.MoveToTarget(npcId, World, pos, false, true); 2492 module.MoveToTarget(npcId, World, pos, false, true, false);
2484 } 2493 }
2485 } 2494 }
2486 2495
@@ -2505,7 +2514,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2505 World, 2514 World,
2506 pos, 2515 pos,
2507 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, 2516 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2508 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); 2517 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
2518 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
2509 } 2519 }
2510 } 2520 }
2511 2521
@@ -2555,7 +2565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 2565
2556 public void osNpcStopMoveToTarget(LSL_Key npc) 2566 public void osNpcStopMoveToTarget(LSL_Key npc)
2557 { 2567 {
2558 CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); 2568 CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget");
2559 m_host.AddScriptLPS(1); 2569 m_host.AddScriptLPS(1);
2560 2570
2561 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2571 INPCModule module = World.RequestModuleInterface<INPCModule>();
@@ -2572,6 +2582,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2572 2582
2573 public void osNpcSay(LSL_Key npc, string message) 2583 public void osNpcSay(LSL_Key npc, string message)
2574 { 2584 {
2585 osNpcSay(npc, 0, message);
2586 }
2587
2588 public void osNpcSay(LSL_Key npc, int channel, string message)
2589 {
2575 CheckThreatLevel(ThreatLevel.High, "osNpcSay"); 2590 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
2576 m_host.AddScriptLPS(1); 2591 m_host.AddScriptLPS(1);
2577 2592
@@ -2583,7 +2598,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2583 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2598 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2584 return; 2599 return;
2585 2600
2586 module.Say(npcId, World, message); 2601 module.Say(npcId, World, message, channel);
2602 }
2603 }
2604
2605 public void osNpcShout(LSL_Key npc, int channel, string message)
2606 {
2607 CheckThreatLevel(ThreatLevel.High, "osNpcShout");
2608 m_host.AddScriptLPS(1);
2609
2610 INPCModule module = World.RequestModuleInterface<INPCModule>();
2611 if (module != null)
2612 {
2613 UUID npcId = new UUID(npc.m_string);
2614
2615 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2616 return;
2617
2618 module.Shout(npcId, World, message, channel);
2587 } 2619 }
2588 } 2620 }
2589 2621
@@ -2684,6 +2716,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2684 } 2716 }
2685 } 2717 }
2686 2718
2719 public void osNpcWhisper(LSL_Key npc, int channel, string message)
2720 {
2721 CheckThreatLevel(ThreatLevel.High, "osNpcWhisper");
2722 m_host.AddScriptLPS(1);
2723
2724 INPCModule module = World.RequestModuleInterface<INPCModule>();
2725 if (module != null)
2726 {
2727 UUID npcId = new UUID(npc.m_string);
2728
2729 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2730 return;
2731
2732 module.Whisper(npcId, World, message, channel);
2733 }
2734 }
2735
2736 public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
2737 {
2738 CheckThreatLevel(ThreatLevel.High, "osNpcTouch");
2739 m_host.AddScriptLPS(1);
2740 INPCModule module = World.RequestModuleInterface<INPCModule>();
2741 int linkNum = link_num.value;
2742 if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
2743 {
2744 UUID npcId;
2745 if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
2746 return;
2747 SceneObjectPart part = null;
2748 UUID objectId;
2749 if (UUID.TryParse(LSL_String.ToString(object_key), out objectId))
2750 part = World.GetSceneObjectPart(objectId);
2751 if (part == null)
2752 return;
2753 if (linkNum != ScriptBaseClass.LINK_THIS)
2754 {
2755 if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT)
2756 { // 0 and 1 are treated as root, find the root if the current part isnt it
2757 if (!part.IsRoot)
2758 part = part.ParentGroup.RootPart;
2759 }
2760 else
2761 { // Find the prim with the given link number if not found then fail silently
2762 part = part.ParentGroup.GetLinkNumPart(linkNum);
2763 if (part == null)
2764 return;
2765 }
2766 }
2767 module.Touch(npcId, part.UUID);
2768 }
2769 }
2770
2687 /// <summary> 2771 /// <summary>
2688 /// Save the current appearance of the script owner permanently to the named notecard. 2772 /// Save the current appearance of the script owner permanently to the named notecard.
2689 /// </summary> 2773 /// </summary>
@@ -2835,21 +2919,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2835 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 2919 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
2836 m_host.AddScriptLPS(1); 2920 m_host.AddScriptLPS(1);
2837 2921
2838 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 2922 World.ForEachRootScenePresence(delegate(ScenePresence sp)
2839 { 2923 {
2840 World.ForEachRootScenePresence(delegate(ScenePresence sp) 2924 if (sp.Firstname == FirstName && sp.Lastname == SurName)
2841 { 2925 {
2842 if (sp.Firstname == FirstName && sp.Lastname == SurName) 2926 // kick client...
2843 { 2927 if (alert != null)
2844 // kick client... 2928 sp.ControllingClient.Kick(alert);
2845 if (alert != null)
2846 sp.ControllingClient.Kick(alert);
2847 2929
2848 // ...and close on our side 2930 // ...and close on our side
2849 sp.Scene.IncomingCloseAgent(sp.UUID); 2931 sp.Scene.IncomingCloseAgent(sp.UUID);
2850 } 2932 }
2851 }); 2933 });
2852 }
2853 } 2934 }
2854 2935
2855 public void osCauseDamage(string avatar, double damage) 2936 public void osCauseDamage(string avatar, double damage)
@@ -3095,5 +3176,151 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3176
3096 return ScriptBaseClass.TRUE; 3177 return ScriptBaseClass.TRUE;
3097 } 3178 }
3179
3180 /// <summary>
3181 /// Sets terrain estate texture
3182 /// </summary>
3183 /// <param name="level"></param>
3184 /// <param name="texture"></param>
3185 /// <returns></returns>
3186 public void osSetTerrainTexture(int level, LSL_Key texture)
3187 {
3188 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3189
3190 m_host.AddScriptLPS(1);
3191 //Check to make sure that the script's owner is the estate manager/master
3192 //World.Permissions.GenericEstatePermission(
3193 if (World.Permissions.IsGod(m_host.OwnerID))
3194 {
3195 if (level < 0 || level > 3)
3196 return;
3197
3198 UUID textureID = new UUID();
3199 if (!UUID.TryParse(texture, out textureID))
3200 return;
3201
3202 // estate module is required
3203 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3204 if (estate != null)
3205 estate.setEstateTerrainBaseTexture(level, textureID);
3206 }
3207 }
3208
3209 /// <summary>
3210 /// Sets terrain heights of estate
3211 /// </summary>
3212 /// <param name="corner"></param>
3213 /// <param name="low"></param>
3214 /// <param name="high"></param>
3215 /// <returns></returns>
3216 public void osSetTerrainTextureHeight(int corner, double low, double high)
3217 {
3218 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3219
3220 m_host.AddScriptLPS(1);
3221 //Check to make sure that the script's owner is the estate manager/master
3222 //World.Permissions.GenericEstatePermission(
3223 if (World.Permissions.IsGod(m_host.OwnerID))
3224 {
3225 if (corner < 0 || corner > 3)
3226 return;
3227
3228 // estate module is required
3229 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3230 if (estate != null)
3231 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3232 }
3233 }
3234
3235 public void osForceAttachToAvatar(int attachmentPoint)
3236 {
3237 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3238
3239 m_host.AddScriptLPS(1);
3240
3241 InitLSL();
3242 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3243 }
3244
3245 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
3246 {
3247 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
3248
3249 m_host.AddScriptLPS(1);
3250
3251 ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint);
3252 }
3253
3254 public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
3255 {
3256 CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory");
3257
3258 m_host.AddScriptLPS(1);
3259
3260 UUID avatarId;
3261
3262 if (!UUID.TryParse(rawAvatarId, out avatarId))
3263 return;
3264
3265 ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint);
3266 }
3267
3268 public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint)
3269 {
3270 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3271
3272 if (attachmentsModule == null)
3273 return;
3274
3275 InitLSL();
3276
3277 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
3278
3279 if (item == null)
3280 {
3281 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName));
3282 throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName));
3283 }
3284
3285 if (item.InvType != (int)InventoryType.Object)
3286 {
3287 // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set
3288 // up the api reference.
3289 if (m_LSL_Api != null)
3290 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
3291
3292 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
3293
3294 return;
3295 }
3296
3297 ScenePresence sp = World.GetScenePresence(avatarId);
3298
3299 if (sp == null)
3300 return;
3301
3302 InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID);
3303
3304 if (newItem == null)
3305 {
3306 m_log.ErrorFormat(
3307 "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}",
3308 itemName, m_host.Name, attachmentPoint, World.Name);
3309
3310 return;
3311 }
3312
3313 attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
3314 }
3315
3316 public void osForceDetachFromAvatar()
3317 {
3318 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3319
3320 m_host.AddScriptLPS(1);
3321
3322 InitLSL();
3323 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3324 }
3098 } 3325 }
3099} 3326}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
index 93e0261..efa86fc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
@@ -88,13 +88,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
88 88
89 public Object[] GetSerializationData(UUID itemID) 89 public Object[] GetSerializationData(UUID itemID)
90 { 90 {
91 return m_commsPlugin.GetSerializationData(itemID); 91 if (m_commsPlugin != null)
92 return m_commsPlugin.GetSerializationData(itemID);
93 else
94 return new Object[]{};
92 } 95 }
93 96
94 public void CreateFromData(uint localID, UUID itemID, UUID hostID, 97 public void CreateFromData(uint localID, UUID itemID, UUID hostID,
95 Object[] data) 98 Object[] data)
96 { 99 {
97 m_commsPlugin.CreateFromData(localID, itemID, hostID, data); 100 if (m_commsPlugin != null)
101 m_commsPlugin.CreateFromData(localID, itemID, hostID, data);
98 } 102 }
99 } 103 }
100} \ No newline at end of file 104} \ No newline at end of file
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}