diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
12 files changed, 1387 insertions, 670 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/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d06b134..1dd4ca4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -81,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
81 | /// </summary> | 82 | /// </summary> |
82 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | 83 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi |
83 | { | 84 | { |
84 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 85 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
85 | protected IScriptEngine m_ScriptEngine; | 86 | protected IScriptEngine m_ScriptEngine; |
86 | protected SceneObjectPart m_host; | 87 | protected SceneObjectPart m_host; |
87 | protected uint m_localID; | 88 | protected uint m_localID; |
@@ -99,6 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
99 | protected int m_notecardLineReadCharsMax = 255; | 100 | protected int m_notecardLineReadCharsMax = 255; |
100 | protected int m_scriptConsoleChannel = 0; | 101 | protected int m_scriptConsoleChannel = 0; |
101 | protected bool m_scriptConsoleChannelEnabled = false; | 102 | protected bool m_scriptConsoleChannelEnabled = false; |
103 | protected bool m_debuggerSafe = false; | ||
102 | protected IUrlModule m_UrlModule = null; | 104 | protected IUrlModule m_UrlModule = null; |
103 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 105 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
104 | new Dictionary<UUID, UserInfoCacheEntry>(); | 106 | new Dictionary<UUID, UserInfoCacheEntry>(); |
@@ -109,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
109 | m_host = host; | 111 | m_host = host; |
110 | m_localID = localID; | 112 | m_localID = localID; |
111 | m_itemID = itemID; | 113 | m_itemID = itemID; |
114 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
112 | 115 | ||
113 | m_ScriptDelayFactor = | 116 | m_ScriptDelayFactor = |
114 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 117 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
@@ -161,6 +164,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
161 | get { return m_ScriptEngine.World; } | 164 | get { return m_ScriptEngine.World; } |
162 | } | 165 | } |
163 | 166 | ||
167 | [DebuggerNonUserCode] | ||
164 | public void state(string newState) | 168 | public void state(string newState) |
165 | { | 169 | { |
166 | m_ScriptEngine.SetState(m_itemID, newState); | 170 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -170,6 +174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
170 | /// Reset the named script. The script must be present | 174 | /// Reset the named script. The script must be present |
171 | /// in the same prim. | 175 | /// in the same prim. |
172 | /// </summary> | 176 | /// </summary> |
177 | [DebuggerNonUserCode] | ||
173 | public void llResetScript() | 178 | public void llResetScript() |
174 | { | 179 | { |
175 | m_host.AddScriptLPS(1); | 180 | m_host.AddScriptLPS(1); |
@@ -226,9 +231,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
226 | } | 231 | } |
227 | } | 232 | } |
228 | 233 | ||
234 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
235 | { | ||
236 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
237 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
238 | return ret; | ||
239 | |||
240 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
241 | |||
242 | switch (linkType) | ||
243 | { | ||
244 | case ScriptBaseClass.LINK_SET: | ||
245 | return avs; | ||
246 | |||
247 | case ScriptBaseClass.LINK_ROOT: | ||
248 | return ret; | ||
249 | |||
250 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
251 | return avs; | ||
252 | |||
253 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
254 | return avs; | ||
255 | |||
256 | case ScriptBaseClass.LINK_THIS: | ||
257 | return ret; | ||
258 | |||
259 | default: | ||
260 | if (linkType < 0) | ||
261 | return ret; | ||
262 | |||
263 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
264 | |||
265 | if (linkType <= partCount) | ||
266 | { | ||
267 | return ret; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | linkType = linkType - partCount; | ||
272 | if (linkType > avs.Count) | ||
273 | { | ||
274 | return ret; | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | ret.Add(avs[linkType-1]); | ||
279 | return ret; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | |||
229 | public List<SceneObjectPart> GetLinkParts(int linkType) | 285 | public List<SceneObjectPart> GetLinkParts(int linkType) |
230 | { | 286 | { |
231 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 287 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
288 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
289 | return ret; | ||
232 | ret.Add(m_host); | 290 | ret.Add(m_host); |
233 | 291 | ||
234 | switch (linkType) | 292 | switch (linkType) |
@@ -288,40 +346,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
288 | protected UUID InventorySelf() | 346 | protected UUID InventorySelf() |
289 | { | 347 | { |
290 | UUID invItemID = new UUID(); | 348 | UUID invItemID = new UUID(); |
291 | 349 | bool unlock = false; | |
292 | lock (m_host.TaskInventory) | 350 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
293 | { | 351 | { |
294 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 352 | m_host.TaskInventory.LockItemsForRead(true); |
353 | unlock = true; | ||
354 | } | ||
355 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
356 | { | ||
357 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
295 | { | 358 | { |
296 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 359 | invItemID = inv.Key; |
297 | { | 360 | break; |
298 | invItemID = inv.Key; | ||
299 | break; | ||
300 | } | ||
301 | } | 361 | } |
302 | } | 362 | } |
303 | 363 | if (unlock) | |
364 | { | ||
365 | m_host.TaskInventory.LockItemsForRead(false); | ||
366 | } | ||
304 | return invItemID; | 367 | return invItemID; |
305 | } | 368 | } |
306 | 369 | ||
307 | protected UUID InventoryKey(string name, int type) | 370 | protected UUID InventoryKey(string name, int type) |
308 | { | 371 | { |
309 | m_host.AddScriptLPS(1); | 372 | m_host.AddScriptLPS(1); |
310 | 373 | m_host.TaskInventory.LockItemsForRead(true); | |
311 | lock (m_host.TaskInventory) | 374 | |
375 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
312 | { | 376 | { |
313 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 377 | if (inv.Value.Name == name) |
314 | { | 378 | { |
315 | if (inv.Value.Name == name) | 379 | m_host.TaskInventory.LockItemsForRead(false); |
380 | |||
381 | if (inv.Value.Type != type) | ||
316 | { | 382 | { |
317 | if (inv.Value.Type != type) | 383 | return UUID.Zero; |
318 | return UUID.Zero; | ||
319 | |||
320 | return inv.Value.AssetID; | ||
321 | } | 384 | } |
385 | |||
386 | return inv.Value.AssetID; | ||
322 | } | 387 | } |
323 | } | 388 | } |
324 | 389 | ||
390 | m_host.TaskInventory.LockItemsForRead(false); | ||
325 | return UUID.Zero; | 391 | return UUID.Zero; |
326 | } | 392 | } |
327 | 393 | ||
@@ -329,17 +395,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | { | 395 | { |
330 | m_host.AddScriptLPS(1); | 396 | m_host.AddScriptLPS(1); |
331 | 397 | ||
332 | lock (m_host.TaskInventory) | 398 | |
399 | m_host.TaskInventory.LockItemsForRead(true); | ||
400 | |||
401 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
333 | { | 402 | { |
334 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 403 | if (inv.Value.Name == name) |
335 | { | 404 | { |
336 | if (inv.Value.Name == name) | 405 | m_host.TaskInventory.LockItemsForRead(false); |
337 | { | 406 | return inv.Value.AssetID; |
338 | return inv.Value.AssetID; | ||
339 | } | ||
340 | } | 407 | } |
341 | } | 408 | } |
342 | 409 | ||
410 | m_host.TaskInventory.LockItemsForRead(false); | ||
411 | |||
412 | |||
343 | return UUID.Zero; | 413 | return UUID.Zero; |
344 | } | 414 | } |
345 | 415 | ||
@@ -481,26 +551,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
481 | 551 | ||
482 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 552 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
483 | 553 | ||
484 | // Old implementation of llRot2Euler. Normalization not required as Atan2 function will | 554 | // Utility function for llRot2Euler |
485 | // only return values >= -PI (-180 degrees) and <= PI (180 degrees). | 555 | |
556 | // normalize an angle between -PI and PI (-180 to +180 degrees) | ||
557 | protected double NormalizeAngle(double angle) | ||
558 | { | ||
559 | if (angle > -Math.PI && angle < Math.PI) | ||
560 | return angle; | ||
561 | |||
562 | int numPis = (int)(Math.PI / angle); | ||
563 | double remainder = angle - Math.PI * numPis; | ||
564 | if (numPis % 2 == 1) | ||
565 | return Math.PI - angle; | ||
566 | return remainder; | ||
567 | } | ||
486 | 568 | ||
487 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 569 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
488 | { | 570 | { |
489 | m_host.AddScriptLPS(1); | 571 | m_host.AddScriptLPS(1); |
490 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | 572 | LSL_Vector eul = new LSL_Vector(); |
491 | LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | 573 | |
492 | double m = (t.x + t.y + t.z + t.s); | 574 | double sqw = q1.s*q1.s; |
493 | if (m == 0) return new LSL_Vector(); | 575 | double sqx = q1.x*q1.x; |
494 | double n = 2 * (r.y * r.s + r.x * r.z); | 576 | double sqy = q1.z*q1.z; |
495 | double p = m * m - n * n; | 577 | double sqz = q1.y*q1.y; |
496 | if (p > 0) | 578 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor |
497 | return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), | 579 | double test = q1.x*q1.z + q1.y*q1.s; |
498 | Math.Atan2(n, Math.Sqrt(p)), | 580 | if (test > 0.4999*unit) { // singularity at north pole |
499 | Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); | 581 | eul.z = 2 * Math.Atan2(q1.x,q1.s); |
500 | else if (n > 0) | 582 | eul.y = Math.PI/2; |
501 | 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 | eul.x = 0; |
502 | else | 584 | return eul; |
503 | 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)); | 585 | } |
586 | if (test < -0.4999*unit) { // singularity at south pole | ||
587 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
588 | eul.y = -Math.PI/2; | ||
589 | eul.x = 0; | ||
590 | return eul; | ||
591 | } | ||
592 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
593 | eul.y = Math.Asin(2*test/unit); | ||
594 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
595 | return eul; | ||
504 | } | 596 | } |
505 | 597 | ||
506 | /* From wiki: | 598 | /* From wiki: |
@@ -702,77 +794,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
702 | { | 794 | { |
703 | //A and B should both be normalized | 795 | //A and B should both be normalized |
704 | m_host.AddScriptLPS(1); | 796 | m_host.AddScriptLPS(1); |
705 | LSL_Rotation rotBetween; | 797 | /* This method is more accurate than the SL one, and thus causes problems |
706 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 798 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
707 | // continue calculation. | 799 | |
708 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 800 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | { | 801 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 802 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
711 | } | 803 | double angle = Math.Acos(dotProduct / magProduct); |
712 | else | 804 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); |
713 | { | 805 | double s = Math.Sin(angle / 2); |
714 | a = LSL_Vector.Norm(a); | 806 | |
715 | b = LSL_Vector.Norm(b); | 807 | double x = axis.x * s; |
716 | double dotProduct = LSL_Vector.Dot(a, b); | 808 | double y = axis.y * s; |
717 | // There are two degenerate cases possible. These are for vectors 180 or | 809 | double z = axis.z * s; |
718 | // 0 degrees apart. These have to be detected and handled individually. | 810 | double w = Math.Cos(angle / 2); |
719 | // | 811 | |
720 | // Check for vectors 180 degrees apart. | 812 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) |
721 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 813 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | if (dotProduct < -0.9999999f) | 814 | |
723 | { | 815 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | // First assume X axis is orthogonal to the vectors. | 816 | */ |
725 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 817 | |
726 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 818 | // This method mimics the 180 errors found in SL |
727 | // Check for near zero vector. A very small non-zero number here will create | 819 | // See www.euclideanspace.com... angleBetween |
728 | // a rotation in an undesired direction. | 820 | LSL_Vector vec_a = a; |
729 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 821 | LSL_Vector vec_b = b; |
730 | { | 822 | |
731 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 823 | // Eliminate zero length |
732 | } | 824 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); |
733 | // If the magnitude of the vector was near zero, then assume the X axis is not | 825 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); |
734 | // orthogonal and use the Z axis instead. | 826 | if (vec_a_mag < 0.00001 || |
735 | else | 827 | vec_b_mag < 0.00001) |
736 | { | 828 | { |
737 | // Set 180 z rotation. | 829 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
738 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | 830 | } |
739 | } | 831 | |
740 | } | 832 | // Normalize |
741 | // Check for parallel vectors. | 833 | vec_a = llVecNorm(vec_a); |
742 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | 834 | vec_b = llVecNorm(vec_b); |
743 | else if (dotProduct > 0.9999999f) | 835 | |
744 | { | 836 | // Calculate axis and rotation angle |
745 | // Set zero rotation. | 837 | LSL_Vector axis = vec_a % vec_b; |
746 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 838 | LSL_Float cos_theta = vec_a * vec_b; |
747 | } | 839 | |
748 | else | 840 | // Check if parallel |
749 | { | 841 | if (cos_theta > 0.99999) |
750 | // All special checks have been performed so get the axis of rotation. | 842 | { |
751 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 843 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
752 | // Quarternion s value is the length of the unit vector + dot product. | 844 | } |
753 | double qs = 1.0 + dotProduct; | 845 | |
754 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | 846 | // Check if anti-parallel |
755 | // Normalize the rotation. | 847 | else if (cos_theta < -0.99999) |
756 | double mag = LSL_Rotation.Mag(rotBetween); | 848 | { |
757 | // We shouldn't have to worry about a divide by zero here. The qs value will be | 849 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
758 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | 850 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
759 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | 851 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
760 | // crossProduct vector should also not be zero. | 852 | } |
761 | rotBetween.x = rotBetween.x / mag; | 853 | else // other rotation |
762 | rotBetween.y = rotBetween.y / mag; | 854 | { |
763 | rotBetween.z = rotBetween.z / mag; | 855 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
764 | rotBetween.s = rotBetween.s / mag; | 856 | axis = llVecNorm(axis); |
765 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | 857 | double x, y, z, s, t; |
766 | // any longer since zero vectors are checked for at the top. | 858 | s = Math.Cos(theta); |
767 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | 859 | t = Math.Sin(theta); |
768 | { | 860 | x = axis.x * t; |
769 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 861 | y = axis.y * t; |
770 | } | 862 | z = axis.z * t; |
771 | } | 863 | return new LSL_Rotation(x,y,z,s); |
772 | } | 864 | } |
773 | return rotBetween; | 865 | } |
774 | } | 866 | |
775 | |||
776 | public void llWhisper(int channelID, string text) | 867 | public void llWhisper(int channelID, string text) |
777 | { | 868 | { |
778 | m_host.AddScriptLPS(1); | 869 | m_host.AddScriptLPS(1); |
@@ -1096,10 +1187,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1096 | return detectedParams.TouchUV; | 1187 | return detectedParams.TouchUV; |
1097 | } | 1188 | } |
1098 | 1189 | ||
1190 | [DebuggerNonUserCode] | ||
1099 | public virtual void llDie() | 1191 | public virtual void llDie() |
1100 | { | 1192 | { |
1101 | m_host.AddScriptLPS(1); | 1193 | m_host.AddScriptLPS(1); |
1102 | throw new SelfDeleteException(); | 1194 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1103 | } | 1195 | } |
1104 | 1196 | ||
1105 | public LSL_Float llGround(LSL_Vector offset) | 1197 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1172,6 +1264,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1172 | 1264 | ||
1173 | public void llSetStatus(int status, int value) | 1265 | public void llSetStatus(int status, int value) |
1174 | { | 1266 | { |
1267 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1268 | return; | ||
1175 | m_host.AddScriptLPS(1); | 1269 | m_host.AddScriptLPS(1); |
1176 | 1270 | ||
1177 | int statusrotationaxis = 0; | 1271 | int statusrotationaxis = 0; |
@@ -1402,6 +1496,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1402 | { | 1496 | { |
1403 | m_host.AddScriptLPS(1); | 1497 | m_host.AddScriptLPS(1); |
1404 | 1498 | ||
1499 | SetColor(m_host, color, face); | ||
1500 | } | ||
1501 | |||
1502 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1503 | { | ||
1504 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1505 | return; | ||
1506 | |||
1507 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1508 | Color4 texcolor; | ||
1509 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1510 | { | ||
1511 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1512 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1513 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1514 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1515 | tex.FaceTextures[face].RGBA = texcolor; | ||
1516 | part.UpdateTexture(tex); | ||
1517 | return; | ||
1518 | } | ||
1519 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1520 | { | ||
1521 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1522 | { | ||
1523 | if (tex.FaceTextures[i] != null) | ||
1524 | { | ||
1525 | texcolor = tex.FaceTextures[i].RGBA; | ||
1526 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1527 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1528 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1529 | tex.FaceTextures[i].RGBA = texcolor; | ||
1530 | } | ||
1531 | texcolor = tex.DefaultTexture.RGBA; | ||
1532 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1533 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1534 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1535 | tex.DefaultTexture.RGBA = texcolor; | ||
1536 | } | ||
1537 | part.UpdateTexture(tex); | ||
1538 | return; | ||
1539 | } | ||
1540 | |||
1405 | if (face == ScriptBaseClass.ALL_SIDES) | 1541 | if (face == ScriptBaseClass.ALL_SIDES) |
1406 | face = SceneObjectPart.ALL_SIDES; | 1542 | face = SceneObjectPart.ALL_SIDES; |
1407 | 1543 | ||
@@ -1410,6 +1546,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1410 | 1546 | ||
1411 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1547 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1412 | { | 1548 | { |
1549 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1550 | return; | ||
1551 | |||
1413 | Primitive.TextureEntry tex = part.Shape.Textures; | 1552 | Primitive.TextureEntry tex = part.Shape.Textures; |
1414 | MappingType textype; | 1553 | MappingType textype; |
1415 | textype = MappingType.Default; | 1554 | textype = MappingType.Default; |
@@ -1440,6 +1579,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1440 | 1579 | ||
1441 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1580 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1442 | { | 1581 | { |
1582 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1583 | return; | ||
1584 | |||
1443 | Primitive.TextureEntry tex = part.Shape.Textures; | 1585 | Primitive.TextureEntry tex = part.Shape.Textures; |
1444 | if (face >= 0 && face < GetNumberOfSides(part)) | 1586 | if (face >= 0 && face < GetNumberOfSides(part)) |
1445 | { | 1587 | { |
@@ -1465,6 +1607,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1465 | 1607 | ||
1466 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1608 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1467 | { | 1609 | { |
1610 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1611 | return; | ||
1468 | 1612 | ||
1469 | Shininess sval = new Shininess(); | 1613 | Shininess sval = new Shininess(); |
1470 | 1614 | ||
@@ -1515,6 +1659,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1515 | 1659 | ||
1516 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1660 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1517 | { | 1661 | { |
1662 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1663 | return; | ||
1664 | |||
1518 | Primitive.TextureEntry tex = part.Shape.Textures; | 1665 | Primitive.TextureEntry tex = part.Shape.Textures; |
1519 | if (face >= 0 && face < GetNumberOfSides(part)) | 1666 | if (face >= 0 && face < GetNumberOfSides(part)) |
1520 | { | 1667 | { |
@@ -1575,13 +1722,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1575 | m_host.AddScriptLPS(1); | 1722 | m_host.AddScriptLPS(1); |
1576 | 1723 | ||
1577 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1724 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1578 | 1725 | if (parts.Count > 0) | |
1579 | foreach (SceneObjectPart part in parts) | 1726 | { |
1580 | SetAlpha(part, alpha, face); | 1727 | try |
1728 | { | ||
1729 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1730 | foreach (SceneObjectPart part in parts) | ||
1731 | SetAlpha(part, alpha, face); | ||
1732 | } | ||
1733 | finally | ||
1734 | { | ||
1735 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1736 | } | ||
1737 | } | ||
1581 | } | 1738 | } |
1582 | 1739 | ||
1583 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1740 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1584 | { | 1741 | { |
1742 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1743 | return; | ||
1744 | |||
1585 | Primitive.TextureEntry tex = part.Shape.Textures; | 1745 | Primitive.TextureEntry tex = part.Shape.Textures; |
1586 | Color4 texcolor; | 1746 | Color4 texcolor; |
1587 | if (face >= 0 && face < GetNumberOfSides(part)) | 1747 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1627,7 +1787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1787 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1628 | float wind, float tension, LSL_Vector Force) | 1788 | float wind, float tension, LSL_Vector Force) |
1629 | { | 1789 | { |
1630 | if (part == null) | 1790 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1631 | return; | 1791 | return; |
1632 | 1792 | ||
1633 | if (flexi) | 1793 | if (flexi) |
@@ -1662,7 +1822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1662 | /// <param name="falloff"></param> | 1822 | /// <param name="falloff"></param> |
1663 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1823 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1664 | { | 1824 | { |
1665 | if (part == null) | 1825 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1666 | return; | 1826 | return; |
1667 | 1827 | ||
1668 | if (light) | 1828 | if (light) |
@@ -1739,15 +1899,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1739 | m_host.AddScriptLPS(1); | 1899 | m_host.AddScriptLPS(1); |
1740 | 1900 | ||
1741 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1901 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1742 | 1902 | if (parts.Count > 0) | |
1743 | foreach (SceneObjectPart part in parts) | 1903 | { |
1744 | SetTexture(part, texture, face); | 1904 | try |
1745 | 1905 | { | |
1906 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1907 | foreach (SceneObjectPart part in parts) | ||
1908 | SetTexture(part, texture, face); | ||
1909 | } | ||
1910 | finally | ||
1911 | { | ||
1912 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1913 | } | ||
1914 | } | ||
1746 | ScriptSleep(200); | 1915 | ScriptSleep(200); |
1747 | } | 1916 | } |
1748 | 1917 | ||
1749 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1918 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1750 | { | 1919 | { |
1920 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1921 | return; | ||
1922 | |||
1751 | UUID textureID=new UUID(); | 1923 | UUID textureID=new UUID(); |
1752 | 1924 | ||
1753 | if (!UUID.TryParse(texture, out textureID)) | 1925 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1793,6 +1965,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1793 | 1965 | ||
1794 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1966 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1795 | { | 1967 | { |
1968 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1969 | return; | ||
1970 | |||
1796 | Primitive.TextureEntry tex = part.Shape.Textures; | 1971 | Primitive.TextureEntry tex = part.Shape.Textures; |
1797 | if (face >= 0 && face < GetNumberOfSides(part)) | 1972 | if (face >= 0 && face < GetNumberOfSides(part)) |
1798 | { | 1973 | { |
@@ -1829,6 +2004,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1829 | 2004 | ||
1830 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2005 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1831 | { | 2006 | { |
2007 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2008 | return; | ||
2009 | |||
1832 | Primitive.TextureEntry tex = part.Shape.Textures; | 2010 | Primitive.TextureEntry tex = part.Shape.Textures; |
1833 | if (face >= 0 && face < GetNumberOfSides(part)) | 2011 | if (face >= 0 && face < GetNumberOfSides(part)) |
1834 | { | 2012 | { |
@@ -1865,6 +2043,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1865 | 2043 | ||
1866 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2044 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1867 | { | 2045 | { |
2046 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2047 | return; | ||
2048 | |||
1868 | Primitive.TextureEntry tex = part.Shape.Textures; | 2049 | Primitive.TextureEntry tex = part.Shape.Textures; |
1869 | if (face >= 0 && face < GetNumberOfSides(part)) | 2050 | if (face >= 0 && face < GetNumberOfSides(part)) |
1870 | { | 2051 | { |
@@ -1935,6 +2116,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1935 | 2116 | ||
1936 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2117 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1937 | { | 2118 | { |
2119 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2120 | return; | ||
2121 | |||
1938 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2122 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1939 | LSL_Vector currentPos = GetPartLocalPos(part); | 2123 | LSL_Vector currentPos = GetPartLocalPos(part); |
1940 | 2124 | ||
@@ -1951,7 +2135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1951 | } | 2135 | } |
1952 | else | 2136 | else |
1953 | { | 2137 | { |
1954 | LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); | 2138 | LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos); |
1955 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | 2139 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); |
1956 | SceneObjectGroup parent = part.ParentGroup; | 2140 | SceneObjectGroup parent = part.ParentGroup; |
1957 | parent.HasGroupChanged = true; | 2141 | parent.HasGroupChanged = true; |
@@ -2003,9 +2187,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2003 | m_host.AddScriptLPS(1); | 2187 | m_host.AddScriptLPS(1); |
2004 | 2188 | ||
2005 | // try to let this work as in SL... | 2189 | // try to let this work as in SL... |
2006 | if (m_host.ParentID == 0) | 2190 | if (m_host.LinkNum < 2) |
2007 | { | 2191 | { |
2008 | // special case: If we are root, rotate complete SOG to new rotation | 2192 | // Special case: If we are root, rotate complete SOG to new |
2193 | // rotation. | ||
2194 | // We are root if the link number is 0 (single prim) or 1 | ||
2195 | // (root prim). ParentID may be nonzero in attachments and | ||
2196 | // using it would cause attachments and HUDs to rotate | ||
2197 | // to the wrong positions. | ||
2009 | SetRot(m_host, Rot2Quaternion(rot)); | 2198 | SetRot(m_host, Rot2Quaternion(rot)); |
2010 | } | 2199 | } |
2011 | else | 2200 | else |
@@ -2034,6 +2223,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2034 | 2223 | ||
2035 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2224 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2036 | { | 2225 | { |
2226 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2227 | return; | ||
2228 | |||
2037 | part.UpdateRotation(rot); | 2229 | part.UpdateRotation(rot); |
2038 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2230 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2039 | 2231 | ||
@@ -2653,12 +2845,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2653 | 2845 | ||
2654 | m_host.AddScriptLPS(1); | 2846 | m_host.AddScriptLPS(1); |
2655 | 2847 | ||
2848 | m_host.TaskInventory.LockItemsForRead(true); | ||
2656 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2849 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2657 | 2850 | m_host.TaskInventory.LockItemsForRead(false); | |
2658 | lock (m_host.TaskInventory) | ||
2659 | { | ||
2660 | item = m_host.TaskInventory[invItemID]; | ||
2661 | } | ||
2662 | 2851 | ||
2663 | if (item.PermsGranter == UUID.Zero) | 2852 | if (item.PermsGranter == UUID.Zero) |
2664 | return 0; | 2853 | return 0; |
@@ -2733,6 +2922,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2733 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2922 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2734 | return; | 2923 | return; |
2735 | 2924 | ||
2925 | //Clone is thread-safe | ||
2736 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2926 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2737 | 2927 | ||
2738 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2928 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2795,6 +2985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2795 | 2985 | ||
2796 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2986 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2797 | { | 2987 | { |
2988 | /* | ||
2798 | m_host.AddScriptLPS(1); | 2989 | m_host.AddScriptLPS(1); |
2799 | // Determine where we are looking from | 2990 | // Determine where we are looking from |
2800 | LSL_Vector from = llGetPos(); | 2991 | LSL_Vector from = llGetPos(); |
@@ -2814,10 +3005,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2814 | // the angles of rotation in radians into rotation value | 3005 | // the angles of rotation in radians into rotation value |
2815 | 3006 | ||
2816 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 3007 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2817 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 3008 | |
2818 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 3009 | // This would only work if your physics system contains an APID controller: |
3010 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
3011 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
3012 | |||
2819 | // Orient the object to the angle calculated | 3013 | // Orient the object to the angle calculated |
2820 | //llSetRot(rot); | 3014 | llSetRot(rot); |
3015 | */ | ||
3016 | |||
3017 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
3018 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
3019 | // http://bugs.meta7.com/view.php?id=28 | ||
3020 | // - Tom | ||
3021 | |||
3022 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
3023 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
3024 | |||
3025 | } | ||
3026 | |||
3027 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3028 | { | ||
3029 | m_host.AddScriptLPS(1); | ||
3030 | // NotImplemented("llRotLookAt"); | ||
3031 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3032 | |||
2821 | } | 3033 | } |
2822 | 3034 | ||
2823 | public void llStopLookAt() | 3035 | public void llStopLookAt() |
@@ -2866,13 +3078,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2866 | { | 3078 | { |
2867 | TaskInventoryItem item; | 3079 | TaskInventoryItem item; |
2868 | 3080 | ||
2869 | lock (m_host.TaskInventory) | 3081 | m_host.TaskInventory.LockItemsForRead(true); |
3082 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2870 | { | 3083 | { |
2871 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3084 | m_host.TaskInventory.LockItemsForRead(false); |
2872 | return; | 3085 | return; |
2873 | else | ||
2874 | item = m_host.TaskInventory[InventorySelf()]; | ||
2875 | } | 3086 | } |
3087 | else | ||
3088 | { | ||
3089 | item = m_host.TaskInventory[InventorySelf()]; | ||
3090 | } | ||
3091 | m_host.TaskInventory.LockItemsForRead(false); | ||
2876 | 3092 | ||
2877 | if (item.PermsGranter != UUID.Zero) | 3093 | if (item.PermsGranter != UUID.Zero) |
2878 | { | 3094 | { |
@@ -2894,13 +3110,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2894 | { | 3110 | { |
2895 | TaskInventoryItem item; | 3111 | TaskInventoryItem item; |
2896 | 3112 | ||
3113 | m_host.TaskInventory.LockItemsForRead(true); | ||
2897 | lock (m_host.TaskInventory) | 3114 | lock (m_host.TaskInventory) |
2898 | { | 3115 | { |
3116 | |||
2899 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3117 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3118 | { | ||
3119 | m_host.TaskInventory.LockItemsForRead(false); | ||
2900 | return; | 3120 | return; |
3121 | } | ||
2901 | else | 3122 | else |
3123 | { | ||
2902 | item = m_host.TaskInventory[InventorySelf()]; | 3124 | item = m_host.TaskInventory[InventorySelf()]; |
3125 | } | ||
2903 | } | 3126 | } |
3127 | m_host.TaskInventory.LockItemsForRead(false); | ||
2904 | 3128 | ||
2905 | m_host.AddScriptLPS(1); | 3129 | m_host.AddScriptLPS(1); |
2906 | 3130 | ||
@@ -2932,18 +3156,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2932 | { | 3156 | { |
2933 | m_host.AddScriptLPS(1); | 3157 | m_host.AddScriptLPS(1); |
2934 | 3158 | ||
2935 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
2936 | return; | ||
2937 | |||
2938 | TaskInventoryItem item; | 3159 | TaskInventoryItem item; |
2939 | 3160 | ||
2940 | lock (m_host.TaskInventory) | 3161 | m_host.TaskInventory.LockItemsForRead(true); |
3162 | |||
3163 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2941 | { | 3164 | { |
2942 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3165 | m_host.TaskInventory.LockItemsForRead(false); |
2943 | return; | 3166 | return; |
2944 | else | ||
2945 | item = m_host.TaskInventory[InventorySelf()]; | ||
2946 | } | 3167 | } |
3168 | else | ||
3169 | { | ||
3170 | item = m_host.TaskInventory[InventorySelf()]; | ||
3171 | } | ||
3172 | |||
3173 | m_host.TaskInventory.LockItemsForRead(false); | ||
2947 | 3174 | ||
2948 | if (item.PermsGranter != m_host.OwnerID) | 3175 | if (item.PermsGranter != m_host.OwnerID) |
2949 | return; | 3176 | return; |
@@ -2954,10 +3181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2954 | 3181 | ||
2955 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3182 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
2956 | 3183 | ||
2957 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3184 | grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false); |
2958 | if (attachmentsModule != null) | ||
2959 | attachmentsModule.AttachObject(presence.ControllingClient, | ||
2960 | grp, (uint)attachment, false); | ||
2961 | } | 3185 | } |
2962 | } | 3186 | } |
2963 | 3187 | ||
@@ -2970,13 +3194,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2970 | 3194 | ||
2971 | TaskInventoryItem item; | 3195 | TaskInventoryItem item; |
2972 | 3196 | ||
2973 | lock (m_host.TaskInventory) | 3197 | m_host.TaskInventory.LockItemsForRead(true); |
3198 | |||
3199 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2974 | { | 3200 | { |
2975 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3201 | m_host.TaskInventory.LockItemsForRead(false); |
2976 | return; | 3202 | return; |
2977 | else | ||
2978 | item = m_host.TaskInventory[InventorySelf()]; | ||
2979 | } | 3203 | } |
3204 | else | ||
3205 | { | ||
3206 | item = m_host.TaskInventory[InventorySelf()]; | ||
3207 | } | ||
3208 | m_host.TaskInventory.LockItemsForRead(false); | ||
3209 | |||
2980 | 3210 | ||
2981 | if (item.PermsGranter != m_host.OwnerID) | 3211 | if (item.PermsGranter != m_host.OwnerID) |
2982 | return; | 3212 | return; |
@@ -3023,6 +3253,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3023 | 3253 | ||
3024 | public void llInstantMessage(string user, string message) | 3254 | public void llInstantMessage(string user, string message) |
3025 | { | 3255 | { |
3256 | UUID result; | ||
3257 | if (!UUID.TryParse(user, out result)) | ||
3258 | { | ||
3259 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3260 | ScriptSleep(2000); | ||
3261 | return; | ||
3262 | } | ||
3263 | |||
3264 | |||
3026 | m_host.AddScriptLPS(1); | 3265 | m_host.AddScriptLPS(1); |
3027 | 3266 | ||
3028 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3267 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3037,14 +3276,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3037 | UUID friendTransactionID = UUID.Random(); | 3276 | UUID friendTransactionID = UUID.Random(); |
3038 | 3277 | ||
3039 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3278 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3040 | 3279 | ||
3041 | GridInstantMessage msg = new GridInstantMessage(); | 3280 | GridInstantMessage msg = new GridInstantMessage(); |
3042 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3281 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3043 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3282 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3044 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3283 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3045 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3284 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3046 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3285 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3047 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3286 | DateTime dt = DateTime.UtcNow; |
3287 | |||
3288 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3289 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3290 | |||
3291 | try | ||
3292 | { | ||
3293 | // Convert that to the PST timezone | ||
3294 | TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3295 | dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3296 | } | ||
3297 | catch | ||
3298 | { | ||
3299 | // No logging here, as it could be VERY spammy | ||
3300 | } | ||
3301 | |||
3302 | // And make it look local again to fool the unix time util | ||
3303 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3304 | |||
3305 | msg.timestamp = (uint)Util.ToUnixTime(dt); | ||
3306 | |||
3048 | //if (client != null) | 3307 | //if (client != null) |
3049 | //{ | 3308 | //{ |
3050 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3309 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3058,13 +3317,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3058 | msg.message = message.Substring(0, 1024); | 3317 | msg.message = message.Substring(0, 1024); |
3059 | else | 3318 | else |
3060 | msg.message = message; | 3319 | msg.message = message; |
3061 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3320 | msg.dialog = (byte)19; // MessageFromObject |
3062 | msg.fromGroup = false;// fromGroup; | 3321 | msg.fromGroup = false;// fromGroup; |
3063 | msg.offline = (byte)0; //offline; | 3322 | msg.offline = (byte)0; //offline; |
3064 | msg.ParentEstateID = 0; //ParentEstateID; | 3323 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3065 | msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); | 3324 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3066 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3325 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3067 | msg.binaryBucket = new byte[0];// binaryBucket; | 3326 | msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); |
3068 | 3327 | ||
3069 | if (m_TransferModule != null) | 3328 | if (m_TransferModule != null) |
3070 | { | 3329 | { |
@@ -3084,7 +3343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3084 | } | 3343 | } |
3085 | 3344 | ||
3086 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3345 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3087 | ScriptSleep(20000); | 3346 | ScriptSleep(15000); |
3088 | } | 3347 | } |
3089 | 3348 | ||
3090 | public void llGetNextEmail(string address, string subject) | 3349 | public void llGetNextEmail(string address, string subject) |
@@ -3186,13 +3445,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3186 | m_host.AddScriptLPS(1); | 3445 | m_host.AddScriptLPS(1); |
3187 | } | 3446 | } |
3188 | 3447 | ||
3189 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3190 | { | ||
3191 | m_host.AddScriptLPS(1); | ||
3192 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3193 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3194 | } | ||
3195 | |||
3196 | public LSL_Integer llStringLength(string str) | 3448 | public LSL_Integer llStringLength(string str) |
3197 | { | 3449 | { |
3198 | m_host.AddScriptLPS(1); | 3450 | m_host.AddScriptLPS(1); |
@@ -3216,14 +3468,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3216 | 3468 | ||
3217 | TaskInventoryItem item; | 3469 | TaskInventoryItem item; |
3218 | 3470 | ||
3219 | lock (m_host.TaskInventory) | 3471 | m_host.TaskInventory.LockItemsForRead(true); |
3472 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3220 | { | 3473 | { |
3221 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3474 | m_host.TaskInventory.LockItemsForRead(false); |
3222 | return; | 3475 | return; |
3223 | else | ||
3224 | item = m_host.TaskInventory[InventorySelf()]; | ||
3225 | } | 3476 | } |
3226 | 3477 | else | |
3478 | { | ||
3479 | item = m_host.TaskInventory[InventorySelf()]; | ||
3480 | } | ||
3481 | m_host.TaskInventory.LockItemsForRead(false); | ||
3227 | if (item.PermsGranter == UUID.Zero) | 3482 | if (item.PermsGranter == UUID.Zero) |
3228 | return; | 3483 | return; |
3229 | 3484 | ||
@@ -3253,13 +3508,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3253 | 3508 | ||
3254 | TaskInventoryItem item; | 3509 | TaskInventoryItem item; |
3255 | 3510 | ||
3256 | lock (m_host.TaskInventory) | 3511 | m_host.TaskInventory.LockItemsForRead(true); |
3512 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3257 | { | 3513 | { |
3258 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3514 | m_host.TaskInventory.LockItemsForRead(false); |
3259 | return; | 3515 | return; |
3260 | else | 3516 | } |
3261 | item = m_host.TaskInventory[InventorySelf()]; | 3517 | else |
3518 | { | ||
3519 | item = m_host.TaskInventory[InventorySelf()]; | ||
3262 | } | 3520 | } |
3521 | m_host.TaskInventory.LockItemsForRead(false); | ||
3522 | |||
3263 | 3523 | ||
3264 | if (item.PermsGranter == UUID.Zero) | 3524 | if (item.PermsGranter == UUID.Zero) |
3265 | return; | 3525 | return; |
@@ -3330,10 +3590,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3330 | 3590 | ||
3331 | TaskInventoryItem item; | 3591 | TaskInventoryItem item; |
3332 | 3592 | ||
3333 | lock (m_host.TaskInventory) | 3593 | |
3594 | m_host.TaskInventory.LockItemsForRead(true); | ||
3595 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3596 | { | ||
3597 | m_host.TaskInventory.LockItemsForRead(false); | ||
3598 | return; | ||
3599 | } | ||
3600 | else | ||
3334 | { | 3601 | { |
3335 | item = m_host.TaskInventory[invItemID]; | 3602 | item = m_host.TaskInventory[invItemID]; |
3336 | } | 3603 | } |
3604 | m_host.TaskInventory.LockItemsForRead(false); | ||
3337 | 3605 | ||
3338 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3606 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3339 | { | 3607 | { |
@@ -3365,11 +3633,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3365 | 3633 | ||
3366 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3634 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3367 | { | 3635 | { |
3368 | lock (m_host.TaskInventory) | 3636 | m_host.TaskInventory.LockItemsForWrite(true); |
3369 | { | 3637 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3370 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3638 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3371 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3639 | m_host.TaskInventory.LockItemsForWrite(false); |
3372 | } | ||
3373 | 3640 | ||
3374 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3641 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3375 | "run_time_permissions", new Object[] { | 3642 | "run_time_permissions", new Object[] { |
@@ -3389,11 +3656,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3389 | 3656 | ||
3390 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3657 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3391 | { | 3658 | { |
3392 | lock (m_host.TaskInventory) | 3659 | m_host.TaskInventory.LockItemsForWrite(true); |
3393 | { | 3660 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3394 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3661 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3395 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3662 | m_host.TaskInventory.LockItemsForWrite(false); |
3396 | } | ||
3397 | 3663 | ||
3398 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3664 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3399 | "run_time_permissions", new Object[] { | 3665 | "run_time_permissions", new Object[] { |
@@ -3414,11 +3680,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3414 | 3680 | ||
3415 | if (!m_waitingForScriptAnswer) | 3681 | if (!m_waitingForScriptAnswer) |
3416 | { | 3682 | { |
3417 | lock (m_host.TaskInventory) | 3683 | m_host.TaskInventory.LockItemsForWrite(true); |
3418 | { | 3684 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3419 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3685 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3420 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3686 | m_host.TaskInventory.LockItemsForWrite(false); |
3421 | } | ||
3422 | 3687 | ||
3423 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3688 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3424 | m_waitingForScriptAnswer=true; | 3689 | m_waitingForScriptAnswer=true; |
@@ -3453,10 +3718,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3453 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3718 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3454 | llReleaseControls(); | 3719 | llReleaseControls(); |
3455 | 3720 | ||
3456 | lock (m_host.TaskInventory) | 3721 | |
3457 | { | 3722 | m_host.TaskInventory.LockItemsForWrite(true); |
3458 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3723 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3459 | } | 3724 | m_host.TaskInventory.LockItemsForWrite(false); |
3725 | |||
3460 | 3726 | ||
3461 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3727 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3462 | "run_time_permissions", new Object[] { | 3728 | "run_time_permissions", new Object[] { |
@@ -3468,16 +3734,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3468 | { | 3734 | { |
3469 | m_host.AddScriptLPS(1); | 3735 | m_host.AddScriptLPS(1); |
3470 | 3736 | ||
3471 | lock (m_host.TaskInventory) | 3737 | m_host.TaskInventory.LockItemsForRead(true); |
3738 | |||
3739 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3472 | { | 3740 | { |
3473 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3741 | if (item.Type == 10 && item.ItemID == m_itemID) |
3474 | { | 3742 | { |
3475 | if (item.Type == 10 && item.ItemID == m_itemID) | 3743 | m_host.TaskInventory.LockItemsForRead(false); |
3476 | { | 3744 | return item.PermsGranter.ToString(); |
3477 | return item.PermsGranter.ToString(); | ||
3478 | } | ||
3479 | } | 3745 | } |
3480 | } | 3746 | } |
3747 | m_host.TaskInventory.LockItemsForRead(false); | ||
3481 | 3748 | ||
3482 | return UUID.Zero.ToString(); | 3749 | return UUID.Zero.ToString(); |
3483 | } | 3750 | } |
@@ -3486,19 +3753,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3486 | { | 3753 | { |
3487 | m_host.AddScriptLPS(1); | 3754 | m_host.AddScriptLPS(1); |
3488 | 3755 | ||
3489 | lock (m_host.TaskInventory) | 3756 | m_host.TaskInventory.LockItemsForRead(true); |
3757 | |||
3758 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3490 | { | 3759 | { |
3491 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3760 | if (item.Type == 10 && item.ItemID == m_itemID) |
3492 | { | 3761 | { |
3493 | if (item.Type == 10 && item.ItemID == m_itemID) | 3762 | int perms = item.PermsMask; |
3494 | { | 3763 | if (m_automaticLinkPermission) |
3495 | int perms = item.PermsMask; | 3764 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3496 | if (m_automaticLinkPermission) | 3765 | m_host.TaskInventory.LockItemsForRead(false); |
3497 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3766 | return perms; |
3498 | return perms; | ||
3499 | } | ||
3500 | } | 3767 | } |
3501 | } | 3768 | } |
3769 | m_host.TaskInventory.LockItemsForRead(false); | ||
3502 | 3770 | ||
3503 | return 0; | 3771 | return 0; |
3504 | } | 3772 | } |
@@ -3520,9 +3788,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3520 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3788 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3521 | { | 3789 | { |
3522 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3790 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3523 | 3791 | if (parts.Count > 0) | |
3524 | foreach (SceneObjectPart part in parts) | 3792 | { |
3525 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3793 | try |
3794 | { | ||
3795 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3796 | foreach (SceneObjectPart part in parts) | ||
3797 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3798 | } | ||
3799 | finally | ||
3800 | { | ||
3801 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3802 | } | ||
3803 | } | ||
3526 | } | 3804 | } |
3527 | 3805 | ||
3528 | public void llCreateLink(string target, int parent) | 3806 | public void llCreateLink(string target, int parent) |
@@ -3535,11 +3813,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3535 | return; | 3813 | return; |
3536 | 3814 | ||
3537 | TaskInventoryItem item; | 3815 | TaskInventoryItem item; |
3538 | lock (m_host.TaskInventory) | 3816 | m_host.TaskInventory.LockItemsForRead(true); |
3539 | { | 3817 | item = m_host.TaskInventory[invItemID]; |
3540 | item = m_host.TaskInventory[invItemID]; | 3818 | m_host.TaskInventory.LockItemsForRead(false); |
3541 | } | 3819 | |
3542 | |||
3543 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3820 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3544 | && !m_automaticLinkPermission) | 3821 | && !m_automaticLinkPermission) |
3545 | { | 3822 | { |
@@ -3560,7 +3837,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3560 | 3837 | ||
3561 | if (targetPart != null) | 3838 | if (targetPart != null) |
3562 | { | 3839 | { |
3563 | if (parent != 0) { | 3840 | if (parent != 0) |
3841 | { | ||
3564 | parentPrim = m_host.ParentGroup; | 3842 | parentPrim = m_host.ParentGroup; |
3565 | childPrim = targetPart.ParentGroup; | 3843 | childPrim = targetPart.ParentGroup; |
3566 | } | 3844 | } |
@@ -3592,16 +3870,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3592 | m_host.AddScriptLPS(1); | 3870 | m_host.AddScriptLPS(1); |
3593 | UUID invItemID = InventorySelf(); | 3871 | UUID invItemID = InventorySelf(); |
3594 | 3872 | ||
3595 | lock (m_host.TaskInventory) | 3873 | m_host.TaskInventory.LockItemsForRead(true); |
3596 | { | ||
3597 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3874 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3598 | && !m_automaticLinkPermission) | 3875 | && !m_automaticLinkPermission) |
3599 | { | 3876 | { |
3600 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3877 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3878 | m_host.TaskInventory.LockItemsForRead(false); | ||
3601 | return; | 3879 | return; |
3602 | } | 3880 | } |
3603 | } | 3881 | m_host.TaskInventory.LockItemsForRead(false); |
3604 | 3882 | ||
3605 | if (linknum < ScriptBaseClass.LINK_THIS) | 3883 | if (linknum < ScriptBaseClass.LINK_THIS) |
3606 | return; | 3884 | return; |
3607 | 3885 | ||
@@ -3640,10 +3918,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3640 | // Restructuring Multiple Prims. | 3918 | // Restructuring Multiple Prims. |
3641 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 3919 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3642 | parts.Remove(parentPrim.RootPart); | 3920 | parts.Remove(parentPrim.RootPart); |
3643 | foreach (SceneObjectPart part in parts) | 3921 | if (parts.Count > 0) |
3644 | { | 3922 | { |
3645 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3923 | try |
3924 | { | ||
3925 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3926 | foreach (SceneObjectPart part in parts) | ||
3927 | { | ||
3928 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3929 | } | ||
3930 | } | ||
3931 | finally | ||
3932 | { | ||
3933 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3934 | } | ||
3646 | } | 3935 | } |
3936 | |||
3647 | parentPrim.HasGroupChanged = true; | 3937 | parentPrim.HasGroupChanged = true; |
3648 | parentPrim.ScheduleGroupForFullUpdate(); | 3938 | parentPrim.ScheduleGroupForFullUpdate(); |
3649 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3939 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3652,11 +3942,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3652 | { | 3942 | { |
3653 | SceneObjectPart newRoot = parts[0]; | 3943 | SceneObjectPart newRoot = parts[0]; |
3654 | parts.Remove(newRoot); | 3944 | parts.Remove(newRoot); |
3655 | foreach (SceneObjectPart part in parts) | 3945 | |
3946 | try | ||
3656 | { | 3947 | { |
3657 | part.UpdateFlag = 0; | 3948 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3658 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3949 | foreach (SceneObjectPart part in parts) |
3950 | { | ||
3951 | part.UpdateFlag = 0; | ||
3952 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3953 | } | ||
3659 | } | 3954 | } |
3955 | finally | ||
3956 | { | ||
3957 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3958 | } | ||
3959 | |||
3960 | |||
3660 | newRoot.ParentGroup.HasGroupChanged = true; | 3961 | newRoot.ParentGroup.HasGroupChanged = true; |
3661 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3962 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3662 | } | 3963 | } |
@@ -3702,6 +4003,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3702 | } | 4003 | } |
3703 | else | 4004 | else |
3704 | { | 4005 | { |
4006 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
4007 | { | ||
4008 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4009 | |||
4010 | if (linknum < 0) | ||
4011 | return UUID.Zero.ToString(); | ||
4012 | |||
4013 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
4014 | if (avatars.Count > linknum) | ||
4015 | { | ||
4016 | return avatars[linknum].UUID.ToString(); | ||
4017 | } | ||
4018 | } | ||
3705 | return UUID.Zero.ToString(); | 4019 | return UUID.Zero.ToString(); |
3706 | } | 4020 | } |
3707 | } | 4021 | } |
@@ -3778,17 +4092,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3778 | m_host.AddScriptLPS(1); | 4092 | m_host.AddScriptLPS(1); |
3779 | int count = 0; | 4093 | int count = 0; |
3780 | 4094 | ||
3781 | lock (m_host.TaskInventory) | 4095 | m_host.TaskInventory.LockItemsForRead(true); |
4096 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3782 | { | 4097 | { |
3783 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4098 | if (inv.Value.Type == type || type == -1) |
3784 | { | 4099 | { |
3785 | if (inv.Value.Type == type || type == -1) | 4100 | count = count + 1; |
3786 | { | ||
3787 | count = count + 1; | ||
3788 | } | ||
3789 | } | 4101 | } |
3790 | } | 4102 | } |
3791 | 4103 | ||
4104 | m_host.TaskInventory.LockItemsForRead(false); | ||
3792 | return count; | 4105 | return count; |
3793 | } | 4106 | } |
3794 | 4107 | ||
@@ -3797,16 +4110,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3797 | m_host.AddScriptLPS(1); | 4110 | m_host.AddScriptLPS(1); |
3798 | ArrayList keys = new ArrayList(); | 4111 | ArrayList keys = new ArrayList(); |
3799 | 4112 | ||
3800 | lock (m_host.TaskInventory) | 4113 | m_host.TaskInventory.LockItemsForRead(true); |
4114 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3801 | { | 4115 | { |
3802 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4116 | if (inv.Value.Type == type || type == -1) |
3803 | { | 4117 | { |
3804 | if (inv.Value.Type == type || type == -1) | 4118 | keys.Add(inv.Value.Name); |
3805 | { | ||
3806 | keys.Add(inv.Value.Name); | ||
3807 | } | ||
3808 | } | 4119 | } |
3809 | } | 4120 | } |
4121 | m_host.TaskInventory.LockItemsForRead(false); | ||
3810 | 4122 | ||
3811 | if (keys.Count == 0) | 4123 | if (keys.Count == 0) |
3812 | { | 4124 | { |
@@ -3843,20 +4155,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3843 | } | 4155 | } |
3844 | 4156 | ||
3845 | // move the first object found with this inventory name | 4157 | // move the first object found with this inventory name |
3846 | lock (m_host.TaskInventory) | 4158 | m_host.TaskInventory.LockItemsForRead(true); |
4159 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3847 | { | 4160 | { |
3848 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4161 | if (inv.Value.Name == inventory) |
3849 | { | 4162 | { |
3850 | if (inv.Value.Name == inventory) | 4163 | found = true; |
3851 | { | 4164 | objId = inv.Key; |
3852 | found = true; | 4165 | assetType = inv.Value.Type; |
3853 | objId = inv.Key; | 4166 | objName = inv.Value.Name; |
3854 | assetType = inv.Value.Type; | 4167 | break; |
3855 | objName = inv.Value.Name; | ||
3856 | break; | ||
3857 | } | ||
3858 | } | 4168 | } |
3859 | } | 4169 | } |
4170 | m_host.TaskInventory.LockItemsForRead(false); | ||
3860 | 4171 | ||
3861 | if (!found) | 4172 | if (!found) |
3862 | { | 4173 | { |
@@ -3864,9 +4175,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3864 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4175 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3865 | } | 4176 | } |
3866 | 4177 | ||
3867 | // check if destination is an avatar | 4178 | // check if destination is an object |
3868 | if (World.GetScenePresence(destId) != null) | 4179 | if (World.GetSceneObjectPart(destId) != null) |
4180 | { | ||
4181 | // destination is an object | ||
4182 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4183 | } | ||
4184 | else | ||
3869 | { | 4185 | { |
4186 | ScenePresence presence = World.GetScenePresence(destId); | ||
4187 | |||
4188 | if (presence == null) | ||
4189 | { | ||
4190 | UserAccount account = | ||
4191 | World.UserAccountService.GetUserAccount( | ||
4192 | World.RegionInfo.ScopeID, | ||
4193 | destId); | ||
4194 | |||
4195 | if (account == null) | ||
4196 | { | ||
4197 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4198 | return; | ||
4199 | } | ||
4200 | } | ||
4201 | |||
3870 | // destination is an avatar | 4202 | // destination is an avatar |
3871 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4203 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3872 | 4204 | ||
@@ -3890,31 +4222,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3890 | 4222 | ||
3891 | if (m_TransferModule != null) | 4223 | if (m_TransferModule != null) |
3892 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4224 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4225 | |||
4226 | //This delay should only occur when giving inventory to avatars. | ||
4227 | ScriptSleep(3000); | ||
3893 | } | 4228 | } |
3894 | else | ||
3895 | { | ||
3896 | // destination is an object | ||
3897 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3898 | } | ||
3899 | ScriptSleep(3000); | ||
3900 | } | 4229 | } |
3901 | 4230 | ||
4231 | [DebuggerNonUserCode] | ||
3902 | public void llRemoveInventory(string name) | 4232 | public void llRemoveInventory(string name) |
3903 | { | 4233 | { |
3904 | m_host.AddScriptLPS(1); | 4234 | m_host.AddScriptLPS(1); |
3905 | 4235 | ||
3906 | lock (m_host.TaskInventory) | 4236 | List<TaskInventoryItem> inv; |
4237 | try | ||
3907 | { | 4238 | { |
3908 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4239 | m_host.TaskInventory.LockItemsForRead(true); |
4240 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | ||
4241 | } | ||
4242 | finally | ||
4243 | { | ||
4244 | m_host.TaskInventory.LockItemsForRead(false); | ||
4245 | } | ||
4246 | foreach (TaskInventoryItem item in inv) | ||
4247 | { | ||
4248 | if (item.Name == name) | ||
3909 | { | 4249 | { |
3910 | if (item.Name == name) | 4250 | if (item.ItemID == m_itemID) |
3911 | { | 4251 | throw new ScriptDeleteException(); |
3912 | if (item.ItemID == m_itemID) | 4252 | else |
3913 | throw new ScriptDeleteException(); | 4253 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3914 | else | 4254 | return; |
3915 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
3916 | return; | ||
3917 | } | ||
3918 | } | 4255 | } |
3919 | } | 4256 | } |
3920 | } | 4257 | } |
@@ -3980,6 +4317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3980 | ce.time = Util.EnvironmentTickCount(); | 4317 | ce.time = Util.EnvironmentTickCount(); |
3981 | ce.account = account; | 4318 | ce.account = account; |
3982 | ce.pinfo = pinfo; | 4319 | ce.pinfo = pinfo; |
4320 | m_userInfoCache[uuid] = ce; | ||
3983 | } | 4321 | } |
3984 | else | 4322 | else |
3985 | { | 4323 | { |
@@ -4055,6 +4393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4055 | { | 4393 | { |
4056 | m_host.AddScriptLPS(1); | 4394 | m_host.AddScriptLPS(1); |
4057 | 4395 | ||
4396 | //Clone is thread safe | ||
4058 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4397 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
4059 | 4398 | ||
4060 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4399 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4108,6 +4447,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4108 | ScenePresence presence = World.GetScenePresence(agentId); | 4447 | ScenePresence presence = World.GetScenePresence(agentId); |
4109 | if (presence != null) | 4448 | if (presence != null) |
4110 | { | 4449 | { |
4450 | // agent must not be a god | ||
4451 | if (presence.GodLevel >= 200) return; | ||
4452 | |||
4111 | // agent must be over the owners land | 4453 | // agent must be over the owners land |
4112 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4454 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4113 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4455 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4130,7 +4472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4130 | UUID av = new UUID(); | 4472 | UUID av = new UUID(); |
4131 | if (!UUID.TryParse(agent,out av)) | 4473 | if (!UUID.TryParse(agent,out av)) |
4132 | { | 4474 | { |
4133 | LSLError("First parameter to llDialog needs to be a key"); | 4475 | //LSLError("First parameter to llDialog needs to be a key"); |
4134 | return; | 4476 | return; |
4135 | } | 4477 | } |
4136 | 4478 | ||
@@ -4167,17 +4509,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4167 | UUID soundId = UUID.Zero; | 4509 | UUID soundId = UUID.Zero; |
4168 | if (!UUID.TryParse(impact_sound, out soundId)) | 4510 | if (!UUID.TryParse(impact_sound, out soundId)) |
4169 | { | 4511 | { |
4170 | lock (m_host.TaskInventory) | 4512 | m_host.TaskInventory.LockItemsForRead(true); |
4513 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4171 | { | 4514 | { |
4172 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4515 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4173 | { | 4516 | { |
4174 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4517 | soundId = item.AssetID; |
4175 | { | 4518 | break; |
4176 | soundId = item.AssetID; | ||
4177 | break; | ||
4178 | } | ||
4179 | } | 4519 | } |
4180 | } | 4520 | } |
4521 | m_host.TaskInventory.LockItemsForRead(false); | ||
4181 | } | 4522 | } |
4182 | m_host.CollisionSound = soundId; | 4523 | m_host.CollisionSound = soundId; |
4183 | m_host.CollisionSoundVolume = (float)impact_volume; | 4524 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4223,6 +4564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4223 | UUID partItemID; | 4564 | UUID partItemID; |
4224 | foreach (SceneObjectPart part in parts) | 4565 | foreach (SceneObjectPart part in parts) |
4225 | { | 4566 | { |
4567 | //Clone is thread safe | ||
4226 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4568 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4227 | 4569 | ||
4228 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4570 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4437,17 +4779,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4437 | 4779 | ||
4438 | m_host.AddScriptLPS(1); | 4780 | m_host.AddScriptLPS(1); |
4439 | 4781 | ||
4440 | lock (m_host.TaskInventory) | 4782 | m_host.TaskInventory.LockItemsForRead(true); |
4783 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4441 | { | 4784 | { |
4442 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4785 | if (item.Type == 10 && item.ItemID == m_itemID) |
4443 | { | 4786 | { |
4444 | if (item.Type == 10 && item.ItemID == m_itemID) | 4787 | result = item.Name!=null?item.Name:String.Empty; |
4445 | { | 4788 | break; |
4446 | result = item.Name != null ? item.Name : String.Empty; | ||
4447 | break; | ||
4448 | } | ||
4449 | } | 4789 | } |
4450 | } | 4790 | } |
4791 | m_host.TaskInventory.LockItemsForRead(false); | ||
4451 | 4792 | ||
4452 | return result; | 4793 | return result; |
4453 | } | 4794 | } |
@@ -4600,23 +4941,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4600 | { | 4941 | { |
4601 | m_host.AddScriptLPS(1); | 4942 | m_host.AddScriptLPS(1); |
4602 | 4943 | ||
4603 | lock (m_host.TaskInventory) | 4944 | m_host.TaskInventory.LockItemsForRead(true); |
4945 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4604 | { | 4946 | { |
4605 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4947 | if (inv.Value.Name == name) |
4606 | { | 4948 | { |
4607 | if (inv.Value.Name == name) | 4949 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4608 | { | 4950 | { |
4609 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4951 | m_host.TaskInventory.LockItemsForRead(false); |
4610 | { | 4952 | return inv.Value.AssetID.ToString(); |
4611 | return inv.Value.AssetID.ToString(); | 4953 | } |
4612 | } | 4954 | else |
4613 | else | 4955 | { |
4614 | { | 4956 | m_host.TaskInventory.LockItemsForRead(false); |
4615 | return UUID.Zero.ToString(); | 4957 | return UUID.Zero.ToString(); |
4616 | } | ||
4617 | } | 4958 | } |
4618 | } | 4959 | } |
4619 | } | 4960 | } |
4961 | m_host.TaskInventory.LockItemsForRead(false); | ||
4620 | 4962 | ||
4621 | return UUID.Zero.ToString(); | 4963 | return UUID.Zero.ToString(); |
4622 | } | 4964 | } |
@@ -4769,14 +5111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4769 | { | 5111 | { |
4770 | m_host.AddScriptLPS(1); | 5112 | m_host.AddScriptLPS(1); |
4771 | 5113 | ||
4772 | if (src == null) | 5114 | return src.Length; |
4773 | { | ||
4774 | return 0; | ||
4775 | } | ||
4776 | else | ||
4777 | { | ||
4778 | return src.Length; | ||
4779 | } | ||
4780 | } | 5115 | } |
4781 | 5116 | ||
4782 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5117 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -4822,7 +5157,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4822 | else if (src.Data[index] is LSL_Float) | 5157 | else if (src.Data[index] is LSL_Float) |
4823 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5158 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
4824 | else if (src.Data[index] is LSL_String) | 5159 | else if (src.Data[index] is LSL_String) |
4825 | return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); | 5160 | { |
5161 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5162 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5163 | if (m != Match.Empty) | ||
5164 | { | ||
5165 | str = m.Value; | ||
5166 | double d = 0.0; | ||
5167 | if (!Double.TryParse(str, out d)) | ||
5168 | return 0.0; | ||
5169 | |||
5170 | return d; | ||
5171 | } | ||
5172 | return 0.0; | ||
5173 | } | ||
4826 | return Convert.ToDouble(src.Data[index]); | 5174 | return Convert.ToDouble(src.Data[index]); |
4827 | } | 5175 | } |
4828 | catch (FormatException) | 5176 | catch (FormatException) |
@@ -5095,7 +5443,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5095 | } | 5443 | } |
5096 | } | 5444 | } |
5097 | } | 5445 | } |
5098 | else { | 5446 | else |
5447 | { | ||
5099 | object[] array = new object[src.Length]; | 5448 | object[] array = new object[src.Length]; |
5100 | Array.Copy(src.Data, 0, array, 0, src.Length); | 5449 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5101 | result = new LSL_List(array); | 5450 | result = new LSL_List(array); |
@@ -5507,7 +5856,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5507 | public void llSetSoundQueueing(int queue) | 5856 | public void llSetSoundQueueing(int queue) |
5508 | { | 5857 | { |
5509 | m_host.AddScriptLPS(1); | 5858 | m_host.AddScriptLPS(1); |
5510 | NotImplemented("llSetSoundQueueing"); | ||
5511 | } | 5859 | } |
5512 | 5860 | ||
5513 | public void llSetSoundRadius(double radius) | 5861 | public void llSetSoundRadius(double radius) |
@@ -5552,10 +5900,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5552 | m_host.AddScriptLPS(1); | 5900 | m_host.AddScriptLPS(1); |
5553 | 5901 | ||
5554 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5902 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5555 | 5903 | if (parts.Count > 0) | |
5556 | foreach (var part in parts) | ||
5557 | { | 5904 | { |
5558 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5905 | try |
5906 | { | ||
5907 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5908 | foreach (var part in parts) | ||
5909 | { | ||
5910 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5911 | } | ||
5912 | } | ||
5913 | finally | ||
5914 | { | ||
5915 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5916 | } | ||
5559 | } | 5917 | } |
5560 | } | 5918 | } |
5561 | 5919 | ||
@@ -5609,6 +5967,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5609 | ScriptSleep(5000); | 5967 | ScriptSleep(5000); |
5610 | } | 5968 | } |
5611 | 5969 | ||
5970 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5971 | { | ||
5972 | return ParseString2List(str, separators, in_spacers, false); | ||
5973 | } | ||
5974 | |||
5612 | public LSL_Integer llOverMyLand(string id) | 5975 | public LSL_Integer llOverMyLand(string id) |
5613 | { | 5976 | { |
5614 | m_host.AddScriptLPS(1); | 5977 | m_host.AddScriptLPS(1); |
@@ -5809,7 +6172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5809 | return m_host.ParentGroup.RootPart.AttachmentPoint; | 6172 | return m_host.ParentGroup.RootPart.AttachmentPoint; |
5810 | } | 6173 | } |
5811 | 6174 | ||
5812 | public LSL_Integer llGetFreeMemory() | 6175 | public virtual LSL_Integer llGetFreeMemory() |
5813 | { | 6176 | { |
5814 | m_host.AddScriptLPS(1); | 6177 | m_host.AddScriptLPS(1); |
5815 | // Make scripts designed for LSO happy | 6178 | // Make scripts designed for LSO happy |
@@ -5926,7 +6289,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5926 | SetParticleSystem(m_host, rules); | 6289 | SetParticleSystem(m_host, rules); |
5927 | } | 6290 | } |
5928 | 6291 | ||
5929 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { | 6292 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) |
6293 | { | ||
5930 | 6294 | ||
5931 | 6295 | ||
5932 | if (rules.Length == 0) | 6296 | if (rules.Length == 0) |
@@ -6120,14 +6484,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6120 | 6484 | ||
6121 | protected UUID GetTaskInventoryItem(string name) | 6485 | protected UUID GetTaskInventoryItem(string name) |
6122 | { | 6486 | { |
6123 | lock (m_host.TaskInventory) | 6487 | m_host.TaskInventory.LockItemsForRead(true); |
6488 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6124 | { | 6489 | { |
6125 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6490 | if (inv.Value.Name == name) |
6126 | { | 6491 | { |
6127 | if (inv.Value.Name == name) | 6492 | m_host.TaskInventory.LockItemsForRead(false); |
6128 | return inv.Key; | 6493 | return inv.Key; |
6129 | } | 6494 | } |
6130 | } | 6495 | } |
6496 | m_host.TaskInventory.LockItemsForRead(false); | ||
6131 | 6497 | ||
6132 | return UUID.Zero; | 6498 | return UUID.Zero; |
6133 | } | 6499 | } |
@@ -6368,13 +6734,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6368 | UUID av = new UUID(); | 6734 | UUID av = new UUID(); |
6369 | if (!UUID.TryParse(avatar,out av)) | 6735 | if (!UUID.TryParse(avatar,out av)) |
6370 | { | 6736 | { |
6371 | LSLError("First parameter to llDialog needs to be a key"); | 6737 | //LSLError("First parameter to llDialog needs to be a key"); |
6372 | return; | 6738 | return; |
6373 | } | 6739 | } |
6374 | if (buttons.Length < 1) | 6740 | if (buttons.Length < 1) |
6375 | { | 6741 | { |
6376 | LSLError("No less than 1 button can be shown"); | 6742 | buttons.Add("OK"); |
6377 | return; | ||
6378 | } | 6743 | } |
6379 | if (buttons.Length > 12) | 6744 | if (buttons.Length > 12) |
6380 | { | 6745 | { |
@@ -6391,7 +6756,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6391 | } | 6756 | } |
6392 | if (buttons.Data[i].ToString().Length > 24) | 6757 | if (buttons.Data[i].ToString().Length > 24) |
6393 | { | 6758 | { |
6394 | LSLError("button label cannot be longer than 24 characters"); | 6759 | llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); |
6395 | return; | 6760 | return; |
6396 | } | 6761 | } |
6397 | buts[i] = buttons.Data[i].ToString(); | 6762 | buts[i] = buttons.Data[i].ToString(); |
@@ -6455,22 +6820,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6455 | } | 6820 | } |
6456 | 6821 | ||
6457 | // copy the first script found with this inventory name | 6822 | // copy the first script found with this inventory name |
6458 | lock (m_host.TaskInventory) | 6823 | m_host.TaskInventory.LockItemsForRead(true); |
6824 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6459 | { | 6825 | { |
6460 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6826 | if (inv.Value.Name == name) |
6461 | { | 6827 | { |
6462 | if (inv.Value.Name == name) | 6828 | // make sure the object is a script |
6829 | if (10 == inv.Value.Type) | ||
6463 | { | 6830 | { |
6464 | // make sure the object is a script | 6831 | found = true; |
6465 | if (10 == inv.Value.Type) | 6832 | srcId = inv.Key; |
6466 | { | 6833 | break; |
6467 | found = true; | ||
6468 | srcId = inv.Key; | ||
6469 | break; | ||
6470 | } | ||
6471 | } | 6834 | } |
6472 | } | 6835 | } |
6473 | } | 6836 | } |
6837 | m_host.TaskInventory.LockItemsForRead(false); | ||
6474 | 6838 | ||
6475 | if (!found) | 6839 | if (!found) |
6476 | { | 6840 | { |
@@ -6554,6 +6918,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6554 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6918 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6555 | { | 6919 | { |
6556 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6920 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6921 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6922 | return shapeBlock; | ||
6557 | 6923 | ||
6558 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6924 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6559 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6925 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6629,6 +6995,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6629 | 6995 | ||
6630 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6996 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6631 | { | 6997 | { |
6998 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6999 | return; | ||
7000 | |||
6632 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7001 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6633 | 7002 | ||
6634 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7003 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6678,6 +7047,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6678 | 7047 | ||
6679 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 7048 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6680 | { | 7049 | { |
7050 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7051 | return; | ||
7052 | |||
6681 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7053 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6682 | 7054 | ||
6683 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7055 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6720,6 +7092,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6720 | 7092 | ||
6721 | 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 fudge) | 7093 | 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 fudge) |
6722 | { | 7094 | { |
7095 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7096 | return; | ||
7097 | |||
6723 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7098 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6724 | 7099 | ||
6725 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7100 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6846,6 +7221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6846 | 7221 | ||
6847 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7222 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6848 | { | 7223 | { |
7224 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7225 | return; | ||
7226 | |||
6849 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7227 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6850 | UUID sculptId; | 7228 | UUID sculptId; |
6851 | 7229 | ||
@@ -6861,13 +7239,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6861 | shapeBlock.PathScaleX = 100; | 7239 | shapeBlock.PathScaleX = 100; |
6862 | shapeBlock.PathScaleY = 150; | 7240 | shapeBlock.PathScaleY = 150; |
6863 | 7241 | ||
6864 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7242 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6865 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7243 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6866 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7244 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6867 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7245 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6868 | { | 7246 | { |
6869 | // default | 7247 | // default |
6870 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7248 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6871 | } | 7249 | } |
6872 | 7250 | ||
6873 | // retain pathcurve | 7251 | // retain pathcurve |
@@ -6886,30 +7264,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6886 | ScriptSleep(200); | 7264 | ScriptSleep(200); |
6887 | } | 7265 | } |
6888 | 7266 | ||
6889 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7267 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
6890 | { | 7268 | { |
6891 | m_host.AddScriptLPS(1); | 7269 | m_host.AddScriptLPS(1); |
6892 | 7270 | ||
6893 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7271 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
7272 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7273 | if (parts.Count>0) | ||
7274 | { | ||
7275 | try | ||
7276 | { | ||
7277 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7278 | foreach (SceneObjectPart part in parts) | ||
7279 | SetPrimParams(part, rules); | ||
7280 | } | ||
7281 | finally | ||
7282 | { | ||
7283 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7284 | } | ||
7285 | } | ||
7286 | if (avatars.Count > 0) | ||
7287 | { | ||
7288 | foreach (ScenePresence avatar in avatars) | ||
7289 | SetPrimParams(avatar, rules); | ||
7290 | } | ||
7291 | } | ||
6894 | 7292 | ||
6895 | foreach (SceneObjectPart part in parts) | 7293 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6896 | SetPrimParams(part, rules); | 7294 | { |
6897 | 7295 | llSetLinkPrimitiveParamsFast(linknumber, rules); | |
6898 | ScriptSleep(200); | 7296 | ScriptSleep(200); |
6899 | } | 7297 | } |
6900 | 7298 | ||
6901 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7299 | protected void SetPrimParams(ScenePresence av, LSL_List rules) |
6902 | { | 7300 | { |
6903 | m_host.AddScriptLPS(1); | 7301 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7302 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
6904 | 7303 | ||
6905 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7304 | int idx = 0; |
6906 | 7305 | ||
6907 | foreach (SceneObjectPart part in parts) | 7306 | while (idx < rules.Length) |
6908 | SetPrimParams(part, rules); | 7307 | { |
7308 | int code = rules.GetLSLIntegerItem(idx++); | ||
7309 | |||
7310 | int remain = rules.Length - idx; | ||
7311 | |||
7312 | |||
7313 | |||
7314 | switch (code) | ||
7315 | { | ||
7316 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7317 | if (remain < 1) | ||
7318 | return; | ||
7319 | LSL_Vector v; | ||
7320 | v = rules.GetVector3Item(idx++); | ||
7321 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7322 | av.SendAvatarDataToAllAgents(); | ||
7323 | |||
7324 | break; | ||
7325 | |||
7326 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7327 | if (remain < 1) | ||
7328 | return; | ||
7329 | LSL_Rotation r; | ||
7330 | r = rules.GetQuaternionItem(idx++); | ||
7331 | av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7332 | av.SendAvatarDataToAllAgents(); | ||
7333 | break; | ||
7334 | } | ||
7335 | } | ||
6909 | } | 7336 | } |
6910 | 7337 | ||
6911 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7338 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6912 | { | 7339 | { |
7340 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7341 | return; | ||
7342 | |||
6913 | int idx = 0; | 7343 | int idx = 0; |
6914 | 7344 | ||
6915 | while (idx < rules.Length) | 7345 | while (idx < rules.Length) |
@@ -7444,13 +7874,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7444 | public LSL_Integer llGetNumberOfPrims() | 7874 | public LSL_Integer llGetNumberOfPrims() |
7445 | { | 7875 | { |
7446 | m_host.AddScriptLPS(1); | 7876 | m_host.AddScriptLPS(1); |
7447 | int avatarCount = 0; | 7877 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; |
7448 | World.ForEachScenePresence(delegate(ScenePresence presence) | 7878 | |
7449 | { | ||
7450 | if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | ||
7451 | avatarCount++; | ||
7452 | }); | ||
7453 | |||
7454 | return m_host.ParentGroup.PrimCount + avatarCount; | 7879 | return m_host.ParentGroup.PrimCount + avatarCount; |
7455 | } | 7880 | } |
7456 | 7881 | ||
@@ -7466,55 +7891,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7466 | m_host.AddScriptLPS(1); | 7891 | m_host.AddScriptLPS(1); |
7467 | UUID objID = UUID.Zero; | 7892 | UUID objID = UUID.Zero; |
7468 | LSL_List result = new LSL_List(); | 7893 | LSL_List result = new LSL_List(); |
7894 | |||
7895 | // If the ID is not valid, return null result | ||
7469 | if (!UUID.TryParse(obj, out objID)) | 7896 | if (!UUID.TryParse(obj, out objID)) |
7470 | { | 7897 | { |
7471 | result.Add(new LSL_Vector()); | 7898 | result.Add(new LSL_Vector()); |
7472 | result.Add(new LSL_Vector()); | 7899 | result.Add(new LSL_Vector()); |
7473 | return result; | 7900 | return result; |
7474 | } | 7901 | } |
7902 | |||
7903 | // Check if this is an attached prim. If so, replace | ||
7904 | // the UUID with the avatar UUID and report it's bounding box | ||
7905 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
7906 | if (part != null && part.ParentGroup.IsAttachment) | ||
7907 | objID = part.ParentGroup.RootPart.AttachedAvatar; | ||
7908 | |||
7909 | // Find out if this is an avatar ID. If so, return it's box | ||
7475 | ScenePresence presence = World.GetScenePresence(objID); | 7910 | ScenePresence presence = World.GetScenePresence(objID); |
7476 | if (presence != null) | 7911 | if (presence != null) |
7477 | { | 7912 | { |
7478 | if (presence.ParentID == 0) // not sat on an object | 7913 | // As per LSL Wiki, there is no difference between sitting |
7914 | // and standing avatar since server 1.36 | ||
7915 | LSL_Vector lower; | ||
7916 | LSL_Vector upper; | ||
7917 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
7918 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7479 | { | 7919 | { |
7480 | LSL_Vector lower; | 7920 | // This is for ground sitting avatars |
7481 | LSL_Vector upper; | 7921 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7482 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7922 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7483 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7923 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7484 | { | ||
7485 | // This is for ground sitting avatars | ||
7486 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7487 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7488 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7489 | } | ||
7490 | else | ||
7491 | { | ||
7492 | // This is for standing/flying avatars | ||
7493 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7494 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7495 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7496 | } | ||
7497 | result.Add(lower); | ||
7498 | result.Add(upper); | ||
7499 | return result; | ||
7500 | } | 7924 | } |
7501 | else | 7925 | else |
7502 | { | 7926 | { |
7503 | // sitting on an object so we need the bounding box of that | 7927 | // This is for standing/flying avatars |
7504 | // which should include the avatar so set the UUID to the | 7928 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7505 | // UUID of the object the avatar is sat on and allow it to fall through | 7929 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7506 | // to processing an object | 7930 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7507 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7508 | objID = p.UUID; | ||
7509 | } | 7931 | } |
7932 | |||
7933 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7934 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7935 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7936 | |||
7937 | if (lower.x > upper.x) | ||
7938 | lower.x = upper.x; | ||
7939 | if (lower.y > upper.y) | ||
7940 | lower.y = upper.y; | ||
7941 | if (lower.z > upper.z) | ||
7942 | lower.z = upper.z; | ||
7943 | |||
7944 | result.Add(lower); | ||
7945 | result.Add(upper); | ||
7946 | return result; | ||
7510 | } | 7947 | } |
7511 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 7948 | |
7949 | part = World.GetSceneObjectPart(objID); | ||
7512 | // Currently only works for single prims without a sitting avatar | 7950 | // Currently only works for single prims without a sitting avatar |
7513 | if (part != null) | 7951 | if (part != null) |
7514 | { | 7952 | { |
7515 | Vector3 halfSize = part.Scale / 2.0f; | 7953 | float minX; |
7516 | LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); | 7954 | float maxX; |
7517 | LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); | 7955 | float minY; |
7956 | float maxY; | ||
7957 | float minZ; | ||
7958 | float maxZ; | ||
7959 | |||
7960 | // This BBox is in sim coordinates, with the offset being | ||
7961 | // a contained point. | ||
7962 | Vector3[] offsets = World.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
7963 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
7964 | |||
7965 | minX -= offsets[0].X; | ||
7966 | maxX -= offsets[0].X; | ||
7967 | minY -= offsets[0].Y; | ||
7968 | maxY -= offsets[0].Y; | ||
7969 | minZ -= offsets[0].Z; | ||
7970 | maxZ -= offsets[0].Z; | ||
7971 | |||
7972 | LSL_Vector lower; | ||
7973 | LSL_Vector upper; | ||
7974 | |||
7975 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7976 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
7977 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
7978 | |||
7979 | if (lower.x > upper.x) | ||
7980 | lower.x = upper.x; | ||
7981 | if (lower.y > upper.y) | ||
7982 | lower.y = upper.y; | ||
7983 | if (lower.z > upper.z) | ||
7984 | lower.z = upper.z; | ||
7985 | |||
7518 | result.Add(lower); | 7986 | result.Add(lower); |
7519 | result.Add(upper); | 7987 | result.Add(upper); |
7520 | return result; | 7988 | return result; |
@@ -7594,13 +8062,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7594 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, | 8062 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
7595 | part.AbsolutePosition.Y, | 8063 | part.AbsolutePosition.Y, |
7596 | part.AbsolutePosition.Z); | 8064 | part.AbsolutePosition.Z); |
7597 | // For some reason, the part.AbsolutePosition.* values do not change if the | ||
7598 | // linkset is rotated; they always reflect the child prim's world position | ||
7599 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
7600 | // implementation, so will break scripts imported from there (not to mention it | ||
7601 | // makes it more difficult to determine a child prim's actual inworld position). | ||
7602 | if (part.ParentID != 0) | ||
7603 | v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); | ||
7604 | res.Add(v); | 8065 | res.Add(v); |
7605 | break; | 8066 | break; |
7606 | 8067 | ||
@@ -7759,24 +8220,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7759 | break; | 8220 | break; |
7760 | 8221 | ||
7761 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8222 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7762 | // TODO-------------- | ||
7763 | if (remain < 1) | 8223 | if (remain < 1) |
7764 | return res; | 8224 | return res; |
8225 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7765 | 8226 | ||
7766 | face=(int)rules.GetLSLIntegerItem(idx++); | 8227 | tex = part.Shape.Textures; |
7767 | 8228 | int shiny; | |
7768 | res.Add(new LSL_Integer(0)); | 8229 | if (face == ScriptBaseClass.ALL_SIDES) |
7769 | res.Add(new LSL_Integer(0)); | 8230 | { |
8231 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8232 | { | ||
8233 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8234 | if (shinyness == Shininess.High) | ||
8235 | { | ||
8236 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8237 | } | ||
8238 | else if (shinyness == Shininess.Medium) | ||
8239 | { | ||
8240 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8241 | } | ||
8242 | else if (shinyness == Shininess.Low) | ||
8243 | { | ||
8244 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8245 | } | ||
8246 | else | ||
8247 | { | ||
8248 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8249 | } | ||
8250 | res.Add(new LSL_Integer(shiny)); | ||
8251 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8252 | } | ||
8253 | } | ||
8254 | else | ||
8255 | { | ||
8256 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8257 | if (shinyness == Shininess.High) | ||
8258 | { | ||
8259 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8260 | } | ||
8261 | else if (shinyness == Shininess.Medium) | ||
8262 | { | ||
8263 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8264 | } | ||
8265 | else if (shinyness == Shininess.Low) | ||
8266 | { | ||
8267 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8268 | } | ||
8269 | else | ||
8270 | { | ||
8271 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8272 | } | ||
8273 | res.Add(new LSL_Integer(shiny)); | ||
8274 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8275 | } | ||
7770 | break; | 8276 | break; |
7771 | 8277 | ||
7772 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8278 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7773 | // TODO-------------- | ||
7774 | if (remain < 1) | 8279 | if (remain < 1) |
7775 | return res; | 8280 | return res; |
8281 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7776 | 8282 | ||
7777 | face=(int)rules.GetLSLIntegerItem(idx++); | 8283 | tex = part.Shape.Textures; |
7778 | 8284 | int fullbright; | |
7779 | res.Add(new LSL_Integer(0)); | 8285 | if (face == ScriptBaseClass.ALL_SIDES) |
8286 | { | ||
8287 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8288 | { | ||
8289 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8290 | { | ||
8291 | fullbright = ScriptBaseClass.TRUE; | ||
8292 | } | ||
8293 | else | ||
8294 | { | ||
8295 | fullbright = ScriptBaseClass.FALSE; | ||
8296 | } | ||
8297 | res.Add(new LSL_Integer(fullbright)); | ||
8298 | } | ||
8299 | } | ||
8300 | else | ||
8301 | { | ||
8302 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8303 | { | ||
8304 | fullbright = ScriptBaseClass.TRUE; | ||
8305 | } | ||
8306 | else | ||
8307 | { | ||
8308 | fullbright = ScriptBaseClass.FALSE; | ||
8309 | } | ||
8310 | res.Add(new LSL_Integer(fullbright)); | ||
8311 | } | ||
7780 | break; | 8312 | break; |
7781 | 8313 | ||
7782 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8314 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7797,14 +8329,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7797 | break; | 8329 | break; |
7798 | 8330 | ||
7799 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8331 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7800 | // TODO-------------- | ||
7801 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8332 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7802 | if (remain < 1) | 8333 | if (remain < 1) |
7803 | return res; | 8334 | return res; |
8335 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7804 | 8336 | ||
7805 | face=(int)rules.GetLSLIntegerItem(idx++); | 8337 | tex = part.Shape.Textures; |
7806 | 8338 | if (face == ScriptBaseClass.ALL_SIDES) | |
7807 | res.Add(new LSL_Integer(0)); | 8339 | { |
8340 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8341 | { | ||
8342 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8343 | { | ||
8344 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8345 | } | ||
8346 | else | ||
8347 | { | ||
8348 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8349 | } | ||
8350 | } | ||
8351 | } | ||
8352 | else | ||
8353 | { | ||
8354 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8355 | { | ||
8356 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8357 | } | ||
8358 | else | ||
8359 | { | ||
8360 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8361 | } | ||
8362 | } | ||
7808 | break; | 8363 | break; |
7809 | 8364 | ||
7810 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8365 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7823,13 +8378,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7823 | break; | 8378 | break; |
7824 | 8379 | ||
7825 | case (int)ScriptBaseClass.PRIM_GLOW: | 8380 | case (int)ScriptBaseClass.PRIM_GLOW: |
7826 | // TODO-------------- | ||
7827 | if (remain < 1) | 8381 | if (remain < 1) |
7828 | return res; | 8382 | return res; |
8383 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7829 | 8384 | ||
7830 | face=(int)rules.GetLSLIntegerItem(idx++); | 8385 | tex = part.Shape.Textures; |
7831 | 8386 | float primglow; | |
7832 | res.Add(new LSL_Float(0)); | 8387 | if (face == ScriptBaseClass.ALL_SIDES) |
8388 | { | ||
8389 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8390 | { | ||
8391 | primglow = tex.GetFace((uint)face).Glow; | ||
8392 | res.Add(new LSL_Float(primglow)); | ||
8393 | } | ||
8394 | } | ||
8395 | else | ||
8396 | { | ||
8397 | primglow = tex.GetFace((uint)face).Glow; | ||
8398 | res.Add(new LSL_Float(primglow)); | ||
8399 | } | ||
7833 | break; | 8400 | break; |
7834 | case (int)ScriptBaseClass.PRIM_TEXT: | 8401 | case (int)ScriptBaseClass.PRIM_TEXT: |
7835 | Color4 textColor = part.GetTextColor(); | 8402 | Color4 textColor = part.GetTextColor(); |
@@ -8379,8 +8946,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8379 | // The function returns an ordered list | 8946 | // The function returns an ordered list |
8380 | // representing the tokens found in the supplied | 8947 | // representing the tokens found in the supplied |
8381 | // sources string. If two successive tokenizers | 8948 | // sources string. If two successive tokenizers |
8382 | // are encountered, then a NULL entry is added | 8949 | // are encountered, then a null-string entry is |
8383 | // to the list. | 8950 | // added to the list. |
8384 | // | 8951 | // |
8385 | // It is a precondition that the source and | 8952 | // It is a precondition that the source and |
8386 | // toekizer lisst are non-null. If they are null, | 8953 | // toekizer lisst are non-null. If they are null, |
@@ -8388,7 +8955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8388 | // while their lengths are being determined. | 8955 | // while their lengths are being determined. |
8389 | // | 8956 | // |
8390 | // A small amount of working memoryis required | 8957 | // A small amount of working memoryis required |
8391 | // of approximately 8*#tokenizers. | 8958 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8392 | // | 8959 | // |
8393 | // There are many ways in which this function | 8960 | // There are many ways in which this function |
8394 | // can be implemented, this implementation is | 8961 | // can be implemented, this implementation is |
@@ -8404,155 +8971,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8404 | // and eliminates redundant tokenizers as soon | 8971 | // and eliminates redundant tokenizers as soon |
8405 | // as is possible. | 8972 | // as is possible. |
8406 | // | 8973 | // |
8407 | // The implementation tries to avoid any copying | 8974 | // The implementation tries to minimize temporary |
8408 | // of arrays or other objects. | 8975 | // garbage generation. |
8409 | // </remarks> | 8976 | // </remarks> |
8410 | 8977 | ||
8411 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 8978 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8412 | { | 8979 | { |
8413 | int beginning = 0; | 8980 | return ParseString2List(src, separators, spacers, true); |
8414 | int srclen = src.Length; | 8981 | } |
8415 | int seplen = separators.Length; | ||
8416 | object[] separray = separators.Data; | ||
8417 | int spclen = spacers.Length; | ||
8418 | object[] spcarray = spacers.Data; | ||
8419 | int mlen = seplen+spclen; | ||
8420 | |||
8421 | int[] offset = new int[mlen+1]; | ||
8422 | bool[] active = new bool[mlen]; | ||
8423 | |||
8424 | int best; | ||
8425 | int j; | ||
8426 | |||
8427 | // Initial capacity reduces resize cost | ||
8428 | 8982 | ||
8429 | LSL_List tokens = new LSL_List(); | 8983 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8984 | { | ||
8985 | int srclen = src.Length; | ||
8986 | int seplen = separators.Length; | ||
8987 | object[] separray = separators.Data; | ||
8988 | int spclen = spacers.Length; | ||
8989 | object[] spcarray = spacers.Data; | ||
8990 | int dellen = 0; | ||
8991 | string[] delarray = new string[seplen+spclen]; | ||
8430 | 8992 | ||
8431 | // All entries are initially valid | 8993 | int outlen = 0; |
8994 | string[] outarray = new string[srclen*2+1]; | ||
8432 | 8995 | ||
8433 | for (int i = 0; i < mlen; i++) | 8996 | int i, j; |
8434 | active[i] = true; | 8997 | string d; |
8435 | 8998 | ||
8436 | offset[mlen] = srclen; | 8999 | m_host.AddScriptLPS(1); |
8437 | 9000 | ||
8438 | while (beginning < srclen) | 9001 | /* |
9002 | * Convert separator and spacer lists to C# strings. | ||
9003 | * Also filter out null strings so we don't hang. | ||
9004 | */ | ||
9005 | for (i = 0; i < seplen; i ++) | ||
8439 | { | 9006 | { |
9007 | d = separray[i].ToString(); | ||
9008 | if (d.Length > 0) | ||
9009 | { | ||
9010 | delarray[dellen++] = d; | ||
9011 | } | ||
9012 | } | ||
9013 | seplen = dellen; | ||
8440 | 9014 | ||
8441 | best = mlen; // as bad as it gets | 9015 | for (i = 0; i < spclen; i ++) |
9016 | { | ||
9017 | d = spcarray[i].ToString(); | ||
9018 | if (d.Length > 0) | ||
9019 | { | ||
9020 | delarray[dellen++] = d; | ||
9021 | } | ||
9022 | } | ||
8442 | 9023 | ||
8443 | // Scan for separators | 9024 | /* |
9025 | * Scan through source string from beginning to end. | ||
9026 | */ | ||
9027 | for (i = 0;;) | ||
9028 | { | ||
8444 | 9029 | ||
8445 | for (j = 0; j < seplen; j++) | 9030 | /* |
9031 | * Find earliest delimeter in src starting at i (if any). | ||
9032 | */ | ||
9033 | int earliestDel = -1; | ||
9034 | int earliestSrc = srclen; | ||
9035 | string earliestStr = null; | ||
9036 | for (j = 0; j < dellen; j ++) | ||
8446 | { | 9037 | { |
8447 | if (separray[j].ToString() == String.Empty) | 9038 | d = delarray[j]; |
8448 | active[j] = false; | 9039 | if (d != null) |
8449 | |||
8450 | if (active[j]) | ||
8451 | { | 9040 | { |
8452 | // scan all of the markers | 9041 | int index = src.IndexOf(d, i); |
8453 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 9042 | if (index < 0) |
8454 | { | 9043 | { |
8455 | // not present at all | 9044 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8456 | active[j] = false; | ||
8457 | } | 9045 | } |
8458 | else | 9046 | else if (index < earliestSrc) |
8459 | { | 9047 | { |
8460 | // present and correct | 9048 | earliestSrc = index; // where delimeter starts in source string |
8461 | if (offset[j] < offset[best]) | 9049 | earliestDel = j; // where delimeter is in delarray[] |
8462 | { | 9050 | earliestStr = d; // the delimeter string from delarray[] |
8463 | // closest so far | 9051 | if (index == i) break; // can't do any better than found at beg of string |
8464 | best = j; | ||
8465 | if (offset[best] == beginning) | ||
8466 | break; | ||
8467 | } | ||
8468 | } | 9052 | } |
8469 | } | 9053 | } |
8470 | } | 9054 | } |
8471 | 9055 | ||
8472 | // Scan for spacers | 9056 | /* |
8473 | 9057 | * Output source string starting at i through start of earliest delimeter. | |
8474 | if (offset[best] != beginning) | 9058 | */ |
9059 | if (keepNulls || (earliestSrc > i)) | ||
8475 | { | 9060 | { |
8476 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 9061 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8477 | { | ||
8478 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
8479 | active[j] = false; | ||
8480 | |||
8481 | if (active[j]) | ||
8482 | { | ||
8483 | // scan all of the markers | ||
8484 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
8485 | { | ||
8486 | // not present at all | ||
8487 | active[j] = false; | ||
8488 | } | ||
8489 | else | ||
8490 | { | ||
8491 | // present and correct | ||
8492 | if (offset[j] < offset[best]) | ||
8493 | { | ||
8494 | // closest so far | ||
8495 | best = j; | ||
8496 | } | ||
8497 | } | ||
8498 | } | ||
8499 | } | ||
8500 | } | 9062 | } |
8501 | 9063 | ||
8502 | // This is the normal exit from the scanning loop | 9064 | /* |
9065 | * If no delimeter found at or after i, we're done scanning. | ||
9066 | */ | ||
9067 | if (earliestDel < 0) break; | ||
8503 | 9068 | ||
8504 | if (best == mlen) | 9069 | /* |
9070 | * If delimeter was a spacer, output the spacer. | ||
9071 | */ | ||
9072 | if (earliestDel >= seplen) | ||
8505 | { | 9073 | { |
8506 | // no markers were found on this pass | 9074 | outarray[outlen++] = earliestStr; |
8507 | // so we're pretty much done | ||
8508 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
8509 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8510 | break; | ||
8511 | } | 9075 | } |
8512 | 9076 | ||
8513 | // Otherwise we just add the newly delimited token | 9077 | /* |
8514 | // and recalculate where the search should continue. | 9078 | * Look at rest of src string following delimeter. |
8515 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 9079 | */ |
8516 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 9080 | i = earliestSrc + earliestStr.Length; |
8517 | |||
8518 | if (best < seplen) | ||
8519 | { | ||
8520 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
8521 | } | ||
8522 | else | ||
8523 | { | ||
8524 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8525 | string str = spcarray[best - seplen].ToString(); | ||
8526 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8527 | tokens.Add(new LSL_String(str)); | ||
8528 | } | ||
8529 | } | 9081 | } |
8530 | 9082 | ||
8531 | // This an awkward an not very intuitive boundary case. If the | 9083 | /* |
8532 | // last substring is a tokenizer, then there is an implied trailing | 9084 | * Make up an exact-sized output array suitable for an LSL_List object. |
8533 | // null list entry. Hopefully the single comparison will not be too | 9085 | */ |
8534 | // arduous. Alternatively the 'break' could be replced with a return | 9086 | object[] outlist = new object[outlen]; |
8535 | // but that's shabby programming. | 9087 | for (i = 0; i < outlen; i ++) |
8536 | |||
8537 | if ((beginning == srclen) && (keepNulls)) | ||
8538 | { | 9088 | { |
8539 | if (srclen != 0) | 9089 | outlist[i] = new LSL_String(outarray[i]); |
8540 | tokens.Add(new LSL_String("")); | ||
8541 | } | 9090 | } |
8542 | 9091 | return new LSL_List(outlist); | |
8543 | return tokens; | ||
8544 | } | ||
8545 | |||
8546 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8547 | { | ||
8548 | m_host.AddScriptLPS(1); | ||
8549 | return this.ParseString(src, separators, spacers, false); | ||
8550 | } | ||
8551 | |||
8552 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8553 | { | ||
8554 | m_host.AddScriptLPS(1); | ||
8555 | return this.ParseString(src, separators, spacers, true); | ||
8556 | } | 9092 | } |
8557 | 9093 | ||
8558 | public LSL_Integer llGetObjectPermMask(int mask) | 9094 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -8629,28 +9165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8629 | { | 9165 | { |
8630 | m_host.AddScriptLPS(1); | 9166 | m_host.AddScriptLPS(1); |
8631 | 9167 | ||
8632 | lock (m_host.TaskInventory) | 9168 | m_host.TaskInventory.LockItemsForRead(true); |
9169 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8633 | { | 9170 | { |
8634 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9171 | if (inv.Value.Name == item) |
8635 | { | 9172 | { |
8636 | if (inv.Value.Name == item) | 9173 | m_host.TaskInventory.LockItemsForRead(false); |
9174 | switch (mask) | ||
8637 | { | 9175 | { |
8638 | switch (mask) | 9176 | case 0: |
8639 | { | 9177 | return (int)inv.Value.BasePermissions; |
8640 | case 0: | 9178 | case 1: |
8641 | return (int)inv.Value.BasePermissions; | 9179 | return (int)inv.Value.CurrentPermissions; |
8642 | case 1: | 9180 | case 2: |
8643 | return (int)inv.Value.CurrentPermissions; | 9181 | return (int)inv.Value.GroupPermissions; |
8644 | case 2: | 9182 | case 3: |
8645 | return (int)inv.Value.GroupPermissions; | 9183 | return (int)inv.Value.EveryonePermissions; |
8646 | case 3: | 9184 | case 4: |
8647 | return (int)inv.Value.EveryonePermissions; | 9185 | return (int)inv.Value.NextPermissions; |
8648 | case 4: | ||
8649 | return (int)inv.Value.NextPermissions; | ||
8650 | } | ||
8651 | } | 9186 | } |
8652 | } | 9187 | } |
8653 | } | 9188 | } |
9189 | m_host.TaskInventory.LockItemsForRead(false); | ||
8654 | 9190 | ||
8655 | return -1; | 9191 | return -1; |
8656 | } | 9192 | } |
@@ -8697,16 +9233,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8697 | { | 9233 | { |
8698 | m_host.AddScriptLPS(1); | 9234 | m_host.AddScriptLPS(1); |
8699 | 9235 | ||
8700 | lock (m_host.TaskInventory) | 9236 | m_host.TaskInventory.LockItemsForRead(true); |
9237 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8701 | { | 9238 | { |
8702 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9239 | if (inv.Value.Name == item) |
8703 | { | 9240 | { |
8704 | if (inv.Value.Name == item) | 9241 | m_host.TaskInventory.LockItemsForRead(false); |
8705 | { | 9242 | return inv.Value.CreatorID.ToString(); |
8706 | return inv.Value.CreatorID.ToString(); | ||
8707 | } | ||
8708 | } | 9243 | } |
8709 | } | 9244 | } |
9245 | m_host.TaskInventory.LockItemsForRead(false); | ||
8710 | 9246 | ||
8711 | llSay(0, "No item name '" + item + "'"); | 9247 | llSay(0, "No item name '" + item + "'"); |
8712 | 9248 | ||
@@ -8971,17 +9507,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8971 | int width = 0; | 9507 | int width = 0; |
8972 | int height = 0; | 9508 | int height = 0; |
8973 | 9509 | ||
8974 | ParcelMediaCommandEnum? commandToSend = null; | 9510 | uint commandToSend = 0; |
8975 | float time = 0.0f; // default is from start | 9511 | float time = 0.0f; // default is from start |
8976 | 9512 | ||
8977 | ScenePresence presence = null; | 9513 | ScenePresence presence = null; |
8978 | 9514 | ||
8979 | for (int i = 0; i < commandList.Data.Length; i++) | 9515 | for (int i = 0; i < commandList.Data.Length; i++) |
8980 | { | 9516 | { |
8981 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9517 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8982 | switch (command) | 9518 | switch (command) |
8983 | { | 9519 | { |
8984 | case ParcelMediaCommandEnum.Agent: | 9520 | case (uint)ParcelMediaCommandEnum.Agent: |
8985 | // we send only to one agent | 9521 | // we send only to one agent |
8986 | if ((i + 1) < commandList.Length) | 9522 | if ((i + 1) < commandList.Length) |
8987 | { | 9523 | { |
@@ -8998,25 +9534,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8998 | } | 9534 | } |
8999 | break; | 9535 | break; |
9000 | 9536 | ||
9001 | case ParcelMediaCommandEnum.Loop: | 9537 | case (uint)ParcelMediaCommandEnum.Loop: |
9002 | loop = 1; | 9538 | loop = 1; |
9003 | commandToSend = command; | 9539 | commandToSend = command; |
9004 | update = true; //need to send the media update packet to set looping | 9540 | update = true; //need to send the media update packet to set looping |
9005 | break; | 9541 | break; |
9006 | 9542 | ||
9007 | case ParcelMediaCommandEnum.Play: | 9543 | case (uint)ParcelMediaCommandEnum.Play: |
9008 | loop = 0; | 9544 | loop = 0; |
9009 | commandToSend = command; | 9545 | commandToSend = command; |
9010 | update = true; //need to send the media update packet to make sure it doesn't loop | 9546 | update = true; //need to send the media update packet to make sure it doesn't loop |
9011 | break; | 9547 | break; |
9012 | 9548 | ||
9013 | case ParcelMediaCommandEnum.Pause: | 9549 | case (uint)ParcelMediaCommandEnum.Pause: |
9014 | case ParcelMediaCommandEnum.Stop: | 9550 | case (uint)ParcelMediaCommandEnum.Stop: |
9015 | case ParcelMediaCommandEnum.Unload: | 9551 | case (uint)ParcelMediaCommandEnum.Unload: |
9016 | commandToSend = command; | 9552 | commandToSend = command; |
9017 | break; | 9553 | break; |
9018 | 9554 | ||
9019 | case ParcelMediaCommandEnum.Url: | 9555 | case (uint)ParcelMediaCommandEnum.Url: |
9020 | if ((i + 1) < commandList.Length) | 9556 | if ((i + 1) < commandList.Length) |
9021 | { | 9557 | { |
9022 | if (commandList.Data[i + 1] is LSL_String) | 9558 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9029,7 +9565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9029 | } | 9565 | } |
9030 | break; | 9566 | break; |
9031 | 9567 | ||
9032 | case ParcelMediaCommandEnum.Texture: | 9568 | case (uint)ParcelMediaCommandEnum.Texture: |
9033 | if ((i + 1) < commandList.Length) | 9569 | if ((i + 1) < commandList.Length) |
9034 | { | 9570 | { |
9035 | if (commandList.Data[i + 1] is LSL_String) | 9571 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9042,7 +9578,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9042 | } | 9578 | } |
9043 | break; | 9579 | break; |
9044 | 9580 | ||
9045 | case ParcelMediaCommandEnum.Time: | 9581 | case (uint)ParcelMediaCommandEnum.Time: |
9046 | if ((i + 1) < commandList.Length) | 9582 | if ((i + 1) < commandList.Length) |
9047 | { | 9583 | { |
9048 | if (commandList.Data[i + 1] is LSL_Float) | 9584 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9054,7 +9590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9054 | } | 9590 | } |
9055 | break; | 9591 | break; |
9056 | 9592 | ||
9057 | case ParcelMediaCommandEnum.AutoAlign: | 9593 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9058 | if ((i + 1) < commandList.Length) | 9594 | if ((i + 1) < commandList.Length) |
9059 | { | 9595 | { |
9060 | if (commandList.Data[i + 1] is LSL_Integer) | 9596 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9068,7 +9604,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9068 | } | 9604 | } |
9069 | break; | 9605 | break; |
9070 | 9606 | ||
9071 | case ParcelMediaCommandEnum.Type: | 9607 | case (uint)ParcelMediaCommandEnum.Type: |
9072 | if ((i + 1) < commandList.Length) | 9608 | if ((i + 1) < commandList.Length) |
9073 | { | 9609 | { |
9074 | if (commandList.Data[i + 1] is LSL_String) | 9610 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9081,7 +9617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9081 | } | 9617 | } |
9082 | break; | 9618 | break; |
9083 | 9619 | ||
9084 | case ParcelMediaCommandEnum.Desc: | 9620 | case (uint)ParcelMediaCommandEnum.Desc: |
9085 | if ((i + 1) < commandList.Length) | 9621 | if ((i + 1) < commandList.Length) |
9086 | { | 9622 | { |
9087 | if (commandList.Data[i + 1] is LSL_String) | 9623 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9094,7 +9630,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9094 | } | 9630 | } |
9095 | break; | 9631 | break; |
9096 | 9632 | ||
9097 | case ParcelMediaCommandEnum.Size: | 9633 | case (uint)ParcelMediaCommandEnum.Size: |
9098 | if ((i + 2) < commandList.Length) | 9634 | if ((i + 2) < commandList.Length) |
9099 | { | 9635 | { |
9100 | if (commandList.Data[i + 1] is LSL_Integer) | 9636 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9164,7 +9700,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9164 | } | 9700 | } |
9165 | } | 9701 | } |
9166 | 9702 | ||
9167 | if (commandToSend != null) | 9703 | if (commandToSend != 0) |
9168 | { | 9704 | { |
9169 | // the commandList contained a start/stop/... command, too | 9705 | // the commandList contained a start/stop/... command, too |
9170 | if (presence == null) | 9706 | if (presence == null) |
@@ -9201,7 +9737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9201 | 9737 | ||
9202 | if (aList.Data[i] != null) | 9738 | if (aList.Data[i] != null) |
9203 | { | 9739 | { |
9204 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 9740 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9205 | { | 9741 | { |
9206 | case ParcelMediaCommandEnum.Url: | 9742 | case ParcelMediaCommandEnum.Url: |
9207 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 9743 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9244,16 +9780,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9244 | { | 9780 | { |
9245 | m_host.AddScriptLPS(1); | 9781 | m_host.AddScriptLPS(1); |
9246 | 9782 | ||
9247 | lock (m_host.TaskInventory) | 9783 | m_host.TaskInventory.LockItemsForRead(true); |
9784 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9248 | { | 9785 | { |
9249 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9786 | if (inv.Value.Name == name) |
9250 | { | 9787 | { |
9251 | if (inv.Value.Name == name) | 9788 | m_host.TaskInventory.LockItemsForRead(false); |
9252 | { | 9789 | return inv.Value.Type; |
9253 | return inv.Value.Type; | ||
9254 | } | ||
9255 | } | 9790 | } |
9256 | } | 9791 | } |
9792 | m_host.TaskInventory.LockItemsForRead(false); | ||
9257 | 9793 | ||
9258 | return -1; | 9794 | return -1; |
9259 | } | 9795 | } |
@@ -9264,15 +9800,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9264 | 9800 | ||
9265 | if (quick_pay_buttons.Data.Length < 4) | 9801 | if (quick_pay_buttons.Data.Length < 4) |
9266 | { | 9802 | { |
9267 | LSLError("List must have at least 4 elements"); | 9803 | int x; |
9268 | return; | 9804 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9805 | { | ||
9806 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9807 | } | ||
9269 | } | 9808 | } |
9270 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9809 | int[] nPrice = new int[5]; |
9271 | 9810 | nPrice[0]=price; | |
9272 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9811 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
9273 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9812 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
9274 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9813 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
9275 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9814 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9815 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9276 | m_host.ParentGroup.HasGroupChanged = true; | 9816 | m_host.ParentGroup.HasGroupChanged = true; |
9277 | } | 9817 | } |
9278 | 9818 | ||
@@ -9284,17 +9824,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9284 | if (invItemID == UUID.Zero) | 9824 | if (invItemID == UUID.Zero) |
9285 | return new LSL_Vector(); | 9825 | return new LSL_Vector(); |
9286 | 9826 | ||
9287 | lock (m_host.TaskInventory) | 9827 | m_host.TaskInventory.LockItemsForRead(true); |
9828 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9288 | { | 9829 | { |
9289 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9830 | m_host.TaskInventory.LockItemsForRead(false); |
9290 | return new LSL_Vector(); | 9831 | return new LSL_Vector(); |
9832 | } | ||
9291 | 9833 | ||
9292 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9834 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9293 | { | 9835 | { |
9294 | ShoutError("No permissions to track the camera"); | 9836 | ShoutError("No permissions to track the camera"); |
9295 | return new LSL_Vector(); | 9837 | m_host.TaskInventory.LockItemsForRead(false); |
9296 | } | 9838 | return new LSL_Vector(); |
9297 | } | 9839 | } |
9840 | m_host.TaskInventory.LockItemsForRead(false); | ||
9298 | 9841 | ||
9299 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9842 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9300 | if (presence != null) | 9843 | if (presence != null) |
@@ -9312,17 +9855,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9312 | if (invItemID == UUID.Zero) | 9855 | if (invItemID == UUID.Zero) |
9313 | return new LSL_Rotation(); | 9856 | return new LSL_Rotation(); |
9314 | 9857 | ||
9315 | lock (m_host.TaskInventory) | 9858 | m_host.TaskInventory.LockItemsForRead(true); |
9859 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9316 | { | 9860 | { |
9317 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9861 | m_host.TaskInventory.LockItemsForRead(false); |
9318 | return new LSL_Rotation(); | 9862 | return new LSL_Rotation(); |
9319 | 9863 | } | |
9320 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9864 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9321 | { | 9865 | { |
9322 | ShoutError("No permissions to track the camera"); | 9866 | ShoutError("No permissions to track the camera"); |
9323 | return new LSL_Rotation(); | 9867 | m_host.TaskInventory.LockItemsForRead(false); |
9324 | } | 9868 | return new LSL_Rotation(); |
9325 | } | 9869 | } |
9870 | m_host.TaskInventory.LockItemsForRead(false); | ||
9326 | 9871 | ||
9327 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9872 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9328 | if (presence != null) | 9873 | if (presence != null) |
@@ -9384,8 +9929,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9384 | { | 9929 | { |
9385 | m_host.AddScriptLPS(1); | 9930 | m_host.AddScriptLPS(1); |
9386 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9931 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9387 | if (detectedParams == null) return; // only works on the first detected avatar | 9932 | if (detectedParams == null) |
9388 | 9933 | { | |
9934 | if (m_host.IsAttachment == true) | ||
9935 | { | ||
9936 | detectedParams = new DetectParams(); | ||
9937 | detectedParams.Key = m_host.OwnerID; | ||
9938 | } | ||
9939 | else | ||
9940 | { | ||
9941 | return; | ||
9942 | } | ||
9943 | } | ||
9944 | |||
9389 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9945 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9390 | if (avatar != null) | 9946 | if (avatar != null) |
9391 | { | 9947 | { |
@@ -9393,6 +9949,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9393 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9949 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9394 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9950 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9395 | } | 9951 | } |
9952 | |||
9396 | ScriptSleep(1000); | 9953 | ScriptSleep(1000); |
9397 | } | 9954 | } |
9398 | 9955 | ||
@@ -9472,14 +10029,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9472 | if (objectID == UUID.Zero) return; | 10029 | if (objectID == UUID.Zero) return; |
9473 | 10030 | ||
9474 | UUID agentID; | 10031 | UUID agentID; |
9475 | lock (m_host.TaskInventory) | 10032 | m_host.TaskInventory.LockItemsForRead(true); |
9476 | { | 10033 | // we need the permission first, to know which avatar we want to set the camera for |
9477 | // we need the permission first, to know which avatar we want to set the camera for | 10034 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9478 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9479 | 10035 | ||
9480 | if (agentID == UUID.Zero) return; | 10036 | if (agentID == UUID.Zero) |
9481 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 10037 | { |
10038 | m_host.TaskInventory.LockItemsForRead(false); | ||
10039 | return; | ||
10040 | } | ||
10041 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
10042 | { | ||
10043 | m_host.TaskInventory.LockItemsForRead(false); | ||
10044 | return; | ||
9482 | } | 10045 | } |
10046 | m_host.TaskInventory.LockItemsForRead(false); | ||
9483 | 10047 | ||
9484 | ScenePresence presence = World.GetScenePresence(agentID); | 10048 | ScenePresence presence = World.GetScenePresence(agentID); |
9485 | 10049 | ||
@@ -9488,12 +10052,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9488 | 10052 | ||
9489 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | 10053 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); |
9490 | object[] data = rules.Data; | 10054 | object[] data = rules.Data; |
9491 | for (int i = 0; i < data.Length; ++i) { | 10055 | for (int i = 0; i < data.Length; ++i) |
10056 | { | ||
9492 | int type = Convert.ToInt32(data[i++].ToString()); | 10057 | int type = Convert.ToInt32(data[i++].ToString()); |
9493 | if (i >= data.Length) break; // odd number of entries => ignore the last | 10058 | if (i >= data.Length) break; // odd number of entries => ignore the last |
9494 | 10059 | ||
9495 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 10060 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
9496 | switch (type) { | 10061 | switch (type) |
10062 | { | ||
9497 | case ScriptBaseClass.CAMERA_FOCUS: | 10063 | case ScriptBaseClass.CAMERA_FOCUS: |
9498 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | 10064 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: |
9499 | case ScriptBaseClass.CAMERA_POSITION: | 10065 | case ScriptBaseClass.CAMERA_POSITION: |
@@ -9529,12 +10095,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9529 | 10095 | ||
9530 | // we need the permission first, to know which avatar we want to clear the camera for | 10096 | // we need the permission first, to know which avatar we want to clear the camera for |
9531 | UUID agentID; | 10097 | UUID agentID; |
9532 | lock (m_host.TaskInventory) | 10098 | m_host.TaskInventory.LockItemsForRead(true); |
10099 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10100 | if (agentID == UUID.Zero) | ||
10101 | { | ||
10102 | m_host.TaskInventory.LockItemsForRead(false); | ||
10103 | return; | ||
10104 | } | ||
10105 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9533 | { | 10106 | { |
9534 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10107 | m_host.TaskInventory.LockItemsForRead(false); |
9535 | if (agentID == UUID.Zero) return; | 10108 | return; |
9536 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9537 | } | 10109 | } |
10110 | m_host.TaskInventory.LockItemsForRead(false); | ||
9538 | 10111 | ||
9539 | ScenePresence presence = World.GetScenePresence(agentID); | 10112 | ScenePresence presence = World.GetScenePresence(agentID); |
9540 | 10113 | ||
@@ -9601,19 +10174,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9601 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 10174 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
9602 | { | 10175 | { |
9603 | m_host.AddScriptLPS(1); | 10176 | m_host.AddScriptLPS(1); |
9604 | string ret = String.Empty; | 10177 | |
9605 | string src1 = llBase64ToString(str1); | 10178 | if (str1 == String.Empty) |
9606 | string src2 = llBase64ToString(str2); | 10179 | return String.Empty; |
9607 | int c = 0; | 10180 | if (str2 == String.Empty) |
9608 | for (int i = 0; i < src1.Length; i++) | 10181 | return str1; |
10182 | |||
10183 | int len = str2.Length; | ||
10184 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
10185 | { | ||
10186 | while (str2.EndsWith("=")) | ||
10187 | str2 = str2.Substring(0, str2.Length - 1); | ||
10188 | |||
10189 | len = str2.Length; | ||
10190 | int mod = len % 4; | ||
10191 | |||
10192 | if (mod == 1) | ||
10193 | str2 = str2.Substring(0, str2.Length - 1); | ||
10194 | else if (mod == 2) | ||
10195 | str2 += "=="; | ||
10196 | else if (mod == 3) | ||
10197 | str2 += "="; | ||
10198 | } | ||
10199 | |||
10200 | byte[] data1; | ||
10201 | byte[] data2; | ||
10202 | try | ||
10203 | { | ||
10204 | data1 = Convert.FromBase64String(str1); | ||
10205 | data2 = Convert.FromBase64String(str2); | ||
10206 | } | ||
10207 | catch (Exception) | ||
10208 | { | ||
10209 | return new LSL_String(String.Empty); | ||
10210 | } | ||
10211 | |||
10212 | byte[] d2 = new Byte[data1.Length]; | ||
10213 | int pos = 0; | ||
10214 | |||
10215 | if (data1.Length <= data2.Length) | ||
10216 | { | ||
10217 | Array.Copy(data2, 0, d2, 0, data1.Length); | ||
10218 | } | ||
10219 | else | ||
9609 | { | 10220 | { |
9610 | ret += (char) (src1[i] ^ src2[c]); | 10221 | while (pos < data1.Length) |
10222 | { | ||
10223 | len = data1.Length - pos; | ||
10224 | if (len > data2.Length) | ||
10225 | len = data2.Length; | ||
9611 | 10226 | ||
9612 | c++; | 10227 | Array.Copy(data2, 0, d2, pos, len); |
9613 | if (c >= src2.Length) | 10228 | pos += len; |
9614 | c = 0; | 10229 | } |
9615 | } | 10230 | } |
9616 | return llStringToBase64(ret); | 10231 | |
10232 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
10233 | data1[pos] ^= d2[pos]; | ||
10234 | |||
10235 | return Convert.ToBase64String(data1); | ||
9617 | } | 10236 | } |
9618 | 10237 | ||
9619 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 10238 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -9672,12 +10291,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9672 | Regex r = new Regex(authregex); | 10291 | Regex r = new Regex(authregex); |
9673 | int[] gnums = r.GetGroupNumbers(); | 10292 | int[] gnums = r.GetGroupNumbers(); |
9674 | Match m = r.Match(url); | 10293 | Match m = r.Match(url); |
9675 | if (m.Success) { | 10294 | if (m.Success) |
9676 | for (int i = 1; i < gnums.Length; i++) { | 10295 | { |
10296 | for (int i = 1; i < gnums.Length; i++) | ||
10297 | { | ||
9677 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 10298 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
9678 | //CaptureCollection cc = g.Captures; | 10299 | //CaptureCollection cc = g.Captures; |
9679 | } | 10300 | } |
9680 | if (m.Groups.Count == 5) { | 10301 | if (m.Groups.Count == 5) |
10302 | { | ||
9681 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 10303 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
9682 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 10304 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
9683 | } | 10305 | } |
@@ -9994,15 +10616,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9994 | 10616 | ||
9995 | internal UUID ScriptByName(string name) | 10617 | internal UUID ScriptByName(string name) |
9996 | { | 10618 | { |
9997 | lock (m_host.TaskInventory) | 10619 | m_host.TaskInventory.LockItemsForRead(true); |
10620 | |||
10621 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9998 | { | 10622 | { |
9999 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10623 | if (item.Type == 10 && item.Name == name) |
10000 | { | 10624 | { |
10001 | if (item.Type == 10 && item.Name == name) | 10625 | m_host.TaskInventory.LockItemsForRead(false); |
10002 | return item.ItemID; | 10626 | return item.ItemID; |
10003 | } | 10627 | } |
10004 | } | 10628 | } |
10005 | 10629 | ||
10630 | m_host.TaskInventory.LockItemsForRead(false); | ||
10631 | |||
10006 | return UUID.Zero; | 10632 | return UUID.Zero; |
10007 | } | 10633 | } |
10008 | 10634 | ||
@@ -10043,6 +10669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10043 | { | 10669 | { |
10044 | m_host.AddScriptLPS(1); | 10670 | m_host.AddScriptLPS(1); |
10045 | 10671 | ||
10672 | //Clone is thread safe | ||
10046 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10673 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10047 | 10674 | ||
10048 | UUID assetID = UUID.Zero; | 10675 | UUID assetID = UUID.Zero; |
@@ -10105,6 +10732,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10105 | { | 10732 | { |
10106 | m_host.AddScriptLPS(1); | 10733 | m_host.AddScriptLPS(1); |
10107 | 10734 | ||
10735 | //Clone is thread safe | ||
10108 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10736 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10109 | 10737 | ||
10110 | UUID assetID = UUID.Zero; | 10738 | UUID assetID = UUID.Zero; |
@@ -10184,6 +10812,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10184 | 10812 | ||
10185 | return GetLinkPrimitiveParams(obj, rules); | 10813 | return GetLinkPrimitiveParams(obj, rules); |
10186 | } | 10814 | } |
10815 | |||
10816 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | ||
10817 | { | ||
10818 | List<SceneObjectPart> parts = GetLinkParts(link); | ||
10819 | if (parts.Count < 1) | ||
10820 | return 0; | ||
10821 | |||
10822 | return GetNumberOfSides(parts[0]); | ||
10823 | } | ||
10187 | } | 10824 | } |
10188 | 10825 | ||
10189 | public class NotecardCache | 10826 | public class NotecardCache |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 827626f..eba6e75 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -129,6 +129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
129 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | 129 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; |
130 | internal float m_ScriptDelayFactor = 1.0f; | 130 | internal float m_ScriptDelayFactor = 1.0f; |
131 | internal float m_ScriptDistanceFactor = 1.0f; | 131 | internal float m_ScriptDistanceFactor = 1.0f; |
132 | internal bool m_debuggerSafe = false; | ||
132 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 133 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
133 | 134 | ||
134 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 135 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) |
@@ -137,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
137 | m_host = host; | 138 | m_host = host; |
138 | m_localID = localID; | 139 | m_localID = localID; |
139 | m_itemID = itemID; | 140 | m_itemID = itemID; |
141 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
140 | 142 | ||
141 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | 143 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) |
142 | m_OSFunctionsEnabled = true; | 144 | m_OSFunctionsEnabled = true; |
@@ -195,7 +197,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
195 | 197 | ||
196 | internal void OSSLError(string msg) | 198 | internal void OSSLError(string msg) |
197 | { | 199 | { |
198 | throw new Exception("OSSL Runtime Error: " + msg); | 200 | if (m_debuggerSafe) |
201 | { | ||
202 | OSSLShoutError(msg); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | throw new Exception("OSSL Runtime Error: " + msg); | ||
207 | } | ||
199 | } | 208 | } |
200 | 209 | ||
201 | private void InitLSL() | 210 | private void InitLSL() |
@@ -818,18 +827,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
818 | if (target != null) | 827 | if (target != null) |
819 | { | 828 | { |
820 | UUID animID=UUID.Zero; | 829 | UUID animID=UUID.Zero; |
821 | lock (m_host.TaskInventory) | 830 | m_host.TaskInventory.LockItemsForRead(true); |
831 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
822 | { | 832 | { |
823 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 833 | if (inv.Value.Name == animation) |
824 | { | 834 | { |
825 | if (inv.Value.Name == animation) | 835 | if (inv.Value.Type == (int)AssetType.Animation) |
826 | { | 836 | animID = inv.Value.AssetID; |
827 | if (inv.Value.Type == (int)AssetType.Animation) | 837 | continue; |
828 | animID = inv.Value.AssetID; | ||
829 | continue; | ||
830 | } | ||
831 | } | 838 | } |
832 | } | 839 | } |
840 | m_host.TaskInventory.LockItemsForRead(false); | ||
833 | if (animID == UUID.Zero) | 841 | if (animID == UUID.Zero) |
834 | target.Animator.AddAnimation(animation, m_host.UUID); | 842 | target.Animator.AddAnimation(animation, m_host.UUID); |
835 | else | 843 | else |
@@ -851,18 +859,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
851 | if (target != null) | 859 | if (target != null) |
852 | { | 860 | { |
853 | UUID animID=UUID.Zero; | 861 | UUID animID=UUID.Zero; |
854 | lock (m_host.TaskInventory) | 862 | m_host.TaskInventory.LockItemsForRead(true); |
863 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
855 | { | 864 | { |
856 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 865 | if (inv.Value.Name == animation) |
857 | { | 866 | { |
858 | if (inv.Value.Name == animation) | 867 | if (inv.Value.Type == (int)AssetType.Animation) |
859 | { | 868 | animID = inv.Value.AssetID; |
860 | if (inv.Value.Type == (int)AssetType.Animation) | 869 | continue; |
861 | animID = inv.Value.AssetID; | ||
862 | continue; | ||
863 | } | ||
864 | } | 870 | } |
865 | } | 871 | } |
872 | m_host.TaskInventory.LockItemsForRead(false); | ||
866 | 873 | ||
867 | if (animID == UUID.Zero) | 874 | if (animID == UUID.Zero) |
868 | target.Animator.RemoveAnimation(animation); | 875 | target.Animator.RemoveAnimation(animation); |
@@ -1713,6 +1720,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1713 | 1720 | ||
1714 | if (!UUID.TryParse(name, out assetID)) | 1721 | if (!UUID.TryParse(name, out assetID)) |
1715 | { | 1722 | { |
1723 | m_host.TaskInventory.LockItemsForRead(true); | ||
1716 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1724 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1717 | { | 1725 | { |
1718 | if (item.Type == 7 && item.Name == name) | 1726 | if (item.Type == 7 && item.Name == name) |
@@ -1720,6 +1728,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1720 | assetID = item.AssetID; | 1728 | assetID = item.AssetID; |
1721 | } | 1729 | } |
1722 | } | 1730 | } |
1731 | m_host.TaskInventory.LockItemsForRead(false); | ||
1723 | } | 1732 | } |
1724 | 1733 | ||
1725 | if (assetID == UUID.Zero) | 1734 | if (assetID == UUID.Zero) |
@@ -1766,6 +1775,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1766 | 1775 | ||
1767 | if (!UUID.TryParse(name, out assetID)) | 1776 | if (!UUID.TryParse(name, out assetID)) |
1768 | { | 1777 | { |
1778 | m_host.TaskInventory.LockItemsForRead(true); | ||
1769 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1779 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1770 | { | 1780 | { |
1771 | if (item.Type == 7 && item.Name == name) | 1781 | if (item.Type == 7 && item.Name == name) |
@@ -1773,6 +1783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1773 | assetID = item.AssetID; | 1783 | assetID = item.AssetID; |
1774 | } | 1784 | } |
1775 | } | 1785 | } |
1786 | m_host.TaskInventory.LockItemsForRead(false); | ||
1776 | } | 1787 | } |
1777 | 1788 | ||
1778 | if (assetID == UUID.Zero) | 1789 | if (assetID == UUID.Zero) |
@@ -1823,6 +1834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1823 | 1834 | ||
1824 | if (!UUID.TryParse(name, out assetID)) | 1835 | if (!UUID.TryParse(name, out assetID)) |
1825 | { | 1836 | { |
1837 | m_host.TaskInventory.LockItemsForRead(true); | ||
1826 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1838 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1827 | { | 1839 | { |
1828 | if (item.Type == 7 && item.Name == name) | 1840 | if (item.Type == 7 && item.Name == name) |
@@ -1830,6 +1842,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1830 | assetID = item.AssetID; | 1842 | assetID = item.AssetID; |
1831 | } | 1843 | } |
1832 | } | 1844 | } |
1845 | m_host.TaskInventory.LockItemsForRead(false); | ||
1833 | } | 1846 | } |
1834 | 1847 | ||
1835 | if (assetID == UUID.Zero) | 1848 | if (assetID == UUID.Zero) |
@@ -2309,9 +2322,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2309 | { | 2322 | { |
2310 | if (avatar.IsChildAgent == false) | 2323 | if (avatar.IsChildAgent == false) |
2311 | { | 2324 | { |
2312 | result.Add(avatar.UUID); | 2325 | result.Add(new LSL_Key(avatar.UUID.ToString())); |
2313 | result.Add(avatar.AbsolutePosition); | 2326 | result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z)); |
2314 | result.Add(avatar.Name); | 2327 | result.Add(new LSL_String(avatar.Name)); |
2315 | } | 2328 | } |
2316 | } | 2329 | } |
2317 | }); | 2330 | }); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fefbb35..3b7de53 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
204 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 204 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) | 205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) |
206 | { | 206 | { |
207 | sensedEntities.AddRange(doAgentSensor(ts)); | 207 | sensedEntities.AddRange(doAgentSensor(ts)); |
208 | } | 208 | } |
209 | 209 | ||
210 | // If SCRIPTED or PASSIVE or ACTIVE check objects | 210 | // If SCRIPTED or PASSIVE or ACTIVE check objects |
@@ -309,6 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
309 | // in mouselook. | 309 | // in mouselook. |
310 | 310 | ||
311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); |
312 | fromRegionPos = avatar.AbsolutePosition; | ||
312 | q = avatar.Rotation; | 313 | q = avatar.Rotation; |
313 | } | 314 | } |
314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 315 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -422,6 +423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
422 | SceneObjectPart SensePoint = ts.host; | 423 | SceneObjectPart SensePoint = ts.host; |
423 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 424 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
424 | Quaternion q = SensePoint.RotationOffset; | 425 | Quaternion q = SensePoint.RotationOffset; |
426 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | ||
427 | { | ||
428 | // In attachments, the sensor cone always orients with the | ||
429 | // avatar rotation. This may include a nonzero elevation if | ||
430 | // in mouselook. | ||
431 | |||
432 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | ||
433 | fromRegionPos = avatar.AbsolutePosition; | ||
434 | q = avatar.Rotation; | ||
435 | } | ||
425 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 436 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
426 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 437 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
427 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 438 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
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/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 561e3b3..bae7d4b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -398,6 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
398 | LSL_Vector llWind(LSL_Vector offset); | 398 | LSL_Vector llWind(LSL_Vector offset); |
399 | LSL_String llXorBase64Strings(string str1, string str2); | 399 | LSL_String llXorBase64Strings(string str1, string str2); |
400 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 400 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
401 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); | ||
401 | 402 | ||
402 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 403 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
403 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 404 | 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 10d61ca..961987d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
81 | // Avatar Info Commands | 81 | // Avatar Info Commands |
82 | string osGetAgentIP(string agent); | 82 | string osGetAgentIP(string agent); |
83 | LSL_List osGetAgents(); | 83 | LSL_List osGetAgents(); |
84 | 84 | ||
85 | // Teleport commands | 85 | // Teleport commands |
86 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
87 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 87 | 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/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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using 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 b3c4d95..93d544b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -279,6 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
280 | public const int CHANGED_MEDIA = 2048; | 280 | public const int CHANGED_MEDIA = 2048; |
281 | public const int CHANGED_ANIMATION = 16384; | 281 | public const int CHANGED_ANIMATION = 16384; |
282 | public const int CHANGED_POSITION = 32768; | ||
282 | public const int TYPE_INVALID = 0; | 283 | public const int TYPE_INVALID = 0; |
283 | public const int TYPE_INTEGER = 1; | 284 | public const int TYPE_INTEGER = 1; |
284 | public const int TYPE_FLOAT = 2; | 285 | public const int TYPE_FLOAT = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 451163f..7c26824 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
309 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 310 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
310 | } | 311 | } |
311 | 312 | ||
313 | [DebuggerNonUserCode] | ||
312 | public void llDie() | 314 | public void llDie() |
313 | { | 315 | { |
314 | m_LSL_Functions.llDie(); | 316 | m_LSL_Functions.llDie(); |
@@ -1847,5 +1849,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1847 | { | 1849 | { |
1848 | return m_LSL_Functions.llClearPrimMedia(face); | 1850 | return m_LSL_Functions.llClearPrimMedia(face); |
1849 | } | 1851 | } |
1852 | |||
1853 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | ||
1854 | { | ||
1855 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | ||
1856 | } | ||
1850 | } | 1857 | } |
1851 | } | 1858 | } |
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; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using 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); |