aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2252
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs71
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
15 files changed, 1841 insertions, 795 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index ee32755..61e4934 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -248,6 +248,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
248 248
249 } 249 }
250 250
251 public static void StateChange(IScriptEngine engine, uint localID, UUID itemID)
252 {
253 // Remove a specific script
254
255 // Remove dataserver events
256 m_Dataserver[engine].RemoveEvents(localID, itemID);
257
258 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
259 if (comms != null)
260 comms.DeleteListener(itemID);
261
262 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
263 xmlrpc.DeleteChannels(itemID);
264 xmlrpc.CancelSRDRequests(itemID);
265
266 // Remove Sensors
267 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
268
269 }
270
251 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) 271 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID)
252 { 272 {
253 List<Object> data = new List<Object>(); 273 List<Object> data = new List<Object>();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..489c1c6
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,118 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections;
31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse;
34using Nini.Config;
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.World.LightShare;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
45using OpenSim.Services.Interfaces;
46
47using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
50using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54
55namespace OpenSim.Region.ScriptEngine.Shared.Api
56{
57 [Serializable]
58 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
59 {
60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host;
62 internal uint m_localID;
63 internal UUID m_itemID;
64 internal bool m_CMFunctionsEnabled = false;
65
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
67 {
68 m_ScriptEngine = ScriptEngine;
69 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72
73 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
74 m_CMFunctionsEnabled = true;
75 }
76
77 public override Object InitializeLifetimeService()
78 {
79 ILease lease = (ILease)base.InitializeLifetimeService();
80
81 if (lease.CurrentState == LeaseState.Initial)
82 {
83 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
84 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
85 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
86 }
87 return lease;
88 }
89
90 public Scene World
91 {
92 get { return m_ScriptEngine.World; }
93 }
94
95 public string cmDetectedCountry(int number)
96 {
97 m_host.AddScriptLPS(1);
98 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number);
99 if (detectedParams == null)
100 return String.Empty;
101 return detectedParams.Country;
102 }
103
104 public string cmGetAgentCountry(LSL_Key key)
105 {
106 if (!World.Permissions.IsGod(m_host.OwnerID))
107 return String.Empty;
108
109 UUID uuid;
110
111 if (!UUID.TryParse(key, out uuid))
112 return String.Empty;
113
114 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
115 return account.UserCountry;
116 }
117 }
118}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 39da563..1b82ad1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -28,10 +28,12 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; //for [DebuggerNonUserCode]
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
34using System.Text.RegularExpressions; 35using System.Text.RegularExpressions;
36using System.Timers;
35using Nini.Config; 37using Nini.Config;
36using log4net; 38using log4net;
37using OpenMetaverse; 39using OpenMetaverse;
@@ -44,6 +46,7 @@ using OpenSim.Region.CoreModules.World.Land;
44using OpenSim.Region.CoreModules.World.Terrain; 46using OpenSim.Region.CoreModules.World.Terrain;
45using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 48using OpenSim.Region.Framework.Scenes;
49using OpenSim.Region.Framework.Scenes.Serialization;
47using OpenSim.Region.Framework.Scenes.Animation; 50using OpenSim.Region.Framework.Scenes.Animation;
48using OpenSim.Region.Physics.Manager; 51using OpenSim.Region.Physics.Manager;
49using OpenSim.Region.ScriptEngine.Shared; 52using OpenSim.Region.ScriptEngine.Shared;
@@ -65,6 +68,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
65using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 68using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
66using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 69using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
67using System.Reflection; 70using System.Reflection;
71using Timer = System.Timers.Timer;
68 72
69namespace OpenSim.Region.ScriptEngine.Shared.Api 73namespace OpenSim.Region.ScriptEngine.Shared.Api
70{ 74{
@@ -81,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
81 /// </summary> 85 /// </summary>
82 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 86 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
83 { 87 {
84 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 88// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
85 protected IScriptEngine m_ScriptEngine; 89 protected IScriptEngine m_ScriptEngine;
86 protected SceneObjectPart m_host; 90 protected SceneObjectPart m_host;
87 protected uint m_localID; 91 protected uint m_localID;
@@ -99,16 +103,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
99 protected int m_notecardLineReadCharsMax = 255; 103 protected int m_notecardLineReadCharsMax = 255;
100 protected int m_scriptConsoleChannel = 0; 104 protected int m_scriptConsoleChannel = 0;
101 protected bool m_scriptConsoleChannelEnabled = false; 105 protected bool m_scriptConsoleChannelEnabled = false;
106 protected bool m_debuggerSafe = false;
102 protected IUrlModule m_UrlModule = null; 107 protected IUrlModule m_UrlModule = null;
103 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = 108 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
104 new Dictionary<UUID, UserInfoCacheEntry>(); 109 new Dictionary<UUID, UserInfoCacheEntry>();
105 110
111 protected Timer m_ShoutSayTimer;
112 protected int m_SayShoutCount = 0;
113
106 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 114 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
107 { 115 {
116 m_ShoutSayTimer = new Timer(1000);
117 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed;
118 m_ShoutSayTimer.AutoReset = true;
119 m_ShoutSayTimer.Start();
120
108 m_ScriptEngine = ScriptEngine; 121 m_ScriptEngine = ScriptEngine;
109 m_host = host; 122 m_host = host;
110 m_localID = localID; 123 m_localID = localID;
111 m_itemID = itemID; 124 m_itemID = itemID;
125 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
112 126
113 m_ScriptDelayFactor = 127 m_ScriptDelayFactor =
114 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 128 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
@@ -161,6 +175,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
161 get { return m_ScriptEngine.World; } 175 get { return m_ScriptEngine.World; }
162 } 176 }
163 177
178 [DebuggerNonUserCode]
164 public void state(string newState) 179 public void state(string newState)
165 { 180 {
166 m_ScriptEngine.SetState(m_itemID, newState); 181 m_ScriptEngine.SetState(m_itemID, newState);
@@ -170,6 +185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
170 /// Reset the named script. The script must be present 185 /// Reset the named script. The script must be present
171 /// in the same prim. 186 /// in the same prim.
172 /// </summary> 187 /// </summary>
188 [DebuggerNonUserCode]
173 public void llResetScript() 189 public void llResetScript()
174 { 190 {
175 m_host.AddScriptLPS(1); 191 m_host.AddScriptLPS(1);
@@ -226,9 +242,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
226 } 242 }
227 } 243 }
228 244
245 public List<ScenePresence> GetLinkAvatars(int linkType)
246 {
247 List<ScenePresence> ret = new List<ScenePresence>();
248 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
249 return ret;
250
251 List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars();
252
253 switch (linkType)
254 {
255 case ScriptBaseClass.LINK_SET:
256 return avs;
257
258 case ScriptBaseClass.LINK_ROOT:
259 return ret;
260
261 case ScriptBaseClass.LINK_ALL_OTHERS:
262 return avs;
263
264 case ScriptBaseClass.LINK_ALL_CHILDREN:
265 return avs;
266
267 case ScriptBaseClass.LINK_THIS:
268 return ret;
269
270 default:
271 if (linkType < 0)
272 return ret;
273
274 int partCount = m_host.ParentGroup.GetPartCount();
275
276 if (linkType <= partCount)
277 {
278 return ret;
279 }
280 else
281 {
282 linkType = linkType - partCount;
283 if (linkType > avs.Count)
284 {
285 return ret;
286 }
287 else
288 {
289 ret.Add(avs[linkType-1]);
290 return ret;
291 }
292 }
293 }
294 }
295
229 public List<SceneObjectPart> GetLinkParts(int linkType) 296 public List<SceneObjectPart> GetLinkParts(int linkType)
230 { 297 {
231 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 298 List<SceneObjectPart> ret = new List<SceneObjectPart>();
299 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
300 return ret;
232 ret.Add(m_host); 301 ret.Add(m_host);
233 302
234 switch (linkType) 303 switch (linkType)
@@ -275,40 +344,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
275 protected UUID InventorySelf() 344 protected UUID InventorySelf()
276 { 345 {
277 UUID invItemID = new UUID(); 346 UUID invItemID = new UUID();
278 347 bool unlock = false;
279 lock (m_host.TaskInventory) 348 if (!m_host.TaskInventory.IsReadLockedByMe())
349 {
350 m_host.TaskInventory.LockItemsForRead(true);
351 unlock = true;
352 }
353 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
280 { 354 {
281 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 355 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
282 { 356 {
283 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 357 invItemID = inv.Key;
284 { 358 break;
285 invItemID = inv.Key;
286 break;
287 }
288 } 359 }
289 } 360 }
290 361 if (unlock)
362 {
363 m_host.TaskInventory.LockItemsForRead(false);
364 }
291 return invItemID; 365 return invItemID;
292 } 366 }
293 367
294 protected UUID InventoryKey(string name, int type) 368 protected UUID InventoryKey(string name, int type)
295 { 369 {
296 m_host.AddScriptLPS(1); 370 m_host.AddScriptLPS(1);
297 371 m_host.TaskInventory.LockItemsForRead(true);
298 lock (m_host.TaskInventory) 372
373 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
299 { 374 {
300 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 375 if (inv.Value.Name == name)
301 { 376 {
302 if (inv.Value.Name == name) 377 m_host.TaskInventory.LockItemsForRead(false);
378
379 if (inv.Value.Type != type)
303 { 380 {
304 if (inv.Value.Type != type) 381 return UUID.Zero;
305 return UUID.Zero;
306
307 return inv.Value.AssetID;
308 } 382 }
383
384 return inv.Value.AssetID;
309 } 385 }
310 } 386 }
311 387
388 m_host.TaskInventory.LockItemsForRead(false);
312 return UUID.Zero; 389 return UUID.Zero;
313 } 390 }
314 391
@@ -316,17 +393,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
316 { 393 {
317 m_host.AddScriptLPS(1); 394 m_host.AddScriptLPS(1);
318 395
319 lock (m_host.TaskInventory) 396
397 m_host.TaskInventory.LockItemsForRead(true);
398
399 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
320 { 400 {
321 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 401 if (inv.Value.Name == name)
322 { 402 {
323 if (inv.Value.Name == name) 403 m_host.TaskInventory.LockItemsForRead(false);
324 { 404 return inv.Value.AssetID;
325 return inv.Value.AssetID;
326 }
327 } 405 }
328 } 406 }
329 407
408 m_host.TaskInventory.LockItemsForRead(false);
409
410
330 return UUID.Zero; 411 return UUID.Zero;
331 } 412 }
332 413
@@ -468,26 +549,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
468 549
469 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 550 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
470 551
471 // Old implementation of llRot2Euler. Normalization not required as Atan2 function will 552 // Utility function for llRot2Euler
472 // only return values >= -PI (-180 degrees) and <= PI (180 degrees). 553
554 // normalize an angle between -PI and PI (-180 to +180 degrees)
555 protected double NormalizeAngle(double angle)
556 {
557 if (angle > -Math.PI && angle < Math.PI)
558 return angle;
559
560 int numPis = (int)(Math.PI / angle);
561 double remainder = angle - Math.PI * numPis;
562 if (numPis % 2 == 1)
563 return Math.PI - angle;
564 return remainder;
565 }
473 566
474 public LSL_Vector llRot2Euler(LSL_Rotation r) 567 public LSL_Vector llRot2Euler(LSL_Rotation q1)
475 { 568 {
476 m_host.AddScriptLPS(1); 569 m_host.AddScriptLPS(1);
477 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke 570 LSL_Vector eul = new LSL_Vector();
478 LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); 571
479 double m = (t.x + t.y + t.z + t.s); 572 double sqw = q1.s*q1.s;
480 if (m == 0) return new LSL_Vector(); 573 double sqx = q1.x*q1.x;
481 double n = 2 * (r.y * r.s + r.x * r.z); 574 double sqy = q1.z*q1.z;
482 double p = m * m - n * n; 575 double sqz = q1.y*q1.y;
483 if (p > 0) 576 double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
484 return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), 577 double test = q1.x*q1.z + q1.y*q1.s;
485 Math.Atan2(n, Math.Sqrt(p)), 578 if (test > 0.4999*unit) { // singularity at north pole
486 Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); 579 eul.z = 2 * Math.Atan2(q1.x,q1.s);
487 else if (n > 0) 580 eul.y = Math.PI/2;
488 return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); 581 eul.x = 0;
489 else 582 return eul;
490 return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); 583 }
584 if (test < -0.4999*unit) { // singularity at south pole
585 eul.z = -2 * Math.Atan2(q1.x,q1.s);
586 eul.y = -Math.PI/2;
587 eul.x = 0;
588 return eul;
589 }
590 eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw);
591 eul.y = Math.Asin(2*test/unit);
592 eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw);
593 return eul;
491 } 594 }
492 595
493 /* From wiki: 596 /* From wiki:
@@ -689,77 +792,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
689 { 792 {
690 //A and B should both be normalized 793 //A and B should both be normalized
691 m_host.AddScriptLPS(1); 794 m_host.AddScriptLPS(1);
692 LSL_Rotation rotBetween; 795 /* This method is more accurate than the SL one, and thus causes problems
693 // Check for zero vectors. If either is zero, return zero rotation. Otherwise, 796 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
694 // continue calculation. 797
695 if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) 798 double dotProduct = LSL_Vector.Dot(a, b);
799 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
800 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
801 double angle = Math.Acos(dotProduct / magProduct);
802 LSL_Vector axis = LSL_Vector.Norm(crossProduct);
803 double s = Math.Sin(angle / 2);
804
805 double x = axis.x * s;
806 double y = axis.y * s;
807 double z = axis.z * s;
808 double w = Math.Cos(angle / 2);
809
810 if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w))
811 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
812
813 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
814 */
815
816 // This method mimics the 180 errors found in SL
817 // See www.euclideanspace.com... angleBetween
818 LSL_Vector vec_a = a;
819 LSL_Vector vec_b = b;
820
821 // Eliminate zero length
822 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
823 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
824 if (vec_a_mag < 0.00001 ||
825 vec_b_mag < 0.00001)
696 { 826 {
697 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 827 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
698 } 828 }
699 else 829
830 // Normalize
831 vec_a = llVecNorm(vec_a);
832 vec_b = llVecNorm(vec_b);
833
834 // Calculate axis and rotation angle
835 LSL_Vector axis = vec_a % vec_b;
836 LSL_Float cos_theta = vec_a * vec_b;
837
838 // Check if parallel
839 if (cos_theta > 0.99999)
700 { 840 {
701 a = LSL_Vector.Norm(a); 841 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
702 b = LSL_Vector.Norm(b); 842 }
703 double dotProduct = LSL_Vector.Dot(a, b); 843
704 // There are two degenerate cases possible. These are for vectors 180 or 844 // Check if anti-parallel
705 // 0 degrees apart. These have to be detected and handled individually. 845 else if (cos_theta < -0.99999)
706 // 846 {
707 // Check for vectors 180 degrees apart. 847 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
708 // A dot product of -1 would mean the angle between vectors is 180 degrees. 848 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
709 if (dotProduct < -0.9999999f) 849 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
710 { 850 }
711 // First assume X axis is orthogonal to the vectors. 851 else // other rotation
712 LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); 852 {
713 orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); 853 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
714 // Check for near zero vector. A very small non-zero number here will create 854 axis = llVecNorm(axis);
715 // a rotation in an undesired direction. 855 double x, y, z, s, t;
716 if (LSL_Vector.Mag(orthoVector) > 0.0001) 856 s = Math.Cos(theta);
717 { 857 t = Math.Sin(theta);
718 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); 858 x = axis.x * t;
719 } 859 y = axis.y * t;
720 // If the magnitude of the vector was near zero, then assume the X axis is not 860 z = axis.z * t;
721 // orthogonal and use the Z axis instead. 861 return new LSL_Rotation(x,y,z,s);
722 else
723 {
724 // Set 180 z rotation.
725 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f);
726 }
727 }
728 // Check for parallel vectors.
729 // A dot product of 1 would mean the angle between vectors is 0 degrees.
730 else if (dotProduct > 0.9999999f)
731 {
732 // Set zero rotation.
733 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
734 }
735 else
736 {
737 // All special checks have been performed so get the axis of rotation.
738 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
739 // Quarternion s value is the length of the unit vector + dot product.
740 double qs = 1.0 + dotProduct;
741 rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs);
742 // Normalize the rotation.
743 double mag = LSL_Rotation.Mag(rotBetween);
744 // We shouldn't have to worry about a divide by zero here. The qs value will be
745 // non-zero because we already know if we're here, then the dotProduct is not -1 so
746 // qs will not be zero. Also, we've already handled the input vectors being zero so the
747 // crossProduct vector should also not be zero.
748 rotBetween.x = rotBetween.x / mag;
749 rotBetween.y = rotBetween.y / mag;
750 rotBetween.z = rotBetween.z / mag;
751 rotBetween.s = rotBetween.s / mag;
752 // Check for undefined values and set zero rotation if any found. This code might not actually be required
753 // any longer since zero vectors are checked for at the top.
754 if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s))
755 {
756 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
757 }
758 }
759 } 862 }
760 return rotBetween;
761 } 863 }
762 864
763 public void llWhisper(int channelID, string text) 865 public void llWhisper(int channelID, string text)
764 { 866 {
765 m_host.AddScriptLPS(1); 867 m_host.AddScriptLPS(1);
@@ -779,6 +881,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
779 { 881 {
780 m_host.AddScriptLPS(1); 882 m_host.AddScriptLPS(1);
781 883
884 if (channelID == 0)
885 m_SayShoutCount++;
886
887 if (m_SayShoutCount >= 11)
888 ScriptSleep(2000);
889
782 if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) 890 if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel))
783 { 891 {
784 Console.WriteLine(text); 892 Console.WriteLine(text);
@@ -801,6 +909,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
801 { 909 {
802 m_host.AddScriptLPS(1); 910 m_host.AddScriptLPS(1);
803 911
912 if (channelID == 0)
913 m_SayShoutCount++;
914
915 if (m_SayShoutCount >= 11)
916 ScriptSleep(2000);
917
804 if (text.Length > 1023) 918 if (text.Length > 1023)
805 text = text.Substring(0, 1023); 919 text = text.Substring(0, 1023);
806 920
@@ -1101,10 +1215,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1101 return detectedParams.TouchUV; 1215 return detectedParams.TouchUV;
1102 } 1216 }
1103 1217
1218 [DebuggerNonUserCode]
1104 public virtual void llDie() 1219 public virtual void llDie()
1105 { 1220 {
1106 m_host.AddScriptLPS(1); 1221 m_host.AddScriptLPS(1);
1107 throw new SelfDeleteException(); 1222 if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException();
1108 } 1223 }
1109 1224
1110 public LSL_Float llGround(LSL_Vector offset) 1225 public LSL_Float llGround(LSL_Vector offset)
@@ -1177,6 +1292,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1177 1292
1178 public void llSetStatus(int status, int value) 1293 public void llSetStatus(int status, int value)
1179 { 1294 {
1295 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1296 return;
1180 m_host.AddScriptLPS(1); 1297 m_host.AddScriptLPS(1);
1181 1298
1182 int statusrotationaxis = 0; 1299 int statusrotationaxis = 0;
@@ -1406,6 +1523,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1406 { 1523 {
1407 m_host.AddScriptLPS(1); 1524 m_host.AddScriptLPS(1);
1408 1525
1526 SetColor(m_host, color, face);
1527 }
1528
1529 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1530 {
1531 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1532 return;
1533
1534 Primitive.TextureEntry tex = part.Shape.Textures;
1535 Color4 texcolor;
1536 if (face >= 0 && face < GetNumberOfSides(part))
1537 {
1538 texcolor = tex.CreateFace((uint)face).RGBA;
1539 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1540 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1541 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1542 tex.FaceTextures[face].RGBA = texcolor;
1543 part.UpdateTexture(tex);
1544 return;
1545 }
1546 else if (face == ScriptBaseClass.ALL_SIDES)
1547 {
1548 for (uint i = 0; i < GetNumberOfSides(part); i++)
1549 {
1550 if (tex.FaceTextures[i] != null)
1551 {
1552 texcolor = tex.FaceTextures[i].RGBA;
1553 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1554 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1555 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1556 tex.FaceTextures[i].RGBA = texcolor;
1557 }
1558 texcolor = tex.DefaultTexture.RGBA;
1559 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1560 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1561 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1562 tex.DefaultTexture.RGBA = texcolor;
1563 }
1564 part.UpdateTexture(tex);
1565 return;
1566 }
1567
1409 if (face == ScriptBaseClass.ALL_SIDES) 1568 if (face == ScriptBaseClass.ALL_SIDES)
1410 face = SceneObjectPart.ALL_SIDES; 1569 face = SceneObjectPart.ALL_SIDES;
1411 1570
@@ -1414,6 +1573,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1414 1573
1415 public void SetTexGen(SceneObjectPart part, int face,int style) 1574 public void SetTexGen(SceneObjectPart part, int face,int style)
1416 { 1575 {
1576 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1577 return;
1578
1417 Primitive.TextureEntry tex = part.Shape.Textures; 1579 Primitive.TextureEntry tex = part.Shape.Textures;
1418 MappingType textype; 1580 MappingType textype;
1419 textype = MappingType.Default; 1581 textype = MappingType.Default;
@@ -1444,6 +1606,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1444 1606
1445 public void SetGlow(SceneObjectPart part, int face, float glow) 1607 public void SetGlow(SceneObjectPart part, int face, float glow)
1446 { 1608 {
1609 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1610 return;
1611
1447 Primitive.TextureEntry tex = part.Shape.Textures; 1612 Primitive.TextureEntry tex = part.Shape.Textures;
1448 if (face >= 0 && face < GetNumberOfSides(part)) 1613 if (face >= 0 && face < GetNumberOfSides(part))
1449 { 1614 {
@@ -1469,6 +1634,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1469 1634
1470 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1635 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1471 { 1636 {
1637 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1638 return;
1472 1639
1473 Shininess sval = new Shininess(); 1640 Shininess sval = new Shininess();
1474 1641
@@ -1519,6 +1686,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1519 1686
1520 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1687 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1521 { 1688 {
1689 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1690 return;
1691
1522 Primitive.TextureEntry tex = part.Shape.Textures; 1692 Primitive.TextureEntry tex = part.Shape.Textures;
1523 if (face >= 0 && face < GetNumberOfSides(part)) 1693 if (face >= 0 && face < GetNumberOfSides(part))
1524 { 1694 {
@@ -1579,13 +1749,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1579 m_host.AddScriptLPS(1); 1749 m_host.AddScriptLPS(1);
1580 1750
1581 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1751 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1582 1752 if (parts.Count > 0)
1583 foreach (SceneObjectPart part in parts) 1753 {
1584 SetAlpha(part, alpha, face); 1754 try
1755 {
1756 parts[0].ParentGroup.areUpdatesSuspended = true;
1757 foreach (SceneObjectPart part in parts)
1758 SetAlpha(part, alpha, face);
1759 }
1760 finally
1761 {
1762 parts[0].ParentGroup.areUpdatesSuspended = false;
1763 }
1764 }
1585 } 1765 }
1586 1766
1587 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1767 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1588 { 1768 {
1769 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1770 return;
1771
1589 Primitive.TextureEntry tex = part.Shape.Textures; 1772 Primitive.TextureEntry tex = part.Shape.Textures;
1590 Color4 texcolor; 1773 Color4 texcolor;
1591 if (face >= 0 && face < GetNumberOfSides(part)) 1774 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1638,7 +1821,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1638 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1821 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1639 float wind, float tension, LSL_Vector Force) 1822 float wind, float tension, LSL_Vector Force)
1640 { 1823 {
1641 if (part == null) 1824 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1642 return; 1825 return;
1643 1826
1644 if (flexi) 1827 if (flexi)
@@ -1673,7 +1856,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1673 /// <param name="falloff"></param> 1856 /// <param name="falloff"></param>
1674 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1857 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1675 { 1858 {
1676 if (part == null) 1859 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1677 return; 1860 return;
1678 1861
1679 if (light) 1862 if (light)
@@ -1750,15 +1933,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1750 m_host.AddScriptLPS(1); 1933 m_host.AddScriptLPS(1);
1751 1934
1752 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1935 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1753 1936 if (parts.Count > 0)
1754 foreach (SceneObjectPart part in parts) 1937 {
1755 SetTexture(part, texture, face); 1938 try
1756 1939 {
1940 parts[0].ParentGroup.areUpdatesSuspended = true;
1941 foreach (SceneObjectPart part in parts)
1942 SetTexture(part, texture, face);
1943 }
1944 finally
1945 {
1946 parts[0].ParentGroup.areUpdatesSuspended = false;
1947 }
1948 }
1757 ScriptSleep(200); 1949 ScriptSleep(200);
1758 } 1950 }
1759 1951
1760 protected void SetTexture(SceneObjectPart part, string texture, int face) 1952 protected void SetTexture(SceneObjectPart part, string texture, int face)
1761 { 1953 {
1954 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1955 return;
1956
1762 UUID textureID = new UUID(); 1957 UUID textureID = new UUID();
1763 1958
1764 textureID = InventoryKey(texture, (int)AssetType.Texture); 1959 textureID = InventoryKey(texture, (int)AssetType.Texture);
@@ -1803,6 +1998,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1803 1998
1804 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1999 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1805 { 2000 {
2001 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2002 return;
2003
1806 Primitive.TextureEntry tex = part.Shape.Textures; 2004 Primitive.TextureEntry tex = part.Shape.Textures;
1807 if (face >= 0 && face < GetNumberOfSides(part)) 2005 if (face >= 0 && face < GetNumberOfSides(part))
1808 { 2006 {
@@ -1839,6 +2037,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1839 2037
1840 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 2038 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1841 { 2039 {
2040 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2041 return;
2042
1842 Primitive.TextureEntry tex = part.Shape.Textures; 2043 Primitive.TextureEntry tex = part.Shape.Textures;
1843 if (face >= 0 && face < GetNumberOfSides(part)) 2044 if (face >= 0 && face < GetNumberOfSides(part))
1844 { 2045 {
@@ -1875,6 +2076,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1875 2076
1876 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2077 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1877 { 2078 {
2079 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2080 return;
2081
1878 Primitive.TextureEntry tex = part.Shape.Textures; 2082 Primitive.TextureEntry tex = part.Shape.Textures;
1879 if (face >= 0 && face < GetNumberOfSides(part)) 2083 if (face >= 0 && face < GetNumberOfSides(part))
1880 { 2084 {
@@ -1943,10 +2147,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1943 return end; 2147 return end;
1944 } 2148 }
1945 2149
1946 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2150 protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos)
1947 { 2151 {
2152 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2153 return fromPos;
2154
1948 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2155 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1949 LSL_Vector currentPos = GetPartLocalPos(part); 2156
1950 2157
1951 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); 2158 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
1952 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); 2159 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
@@ -1955,14 +2162,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1955 { 2162 {
1956 if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) 2163 if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
1957 targetPos.z = ground; 2164 targetPos.z = ground;
2165 }
2166 LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos);
2167
2168 return real_vec;
2169 }
2170
2171 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
2172 {
2173 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2174 return;
2175
2176 LSL_Vector currentPos = GetPartLocalPos(part);
2177 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos);
2178
2179 if (part.ParentGroup.RootPart == part)
2180 {
1958 SceneObjectGroup parent = part.ParentGroup; 2181 SceneObjectGroup parent = part.ParentGroup;
1959 LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos); 2182 parent.UpdateGroupPosition(new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z));
1960 parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
1961 } 2183 }
1962 else 2184 else
1963 { 2185 {
1964 LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); 2186 part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z);
1965 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
1966 SceneObjectGroup parent = part.ParentGroup; 2187 SceneObjectGroup parent = part.ParentGroup;
1967 parent.HasGroupChanged = true; 2188 parent.HasGroupChanged = true;
1968 parent.ScheduleGroupForTerseUpdate(); 2189 parent.ScheduleGroupForTerseUpdate();
@@ -2013,9 +2234,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2013 m_host.AddScriptLPS(1); 2234 m_host.AddScriptLPS(1);
2014 2235
2015 // try to let this work as in SL... 2236 // try to let this work as in SL...
2016 if (m_host.ParentID == 0) 2237 if (m_host.LinkNum < 2)
2017 { 2238 {
2018 // special case: If we are root, rotate complete SOG to new rotation 2239 // Special case: If we are root, rotate complete SOG to new
2240 // rotation.
2241 // We are root if the link number is 0 (single prim) or 1
2242 // (root prim). ParentID may be nonzero in attachments and
2243 // using it would cause attachments and HUDs to rotate
2244 // to the wrong positions.
2019 SetRot(m_host, Rot2Quaternion(rot)); 2245 SetRot(m_host, Rot2Quaternion(rot));
2020 } 2246 }
2021 else 2247 else
@@ -2040,6 +2266,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2040 2266
2041 protected void SetRot(SceneObjectPart part, Quaternion rot) 2267 protected void SetRot(SceneObjectPart part, Quaternion rot)
2042 { 2268 {
2269 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2270 return;
2271
2043 part.UpdateRotation(rot); 2272 part.UpdateRotation(rot);
2044 // Update rotation does not move the object in the physics scene if it's a linkset. 2273 // Update rotation does not move the object in the physics scene if it's a linkset.
2045 2274
@@ -2665,12 +2894,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2665 2894
2666 m_host.AddScriptLPS(1); 2895 m_host.AddScriptLPS(1);
2667 2896
2897 m_host.TaskInventory.LockItemsForRead(true);
2668 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2898 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2669 2899 m_host.TaskInventory.LockItemsForRead(false);
2670 lock (m_host.TaskInventory)
2671 {
2672 item = m_host.TaskInventory[invItemID];
2673 }
2674 2900
2675 if (item.PermsGranter == UUID.Zero) 2901 if (item.PermsGranter == UUID.Zero)
2676 return 0; 2902 return 0;
@@ -2745,6 +2971,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2745 if (dist > m_ScriptDistanceFactor * 10.0f) 2971 if (dist > m_ScriptDistanceFactor * 10.0f)
2746 return; 2972 return;
2747 2973
2974 //Clone is thread-safe
2748 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2975 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2749 2976
2750 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2977 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2805,6 +3032,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2805 3032
2806 public void llLookAt(LSL_Vector target, double strength, double damping) 3033 public void llLookAt(LSL_Vector target, double strength, double damping)
2807 { 3034 {
3035 /*
2808 m_host.AddScriptLPS(1); 3036 m_host.AddScriptLPS(1);
2809 // Determine where we are looking from 3037 // Determine where we are looking from
2810 LSL_Vector from = llGetPos(); 3038 LSL_Vector from = llGetPos();
@@ -2824,10 +3052,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2824 // the angles of rotation in radians into rotation value 3052 // the angles of rotation in radians into rotation value
2825 3053
2826 LSL_Types.Quaternion rot = llEuler2Rot(angle); 3054 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2827 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 3055
2828 m_host.startLookAt(rotation, (float)damping, (float)strength); 3056 // This would only work if your physics system contains an APID controller:
3057 // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
3058 // m_host.startLookAt(rotation, (float)damping, (float)strength);
3059
2829 // Orient the object to the angle calculated 3060 // Orient the object to the angle calculated
2830 //llSetRot(rot); 3061 llSetRot(rot);
3062 */
3063
3064 //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object.
3065 //There's probably a smarter way of doing this, my rotation math-fu is weak.
3066 // http://bugs.meta7.com/view.php?id=28
3067 // - Tom
3068
3069 /* And the following does not do the job either. It has to be performed inside the ODE glue-code. -.- .._.
3070 LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d));
3071 llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos()));
3072 */
3073 if (m_host.PhysActor != null && !m_host.PhysActor.IsPhysical)
3074 {
3075 // Part is non-phys, convert this to a llSetRot()
3076 Vector3 tgt = new Vector3((float)target.x, (float)target.y, (float)target.z);
3077 Vector3 dir = tgt - m_host.GroupPosition;
3078 dir.Normalize();
3079 float tzrot = (float)Math.Atan2(dir.Y, dir.X);
3080 float txy = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y));
3081 float terot = (float)Math.Atan2(-dir.Z, txy);
3082 LSL_Vector az = new LSL_Vector(0.0f, 0.0f, tzrot);
3083 LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f);
3084 LSL_Types.Quaternion spin = llEuler2Rot(az);
3085 LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin;
3086 llSetRot(rot);
3087 }
3088 else
3089 {
3090 // Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt.
3091 Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f);
3092 m_host.RotLookAt(q, (float)strength, (float)damping);
3093 }
3094
3095 }
3096
3097 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3098 {
3099 m_host.AddScriptLPS(1);
3100// NotImplemented("llRotLookAt");
3101 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
3102
2831 } 3103 }
2832 3104
2833 public void llStopLookAt() 3105 public void llStopLookAt()
@@ -2876,13 +3148,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2876 { 3148 {
2877 TaskInventoryItem item; 3149 TaskInventoryItem item;
2878 3150
2879 lock (m_host.TaskInventory) 3151 m_host.TaskInventory.LockItemsForRead(true);
3152 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2880 { 3153 {
2881 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3154 m_host.TaskInventory.LockItemsForRead(false);
2882 return; 3155 return;
2883 else
2884 item = m_host.TaskInventory[InventorySelf()];
2885 } 3156 }
3157 else
3158 {
3159 item = m_host.TaskInventory[InventorySelf()];
3160 }
3161 m_host.TaskInventory.LockItemsForRead(false);
2886 3162
2887 if (item.PermsGranter != UUID.Zero) 3163 if (item.PermsGranter != UUID.Zero)
2888 { 3164 {
@@ -2904,13 +3180,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2904 { 3180 {
2905 TaskInventoryItem item; 3181 TaskInventoryItem item;
2906 3182
3183 m_host.TaskInventory.LockItemsForRead(true);
2907 lock (m_host.TaskInventory) 3184 lock (m_host.TaskInventory)
2908 { 3185 {
3186
2909 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3187 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3188 {
3189 m_host.TaskInventory.LockItemsForRead(false);
2910 return; 3190 return;
3191 }
2911 else 3192 else
3193 {
2912 item = m_host.TaskInventory[InventorySelf()]; 3194 item = m_host.TaskInventory[InventorySelf()];
3195 }
2913 } 3196 }
3197 m_host.TaskInventory.LockItemsForRead(false);
2914 3198
2915 m_host.AddScriptLPS(1); 3199 m_host.AddScriptLPS(1);
2916 3200
@@ -2942,19 +3226,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2942 { 3226 {
2943 m_host.AddScriptLPS(1); 3227 m_host.AddScriptLPS(1);
2944 3228
2945// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
2946// return;
2947
2948 TaskInventoryItem item; 3229 TaskInventoryItem item;
2949 3230
2950 lock (m_host.TaskInventory) 3231 m_host.TaskInventory.LockItemsForRead(true);
3232
3233 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2951 { 3234 {
2952 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3235 m_host.TaskInventory.LockItemsForRead(false);
2953 return; 3236 return;
2954 else 3237 }
2955 item = m_host.TaskInventory[InventorySelf()]; 3238 else
3239 {
3240 item = m_host.TaskInventory[InventorySelf()];
2956 } 3241 }
2957 3242
3243 m_host.TaskInventory.LockItemsForRead(false);
3244
2958 if (item.PermsGranter != m_host.OwnerID) 3245 if (item.PermsGranter != m_host.OwnerID)
2959 return; 3246 return;
2960 3247
@@ -2963,11 +3250,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2963 SceneObjectGroup grp = m_host.ParentGroup; 3250 SceneObjectGroup grp = m_host.ParentGroup;
2964 3251
2965 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3252 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2966 3253 if (presence.Scene.AttachmentsModule != null)
2967 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3254 {
2968 if (attachmentsModule != null) 3255 presence.Scene.AttachmentsModule.AttachObject(presence.ControllingClient, grp, (uint)attachment, false);
2969 attachmentsModule.AttachObject(presence.ControllingClient, 3256 }
2970 grp, (uint)attachment, false);
2971 } 3257 }
2972 } 3258 }
2973 3259
@@ -2980,13 +3266,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2980 3266
2981 TaskInventoryItem item; 3267 TaskInventoryItem item;
2982 3268
2983 lock (m_host.TaskInventory) 3269 m_host.TaskInventory.LockItemsForRead(true);
3270
3271 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2984 { 3272 {
2985 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3273 m_host.TaskInventory.LockItemsForRead(false);
2986 return; 3274 return;
2987 else 3275 }
2988 item = m_host.TaskInventory[InventorySelf()]; 3276 else
3277 {
3278 item = m_host.TaskInventory[InventorySelf()];
2989 } 3279 }
3280 m_host.TaskInventory.LockItemsForRead(false);
3281
2990 3282
2991 if (item.PermsGranter != m_host.OwnerID) 3283 if (item.PermsGranter != m_host.OwnerID)
2992 return; 3284 return;
@@ -3033,6 +3325,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3033 3325
3034 public void llInstantMessage(string user, string message) 3326 public void llInstantMessage(string user, string message)
3035 { 3327 {
3328 UUID result;
3329 if (!UUID.TryParse(user, out result))
3330 {
3331 ShoutError("An invalid key was passed to llInstantMessage");
3332 ScriptSleep(2000);
3333 return;
3334 }
3335
3336
3036 m_host.AddScriptLPS(1); 3337 m_host.AddScriptLPS(1);
3037 3338
3038 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3339 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -3047,14 +3348,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3047 UUID friendTransactionID = UUID.Random(); 3348 UUID friendTransactionID = UUID.Random();
3048 3349
3049 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3350 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
3050 3351
3051 GridInstantMessage msg = new GridInstantMessage(); 3352 GridInstantMessage msg = new GridInstantMessage();
3052 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3353 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
3053 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3354 msg.toAgentID = new Guid(user); // toAgentID.Guid;
3054 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3355 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3055// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3356// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3056// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3357// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3057 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3358// DateTime dt = DateTime.UtcNow;
3359//
3360// // Ticks from UtcNow, but make it look like local. Evil, huh?
3361// dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3362//
3363// try
3364// {
3365// // Convert that to the PST timezone
3366// TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3367// dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3368// }
3369// catch
3370// {
3371// // No logging here, as it could be VERY spammy
3372// }
3373//
3374// // And make it look local again to fool the unix time util
3375// dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3376
3377 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
3378
3058 //if (client != null) 3379 //if (client != null)
3059 //{ 3380 //{
3060 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3381 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
@@ -3068,12 +3389,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3068 msg.message = message.Substring(0, 1024); 3389 msg.message = message.Substring(0, 1024);
3069 else 3390 else
3070 msg.message = message; 3391 msg.message = message;
3071 msg.dialog = (byte)19; // messgage from script ??? // dialog; 3392 msg.dialog = (byte)19; // MessageFromObject
3072 msg.fromGroup = false;// fromGroup; 3393 msg.fromGroup = false;// fromGroup;
3073 msg.offline = (byte)0; //offline; 3394 msg.offline = (byte)0; //offline;
3074 msg.ParentEstateID = 0; //ParentEstateID; 3395 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3075 msg.Position = new Vector3(m_host.AbsolutePosition); 3396 msg.Position = new Vector3(m_host.AbsolutePosition);
3076 msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; 3397 msg.RegionID = World.RegionInfo.RegionID.Guid;
3077 msg.binaryBucket 3398 msg.binaryBucket
3078 = Util.StringToBytes256( 3399 = Util.StringToBytes256(
3079 "{0}/{1}/{2}/{3}", 3400 "{0}/{1}/{2}/{3}",
@@ -3101,7 +3422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3101 } 3422 }
3102 3423
3103 emailModule.SendEmail(m_host.UUID, address, subject, message); 3424 emailModule.SendEmail(m_host.UUID, address, subject, message);
3104 ScriptSleep(20000); 3425 ScriptSleep(15000);
3105 } 3426 }
3106 3427
3107 public void llGetNextEmail(string address, string subject) 3428 public void llGetNextEmail(string address, string subject)
@@ -3201,13 +3522,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3201 m_host.AddScriptLPS(1); 3522 m_host.AddScriptLPS(1);
3202 } 3523 }
3203 3524
3204 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3205 {
3206 m_host.AddScriptLPS(1);
3207 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3208 m_host.RotLookAt(rot, (float)strength, (float)damping);
3209 }
3210
3211 public LSL_Integer llStringLength(string str) 3525 public LSL_Integer llStringLength(string str)
3212 { 3526 {
3213 m_host.AddScriptLPS(1); 3527 m_host.AddScriptLPS(1);
@@ -3231,14 +3545,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3231 3545
3232 TaskInventoryItem item; 3546 TaskInventoryItem item;
3233 3547
3234 lock (m_host.TaskInventory) 3548 m_host.TaskInventory.LockItemsForRead(true);
3549 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3235 { 3550 {
3236 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3551 m_host.TaskInventory.LockItemsForRead(false);
3237 return; 3552 return;
3238 else
3239 item = m_host.TaskInventory[InventorySelf()];
3240 } 3553 }
3241 3554 else
3555 {
3556 item = m_host.TaskInventory[InventorySelf()];
3557 }
3558 m_host.TaskInventory.LockItemsForRead(false);
3242 if (item.PermsGranter == UUID.Zero) 3559 if (item.PermsGranter == UUID.Zero)
3243 return; 3560 return;
3244 3561
@@ -3268,13 +3585,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3268 3585
3269 TaskInventoryItem item; 3586 TaskInventoryItem item;
3270 3587
3271 lock (m_host.TaskInventory) 3588 m_host.TaskInventory.LockItemsForRead(true);
3589 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3272 { 3590 {
3273 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3591 m_host.TaskInventory.LockItemsForRead(false);
3274 return; 3592 return;
3275 else 3593 }
3276 item = m_host.TaskInventory[InventorySelf()]; 3594 else
3595 {
3596 item = m_host.TaskInventory[InventorySelf()];
3277 } 3597 }
3598 m_host.TaskInventory.LockItemsForRead(false);
3599
3278 3600
3279 if (item.PermsGranter == UUID.Zero) 3601 if (item.PermsGranter == UUID.Zero)
3280 return; 3602 return;
@@ -3339,10 +3661,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3339 3661
3340 TaskInventoryItem item; 3662 TaskInventoryItem item;
3341 3663
3342 lock (m_host.TaskInventory) 3664
3665 m_host.TaskInventory.LockItemsForRead(true);
3666 if (!m_host.TaskInventory.ContainsKey(invItemID))
3667 {
3668 m_host.TaskInventory.LockItemsForRead(false);
3669 return;
3670 }
3671 else
3343 { 3672 {
3344 item = m_host.TaskInventory[invItemID]; 3673 item = m_host.TaskInventory[invItemID];
3345 } 3674 }
3675 m_host.TaskInventory.LockItemsForRead(false);
3346 3676
3347 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3677 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3348 { 3678 {
@@ -3370,15 +3700,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3370 int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | 3700 int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS |
3371 ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | 3701 ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
3372 ScriptBaseClass.PERMISSION_CONTROL_CAMERA | 3702 ScriptBaseClass.PERMISSION_CONTROL_CAMERA |
3703 ScriptBaseClass.PERMISSION_TRACK_CAMERA |
3373 ScriptBaseClass.PERMISSION_ATTACH; 3704 ScriptBaseClass.PERMISSION_ATTACH;
3374 3705
3375 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3706 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3376 { 3707 {
3377 lock (m_host.TaskInventory) 3708 m_host.TaskInventory.LockItemsForWrite(true);
3378 { 3709 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3379 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3710 m_host.TaskInventory[invItemID].PermsMask = perm;
3380 m_host.TaskInventory[invItemID].PermsMask = perm; 3711 m_host.TaskInventory.LockItemsForWrite(false);
3381 }
3382 3712
3383 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3713 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3384 "run_time_permissions", new Object[] { 3714 "run_time_permissions", new Object[] {
@@ -3388,28 +3718,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3388 return; 3718 return;
3389 } 3719 }
3390 } 3720 }
3391 else if (m_host.SitTargetAvatar == agentID) // Sitting avatar 3721 else
3392 { 3722 {
3393 // When agent is sitting, certain permissions are implicit if requested from sitting agent 3723 bool sitting = false;
3394 int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | 3724 if (m_host.SitTargetAvatar == agentID)
3395 ScriptBaseClass.PERMISSION_CONTROL_CAMERA | 3725 {
3396 ScriptBaseClass.PERMISSION_TRACK_CAMERA | 3726 sitting = true;
3397 ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 3727 }
3728 else
3729 {
3730 foreach (SceneObjectPart p in m_host.ParentGroup.Parts)
3731 {
3732 if (p.SitTargetAvatar == agentID)
3733 sitting = true;
3734 }
3735 }
3398 3736
3399 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3737 if (sitting)
3400 { 3738 {
3401 lock (m_host.TaskInventory) 3739 // When agent is sitting, certain permissions are implicit if requested from sitting agent
3740 int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
3741 ScriptBaseClass.PERMISSION_CONTROL_CAMERA |
3742 ScriptBaseClass.PERMISSION_TRACK_CAMERA |
3743 ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
3744
3745 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3402 { 3746 {
3747 m_host.TaskInventory.LockItemsForWrite(true);
3403 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3748 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3404 m_host.TaskInventory[invItemID].PermsMask = perm; 3749 m_host.TaskInventory[invItemID].PermsMask = perm;
3405 } 3750 m_host.TaskInventory.LockItemsForWrite(false);
3406 3751
3407 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3752 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3408 "run_time_permissions", new Object[] { 3753 "run_time_permissions", new Object[] {
3409 new LSL_Integer(perm) }, 3754 new LSL_Integer(perm) },
3410 new DetectParams[0])); 3755 new DetectParams[0]));
3411 3756
3412 return; 3757 return;
3758 }
3413 } 3759 }
3414 } 3760 }
3415 3761
@@ -3423,11 +3769,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3423 3769
3424 if (!m_waitingForScriptAnswer) 3770 if (!m_waitingForScriptAnswer)
3425 { 3771 {
3426 lock (m_host.TaskInventory) 3772 m_host.TaskInventory.LockItemsForWrite(true);
3427 { 3773 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3428 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3774 m_host.TaskInventory[invItemID].PermsMask = 0;
3429 m_host.TaskInventory[invItemID].PermsMask = 0; 3775 m_host.TaskInventory.LockItemsForWrite(false);
3430 }
3431 3776
3432 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3777 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3433 m_waitingForScriptAnswer=true; 3778 m_waitingForScriptAnswer=true;
@@ -3462,10 +3807,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3462 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3807 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3463 llReleaseControls(); 3808 llReleaseControls();
3464 3809
3465 lock (m_host.TaskInventory) 3810
3466 { 3811 m_host.TaskInventory.LockItemsForWrite(true);
3467 m_host.TaskInventory[invItemID].PermsMask = answer; 3812 m_host.TaskInventory[invItemID].PermsMask = answer;
3468 } 3813 m_host.TaskInventory.LockItemsForWrite(false);
3814
3469 3815
3470 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3816 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3471 "run_time_permissions", new Object[] { 3817 "run_time_permissions", new Object[] {
@@ -3477,16 +3823,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3477 { 3823 {
3478 m_host.AddScriptLPS(1); 3824 m_host.AddScriptLPS(1);
3479 3825
3480 lock (m_host.TaskInventory) 3826 m_host.TaskInventory.LockItemsForRead(true);
3827
3828 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3481 { 3829 {
3482 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3830 if (item.Type == 10 && item.ItemID == m_itemID)
3483 { 3831 {
3484 if (item.Type == 10 && item.ItemID == m_itemID) 3832 m_host.TaskInventory.LockItemsForRead(false);
3485 { 3833 return item.PermsGranter.ToString();
3486 return item.PermsGranter.ToString();
3487 }
3488 } 3834 }
3489 } 3835 }
3836 m_host.TaskInventory.LockItemsForRead(false);
3490 3837
3491 return UUID.Zero.ToString(); 3838 return UUID.Zero.ToString();
3492 } 3839 }
@@ -3495,19 +3842,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3495 { 3842 {
3496 m_host.AddScriptLPS(1); 3843 m_host.AddScriptLPS(1);
3497 3844
3498 lock (m_host.TaskInventory) 3845 m_host.TaskInventory.LockItemsForRead(true);
3846
3847 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3499 { 3848 {
3500 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3849 if (item.Type == 10 && item.ItemID == m_itemID)
3501 { 3850 {
3502 if (item.Type == 10 && item.ItemID == m_itemID) 3851 int perms = item.PermsMask;
3503 { 3852 if (m_automaticLinkPermission)
3504 int perms = item.PermsMask; 3853 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3505 if (m_automaticLinkPermission) 3854 m_host.TaskInventory.LockItemsForRead(false);
3506 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3855 return perms;
3507 return perms;
3508 }
3509 } 3856 }
3510 } 3857 }
3858 m_host.TaskInventory.LockItemsForRead(false);
3511 3859
3512 return 0; 3860 return 0;
3513 } 3861 }
@@ -3529,9 +3877,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3529 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3877 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3530 { 3878 {
3531 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3879 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3532 3880 if (parts.Count > 0)
3533 foreach (SceneObjectPart part in parts) 3881 {
3534 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3882 try
3883 {
3884 parts[0].ParentGroup.areUpdatesSuspended = true;
3885 foreach (SceneObjectPart part in parts)
3886 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3887 }
3888 finally
3889 {
3890 parts[0].ParentGroup.areUpdatesSuspended = false;
3891 }
3892 }
3535 } 3893 }
3536 3894
3537 public void llCreateLink(string target, int parent) 3895 public void llCreateLink(string target, int parent)
@@ -3544,11 +3902,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3544 return; 3902 return;
3545 3903
3546 TaskInventoryItem item; 3904 TaskInventoryItem item;
3547 lock (m_host.TaskInventory) 3905 m_host.TaskInventory.LockItemsForRead(true);
3548 { 3906 item = m_host.TaskInventory[invItemID];
3549 item = m_host.TaskInventory[invItemID]; 3907 m_host.TaskInventory.LockItemsForRead(false);
3550 } 3908
3551
3552 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3909 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3553 && !m_automaticLinkPermission) 3910 && !m_automaticLinkPermission)
3554 { 3911 {
@@ -3565,11 +3922,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3565 3922
3566 if (targetPart.ParentGroup.AttachmentPoint != 0) 3923 if (targetPart.ParentGroup.AttachmentPoint != 0)
3567 return; // Fail silently if attached 3924 return; // Fail silently if attached
3925
3926 if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID)
3927 return;
3928
3568 SceneObjectGroup parentPrim = null, childPrim = null; 3929 SceneObjectGroup parentPrim = null, childPrim = null;
3569 3930
3570 if (targetPart != null) 3931 if (targetPart != null)
3571 { 3932 {
3572 if (parent != 0) { 3933 if (parent != 0)
3934 {
3573 parentPrim = m_host.ParentGroup; 3935 parentPrim = m_host.ParentGroup;
3574 childPrim = targetPart.ParentGroup; 3936 childPrim = targetPart.ParentGroup;
3575 } 3937 }
@@ -3601,16 +3963,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3601 m_host.AddScriptLPS(1); 3963 m_host.AddScriptLPS(1);
3602 UUID invItemID = InventorySelf(); 3964 UUID invItemID = InventorySelf();
3603 3965
3604 lock (m_host.TaskInventory) 3966 m_host.TaskInventory.LockItemsForRead(true);
3605 {
3606 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3967 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3607 && !m_automaticLinkPermission) 3968 && !m_automaticLinkPermission)
3608 { 3969 {
3609 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3970 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3971 m_host.TaskInventory.LockItemsForRead(false);
3610 return; 3972 return;
3611 } 3973 }
3612 } 3974 m_host.TaskInventory.LockItemsForRead(false);
3613 3975
3614 if (linknum < ScriptBaseClass.LINK_THIS) 3976 if (linknum < ScriptBaseClass.LINK_THIS)
3615 return; 3977 return;
3616 3978
@@ -3649,10 +4011,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3649 // Restructuring Multiple Prims. 4011 // Restructuring Multiple Prims.
3650 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); 4012 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts);
3651 parts.Remove(parentPrim.RootPart); 4013 parts.Remove(parentPrim.RootPart);
3652 foreach (SceneObjectPart part in parts) 4014 if (parts.Count > 0)
3653 { 4015 {
3654 parentPrim.DelinkFromGroup(part.LocalId, true); 4016 try
4017 {
4018 parts[0].ParentGroup.areUpdatesSuspended = true;
4019 foreach (SceneObjectPart part in parts)
4020 {
4021 parentPrim.DelinkFromGroup(part.LocalId, true);
4022 }
4023 }
4024 finally
4025 {
4026 parts[0].ParentGroup.areUpdatesSuspended = false;
4027 }
3655 } 4028 }
4029
3656 parentPrim.HasGroupChanged = true; 4030 parentPrim.HasGroupChanged = true;
3657 parentPrim.ScheduleGroupForFullUpdate(); 4031 parentPrim.ScheduleGroupForFullUpdate();
3658 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 4032 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3661,11 +4035,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3661 { 4035 {
3662 SceneObjectPart newRoot = parts[0]; 4036 SceneObjectPart newRoot = parts[0];
3663 parts.Remove(newRoot); 4037 parts.Remove(newRoot);
3664 foreach (SceneObjectPart part in parts) 4038
4039 try
3665 { 4040 {
3666 part.UpdateFlag = 0; 4041 parts[0].ParentGroup.areUpdatesSuspended = true;
3667 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 4042 foreach (SceneObjectPart part in parts)
4043 {
4044 part.UpdateFlag = 0;
4045 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
4046 }
3668 } 4047 }
4048 finally
4049 {
4050 parts[0].ParentGroup.areUpdatesSuspended = false;
4051 }
4052
4053
3669 newRoot.ParentGroup.HasGroupChanged = true; 4054 newRoot.ParentGroup.HasGroupChanged = true;
3670 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 4055 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3671 } 4056 }
@@ -3685,6 +4070,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3685 public void llBreakAllLinks() 4070 public void llBreakAllLinks()
3686 { 4071 {
3687 m_host.AddScriptLPS(1); 4072 m_host.AddScriptLPS(1);
4073
4074 UUID invItemID = InventorySelf();
4075
4076 TaskInventoryItem item;
4077 m_host.TaskInventory.LockItemsForRead(true);
4078 item = m_host.TaskInventory[invItemID];
4079 m_host.TaskInventory.LockItemsForRead(false);
4080
4081 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4082 && !m_automaticLinkPermission)
4083 {
4084 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4085 return;
4086 }
4087
3688 SceneObjectGroup parentPrim = m_host.ParentGroup; 4088 SceneObjectGroup parentPrim = m_host.ParentGroup;
3689 if (parentPrim.AttachmentPoint != 0) 4089 if (parentPrim.AttachmentPoint != 0)
3690 return; // Fail silently if attached 4090 return; // Fail silently if attached
@@ -3711,6 +4111,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3711 } 4111 }
3712 else 4112 else
3713 { 4113 {
4114 if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1))
4115 {
4116 linknum -= (m_host.ParentGroup.PrimCount) + 1;
4117
4118 if (linknum < 0)
4119 return UUID.Zero.ToString();
4120
4121 List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET);
4122 if (avatars.Count > linknum)
4123 {
4124 return avatars[linknum].UUID.ToString();
4125 }
4126 }
3714 return UUID.Zero.ToString(); 4127 return UUID.Zero.ToString();
3715 } 4128 }
3716 } 4129 }
@@ -3787,17 +4200,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3787 m_host.AddScriptLPS(1); 4200 m_host.AddScriptLPS(1);
3788 int count = 0; 4201 int count = 0;
3789 4202
3790 lock (m_host.TaskInventory) 4203 m_host.TaskInventory.LockItemsForRead(true);
4204 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3791 { 4205 {
3792 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4206 if (inv.Value.Type == type || type == -1)
3793 { 4207 {
3794 if (inv.Value.Type == type || type == -1) 4208 count = count + 1;
3795 {
3796 count = count + 1;
3797 }
3798 } 4209 }
3799 } 4210 }
3800 4211
4212 m_host.TaskInventory.LockItemsForRead(false);
3801 return count; 4213 return count;
3802 } 4214 }
3803 4215
@@ -3806,16 +4218,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3806 m_host.AddScriptLPS(1); 4218 m_host.AddScriptLPS(1);
3807 ArrayList keys = new ArrayList(); 4219 ArrayList keys = new ArrayList();
3808 4220
3809 lock (m_host.TaskInventory) 4221 m_host.TaskInventory.LockItemsForRead(true);
4222 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3810 { 4223 {
3811 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4224 if (inv.Value.Type == type || type == -1)
3812 { 4225 {
3813 if (inv.Value.Type == type || type == -1) 4226 keys.Add(inv.Value.Name);
3814 {
3815 keys.Add(inv.Value.Name);
3816 }
3817 } 4227 }
3818 } 4228 }
4229 m_host.TaskInventory.LockItemsForRead(false);
3819 4230
3820 if (keys.Count == 0) 4231 if (keys.Count == 0)
3821 { 4232 {
@@ -3852,25 +4263,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3852 } 4263 }
3853 4264
3854 // move the first object found with this inventory name 4265 // move the first object found with this inventory name
3855 lock (m_host.TaskInventory) 4266 m_host.TaskInventory.LockItemsForRead(true);
4267 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3856 { 4268 {
3857 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4269 if (inv.Value.Name == inventory)
3858 { 4270 {
3859 if (inv.Value.Name == inventory) 4271 found = true;
3860 { 4272 objId = inv.Key;
3861 found = true; 4273 assetType = inv.Value.Type;
3862 objId = inv.Key; 4274 objName = inv.Value.Name;
3863 assetType = inv.Value.Type; 4275 break;
3864 objName = inv.Value.Name;
3865 break;
3866 }
3867 } 4276 }
3868 } 4277 }
4278 m_host.TaskInventory.LockItemsForRead(false);
3869 4279
3870 if (!found) 4280 if (!found)
3871 { 4281 {
3872 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4282 llSay(0, String.Format("Could not find object '{0}'", inventory));
3873 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4283 return;
4284// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3874 } 4285 }
3875 4286
3876 // check if destination is an object 4287 // check if destination is an object
@@ -3896,6 +4307,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3896 return; 4307 return;
3897 } 4308 }
3898 } 4309 }
4310
3899 // destination is an avatar 4311 // destination is an avatar
3900 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4312 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
3901 4313
@@ -3918,26 +4330,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3918 bucket); 4330 bucket);
3919 if (m_TransferModule != null) 4331 if (m_TransferModule != null)
3920 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4332 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4333
4334 //This delay should only occur when giving inventory to avatars.
3921 ScriptSleep(3000); 4335 ScriptSleep(3000);
3922 } 4336 }
3923 } 4337 }
3924 4338
4339 [DebuggerNonUserCode]
3925 public void llRemoveInventory(string name) 4340 public void llRemoveInventory(string name)
3926 { 4341 {
3927 m_host.AddScriptLPS(1); 4342 m_host.AddScriptLPS(1);
3928 4343
3929 lock (m_host.TaskInventory) 4344 List<TaskInventoryItem> inv;
4345 try
3930 { 4346 {
3931 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4347 m_host.TaskInventory.LockItemsForRead(true);
4348 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values);
4349 }
4350 finally
4351 {
4352 m_host.TaskInventory.LockItemsForRead(false);
4353 }
4354 foreach (TaskInventoryItem item in inv)
4355 {
4356 if (item.Name == name)
3932 { 4357 {
3933 if (item.Name == name) 4358 if (item.ItemID == m_itemID)
3934 { 4359 throw new ScriptDeleteException();
3935 if (item.ItemID == m_itemID) 4360 else
3936 throw new ScriptDeleteException(); 4361 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3937 else 4362 return;
3938 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3939 return;
3940 }
3941 } 4363 }
3942 } 4364 }
3943 } 4365 }
@@ -3972,112 +4394,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3972 { 4394 {
3973 m_host.AddScriptLPS(1); 4395 m_host.AddScriptLPS(1);
3974 4396
3975 UUID uuid = (UUID)id; 4397 UUID uuid;
3976 PresenceInfo pinfo = null; 4398 if (UUID.TryParse(id, out uuid))
3977 UserAccount account;
3978
3979 UserInfoCacheEntry ce;
3980 if (!m_userInfoCache.TryGetValue(uuid, out ce))
3981 { 4399 {
3982 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 4400 PresenceInfo pinfo = null;
3983 if (account == null) 4401 UserAccount account;
4402
4403 UserInfoCacheEntry ce;
4404 if (!m_userInfoCache.TryGetValue(uuid, out ce))
3984 { 4405 {
3985 m_userInfoCache[uuid] = null; // Cache negative 4406 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
3986 return UUID.Zero.ToString(); 4407 if (account == null)
3987 } 4408 {
4409 m_userInfoCache[uuid] = null; // Cache negative
4410 return UUID.Zero.ToString();
4411 }
3988 4412
3989 4413
3990 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 4414 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3991 if (pinfos != null && pinfos.Length > 0) 4415 if (pinfos != null && pinfos.Length > 0)
3992 {
3993 foreach (PresenceInfo p in pinfos)
3994 { 4416 {
3995 if (p.RegionID != UUID.Zero) 4417 foreach (PresenceInfo p in pinfos)
3996 { 4418 {
3997 pinfo = p; 4419 if (p.RegionID != UUID.Zero)
4420 {
4421 pinfo = p;
4422 }
3998 } 4423 }
3999 } 4424 }
4000 }
4001 4425
4002 ce = new UserInfoCacheEntry(); 4426 ce = new UserInfoCacheEntry();
4003 ce.time = Util.EnvironmentTickCount(); 4427 ce.time = Util.EnvironmentTickCount();
4004 ce.account = account; 4428 ce.account = account;
4005 ce.pinfo = pinfo; 4429 ce.pinfo = pinfo;
4006 } 4430 m_userInfoCache[uuid] = ce;
4007 else 4431 }
4008 { 4432 else
4009 if (ce == null) 4433 {
4010 return UUID.Zero.ToString(); 4434 if (ce == null)
4435 return UUID.Zero.ToString();
4011 4436
4012 account = ce.account; 4437 account = ce.account;
4013 pinfo = ce.pinfo; 4438 pinfo = ce.pinfo;
4014 } 4439 }
4015 4440
4016 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) 4441 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
4017 {
4018 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4019 if (pinfos != null && pinfos.Length > 0)
4020 { 4442 {
4021 foreach (PresenceInfo p in pinfos) 4443 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4444 if (pinfos != null && pinfos.Length > 0)
4022 { 4445 {
4023 if (p.RegionID != UUID.Zero) 4446 foreach (PresenceInfo p in pinfos)
4024 { 4447 {
4025 pinfo = p; 4448 if (p.RegionID != UUID.Zero)
4449 {
4450 pinfo = p;
4451 }
4026 } 4452 }
4027 } 4453 }
4028 } 4454 else
4029 else 4455 pinfo = null;
4030 pinfo = null;
4031 4456
4032 ce.time = Util.EnvironmentTickCount(); 4457 ce.time = Util.EnvironmentTickCount();
4033 ce.pinfo = pinfo; 4458 ce.pinfo = pinfo;
4034 } 4459 }
4035 4460
4036 string reply = String.Empty; 4461 string reply = String.Empty;
4037 4462
4038 switch (data) 4463 switch (data)
4039 { 4464 {
4040 case 1: // DATA_ONLINE (0|1) 4465 case 1: // DATA_ONLINE (0|1)
4041 if (pinfo != null && pinfo.RegionID != UUID.Zero) 4466 if (pinfo != null && pinfo.RegionID != UUID.Zero)
4042 reply = "1"; 4467 reply = "1";
4043 else 4468 else
4044 reply = "0"; 4469 reply = "0";
4045 break; 4470 break;
4046 case 2: // DATA_NAME (First Last) 4471 case 2: // DATA_NAME (First Last)
4047 reply = account.FirstName + " " + account.LastName; 4472 reply = account.FirstName + " " + account.LastName;
4048 break; 4473 break;
4049 case 3: // DATA_BORN (YYYY-MM-DD) 4474 case 3: // DATA_BORN (YYYY-MM-DD)
4050 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 4475 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
4051 born = born.AddSeconds(account.Created); 4476 born = born.AddSeconds(account.Created);
4052 reply = born.ToString("yyyy-MM-dd"); 4477 reply = born.ToString("yyyy-MM-dd");
4053 break; 4478 break;
4054 case 4: // DATA_RATING (0,0,0,0,0,0) 4479 case 4: // DATA_RATING (0,0,0,0,0,0)
4055 reply = "0,0,0,0,0,0"; 4480 reply = "0,0,0,0,0,0";
4056 break; 4481 break;
4057 case 8: // DATA_PAYINFO (0|1|2|3) 4482 case 8: // DATA_PAYINFO (0|1|2|3)
4058 reply = "0"; 4483 reply = "0";
4059 break; 4484 break;
4060 default: 4485 default:
4061 return UUID.Zero.ToString(); // Raise no event 4486 return UUID.Zero.ToString(); // Raise no event
4062 } 4487 }
4063 4488
4064 UUID rq = UUID.Random(); 4489 UUID rq = UUID.Random();
4065 4490
4066 UUID tid = AsyncCommands. 4491 UUID tid = AsyncCommands.
4067 DataserverPlugin.RegisterRequest(m_localID, 4492 DataserverPlugin.RegisterRequest(m_localID,
4068 m_itemID, rq.ToString()); 4493 m_itemID, rq.ToString());
4069 4494
4070 AsyncCommands. 4495 AsyncCommands.
4071 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4496 DataserverPlugin.DataserverReply(rq.ToString(), reply);
4072 4497
4073 ScriptSleep(100); 4498 ScriptSleep(100);
4074 return tid.ToString(); 4499 return tid.ToString();
4500 }
4501 else
4502 {
4503 ShoutError("Invalid UUID passed to llRequestAgentData.");
4504 }
4505 return "";
4075 } 4506 }
4076 4507
4077 public LSL_String llRequestInventoryData(string name) 4508 public LSL_String llRequestInventoryData(string name)
4078 { 4509 {
4079 m_host.AddScriptLPS(1); 4510 m_host.AddScriptLPS(1);
4080 4511
4512 //Clone is thread safe
4081 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4513 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4082 4514
4083 foreach (TaskInventoryItem item in itemDictionary.Values) 4515 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -4131,6 +4563,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4131 ScenePresence presence = World.GetScenePresence(agentId); 4563 ScenePresence presence = World.GetScenePresence(agentId);
4132 if (presence != null) 4564 if (presence != null)
4133 { 4565 {
4566 // agent must not be a god
4567 if (presence.UserLevel >= 200) return;
4568
4134 // agent must be over the owners land 4569 // agent must be over the owners land
4135 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4570 if (m_host.OwnerID == World.LandChannel.GetLandObject(
4136 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4571 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
@@ -4153,7 +4588,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4153 UUID av = new UUID(); 4588 UUID av = new UUID();
4154 if (!UUID.TryParse(agent,out av)) 4589 if (!UUID.TryParse(agent,out av))
4155 { 4590 {
4156 LSLError("First parameter to llDialog needs to be a key"); 4591 //LSLError("First parameter to llDialog needs to be a key");
4157 return; 4592 return;
4158 } 4593 }
4159 4594
@@ -4190,17 +4625,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4190 UUID soundId = UUID.Zero; 4625 UUID soundId = UUID.Zero;
4191 if (!UUID.TryParse(impact_sound, out soundId)) 4626 if (!UUID.TryParse(impact_sound, out soundId))
4192 { 4627 {
4193 lock (m_host.TaskInventory) 4628 m_host.TaskInventory.LockItemsForRead(true);
4629 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4194 { 4630 {
4195 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4631 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4196 { 4632 {
4197 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4633 soundId = item.AssetID;
4198 { 4634 break;
4199 soundId = item.AssetID;
4200 break;
4201 }
4202 } 4635 }
4203 } 4636 }
4637 m_host.TaskInventory.LockItemsForRead(false);
4204 } 4638 }
4205 m_host.CollisionSound = soundId; 4639 m_host.CollisionSound = soundId;
4206 m_host.CollisionSoundVolume = (float)impact_volume; 4640 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4240,6 +4674,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4240 UUID partItemID; 4674 UUID partItemID;
4241 foreach (SceneObjectPart part in parts) 4675 foreach (SceneObjectPart part in parts)
4242 { 4676 {
4677 //Clone is thread safe
4243 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4678 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4244 4679
4245 foreach (TaskInventoryItem item in itemsDictionary.Values) 4680 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4454,17 +4889,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4454 4889
4455 m_host.AddScriptLPS(1); 4890 m_host.AddScriptLPS(1);
4456 4891
4457 lock (m_host.TaskInventory) 4892 m_host.TaskInventory.LockItemsForRead(true);
4893 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4458 { 4894 {
4459 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4895 if (item.Type == 10 && item.ItemID == m_itemID)
4460 { 4896 {
4461 if (item.Type == 10 && item.ItemID == m_itemID) 4897 result = item.Name!=null?item.Name:String.Empty;
4462 { 4898 break;
4463 result = item.Name != null ? item.Name : String.Empty;
4464 break;
4465 }
4466 } 4899 }
4467 } 4900 }
4901 m_host.TaskInventory.LockItemsForRead(false);
4468 4902
4469 return result; 4903 return result;
4470 } 4904 }
@@ -4633,23 +5067,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4633 { 5067 {
4634 m_host.AddScriptLPS(1); 5068 m_host.AddScriptLPS(1);
4635 5069
4636 lock (m_host.TaskInventory) 5070 m_host.TaskInventory.LockItemsForRead(true);
5071 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4637 { 5072 {
4638 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 5073 if (inv.Value.Name == name)
4639 { 5074 {
4640 if (inv.Value.Name == name) 5075 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4641 { 5076 {
4642 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 5077 m_host.TaskInventory.LockItemsForRead(false);
4643 { 5078 return inv.Value.AssetID.ToString();
4644 return inv.Value.AssetID.ToString(); 5079 }
4645 } 5080 else
4646 else 5081 {
4647 { 5082 m_host.TaskInventory.LockItemsForRead(false);
4648 return UUID.Zero.ToString(); 5083 return UUID.Zero.ToString();
4649 }
4650 } 5084 }
4651 } 5085 }
4652 } 5086 }
5087 m_host.TaskInventory.LockItemsForRead(false);
4653 5088
4654 return UUID.Zero.ToString(); 5089 return UUID.Zero.ToString();
4655 } 5090 }
@@ -4802,14 +5237,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4802 { 5237 {
4803 m_host.AddScriptLPS(1); 5238 m_host.AddScriptLPS(1);
4804 5239
4805 if (src == null) 5240 return src.Length;
4806 {
4807 return 0;
4808 }
4809 else
4810 {
4811 return src.Length;
4812 }
4813 } 5241 }
4814 5242
4815 public LSL_Integer llList2Integer(LSL_List src, int index) 5243 public LSL_Integer llList2Integer(LSL_List src, int index)
@@ -4855,7 +5283,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4855 else if (src.Data[index] is LSL_Float) 5283 else if (src.Data[index] is LSL_Float)
4856 return Convert.ToDouble(((LSL_Float) src.Data[index]).value); 5284 return Convert.ToDouble(((LSL_Float) src.Data[index]).value);
4857 else if (src.Data[index] is LSL_String) 5285 else if (src.Data[index] is LSL_String)
4858 return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); 5286 {
5287 string str = ((LSL_String) src.Data[index]).m_string;
5288 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
5289 if (m != Match.Empty)
5290 {
5291 str = m.Value;
5292 double d = 0.0;
5293 if (!Double.TryParse(str, out d))
5294 return 0.0;
5295
5296 return d;
5297 }
5298 return 0.0;
5299 }
4859 return Convert.ToDouble(src.Data[index]); 5300 return Convert.ToDouble(src.Data[index]);
4860 } 5301 }
4861 catch (FormatException) 5302 catch (FormatException)
@@ -5128,7 +5569,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5128 } 5569 }
5129 } 5570 }
5130 } 5571 }
5131 else { 5572 else
5573 {
5132 object[] array = new object[src.Length]; 5574 object[] array = new object[src.Length];
5133 Array.Copy(src.Data, 0, array, 0, src.Length); 5575 Array.Copy(src.Data, 0, array, 0, src.Length);
5134 result = new LSL_List(array); 5576 result = new LSL_List(array);
@@ -5579,10 +6021,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5579 m_host.AddScriptLPS(1); 6021 m_host.AddScriptLPS(1);
5580 6022
5581 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6023 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5582 6024 if (parts.Count > 0)
5583 foreach (var part in parts)
5584 { 6025 {
5585 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 6026 try
6027 {
6028 parts[0].ParentGroup.areUpdatesSuspended = true;
6029 foreach (var part in parts)
6030 {
6031 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
6032 }
6033 }
6034 finally
6035 {
6036 parts[0].ParentGroup.areUpdatesSuspended = false;
6037 }
5586 } 6038 }
5587 } 6039 }
5588 6040
@@ -5636,6 +6088,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5636 ScriptSleep(5000); 6088 ScriptSleep(5000);
5637 } 6089 }
5638 6090
6091 public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers)
6092 {
6093 return ParseString2List(str, separators, in_spacers, false);
6094 }
6095
5639 public LSL_Integer llOverMyLand(string id) 6096 public LSL_Integer llOverMyLand(string id)
5640 { 6097 {
5641 m_host.AddScriptLPS(1); 6098 m_host.AddScriptLPS(1);
@@ -5836,7 +6293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5836 return m_host.ParentGroup.AttachmentPoint; 6293 return m_host.ParentGroup.AttachmentPoint;
5837 } 6294 }
5838 6295
5839 public LSL_Integer llGetFreeMemory() 6296 public virtual LSL_Integer llGetFreeMemory()
5840 { 6297 {
5841 m_host.AddScriptLPS(1); 6298 m_host.AddScriptLPS(1);
5842 // Make scripts designed for LSO happy 6299 // Make scripts designed for LSO happy
@@ -5953,7 +6410,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5953 SetParticleSystem(m_host, rules); 6410 SetParticleSystem(m_host, rules);
5954 } 6411 }
5955 6412
5956 private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { 6413 private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
6414 {
5957 6415
5958 6416
5959 if (rules.Length == 0) 6417 if (rules.Length == 0)
@@ -6147,14 +6605,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6147 6605
6148 protected UUID GetTaskInventoryItem(string name) 6606 protected UUID GetTaskInventoryItem(string name)
6149 { 6607 {
6150 lock (m_host.TaskInventory) 6608 m_host.TaskInventory.LockItemsForRead(true);
6609 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6151 { 6610 {
6152 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6611 if (inv.Value.Name == name)
6153 { 6612 {
6154 if (inv.Value.Name == name) 6613 m_host.TaskInventory.LockItemsForRead(false);
6155 return inv.Key; 6614 return inv.Key;
6156 } 6615 }
6157 } 6616 }
6617 m_host.TaskInventory.LockItemsForRead(false);
6158 6618
6159 return UUID.Zero; 6619 return UUID.Zero;
6160 } 6620 }
@@ -6404,13 +6864,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6404 UUID av = new UUID(); 6864 UUID av = new UUID();
6405 if (!UUID.TryParse(avatar,out av)) 6865 if (!UUID.TryParse(avatar,out av))
6406 { 6866 {
6407 LSLError("First parameter to llDialog needs to be a key"); 6867 //LSLError("First parameter to llDialog needs to be a key");
6408 return; 6868 return;
6409 } 6869 }
6410 if (buttons.Length < 1) 6870 if (buttons.Length < 1)
6411 { 6871 {
6412 LSLError("No less than 1 button can be shown"); 6872 buttons.Add("OK");
6413 return;
6414 } 6873 }
6415 if (buttons.Length > 12) 6874 if (buttons.Length > 12)
6416 { 6875 {
@@ -6427,7 +6886,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6427 } 6886 }
6428 if (buttons.Data[i].ToString().Length > 24) 6887 if (buttons.Data[i].ToString().Length > 24)
6429 { 6888 {
6430 LSLError("button label cannot be longer than 24 characters"); 6889 llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters");
6431 return; 6890 return;
6432 } 6891 }
6433 buts[i] = buttons.Data[i].ToString(); 6892 buts[i] = buttons.Data[i].ToString();
@@ -6486,22 +6945,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6486 } 6945 }
6487 6946
6488 // copy the first script found with this inventory name 6947 // copy the first script found with this inventory name
6489 lock (m_host.TaskInventory) 6948 TaskInventoryItem scriptItem = null;
6949 m_host.TaskInventory.LockItemsForRead(true);
6950 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6490 { 6951 {
6491 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6952 if (inv.Value.Name == name)
6492 { 6953 {
6493 if (inv.Value.Name == name) 6954 // make sure the object is a script
6955 if (10 == inv.Value.Type)
6494 { 6956 {
6495 // make sure the object is a script 6957 found = true;
6496 if (10 == inv.Value.Type) 6958 srcId = inv.Key;
6497 { 6959 scriptItem = inv.Value;
6498 found = true; 6960 break;
6499 srcId = inv.Key;
6500 break;
6501 }
6502 } 6961 }
6503 } 6962 }
6504 } 6963 }
6964 m_host.TaskInventory.LockItemsForRead(false);
6505 6965
6506 if (!found) 6966 if (!found)
6507 { 6967 {
@@ -6509,8 +6969,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6509 return; 6969 return;
6510 } 6970 }
6511 6971
6512 // the rest of the permission checks are done in RezScript, so check the pin there as well 6972 SceneObjectPart dest = World.GetSceneObjectPart(destId);
6513 World.RezScript(srcId, m_host, destId, pin, running, start_param); 6973 if (dest != null)
6974 {
6975 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
6976 {
6977 // the rest of the permission checks are done in RezScript, so check the pin there as well
6978 World.RezScript(srcId, m_host, destId, pin, running, start_param);
6979
6980 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0)
6981 m_host.Inventory.RemoveInventoryItem(srcId);
6982 }
6983 }
6514 // this will cause the delay even if the script pin or permissions were wrong - seems ok 6984 // this will cause the delay even if the script pin or permissions were wrong - seems ok
6515 ScriptSleep(3000); 6985 ScriptSleep(3000);
6516 } 6986 }
@@ -6573,19 +7043,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6573 public LSL_String llMD5String(string src, int nonce) 7043 public LSL_String llMD5String(string src, int nonce)
6574 { 7044 {
6575 m_host.AddScriptLPS(1); 7045 m_host.AddScriptLPS(1);
6576 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); 7046 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8);
6577 } 7047 }
6578 7048
6579 public LSL_String llSHA1String(string src) 7049 public LSL_String llSHA1String(string src)
6580 { 7050 {
6581 m_host.AddScriptLPS(1); 7051 m_host.AddScriptLPS(1);
6582 return Util.SHA1Hash(src).ToLower(); 7052 return Util.SHA1Hash(src, Encoding.UTF8).ToLower();
6583 } 7053 }
6584 7054
6585 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) 7055 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve)
6586 { 7056 {
6587 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7057 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
6588 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7058 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
7059 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7060 return shapeBlock;
6589 7061
6590 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 7062 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6591 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 7063 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6690,6 +7162,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6690 // Prim type box, cylinder and prism. 7162 // Prim type box, cylinder and prism.
6691 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) 7163 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve)
6692 { 7164 {
7165 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7166 return;
7167
6693 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7168 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
6694 ObjectShapePacket.ObjectDataBlock shapeBlock; 7169 ObjectShapePacket.ObjectDataBlock shapeBlock;
6695 7170
@@ -6743,6 +7218,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6743 // Prim type sphere. 7218 // Prim type sphere.
6744 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) 7219 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve)
6745 { 7220 {
7221 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7222 return;
7223
6746 ObjectShapePacket.ObjectDataBlock shapeBlock; 7224 ObjectShapePacket.ObjectDataBlock shapeBlock;
6747 7225
6748 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); 7226 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve);
@@ -6784,6 +7262,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6784 // Prim type torus, tube and ring. 7262 // Prim type torus, tube and ring.
6785 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) 7263 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve)
6786 { 7264 {
7265 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7266 return;
7267
6787 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7268 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
6788 ObjectShapePacket.ObjectDataBlock shapeBlock; 7269 ObjectShapePacket.ObjectDataBlock shapeBlock;
6789 7270
@@ -6919,6 +7400,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6919 // Prim type sculpt. 7400 // Prim type sculpt.
6920 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) 7401 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve)
6921 { 7402 {
7403 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7404 return;
7405
6922 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7406 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6923 UUID sculptId; 7407 UUID sculptId;
6924 7408
@@ -6935,13 +7419,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6935 shapeBlock.PathScaleX = 100; 7419 shapeBlock.PathScaleX = 100;
6936 shapeBlock.PathScaleY = 150; 7420 shapeBlock.PathScaleY = 150;
6937 7421
6938 if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && 7422 if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 &&
6939 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && 7423 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 &&
6940 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && 7424 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 &&
6941 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) 7425 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0)
6942 { 7426 {
6943 // default 7427 // default
6944 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7428 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
6945 } 7429 }
6946 7430
6947 part.Shape.SetSculptProperties((byte)type, sculptId); 7431 part.Shape.SetSculptProperties((byte)type, sculptId);
@@ -6957,32 +7441,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6957 ScriptSleep(200); 7441 ScriptSleep(200);
6958 } 7442 }
6959 7443
6960 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7444 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
6961 { 7445 {
6962 m_host.AddScriptLPS(1); 7446 m_host.AddScriptLPS(1);
6963 7447
6964 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7448 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7449 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7450 if (parts.Count>0)
7451 {
7452 try
7453 {
7454 parts[0].ParentGroup.areUpdatesSuspended = true;
7455 foreach (SceneObjectPart part in parts)
7456 SetPrimParams(part, rules);
7457 }
7458 finally
7459 {
7460 parts[0].ParentGroup.areUpdatesSuspended = false;
7461 }
7462 }
7463 if (avatars.Count > 0)
7464 {
7465 foreach (ScenePresence avatar in avatars)
7466 SetPrimParams(avatar, rules);
7467 }
7468 }
6965 7469
6966 foreach (SceneObjectPart part in parts) 7470 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6967 SetPrimParams(part, rules); 7471 {
6968 7472 llSetLinkPrimitiveParamsFast(linknumber, rules);
6969 ScriptSleep(200); 7473 ScriptSleep(200);
6970 } 7474 }
6971 7475
6972 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7476 protected void SetPrimParams(ScenePresence av, LSL_List rules)
6973 { 7477 {
6974 m_host.AddScriptLPS(1); 7478 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7479 //We only support PRIM_POSITION and PRIM_ROTATION
6975 7480
6976 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7481 int idx = 0;
6977 7482
6978 foreach (SceneObjectPart part in parts) 7483 while (idx < rules.Length)
6979 SetPrimParams(part, rules); 7484 {
7485 int code = rules.GetLSLIntegerItem(idx++);
7486
7487 int remain = rules.Length - idx;
7488
7489
7490
7491 switch (code)
7492 {
7493 case (int)ScriptBaseClass.PRIM_POSITION:
7494 if (remain < 1)
7495 return;
7496 LSL_Vector v;
7497 v = rules.GetVector3Item(idx++);
7498 av.AbsolutePosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7499 av.SendAvatarDataToAllAgents();
7500
7501 break;
7502
7503 case (int)ScriptBaseClass.PRIM_ROTATION:
7504 if (remain < 1)
7505 return;
7506 LSL_Rotation r;
7507 r = rules.GetQuaternionItem(idx++);
7508 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7509 av.SendAvatarDataToAllAgents();
7510 break;
7511 }
7512 }
6980 } 7513 }
6981 7514
6982 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7515 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6983 { 7516 {
7517 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7518 return;
7519
6984 int idx = 0; 7520 int idx = 0;
6985 7521
7522 bool positionChanged = false;
7523 LSL_Vector currentPosition = GetPartLocalPos(part);
7524
6986 while (idx < rules.Length) 7525 while (idx < rules.Length)
6987 { 7526 {
6988 int code = rules.GetLSLIntegerItem(idx++); 7527 int code = rules.GetLSLIntegerItem(idx++);
@@ -6991,7 +7530,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6991 7530
6992 int face; 7531 int face;
6993 LSL_Vector v; 7532 LSL_Vector v;
6994 7533
6995 switch (code) 7534 switch (code)
6996 { 7535 {
6997 case (int)ScriptBaseClass.PRIM_POSITION: 7536 case (int)ScriptBaseClass.PRIM_POSITION:
@@ -6999,7 +7538,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6999 return; 7538 return;
7000 7539
7001 v=rules.GetVector3Item(idx++); 7540 v=rules.GetVector3Item(idx++);
7002 SetPos(part, v); 7541 positionChanged = true;
7542 currentPosition = GetSetPosTarget(part, v, currentPosition);
7003 7543
7004 break; 7544 break;
7005 case (int)ScriptBaseClass.PRIM_SIZE: 7545 case (int)ScriptBaseClass.PRIM_SIZE:
@@ -7344,6 +7884,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7344 break; 7884 break;
7345 } 7885 }
7346 } 7886 }
7887
7888 if (positionChanged)
7889 {
7890 if (part.ParentGroup.RootPart == part)
7891 {
7892 SceneObjectGroup parent = part.ParentGroup;
7893 parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
7894 }
7895 else
7896 {
7897 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
7898 SceneObjectGroup parent = part.ParentGroup;
7899 parent.HasGroupChanged = true;
7900 parent.ScheduleGroupForTerseUpdate();
7901 }
7902 }
7347 } 7903 }
7348 7904
7349 public LSL_String llStringToBase64(string str) 7905 public LSL_String llStringToBase64(string str)
@@ -7492,13 +8048,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7492 public LSL_Integer llGetNumberOfPrims() 8048 public LSL_Integer llGetNumberOfPrims()
7493 { 8049 {
7494 m_host.AddScriptLPS(1); 8050 m_host.AddScriptLPS(1);
7495 int avatarCount = 0; 8051 int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count;
7496 World.ForEachScenePresence(delegate(ScenePresence presence) 8052
7497 {
7498 if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
7499 avatarCount++;
7500 });
7501
7502 return m_host.ParentGroup.PrimCount + avatarCount; 8053 return m_host.ParentGroup.PrimCount + avatarCount;
7503 } 8054 }
7504 8055
@@ -7514,55 +8065,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7514 m_host.AddScriptLPS(1); 8065 m_host.AddScriptLPS(1);
7515 UUID objID = UUID.Zero; 8066 UUID objID = UUID.Zero;
7516 LSL_List result = new LSL_List(); 8067 LSL_List result = new LSL_List();
8068
8069 // If the ID is not valid, return null result
7517 if (!UUID.TryParse(obj, out objID)) 8070 if (!UUID.TryParse(obj, out objID))
7518 { 8071 {
7519 result.Add(new LSL_Vector()); 8072 result.Add(new LSL_Vector());
7520 result.Add(new LSL_Vector()); 8073 result.Add(new LSL_Vector());
7521 return result; 8074 return result;
7522 } 8075 }
8076
8077 // Check if this is an attached prim. If so, replace
8078 // the UUID with the avatar UUID and report it's bounding box
8079 SceneObjectPart part = World.GetSceneObjectPart(objID);
8080 if (part != null && part.ParentGroup.IsAttachment)
8081 objID = part.ParentGroup.AttachedAvatar;
8082
8083 // Find out if this is an avatar ID. If so, return it's box
7523 ScenePresence presence = World.GetScenePresence(objID); 8084 ScenePresence presence = World.GetScenePresence(objID);
7524 if (presence != null) 8085 if (presence != null)
7525 { 8086 {
7526 if (presence.ParentID == 0) // not sat on an object 8087 // As per LSL Wiki, there is no difference between sitting
8088 // and standing avatar since server 1.36
8089 LSL_Vector lower;
8090 LSL_Vector upper;
8091 if (presence.Animator.Animations.DefaultAnimation.AnimID
8092 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
7527 { 8093 {
7528 LSL_Vector lower; 8094 // This is for ground sitting avatars
7529 LSL_Vector upper; 8095 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7530 if (presence.Animator.Animations.DefaultAnimation.AnimID 8096 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7531 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) 8097 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7532 {
7533 // This is for ground sitting avatars
7534 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7535 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7536 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7537 }
7538 else
7539 {
7540 // This is for standing/flying avatars
7541 float height = presence.Appearance.AvatarHeight / 2.0f;
7542 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7543 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7544 }
7545 result.Add(lower);
7546 result.Add(upper);
7547 return result;
7548 } 8098 }
7549 else 8099 else
7550 { 8100 {
7551 // sitting on an object so we need the bounding box of that 8101 // This is for standing/flying avatars
7552 // which should include the avatar so set the UUID to the 8102 float height = presence.Appearance.AvatarHeight / 2.0f;
7553 // UUID of the object the avatar is sat on and allow it to fall through 8103 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7554 // to processing an object 8104 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7555 SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID);
7556 objID = p.UUID;
7557 } 8105 }
8106
8107 // Adjust to the documented error offsets (see LSL Wiki)
8108 lower += new LSL_Vector(0.05f, 0.05f, 0.05f);
8109 upper -= new LSL_Vector(0.05f, 0.05f, 0.05f);
8110
8111 if (lower.x > upper.x)
8112 lower.x = upper.x;
8113 if (lower.y > upper.y)
8114 lower.y = upper.y;
8115 if (lower.z > upper.z)
8116 lower.z = upper.z;
8117
8118 result.Add(lower);
8119 result.Add(upper);
8120 return result;
7558 } 8121 }
7559 SceneObjectPart part = World.GetSceneObjectPart(objID); 8122
8123 part = World.GetSceneObjectPart(objID);
7560 // Currently only works for single prims without a sitting avatar 8124 // Currently only works for single prims without a sitting avatar
7561 if (part != null) 8125 if (part != null)
7562 { 8126 {
7563 Vector3 halfSize = part.Scale / 2.0f; 8127 float minX;
7564 LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); 8128 float maxX;
7565 LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); 8129 float minY;
8130 float maxY;
8131 float minZ;
8132 float maxZ;
8133
8134 // This BBox is in sim coordinates, with the offset being
8135 // a contained point.
8136 Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup },
8137 out minX, out maxX, out minY, out maxY, out minZ, out maxZ);
8138
8139 minX -= offsets[0].X;
8140 maxX -= offsets[0].X;
8141 minY -= offsets[0].Y;
8142 maxY -= offsets[0].Y;
8143 minZ -= offsets[0].Z;
8144 maxZ -= offsets[0].Z;
8145
8146 LSL_Vector lower;
8147 LSL_Vector upper;
8148
8149 // Adjust to the documented error offsets (see LSL Wiki)
8150 lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f);
8151 upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f);
8152
8153 if (lower.x > upper.x)
8154 lower.x = upper.x;
8155 if (lower.y > upper.y)
8156 lower.y = upper.y;
8157 if (lower.z > upper.z)
8158 lower.z = upper.z;
8159
7566 result.Add(lower); 8160 result.Add(lower);
7567 result.Add(upper); 8161 result.Add(upper);
7568 return result; 8162 return result;
@@ -7642,13 +8236,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7642 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, 8236 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X,
7643 part.AbsolutePosition.Y, 8237 part.AbsolutePosition.Y,
7644 part.AbsolutePosition.Z); 8238 part.AbsolutePosition.Z);
7645 // For some reason, the part.AbsolutePosition.* values do not change if the
7646 // linkset is rotated; they always reflect the child prim's world position
7647 // as though the linkset is unrotated. This is incompatible behavior with SL's
7648 // implementation, so will break scripts imported from there (not to mention it
7649 // makes it more difficult to determine a child prim's actual inworld position).
7650 if (part.ParentID != 0)
7651 v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition();
7652 res.Add(v); 8239 res.Add(v);
7653 break; 8240 break;
7654 8241
@@ -7819,56 +8406,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7819 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8406 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7820 if (remain < 1) 8407 if (remain < 1)
7821 return res; 8408 return res;
7822 8409 face = (int)rules.GetLSLIntegerItem(idx++);
7823 face=(int)rules.GetLSLIntegerItem(idx++);
7824 8410
7825 tex = part.Shape.Textures; 8411 tex = part.Shape.Textures;
8412 int shiny;
7826 if (face == ScriptBaseClass.ALL_SIDES) 8413 if (face == ScriptBaseClass.ALL_SIDES)
7827 { 8414 {
7828 for (face = 0; face < GetNumberOfSides(part); face++) 8415 for (face = 0; face < GetNumberOfSides(part); face++)
7829 { 8416 {
7830 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8417 Shininess shinyness = tex.GetFace((uint)face).Shiny;
7831 // Convert Shininess to PRIM_SHINY_* 8418 if (shinyness == Shininess.High)
7832 res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); 8419 {
7833 // PRIM_BUMP_* 8420 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7834 res.Add(new LSL_Integer((int)texface.Bump)); 8421 }
8422 else if (shinyness == Shininess.Medium)
8423 {
8424 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8425 }
8426 else if (shinyness == Shininess.Low)
8427 {
8428 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8429 }
8430 else
8431 {
8432 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8433 }
8434 res.Add(new LSL_Integer(shiny));
8435 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7835 } 8436 }
7836 } 8437 }
7837 else 8438 else
7838 { 8439 {
7839 if (face >= 0 && face < GetNumberOfSides(part)) 8440 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8441 if (shinyness == Shininess.High)
7840 { 8442 {
7841 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8443 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7842 // Convert Shininess to PRIM_SHINY_*
7843 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7844 // PRIM_BUMP_*
7845 res.Add(new LSL_Integer((int)texface.Bump));
7846 } 8444 }
8445 else if (shinyness == Shininess.Medium)
8446 {
8447 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8448 }
8449 else if (shinyness == Shininess.Low)
8450 {
8451 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8452 }
8453 else
8454 {
8455 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8456 }
8457 res.Add(new LSL_Integer(shiny));
8458 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7847 } 8459 }
7848 break; 8460 break;
7849 8461
7850 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8462 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7851 if (remain < 1) 8463 if (remain < 1)
7852 return res; 8464 return res;
7853 8465 face = (int)rules.GetLSLIntegerItem(idx++);
7854 face=(int)rules.GetLSLIntegerItem(idx++);
7855 8466
7856 tex = part.Shape.Textures; 8467 tex = part.Shape.Textures;
8468 int fullbright;
7857 if (face == ScriptBaseClass.ALL_SIDES) 8469 if (face == ScriptBaseClass.ALL_SIDES)
7858 { 8470 {
7859 for (face = 0; face < GetNumberOfSides(part); face++) 8471 for (face = 0; face < GetNumberOfSides(part); face++)
7860 { 8472 {
7861 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8473 if (tex.GetFace((uint)face).Fullbright == true)
7862 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); 8474 {
8475 fullbright = ScriptBaseClass.TRUE;
8476 }
8477 else
8478 {
8479 fullbright = ScriptBaseClass.FALSE;
8480 }
8481 res.Add(new LSL_Integer(fullbright));
7863 } 8482 }
7864 } 8483 }
7865 else 8484 else
7866 { 8485 {
7867 if (face >= 0 && face < GetNumberOfSides(part)) 8486 if (tex.GetFace((uint)face).Fullbright == true)
7868 { 8487 {
7869 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8488 fullbright = ScriptBaseClass.TRUE;
7870 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7871 } 8489 }
8490 else
8491 {
8492 fullbright = ScriptBaseClass.FALSE;
8493 }
8494 res.Add(new LSL_Integer(fullbright));
7872 } 8495 }
7873 break; 8496 break;
7874 8497
@@ -7890,27 +8513,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7890 break; 8513 break;
7891 8514
7892 case (int)ScriptBaseClass.PRIM_TEXGEN: 8515 case (int)ScriptBaseClass.PRIM_TEXGEN:
8516 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7893 if (remain < 1) 8517 if (remain < 1)
7894 return res; 8518 return res;
7895 8519 face = (int)rules.GetLSLIntegerItem(idx++);
7896 face=(int)rules.GetLSLIntegerItem(idx++);
7897 8520
7898 tex = part.Shape.Textures; 8521 tex = part.Shape.Textures;
7899 if (face == ScriptBaseClass.ALL_SIDES) 8522 if (face == ScriptBaseClass.ALL_SIDES)
7900 { 8523 {
7901 for (face = 0; face < GetNumberOfSides(part); face++) 8524 for (face = 0; face < GetNumberOfSides(part); face++)
7902 { 8525 {
7903 MappingType texgen = tex.GetFace((uint)face).TexMapType; 8526 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7904 // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. 8527 {
7905 res.Add(new LSL_Integer((uint)texgen >> 1)); 8528 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8529 }
8530 else
8531 {
8532 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8533 }
7906 } 8534 }
7907 } 8535 }
7908 else 8536 else
7909 { 8537 {
7910 if (face >= 0 && face < GetNumberOfSides(part)) 8538 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7911 { 8539 {
7912 MappingType texgen = tex.GetFace((uint)face).TexMapType; 8540 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
7913 res.Add(new LSL_Integer((uint)texgen >> 1)); 8541 }
8542 else
8543 {
8544 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
7914 } 8545 }
7915 } 8546 }
7916 break; 8547 break;
@@ -7933,28 +8564,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7933 case (int)ScriptBaseClass.PRIM_GLOW: 8564 case (int)ScriptBaseClass.PRIM_GLOW:
7934 if (remain < 1) 8565 if (remain < 1)
7935 return res; 8566 return res;
7936 8567 face = (int)rules.GetLSLIntegerItem(idx++);
7937 face=(int)rules.GetLSLIntegerItem(idx++);
7938 8568
7939 tex = part.Shape.Textures; 8569 tex = part.Shape.Textures;
8570 float primglow;
7940 if (face == ScriptBaseClass.ALL_SIDES) 8571 if (face == ScriptBaseClass.ALL_SIDES)
7941 { 8572 {
7942 for (face = 0; face < GetNumberOfSides(part); face++) 8573 for (face = 0; face < GetNumberOfSides(part); face++)
7943 { 8574 {
7944 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8575 primglow = tex.GetFace((uint)face).Glow;
7945 res.Add(new LSL_Float(texface.Glow)); 8576 res.Add(new LSL_Float(primglow));
7946 } 8577 }
7947 } 8578 }
7948 else 8579 else
7949 { 8580 {
7950 if (face >= 0 && face < GetNumberOfSides(part)) 8581 primglow = tex.GetFace((uint)face).Glow;
7951 { 8582 res.Add(new LSL_Float(primglow));
7952 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7953 res.Add(new LSL_Float(texface.Glow));
7954 }
7955 } 8583 }
7956 break; 8584 break;
7957
7958 case (int)ScriptBaseClass.PRIM_TEXT: 8585 case (int)ScriptBaseClass.PRIM_TEXT:
7959 Color4 textColor = part.GetTextColor(); 8586 Color4 textColor = part.GetTextColor();
7960 res.Add(new LSL_String(part.Text)); 8587 res.Add(new LSL_String(part.Text));
@@ -8503,8 +9130,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8503 // The function returns an ordered list 9130 // The function returns an ordered list
8504 // representing the tokens found in the supplied 9131 // representing the tokens found in the supplied
8505 // sources string. If two successive tokenizers 9132 // sources string. If two successive tokenizers
8506 // are encountered, then a NULL entry is added 9133 // are encountered, then a null-string entry is
8507 // to the list. 9134 // added to the list.
8508 // 9135 //
8509 // It is a precondition that the source and 9136 // It is a precondition that the source and
8510 // toekizer lisst are non-null. If they are null, 9137 // toekizer lisst are non-null. If they are null,
@@ -8512,7 +9139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8512 // while their lengths are being determined. 9139 // while their lengths are being determined.
8513 // 9140 //
8514 // A small amount of working memoryis required 9141 // A small amount of working memoryis required
8515 // of approximately 8*#tokenizers. 9142 // of approximately 8*#tokenizers + 8*srcstrlen.
8516 // 9143 //
8517 // There are many ways in which this function 9144 // There are many ways in which this function
8518 // can be implemented, this implementation is 9145 // can be implemented, this implementation is
@@ -8528,155 +9155,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8528 // and eliminates redundant tokenizers as soon 9155 // and eliminates redundant tokenizers as soon
8529 // as is possible. 9156 // as is possible.
8530 // 9157 //
8531 // The implementation tries to avoid any copying 9158 // The implementation tries to minimize temporary
8532 // of arrays or other objects. 9159 // garbage generation.
8533 // </remarks> 9160 // </remarks>
8534 9161
8535 private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) 9162 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8536 { 9163 {
8537 int beginning = 0; 9164 return ParseString2List(src, separators, spacers, true);
8538 int srclen = src.Length; 9165 }
8539 int seplen = separators.Length;
8540 object[] separray = separators.Data;
8541 int spclen = spacers.Length;
8542 object[] spcarray = spacers.Data;
8543 int mlen = seplen+spclen;
8544
8545 int[] offset = new int[mlen+1];
8546 bool[] active = new bool[mlen];
8547
8548 int best;
8549 int j;
8550
8551 // Initial capacity reduces resize cost
8552 9166
8553 LSL_List tokens = new LSL_List(); 9167 private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls)
9168 {
9169 int srclen = src.Length;
9170 int seplen = separators.Length;
9171 object[] separray = separators.Data;
9172 int spclen = spacers.Length;
9173 object[] spcarray = spacers.Data;
9174 int dellen = 0;
9175 string[] delarray = new string[seplen+spclen];
8554 9176
8555 // All entries are initially valid 9177 int outlen = 0;
9178 string[] outarray = new string[srclen*2+1];
8556 9179
8557 for (int i = 0; i < mlen; i++) 9180 int i, j;
8558 active[i] = true; 9181 string d;
8559 9182
8560 offset[mlen] = srclen; 9183 m_host.AddScriptLPS(1);
8561 9184
8562 while (beginning < srclen) 9185 /*
9186 * Convert separator and spacer lists to C# strings.
9187 * Also filter out null strings so we don't hang.
9188 */
9189 for (i = 0; i < seplen; i ++)
8563 { 9190 {
9191 d = separray[i].ToString();
9192 if (d.Length > 0)
9193 {
9194 delarray[dellen++] = d;
9195 }
9196 }
9197 seplen = dellen;
8564 9198
8565 best = mlen; // as bad as it gets 9199 for (i = 0; i < spclen; i ++)
9200 {
9201 d = spcarray[i].ToString();
9202 if (d.Length > 0)
9203 {
9204 delarray[dellen++] = d;
9205 }
9206 }
8566 9207
8567 // Scan for separators 9208 /*
9209 * Scan through source string from beginning to end.
9210 */
9211 for (i = 0;;)
9212 {
8568 9213
8569 for (j = 0; j < seplen; j++) 9214 /*
9215 * Find earliest delimeter in src starting at i (if any).
9216 */
9217 int earliestDel = -1;
9218 int earliestSrc = srclen;
9219 string earliestStr = null;
9220 for (j = 0; j < dellen; j ++)
8570 { 9221 {
8571 if (separray[j].ToString() == String.Empty) 9222 d = delarray[j];
8572 active[j] = false; 9223 if (d != null)
8573
8574 if (active[j])
8575 { 9224 {
8576 // scan all of the markers 9225 int index = src.IndexOf(d, i);
8577 if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) 9226 if (index < 0)
8578 { 9227 {
8579 // not present at all 9228 delarray[j] = null; // delim nowhere in src, don't check it anymore
8580 active[j] = false;
8581 } 9229 }
8582 else 9230 else if (index < earliestSrc)
8583 { 9231 {
8584 // present and correct 9232 earliestSrc = index; // where delimeter starts in source string
8585 if (offset[j] < offset[best]) 9233 earliestDel = j; // where delimeter is in delarray[]
8586 { 9234 earliestStr = d; // the delimeter string from delarray[]
8587 // closest so far 9235 if (index == i) break; // can't do any better than found at beg of string
8588 best = j;
8589 if (offset[best] == beginning)
8590 break;
8591 }
8592 } 9236 }
8593 } 9237 }
8594 } 9238 }
8595 9239
8596 // Scan for spacers 9240 /*
8597 9241 * Output source string starting at i through start of earliest delimeter.
8598 if (offset[best] != beginning) 9242 */
9243 if (keepNulls || (earliestSrc > i))
8599 { 9244 {
8600 for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) 9245 outarray[outlen++] = src.Substring(i, earliestSrc - i);
8601 {
8602 if (spcarray[j-seplen].ToString() == String.Empty)
8603 active[j] = false;
8604
8605 if (active[j])
8606 {
8607 // scan all of the markers
8608 if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1)
8609 {
8610 // not present at all
8611 active[j] = false;
8612 }
8613 else
8614 {
8615 // present and correct
8616 if (offset[j] < offset[best])
8617 {
8618 // closest so far
8619 best = j;
8620 }
8621 }
8622 }
8623 }
8624 } 9246 }
8625 9247
8626 // This is the normal exit from the scanning loop 9248 /*
9249 * If no delimeter found at or after i, we're done scanning.
9250 */
9251 if (earliestDel < 0) break;
8627 9252
8628 if (best == mlen) 9253 /*
9254 * If delimeter was a spacer, output the spacer.
9255 */
9256 if (earliestDel >= seplen)
8629 { 9257 {
8630 // no markers were found on this pass 9258 outarray[outlen++] = earliestStr;
8631 // so we're pretty much done
8632 if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0))
8633 tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
8634 break;
8635 } 9259 }
8636 9260
8637 // Otherwise we just add the newly delimited token 9261 /*
8638 // and recalculate where the search should continue. 9262 * Look at rest of src string following delimeter.
8639 if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) 9263 */
8640 tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); 9264 i = earliestSrc + earliestStr.Length;
8641
8642 if (best < seplen)
8643 {
8644 beginning = offset[best] + (separray[best].ToString()).Length;
8645 }
8646 else
8647 {
8648 beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
8649 string str = spcarray[best - seplen].ToString();
8650 if ((keepNulls) || ((!keepNulls) && (str.Length > 0)))
8651 tokens.Add(new LSL_String(str));
8652 }
8653 } 9265 }
8654 9266
8655 // This an awkward an not very intuitive boundary case. If the 9267 /*
8656 // last substring is a tokenizer, then there is an implied trailing 9268 * Make up an exact-sized output array suitable for an LSL_List object.
8657 // null list entry. Hopefully the single comparison will not be too 9269 */
8658 // arduous. Alternatively the 'break' could be replced with a return 9270 object[] outlist = new object[outlen];
8659 // but that's shabby programming. 9271 for (i = 0; i < outlen; i ++)
8660
8661 if ((beginning == srclen) && (keepNulls))
8662 { 9272 {
8663 if (srclen != 0) 9273 outlist[i] = new LSL_String(outarray[i]);
8664 tokens.Add(new LSL_String(""));
8665 } 9274 }
8666 9275 return new LSL_List(outlist);
8667 return tokens;
8668 }
8669
8670 public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers)
8671 {
8672 m_host.AddScriptLPS(1);
8673 return this.ParseString(src, separators, spacers, false);
8674 }
8675
8676 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8677 {
8678 m_host.AddScriptLPS(1);
8679 return this.ParseString(src, separators, spacers, true);
8680 } 9276 }
8681 9277
8682 public LSL_Integer llGetObjectPermMask(int mask) 9278 public LSL_Integer llGetObjectPermMask(int mask)
@@ -8753,28 +9349,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8753 { 9349 {
8754 m_host.AddScriptLPS(1); 9350 m_host.AddScriptLPS(1);
8755 9351
8756 lock (m_host.TaskInventory) 9352 m_host.TaskInventory.LockItemsForRead(true);
9353 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8757 { 9354 {
8758 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9355 if (inv.Value.Name == item)
8759 { 9356 {
8760 if (inv.Value.Name == item) 9357 m_host.TaskInventory.LockItemsForRead(false);
9358 switch (mask)
8761 { 9359 {
8762 switch (mask) 9360 case 0:
8763 { 9361 return (int)inv.Value.BasePermissions;
8764 case 0: 9362 case 1:
8765 return (int)inv.Value.BasePermissions; 9363 return (int)inv.Value.CurrentPermissions;
8766 case 1: 9364 case 2:
8767 return (int)inv.Value.CurrentPermissions; 9365 return (int)inv.Value.GroupPermissions;
8768 case 2: 9366 case 3:
8769 return (int)inv.Value.GroupPermissions; 9367 return (int)inv.Value.EveryonePermissions;
8770 case 3: 9368 case 4:
8771 return (int)inv.Value.EveryonePermissions; 9369 return (int)inv.Value.NextPermissions;
8772 case 4:
8773 return (int)inv.Value.NextPermissions;
8774 }
8775 } 9370 }
8776 } 9371 }
8777 } 9372 }
9373 m_host.TaskInventory.LockItemsForRead(false);
8778 9374
8779 return -1; 9375 return -1;
8780 } 9376 }
@@ -8821,16 +9417,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8821 { 9417 {
8822 m_host.AddScriptLPS(1); 9418 m_host.AddScriptLPS(1);
8823 9419
8824 lock (m_host.TaskInventory) 9420 m_host.TaskInventory.LockItemsForRead(true);
9421 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8825 { 9422 {
8826 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9423 if (inv.Value.Name == item)
8827 { 9424 {
8828 if (inv.Value.Name == item) 9425 m_host.TaskInventory.LockItemsForRead(false);
8829 { 9426 return inv.Value.CreatorID.ToString();
8830 return inv.Value.CreatorID.ToString();
8831 }
8832 } 9427 }
8833 } 9428 }
9429 m_host.TaskInventory.LockItemsForRead(false);
8834 9430
8835 llSay(0, "No item name '" + item + "'"); 9431 llSay(0, "No item name '" + item + "'");
8836 9432
@@ -8978,7 +9574,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8978 } 9574 }
8979 9575
8980 /// <summary> 9576 /// <summary>
8981 /// illListReplaceList removes the sub-list defined by the inclusive indices 9577 /// llListReplaceList removes the sub-list defined by the inclusive indices
8982 /// start and end and inserts the src list in its place. The inclusive 9578 /// start and end and inserts the src list in its place. The inclusive
8983 /// nature of the indices means that at least one element must be deleted 9579 /// nature of the indices means that at least one element must be deleted
8984 /// if the indices are within the bounds of the existing list. I.e. 2,2 9580 /// if the indices are within the bounds of the existing list. I.e. 2,2
@@ -9035,16 +9631,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9035 // based upon end. Note that if end exceeds the upper 9631 // based upon end. Note that if end exceeds the upper
9036 // bound in this case, the entire destination list 9632 // bound in this case, the entire destination list
9037 // is removed. 9633 // is removed.
9038 else 9634 else if (start == 0)
9039 { 9635 {
9040 if (end + 1 < dest.Length) 9636 if (end + 1 < dest.Length)
9041 {
9042 return src + dest.GetSublist(end + 1, -1); 9637 return src + dest.GetSublist(end + 1, -1);
9043 }
9044 else 9638 else
9045 {
9046 return src; 9639 return src;
9047 } 9640 }
9641 else // Start < 0
9642 {
9643 if (end + 1 < dest.Length)
9644 return dest.GetSublist(end + 1, -1);
9645 else
9646 return new LSL_List();
9048 } 9647 }
9049 } 9648 }
9050 // Finally, if start > end, we strip away a prefix and 9649 // Finally, if start > end, we strip away a prefix and
@@ -9095,17 +9694,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9095 int width = 0; 9694 int width = 0;
9096 int height = 0; 9695 int height = 0;
9097 9696
9098 ParcelMediaCommandEnum? commandToSend = null; 9697 uint commandToSend = 0;
9099 float time = 0.0f; // default is from start 9698 float time = 0.0f; // default is from start
9100 9699
9101 ScenePresence presence = null; 9700 ScenePresence presence = null;
9102 9701
9103 for (int i = 0; i < commandList.Data.Length; i++) 9702 for (int i = 0; i < commandList.Data.Length; i++)
9104 { 9703 {
9105 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 9704 uint command = (uint)(commandList.GetLSLIntegerItem(i));
9106 switch (command) 9705 switch (command)
9107 { 9706 {
9108 case ParcelMediaCommandEnum.Agent: 9707 case (uint)ParcelMediaCommandEnum.Agent:
9109 // we send only to one agent 9708 // we send only to one agent
9110 if ((i + 1) < commandList.Length) 9709 if ((i + 1) < commandList.Length)
9111 { 9710 {
@@ -9122,25 +9721,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9122 } 9721 }
9123 break; 9722 break;
9124 9723
9125 case ParcelMediaCommandEnum.Loop: 9724 case (uint)ParcelMediaCommandEnum.Loop:
9126 loop = 1; 9725 loop = 1;
9127 commandToSend = command; 9726 commandToSend = command;
9128 update = true; //need to send the media update packet to set looping 9727 update = true; //need to send the media update packet to set looping
9129 break; 9728 break;
9130 9729
9131 case ParcelMediaCommandEnum.Play: 9730 case (uint)ParcelMediaCommandEnum.Play:
9132 loop = 0; 9731 loop = 0;
9133 commandToSend = command; 9732 commandToSend = command;
9134 update = true; //need to send the media update packet to make sure it doesn't loop 9733 update = true; //need to send the media update packet to make sure it doesn't loop
9135 break; 9734 break;
9136 9735
9137 case ParcelMediaCommandEnum.Pause: 9736 case (uint)ParcelMediaCommandEnum.Pause:
9138 case ParcelMediaCommandEnum.Stop: 9737 case (uint)ParcelMediaCommandEnum.Stop:
9139 case ParcelMediaCommandEnum.Unload: 9738 case (uint)ParcelMediaCommandEnum.Unload:
9140 commandToSend = command; 9739 commandToSend = command;
9141 break; 9740 break;
9142 9741
9143 case ParcelMediaCommandEnum.Url: 9742 case (uint)ParcelMediaCommandEnum.Url:
9144 if ((i + 1) < commandList.Length) 9743 if ((i + 1) < commandList.Length)
9145 { 9744 {
9146 if (commandList.Data[i + 1] is LSL_String) 9745 if (commandList.Data[i + 1] is LSL_String)
@@ -9153,7 +9752,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9153 } 9752 }
9154 break; 9753 break;
9155 9754
9156 case ParcelMediaCommandEnum.Texture: 9755 case (uint)ParcelMediaCommandEnum.Texture:
9157 if ((i + 1) < commandList.Length) 9756 if ((i + 1) < commandList.Length)
9158 { 9757 {
9159 if (commandList.Data[i + 1] is LSL_String) 9758 if (commandList.Data[i + 1] is LSL_String)
@@ -9166,7 +9765,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9166 } 9765 }
9167 break; 9766 break;
9168 9767
9169 case ParcelMediaCommandEnum.Time: 9768 case (uint)ParcelMediaCommandEnum.Time:
9170 if ((i + 1) < commandList.Length) 9769 if ((i + 1) < commandList.Length)
9171 { 9770 {
9172 if (commandList.Data[i + 1] is LSL_Float) 9771 if (commandList.Data[i + 1] is LSL_Float)
@@ -9178,7 +9777,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9178 } 9777 }
9179 break; 9778 break;
9180 9779
9181 case ParcelMediaCommandEnum.AutoAlign: 9780 case (uint)ParcelMediaCommandEnum.AutoAlign:
9182 if ((i + 1) < commandList.Length) 9781 if ((i + 1) < commandList.Length)
9183 { 9782 {
9184 if (commandList.Data[i + 1] is LSL_Integer) 9783 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9192,7 +9791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9192 } 9791 }
9193 break; 9792 break;
9194 9793
9195 case ParcelMediaCommandEnum.Type: 9794 case (uint)ParcelMediaCommandEnum.Type:
9196 if ((i + 1) < commandList.Length) 9795 if ((i + 1) < commandList.Length)
9197 { 9796 {
9198 if (commandList.Data[i + 1] is LSL_String) 9797 if (commandList.Data[i + 1] is LSL_String)
@@ -9205,7 +9804,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9205 } 9804 }
9206 break; 9805 break;
9207 9806
9208 case ParcelMediaCommandEnum.Desc: 9807 case (uint)ParcelMediaCommandEnum.Desc:
9209 if ((i + 1) < commandList.Length) 9808 if ((i + 1) < commandList.Length)
9210 { 9809 {
9211 if (commandList.Data[i + 1] is LSL_String) 9810 if (commandList.Data[i + 1] is LSL_String)
@@ -9218,7 +9817,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9218 } 9817 }
9219 break; 9818 break;
9220 9819
9221 case ParcelMediaCommandEnum.Size: 9820 case (uint)ParcelMediaCommandEnum.Size:
9222 if ((i + 2) < commandList.Length) 9821 if ((i + 2) < commandList.Length)
9223 { 9822 {
9224 if (commandList.Data[i + 1] is LSL_Integer) 9823 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9288,7 +9887,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9288 } 9887 }
9289 } 9888 }
9290 9889
9291 if (commandToSend != null) 9890 if (commandToSend != 0)
9292 { 9891 {
9293 // the commandList contained a start/stop/... command, too 9892 // the commandList contained a start/stop/... command, too
9294 if (presence == null) 9893 if (presence == null)
@@ -9325,7 +9924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9325 9924
9326 if (aList.Data[i] != null) 9925 if (aList.Data[i] != null)
9327 { 9926 {
9328 switch ((ParcelMediaCommandEnum) aList.Data[i]) 9927 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
9329 { 9928 {
9330 case ParcelMediaCommandEnum.Url: 9929 case ParcelMediaCommandEnum.Url:
9331 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 9930 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
@@ -9368,16 +9967,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9368 { 9967 {
9369 m_host.AddScriptLPS(1); 9968 m_host.AddScriptLPS(1);
9370 9969
9371 lock (m_host.TaskInventory) 9970 m_host.TaskInventory.LockItemsForRead(true);
9971 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
9372 { 9972 {
9373 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9973 if (inv.Value.Name == name)
9374 { 9974 {
9375 if (inv.Value.Name == name) 9975 m_host.TaskInventory.LockItemsForRead(false);
9376 { 9976 return inv.Value.Type;
9377 return inv.Value.Type;
9378 }
9379 } 9977 }
9380 } 9978 }
9979 m_host.TaskInventory.LockItemsForRead(false);
9381 9980
9382 return -1; 9981 return -1;
9383 } 9982 }
@@ -9388,15 +9987,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9388 9987
9389 if (quick_pay_buttons.Data.Length < 4) 9988 if (quick_pay_buttons.Data.Length < 4)
9390 { 9989 {
9391 LSLError("List must have at least 4 elements"); 9990 int x;
9392 return; 9991 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9992 {
9993 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9994 }
9393 } 9995 }
9394 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9996 int[] nPrice = new int[5];
9395 9997 nPrice[0] = price;
9396 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9998 nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0);
9397 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9999 nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1);
9398 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 10000 nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2);
9399 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 10001 nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3);
10002 m_host.ParentGroup.RootPart.PayPrice = nPrice;
9400 m_host.ParentGroup.HasGroupChanged = true; 10003 m_host.ParentGroup.HasGroupChanged = true;
9401 } 10004 }
9402 10005
@@ -9408,17 +10011,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9408 if (invItemID == UUID.Zero) 10011 if (invItemID == UUID.Zero)
9409 return new LSL_Vector(); 10012 return new LSL_Vector();
9410 10013
9411 lock (m_host.TaskInventory) 10014 m_host.TaskInventory.LockItemsForRead(true);
10015 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9412 { 10016 {
9413 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10017 m_host.TaskInventory.LockItemsForRead(false);
9414 return new LSL_Vector(); 10018 return new LSL_Vector();
10019 }
9415 10020
9416 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10021 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9417 { 10022 {
9418 ShoutError("No permissions to track the camera"); 10023 ShoutError("No permissions to track the camera");
9419 return new LSL_Vector(); 10024 m_host.TaskInventory.LockItemsForRead(false);
9420 } 10025 return new LSL_Vector();
9421 } 10026 }
10027 m_host.TaskInventory.LockItemsForRead(false);
9422 10028
9423 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 10029 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9424 if (presence != null) 10030 if (presence != null)
@@ -9436,17 +10042,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9436 if (invItemID == UUID.Zero) 10042 if (invItemID == UUID.Zero)
9437 return new LSL_Rotation(); 10043 return new LSL_Rotation();
9438 10044
9439 lock (m_host.TaskInventory) 10045 m_host.TaskInventory.LockItemsForRead(true);
10046 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9440 { 10047 {
9441 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10048 m_host.TaskInventory.LockItemsForRead(false);
9442 return new LSL_Rotation(); 10049 return new LSL_Rotation();
9443
9444 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9445 {
9446 ShoutError("No permissions to track the camera");
9447 return new LSL_Rotation();
9448 }
9449 } 10050 }
10051 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10052 {
10053 ShoutError("No permissions to track the camera");
10054 m_host.TaskInventory.LockItemsForRead(false);
10055 return new LSL_Rotation();
10056 }
10057 m_host.TaskInventory.LockItemsForRead(false);
9450 10058
9451 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 10059 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9452 if (presence != null) 10060 if (presence != null)
@@ -9508,8 +10116,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9508 { 10116 {
9509 m_host.AddScriptLPS(1); 10117 m_host.AddScriptLPS(1);
9510 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 10118 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0);
9511 if (detectedParams == null) return; // only works on the first detected avatar 10119 if (detectedParams == null)
9512 10120 {
10121 if (m_host.ParentGroup.IsAttachment == true)
10122 {
10123 detectedParams = new DetectParams();
10124 detectedParams.Key = m_host.OwnerID;
10125 }
10126 else
10127 {
10128 return;
10129 }
10130 }
10131
9513 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 10132 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9514 if (avatar != null) 10133 if (avatar != null)
9515 { 10134 {
@@ -9517,6 +10136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9517 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 10136 new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
9518 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); 10137 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
9519 } 10138 }
10139
9520 ScriptSleep(1000); 10140 ScriptSleep(1000);
9521 } 10141 }
9522 10142
@@ -9609,14 +10229,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9609 if (objectID == UUID.Zero) return; 10229 if (objectID == UUID.Zero) return;
9610 10230
9611 UUID agentID; 10231 UUID agentID;
9612 lock (m_host.TaskInventory) 10232 m_host.TaskInventory.LockItemsForRead(true);
9613 { 10233 // we need the permission first, to know which avatar we want to set the camera for
9614 // we need the permission first, to know which avatar we want to set the camera for 10234 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9615 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9616 10235
9617 if (agentID == UUID.Zero) return; 10236 if (agentID == UUID.Zero)
9618 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 10237 {
10238 m_host.TaskInventory.LockItemsForRead(false);
10239 return;
10240 }
10241 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10242 {
10243 m_host.TaskInventory.LockItemsForRead(false);
10244 return;
9619 } 10245 }
10246 m_host.TaskInventory.LockItemsForRead(false);
9620 10247
9621 ScenePresence presence = World.GetScenePresence(agentID); 10248 ScenePresence presence = World.GetScenePresence(agentID);
9622 10249
@@ -9625,12 +10252,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9625 10252
9626 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); 10253 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
9627 object[] data = rules.Data; 10254 object[] data = rules.Data;
9628 for (int i = 0; i < data.Length; ++i) { 10255 for (int i = 0; i < data.Length; ++i)
10256 {
9629 int type = Convert.ToInt32(data[i++].ToString()); 10257 int type = Convert.ToInt32(data[i++].ToString());
9630 if (i >= data.Length) break; // odd number of entries => ignore the last 10258 if (i >= data.Length) break; // odd number of entries => ignore the last
9631 10259
9632 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) 10260 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
9633 switch (type) { 10261 switch (type)
10262 {
9634 case ScriptBaseClass.CAMERA_FOCUS: 10263 case ScriptBaseClass.CAMERA_FOCUS:
9635 case ScriptBaseClass.CAMERA_FOCUS_OFFSET: 10264 case ScriptBaseClass.CAMERA_FOCUS_OFFSET:
9636 case ScriptBaseClass.CAMERA_POSITION: 10265 case ScriptBaseClass.CAMERA_POSITION:
@@ -9666,12 +10295,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9666 10295
9667 // we need the permission first, to know which avatar we want to clear the camera for 10296 // we need the permission first, to know which avatar we want to clear the camera for
9668 UUID agentID; 10297 UUID agentID;
9669 lock (m_host.TaskInventory) 10298 m_host.TaskInventory.LockItemsForRead(true);
10299 agentID = m_host.TaskInventory[invItemID].PermsGranter;
10300 if (agentID == UUID.Zero)
9670 { 10301 {
9671 agentID = m_host.TaskInventory[invItemID].PermsGranter; 10302 m_host.TaskInventory.LockItemsForRead(false);
9672 if (agentID == UUID.Zero) return; 10303 return;
9673 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 10304 }
10305 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10306 {
10307 m_host.TaskInventory.LockItemsForRead(false);
10308 return;
9674 } 10309 }
10310 m_host.TaskInventory.LockItemsForRead(false);
9675 10311
9676 ScenePresence presence = World.GetScenePresence(agentID); 10312 ScenePresence presence = World.GetScenePresence(agentID);
9677 10313
@@ -9738,19 +10374,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9738 public LSL_String llXorBase64StringsCorrect(string str1, string str2) 10374 public LSL_String llXorBase64StringsCorrect(string str1, string str2)
9739 { 10375 {
9740 m_host.AddScriptLPS(1); 10376 m_host.AddScriptLPS(1);
9741 string ret = String.Empty; 10377
9742 string src1 = llBase64ToString(str1); 10378 if (str1 == String.Empty)
9743 string src2 = llBase64ToString(str2); 10379 return String.Empty;
9744 int c = 0; 10380 if (str2 == String.Empty)
9745 for (int i = 0; i < src1.Length; i++) 10381 return str1;
10382
10383 int len = str2.Length;
10384 if ((len % 4) != 0) // LL is EVIL!!!!
9746 { 10385 {
9747 ret += (char) (src1[i] ^ src2[c]); 10386 while (str2.EndsWith("="))
10387 str2 = str2.Substring(0, str2.Length - 1);
10388
10389 len = str2.Length;
10390 int mod = len % 4;
10391
10392 if (mod == 1)
10393 str2 = str2.Substring(0, str2.Length - 1);
10394 else if (mod == 2)
10395 str2 += "==";
10396 else if (mod == 3)
10397 str2 += "=";
10398 }
9748 10399
9749 c++; 10400 byte[] data1;
9750 if (c >= src2.Length) 10401 byte[] data2;
9751 c = 0; 10402 try
10403 {
10404 data1 = Convert.FromBase64String(str1);
10405 data2 = Convert.FromBase64String(str2);
9752 } 10406 }
9753 return llStringToBase64(ret); 10407 catch (Exception)
10408 {
10409 return new LSL_String(String.Empty);
10410 }
10411
10412 byte[] d2 = new Byte[data1.Length];
10413 int pos = 0;
10414
10415 if (data1.Length <= data2.Length)
10416 {
10417 Array.Copy(data2, 0, d2, 0, data1.Length);
10418 }
10419 else
10420 {
10421 while (pos < data1.Length)
10422 {
10423 len = data1.Length - pos;
10424 if (len > data2.Length)
10425 len = data2.Length;
10426
10427 Array.Copy(data2, 0, d2, pos, len);
10428 pos += len;
10429 }
10430 }
10431
10432 for (pos = 0 ; pos < data1.Length ; pos++ )
10433 data1[pos] ^= d2[pos];
10434
10435 return Convert.ToBase64String(data1);
9754 } 10436 }
9755 10437
9756 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) 10438 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body)
@@ -9809,12 +10491,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9809 Regex r = new Regex(authregex); 10491 Regex r = new Regex(authregex);
9810 int[] gnums = r.GetGroupNumbers(); 10492 int[] gnums = r.GetGroupNumbers();
9811 Match m = r.Match(url); 10493 Match m = r.Match(url);
9812 if (m.Success) { 10494 if (m.Success)
9813 for (int i = 1; i < gnums.Length; i++) { 10495 {
10496 for (int i = 1; i < gnums.Length; i++)
10497 {
9814 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; 10498 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]];
9815 //CaptureCollection cc = g.Captures; 10499 //CaptureCollection cc = g.Captures;
9816 } 10500 }
9817 if (m.Groups.Count == 5) { 10501 if (m.Groups.Count == 5)
10502 {
9818 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); 10503 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString())));
9819 url = m.Groups[1].ToString() + m.Groups[4].ToString(); 10504 url = m.Groups[1].ToString() + m.Groups[4].ToString();
9820 } 10505 }
@@ -10100,15 +10785,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10100 10785
10101 internal UUID ScriptByName(string name) 10786 internal UUID ScriptByName(string name)
10102 { 10787 {
10103 lock (m_host.TaskInventory) 10788 m_host.TaskInventory.LockItemsForRead(true);
10789
10790 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
10104 { 10791 {
10105 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 10792 if (item.Type == 10 && item.Name == name)
10106 { 10793 {
10107 if (item.Type == 10 && item.Name == name) 10794 m_host.TaskInventory.LockItemsForRead(false);
10108 return item.ItemID; 10795 return item.ItemID;
10109 } 10796 }
10110 } 10797 }
10111 10798
10799 m_host.TaskInventory.LockItemsForRead(false);
10800
10112 return UUID.Zero; 10801 return UUID.Zero;
10113 } 10802 }
10114 10803
@@ -10149,6 +10838,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10149 { 10838 {
10150 m_host.AddScriptLPS(1); 10839 m_host.AddScriptLPS(1);
10151 10840
10841 //Clone is thread safe
10152 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10842 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10153 10843
10154 UUID assetID = UUID.Zero; 10844 UUID assetID = UUID.Zero;
@@ -10211,6 +10901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10211 { 10901 {
10212 m_host.AddScriptLPS(1); 10902 m_host.AddScriptLPS(1);
10213 10903
10904 //Clone is thread safe
10214 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10905 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10215 10906
10216 UUID assetID = UUID.Zero; 10907 UUID assetID = UUID.Zero;
@@ -10291,15 +10982,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10291 return GetLinkPrimitiveParams(obj, rules); 10982 return GetLinkPrimitiveParams(obj, rules);
10292 } 10983 }
10293 10984
10294 public void print(string str) 10985 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
10295 { 10986 {
10296 // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print 10987 List<SceneObjectPart> parts = GetLinkParts(link);
10297 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 10988 if (parts.Count < 1)
10298 if (ossl != null) 10989 return 0;
10299 { 10990
10300 ossl.CheckThreatLevel(ThreatLevel.High, "print"); 10991 return GetNumberOfSides(parts[0]);
10301 m_log.Info("LSL print():" + str);
10302 }
10303 } 10992 }
10304 10993
10305 private string Name2Username(string name) 10994 private string Name2Username(string name)
@@ -10345,6 +11034,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10345 return rq.ToString(); 11034 return rq.ToString();
10346 } 11035 }
10347 11036
11037 private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args)
11038 {
11039 m_SayShoutCount = 0;
11040 }
10348 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) 11041 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10349 { 11042 {
10350 m_host.AddScriptLPS(1); 11043 m_host.AddScriptLPS(1);
@@ -10514,22 +11207,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10514 NotImplemented("llGetSPMaxMemory"); 11207 NotImplemented("llGetSPMaxMemory");
10515 } 11208 }
10516 11209
10517 public void llGetUsedMemory() 11210 public virtual LSL_Integer llGetUsedMemory()
10518 { 11211 {
10519 m_host.AddScriptLPS(1); 11212 m_host.AddScriptLPS(1);
10520 NotImplemented("llGetUsedMemory"); 11213 NotImplemented("llGetUsedMemory");
11214 return 0;
10521 } 11215 }
10522 11216
10523 public void llScriptProfiler(LSL_Integer flags) 11217 public void llScriptProfiler(LSL_Integer flags)
10524 { 11218 {
10525 m_host.AddScriptLPS(1); 11219 m_host.AddScriptLPS(1);
10526 NotImplemented("llScriptProfiler"); 11220 //NotImplemented("llScriptProfiler");
10527 } 11221 }
10528 11222
10529 public void llSetSoundQueueing(int queue) 11223 public void llSetSoundQueueing(int queue)
10530 { 11224 {
10531 m_host.AddScriptLPS(1); 11225 m_host.AddScriptLPS(1);
10532 NotImplemented("llSetSoundQueueing");
10533 } 11226 }
10534 11227
10535 public void llCollisionSprite(string impact_sprite) 11228 public void llCollisionSprite(string impact_sprite)
@@ -10541,7 +11234,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10541 public void llGodLikeRezObject(string inventory, LSL_Vector pos) 11234 public void llGodLikeRezObject(string inventory, LSL_Vector pos)
10542 { 11235 {
10543 m_host.AddScriptLPS(1); 11236 m_host.AddScriptLPS(1);
10544 NotImplemented("llGodLikeRezObject"); 11237
11238 if (!World.Permissions.IsGod(m_host.OwnerID))
11239 NotImplemented("llGodLikeRezObject");
11240
11241 AssetBase rezAsset = World.AssetService.Get(inventory);
11242 if (rezAsset == null)
11243 {
11244 llSay(0, "Asset not found");
11245 return;
11246 }
11247
11248 SceneObjectGroup group = null;
11249
11250 try
11251 {
11252 string xmlData = Utils.BytesToString(rezAsset.Data);
11253 group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
11254 }
11255 catch
11256 {
11257 llSay(0, "Asset not found");
11258 return;
11259 }
11260
11261 if (group == null)
11262 {
11263 llSay(0, "Asset not found");
11264 return;
11265 }
11266
11267 group.RootPart.AttachPoint = group.RootPart.Shape.State;
11268 group.RootPart.AttachOffset = group.AbsolutePosition;
11269
11270 group.ResetIDs();
11271
11272 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
11273 World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero);
11274 group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3);
11275 group.ScheduleGroupForFullUpdate();
11276
11277 // objects rezzed with this method are die_at_edge by default.
11278 group.RootPart.SetDieAtEdge(true);
11279
11280 group.ResumeScripts();
11281
11282 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
11283 "object_rez", new Object[] {
11284 new LSL_String(
11285 group.RootPart.UUID.ToString()) },
11286 new DetectParams[0]));
10545 } 11287 }
10546 11288
10547 #endregion 11289 #endregion
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e1c837e..8f450f8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -135,6 +135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
135 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 135 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
136 internal float m_ScriptDelayFactor = 1.0f; 136 internal float m_ScriptDelayFactor = 1.0f;
137 internal float m_ScriptDistanceFactor = 1.0f; 137 internal float m_ScriptDistanceFactor = 1.0f;
138 internal bool m_debuggerSafe = false;
138 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 139 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
139 140
140 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 141 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
@@ -143,6 +144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
143 m_host = host; 144 m_host = host;
144 m_localID = localID; 145 m_localID = localID;
145 m_itemID = itemID; 146 m_itemID = itemID;
147 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
146 148
147 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 149 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
148 m_OSFunctionsEnabled = true; 150 m_OSFunctionsEnabled = true;
@@ -201,7 +203,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
201 203
202 internal void OSSLError(string msg) 204 internal void OSSLError(string msg)
203 { 205 {
204 throw new Exception("OSSL Runtime Error: " + msg); 206 if (m_debuggerSafe)
207 {
208 OSSLShoutError(msg);
209 }
210 else
211 {
212 throw new Exception("OSSL Runtime Error: " + msg);
213 }
205 } 214 }
206 215
207 private void InitLSL() 216 private void InitLSL()
@@ -840,18 +849,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
840 if (target != null) 849 if (target != null)
841 { 850 {
842 UUID animID=UUID.Zero; 851 UUID animID=UUID.Zero;
843 lock (m_host.TaskInventory) 852 m_host.TaskInventory.LockItemsForRead(true);
853 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
844 { 854 {
845 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 855 if (inv.Value.Name == animation)
846 { 856 {
847 if (inv.Value.Name == animation) 857 if (inv.Value.Type == (int)AssetType.Animation)
848 { 858 animID = inv.Value.AssetID;
849 if (inv.Value.Type == (int)AssetType.Animation) 859 continue;
850 animID = inv.Value.AssetID;
851 continue;
852 }
853 } 860 }
854 } 861 }
862 m_host.TaskInventory.LockItemsForRead(false);
855 if (animID == UUID.Zero) 863 if (animID == UUID.Zero)
856 target.Animator.AddAnimation(animation, m_host.UUID); 864 target.Animator.AddAnimation(animation, m_host.UUID);
857 else 865 else
@@ -873,18 +881,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
873 if (target != null) 881 if (target != null)
874 { 882 {
875 UUID animID = UUID.Zero; 883 UUID animID = UUID.Zero;
876 lock (m_host.TaskInventory) 884 m_host.TaskInventory.LockItemsForRead(true);
885 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
877 { 886 {
878 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 887 if (inv.Value.Name == animation)
879 { 888 {
880 if (inv.Value.Name == animation) 889 if (inv.Value.Type == (int)AssetType.Animation)
881 { 890 animID = inv.Value.AssetID;
882 if (inv.Value.Type == (int)AssetType.Animation) 891 continue;
883 animID = inv.Value.AssetID;
884 continue;
885 }
886 } 892 }
887 } 893 }
894 m_host.TaskInventory.LockItemsForRead(false);
888 895
889 if (animID == UUID.Zero) 896 if (animID == UUID.Zero)
890 target.Animator.RemoveAnimation(animation); 897 target.Animator.RemoveAnimation(animation);
@@ -1834,6 +1841,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1834 1841
1835 if (!UUID.TryParse(notecardNameOrUuid, out assetID)) 1842 if (!UUID.TryParse(notecardNameOrUuid, out assetID))
1836 { 1843 {
1844 m_host.TaskInventory.LockItemsForRead(true);
1837 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1845 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1838 { 1846 {
1839 if (item.Type == 7 && item.Name == notecardNameOrUuid) 1847 if (item.Type == 7 && item.Name == notecardNameOrUuid)
@@ -1841,6 +1849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1841 assetID = item.AssetID; 1849 assetID = item.AssetID;
1842 } 1850 }
1843 } 1851 }
1852 m_host.TaskInventory.LockItemsForRead(false);
1844 } 1853 }
1845 1854
1846 if (assetID == UUID.Zero) 1855 if (assetID == UUID.Zero)
@@ -2164,8 +2173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2164 UUID x = module.CreateNPC(firstname, 2173 UUID x = module.CreateNPC(firstname,
2165 lastname, 2174 lastname,
2166 new Vector3((float) position.x, (float) position.y, (float) position.z), 2175 new Vector3((float) position.x, (float) position.y, (float) position.z),
2167 World, 2176 World,appearance);
2168 appearance);
2169 2177
2170 return new LSL_Key(x.ToString()); 2178 return new LSL_Key(x.ToString());
2171 } 2179 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 4ac7f8b..6de0773 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -205,7 +205,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
205 // Is the sensor type is AGENT and not SCRIPTED then include agents 205 // Is the sensor type is AGENT and not SCRIPTED then include agents
206 if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0) 206 if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0)
207 { 207 {
208 sensedEntities.AddRange(doAgentSensor(ts)); 208 sensedEntities.AddRange(doAgentSensor(ts));
209 } 209 }
210 210
211 // If SCRIPTED or PASSIVE or ACTIVE check objects 211 // If SCRIPTED or PASSIVE or ACTIVE check objects
@@ -302,13 +302,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
302 float dy; 302 float dy;
303 float dz; 303 float dz;
304 304
305 Quaternion q = SensePoint.RotationOffset; 305// Quaternion q = SensePoint.RotationOffset;
306 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation!
306 if (SensePoint.ParentGroup.IsAttachment) 307 if (SensePoint.ParentGroup.IsAttachment)
307 { 308 {
308 // In attachments, the sensor cone always orients with the 309 // In attachments, the sensor cone always orients with the
309 // avatar rotation. This may include a nonzero elevation if 310 // avatar rotation. This may include a nonzero elevation if
310 // in mouselook. 311 // in mouselook.
311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 312 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
313 fromRegionPos = avatar.AbsolutePosition;
312 q = avatar.Rotation; 314 q = avatar.Rotation;
313 } 315 }
314 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 316 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
@@ -429,6 +431,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
429 // avatar rotation. This may include a nonzero elevation if 431 // avatar rotation. This may include a nonzero elevation if
430 // in mouselook. 432 // in mouselook.
431 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 433 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
434 fromRegionPos = avatar.AbsolutePosition;
432 q = avatar.Rotation; 435 q = avatar.Rotation;
433 } 436 }
434 437
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index eeb59d9..2fd33fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
109 if (Timers.Count == 0) 109 if (Timers.Count == 0)
110 return; 110 return;
111 111
112 Dictionary<string, TimerClass>.ValueCollection tvals;
112 lock (TimerListLock) 113 lock (TimerListLock)
113 { 114 {
114 // Go through all timers 115 // Go through all timers
115 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 116 tvals = Timers.Values;
116 foreach (TimerClass ts in tvals) 117 }
118
119 foreach (TimerClass ts in tvals)
120 {
121 // Time has passed?
122 if (ts.next < DateTime.Now.Ticks)
117 { 123 {
118 // Time has passed? 124 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
119 if (ts.next < DateTime.Now.Ticks) 125 // Add it to queue
120 { 126 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
121 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 127 new EventParams("timer", new Object[0],
122 // Add it to queue 128 new DetectParams[0]));
123 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 129 // set next interval
124 new EventParams("timer", new Object[0], 130
125 new DetectParams[0])); 131 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
126 // set next interval 132 ts.next = DateTime.Now.Ticks + ts.interval;
127
128 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
129 ts.next = DateTime.Now.Ticks + ts.interval;
130 }
131 } 133 }
132 } 134 }
133 } 135 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..ab215f3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections;
29using OpenSim.Region.ScriptEngine.Interfaces;
30
31using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
32using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
33using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
34using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
35using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
36using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
37using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
38
39namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
40{
41 public interface ICM_Api
42 {
43 string cmDetectedCountry(int num);
44 string cmGetAgentCountry(key key);
45 }
46}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 62e2854..4ad4123 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -123,6 +123,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
123 LSL_Float llGetEnergy(); 123 LSL_Float llGetEnergy();
124 LSL_Vector llGetForce(); 124 LSL_Vector llGetForce();
125 LSL_Integer llGetFreeMemory(); 125 LSL_Integer llGetFreeMemory();
126 LSL_Integer llGetUsedMemory();
126 LSL_Integer llGetFreeURLs(); 127 LSL_Integer llGetFreeURLs();
127 LSL_Vector llGetGeometricCenter(); 128 LSL_Vector llGetGeometricCenter();
128 LSL_Float llGetGMTclock(); 129 LSL_Float llGetGMTclock();
@@ -405,7 +406,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
405 LSL_Vector llWind(LSL_Vector offset); 406 LSL_Vector llWind(LSL_Vector offset);
406 LSL_String llXorBase64Strings(string str1, string str2); 407 LSL_String llXorBase64Strings(string str1, string str2);
407 LSL_String llXorBase64StringsCorrect(string str1, string str2); 408 LSL_String llXorBase64StringsCorrect(string str1, string str2);
408 void print(string str); 409 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link);
409 410
410 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 411 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
411 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 412 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 87cfe1a..5ddba60 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
83 // Avatar Info Commands 83 // Avatar Info Commands
84 string osGetAgentIP(string agent); 84 string osGetAgentIP(string agent);
85 LSL_List osGetAgents(); 85 LSL_List osGetAgents();
86 86
87 // Teleport commands 87 // Teleport commands
88 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 88 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
89 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 89 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..4132dfa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
46
47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
48{
49 public partial class ScriptBaseClass : MarshalByRefObject
50 {
51 public ICM_Api m_CM_Functions;
52
53 public void ApiTypeCM(IScriptApi api)
54 {
55 if (!(api is ICM_Api))
56 return;
57
58 m_CM_Functions = (ICM_Api)api;
59 }
60
61 public string cmDetectedCountry(int num)
62 {
63 return m_CM_Functions.cmDetectedCountry(num);
64 }
65
66 public string cmGetAgentCountry(key key)
67 {
68 return m_CM_Functions.cmGetAgentCountry(key);
69 }
70 }
71}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 9615315..943d7a2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Reflection; 31using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using OpenSim.Region.ScriptEngine.Shared; 33using OpenSim.Region.ScriptEngine.Shared;
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
132 return (eventFlags); 133 return (eventFlags);
133 } 134 }
134 135
136 [DebuggerNonUserCode]
135 public void ExecuteEvent(string state, string FunctionName, object[] args) 137 public void ExecuteEvent(string state, string FunctionName, object[] args)
136 { 138 {
137 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 139 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index e82c281..59eaccb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -281,6 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
281 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART 281 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
282 public const int CHANGED_MEDIA = 2048; 282 public const int CHANGED_MEDIA = 2048;
283 public const int CHANGED_ANIMATION = 16384; 283 public const int CHANGED_ANIMATION = 16384;
284 public const int CHANGED_POSITION = 32768;
284 public const int TYPE_INVALID = 0; 285 public const int TYPE_INVALID = 0;
285 public const int TYPE_INTEGER = 1; 286 public const int TYPE_INTEGER = 1;
286 public const int TYPE_FLOAT = 2; 287 public const int TYPE_FLOAT = 2;
@@ -374,6 +375,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
374 public const int PRIM_SCULPT_TYPE_TORUS = 2; 375 public const int PRIM_SCULPT_TYPE_TORUS = 2;
375 public const int PRIM_SCULPT_TYPE_PLANE = 3; 376 public const int PRIM_SCULPT_TYPE_PLANE = 3;
376 public const int PRIM_SCULPT_TYPE_CYLINDER = 4; 377 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
378 public const int PRIM_SCULPT_FLAG_INVERT = 64;
379 public const int PRIM_SCULPT_FLAG_MIRROR = 128;
377 380
378 public const int MASK_BASE = 0; 381 public const int MASK_BASE = 0;
379 public const int MASK_OWNER = 1; 382 public const int MASK_OWNER = 1;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 508f33b..a88a1f4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Diagnostics; //for [DebuggerNonUserCode]
29using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
30using System.Threading; 31using System.Threading;
31using System.Reflection; 32using System.Reflection;
@@ -314,6 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
314 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); 315 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
315 } 316 }
316 317
318 [DebuggerNonUserCode]
317 public void llDie() 319 public void llDie()
318 { 320 {
319 m_LSL_Functions.llDie(); 321 m_LSL_Functions.llDie();
@@ -464,6 +466,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
464 return m_LSL_Functions.llGetFreeMemory(); 466 return m_LSL_Functions.llGetFreeMemory();
465 } 467 }
466 468
469 public LSL_Integer llGetUsedMemory()
470 {
471 return m_LSL_Functions.llGetUsedMemory();
472 }
473
467 public LSL_Integer llGetFreeURLs() 474 public LSL_Integer llGetFreeURLs()
468 { 475 {
469 return m_LSL_Functions.llGetFreeURLs(); 476 return m_LSL_Functions.llGetFreeURLs();
@@ -1878,9 +1885,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1878 return m_LSL_Functions.llClearPrimMedia(face); 1885 return m_LSL_Functions.llClearPrimMedia(face);
1879 } 1886 }
1880 1887
1881 public void print(string str) 1888 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
1882 { 1889 {
1883 m_LSL_Functions.print(str); 1890 return m_LSL_Functions.llGetLinkNumberOfSides(link);
1884 } 1891 }
1885 } 1892 }
1886} 1893}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
index 143b497..2e27f16 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
@@ -72,9 +72,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
72 { 72 {
73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); 73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
74 } 74 }
75
75 public void lsClearWindlightScene() 76 public void lsClearWindlightScene()
76 { 77 {
77 m_LS_Functions.lsClearWindlightScene(); 78 m_LS_Functions.lsClearWindlightScene();
78 } 79 }
80
81 public LSL_List cmGetWindlightScene(LSL_List rules)
82 {
83 return m_LS_Functions.lsGetWindlightScene(rules);
84 }
85
86 public int cmSetWindlightScene(LSL_List rules)
87 {
88 return m_LS_Functions.lsSetWindlightScene(rules);
89 }
90
91 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
92 {
93 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
94 }
95
96 public void cmClearWindlightScene()
97 {
98 m_LS_Functions.lsClearWindlightScene();
99 }
79 } 100 }
80} 101}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index edbbc2a..b138da3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using System.Collections; 34using System.Collections;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Diagnostics; //for [DebuggerNonUserCode]
36using OpenSim.Region.ScriptEngine.Interfaces; 37using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 38using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; 39using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
90 return (int)m_Executor.GetStateEventFlags(state); 91 return (int)m_Executor.GetStateEventFlags(state);
91 } 92 }
92 93
94 [DebuggerNonUserCode]
93 public void ExecuteEvent(string state, string FunctionName, object[] args) 95 public void ExecuteEvent(string state, string FunctionName, object[] args)
94 { 96 {
95 m_Executor.ExecuteEvent(state, FunctionName, args); 97 m_Executor.ExecuteEvent(state, FunctionName, args);