diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
14 files changed, 1558 insertions, 825 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 cc6ded7..e94790f 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()) |
351 | { | ||
352 | m_host.TaskInventory.LockItemsForRead(true); | ||
353 | unlock = true; | ||
354 | } | ||
355 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
293 | { | 356 | { |
294 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 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). | ||
486 | 555 | ||
487 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 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 | } | ||
568 | |||
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; |
@@ -2034,6 +2218,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2034 | 2218 | ||
2035 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2219 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2036 | { | 2220 | { |
2221 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2222 | return; | ||
2223 | |||
2037 | part.UpdateRotation(rot); | 2224 | part.UpdateRotation(rot); |
2038 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2225 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2039 | 2226 | ||
@@ -2653,12 +2840,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2653 | 2840 | ||
2654 | m_host.AddScriptLPS(1); | 2841 | m_host.AddScriptLPS(1); |
2655 | 2842 | ||
2843 | m_host.TaskInventory.LockItemsForRead(true); | ||
2656 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2844 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2657 | 2845 | m_host.TaskInventory.LockItemsForRead(false); | |
2658 | lock (m_host.TaskInventory) | ||
2659 | { | ||
2660 | item = m_host.TaskInventory[invItemID]; | ||
2661 | } | ||
2662 | 2846 | ||
2663 | if (item.PermsGranter == UUID.Zero) | 2847 | if (item.PermsGranter == UUID.Zero) |
2664 | return 0; | 2848 | return 0; |
@@ -2733,6 +2917,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2733 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2917 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2734 | return; | 2918 | return; |
2735 | 2919 | ||
2920 | //Clone is thread-safe | ||
2736 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2921 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2737 | 2922 | ||
2738 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2923 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2795,6 +2980,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2795 | 2980 | ||
2796 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2981 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2797 | { | 2982 | { |
2983 | /* | ||
2798 | m_host.AddScriptLPS(1); | 2984 | m_host.AddScriptLPS(1); |
2799 | // Determine where we are looking from | 2985 | // Determine where we are looking from |
2800 | LSL_Vector from = llGetPos(); | 2986 | LSL_Vector from = llGetPos(); |
@@ -2814,10 +3000,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2814 | // the angles of rotation in radians into rotation value | 3000 | // the angles of rotation in radians into rotation value |
2815 | 3001 | ||
2816 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 3002 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2817 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 3003 | |
2818 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 3004 | // This would only work if your physics system contains an APID controller: |
3005 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
3006 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
3007 | |||
2819 | // Orient the object to the angle calculated | 3008 | // Orient the object to the angle calculated |
2820 | //llSetRot(rot); | 3009 | llSetRot(rot); |
3010 | */ | ||
3011 | |||
3012 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
3013 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
3014 | // http://bugs.meta7.com/view.php?id=28 | ||
3015 | // - Tom | ||
3016 | |||
3017 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
3018 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
3019 | |||
3020 | } | ||
3021 | |||
3022 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3023 | { | ||
3024 | m_host.AddScriptLPS(1); | ||
3025 | // NotImplemented("llRotLookAt"); | ||
3026 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3027 | |||
2821 | } | 3028 | } |
2822 | 3029 | ||
2823 | public void llStopLookAt() | 3030 | public void llStopLookAt() |
@@ -2866,13 +3073,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2866 | { | 3073 | { |
2867 | TaskInventoryItem item; | 3074 | TaskInventoryItem item; |
2868 | 3075 | ||
2869 | lock (m_host.TaskInventory) | 3076 | m_host.TaskInventory.LockItemsForRead(true); |
3077 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2870 | { | 3078 | { |
2871 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3079 | m_host.TaskInventory.LockItemsForRead(false); |
2872 | return; | 3080 | return; |
2873 | else | ||
2874 | item = m_host.TaskInventory[InventorySelf()]; | ||
2875 | } | 3081 | } |
3082 | else | ||
3083 | { | ||
3084 | item = m_host.TaskInventory[InventorySelf()]; | ||
3085 | } | ||
3086 | m_host.TaskInventory.LockItemsForRead(false); | ||
2876 | 3087 | ||
2877 | if (item.PermsGranter != UUID.Zero) | 3088 | if (item.PermsGranter != UUID.Zero) |
2878 | { | 3089 | { |
@@ -2894,13 +3105,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2894 | { | 3105 | { |
2895 | TaskInventoryItem item; | 3106 | TaskInventoryItem item; |
2896 | 3107 | ||
3108 | m_host.TaskInventory.LockItemsForRead(true); | ||
2897 | lock (m_host.TaskInventory) | 3109 | lock (m_host.TaskInventory) |
2898 | { | 3110 | { |
3111 | |||
2899 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3112 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3113 | { | ||
3114 | m_host.TaskInventory.LockItemsForRead(false); | ||
2900 | return; | 3115 | return; |
3116 | } | ||
2901 | else | 3117 | else |
3118 | { | ||
2902 | item = m_host.TaskInventory[InventorySelf()]; | 3119 | item = m_host.TaskInventory[InventorySelf()]; |
3120 | } | ||
2903 | } | 3121 | } |
3122 | m_host.TaskInventory.LockItemsForRead(false); | ||
2904 | 3123 | ||
2905 | m_host.AddScriptLPS(1); | 3124 | m_host.AddScriptLPS(1); |
2906 | 3125 | ||
@@ -2932,18 +3151,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2932 | { | 3151 | { |
2933 | m_host.AddScriptLPS(1); | 3152 | m_host.AddScriptLPS(1); |
2934 | 3153 | ||
2935 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
2936 | return; | ||
2937 | |||
2938 | TaskInventoryItem item; | 3154 | TaskInventoryItem item; |
2939 | 3155 | ||
2940 | lock (m_host.TaskInventory) | 3156 | m_host.TaskInventory.LockItemsForRead(true); |
3157 | |||
3158 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2941 | { | 3159 | { |
2942 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3160 | m_host.TaskInventory.LockItemsForRead(false); |
2943 | return; | 3161 | return; |
2944 | else | ||
2945 | item = m_host.TaskInventory[InventorySelf()]; | ||
2946 | } | 3162 | } |
3163 | else | ||
3164 | { | ||
3165 | item = m_host.TaskInventory[InventorySelf()]; | ||
3166 | } | ||
3167 | |||
3168 | m_host.TaskInventory.LockItemsForRead(false); | ||
2947 | 3169 | ||
2948 | if (item.PermsGranter != m_host.OwnerID) | 3170 | if (item.PermsGranter != m_host.OwnerID) |
2949 | return; | 3171 | return; |
@@ -2954,10 +3176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2954 | 3176 | ||
2955 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3177 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
2956 | 3178 | ||
2957 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3179 | 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 | } | 3180 | } |
2962 | } | 3181 | } |
2963 | 3182 | ||
@@ -2970,13 +3189,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2970 | 3189 | ||
2971 | TaskInventoryItem item; | 3190 | TaskInventoryItem item; |
2972 | 3191 | ||
2973 | lock (m_host.TaskInventory) | 3192 | m_host.TaskInventory.LockItemsForRead(true); |
3193 | |||
3194 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2974 | { | 3195 | { |
2975 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3196 | m_host.TaskInventory.LockItemsForRead(false); |
2976 | return; | 3197 | return; |
2977 | else | ||
2978 | item = m_host.TaskInventory[InventorySelf()]; | ||
2979 | } | 3198 | } |
3199 | else | ||
3200 | { | ||
3201 | item = m_host.TaskInventory[InventorySelf()]; | ||
3202 | } | ||
3203 | m_host.TaskInventory.LockItemsForRead(false); | ||
3204 | |||
2980 | 3205 | ||
2981 | if (item.PermsGranter != m_host.OwnerID) | 3206 | if (item.PermsGranter != m_host.OwnerID) |
2982 | return; | 3207 | return; |
@@ -3015,6 +3240,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3015 | 3240 | ||
3016 | public void llInstantMessage(string user, string message) | 3241 | public void llInstantMessage(string user, string message) |
3017 | { | 3242 | { |
3243 | UUID result; | ||
3244 | if (!UUID.TryParse(user, out result)) | ||
3245 | { | ||
3246 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3247 | ScriptSleep(2000); | ||
3248 | return; | ||
3249 | } | ||
3250 | |||
3251 | |||
3018 | m_host.AddScriptLPS(1); | 3252 | m_host.AddScriptLPS(1); |
3019 | 3253 | ||
3020 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3254 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3029,14 +3263,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3029 | UUID friendTransactionID = UUID.Random(); | 3263 | UUID friendTransactionID = UUID.Random(); |
3030 | 3264 | ||
3031 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3265 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3032 | 3266 | ||
3033 | GridInstantMessage msg = new GridInstantMessage(); | 3267 | GridInstantMessage msg = new GridInstantMessage(); |
3034 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3268 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3035 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3269 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3036 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3270 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3037 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3271 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3038 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3272 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3039 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3273 | DateTime dt = DateTime.UtcNow; |
3274 | |||
3275 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3276 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3277 | |||
3278 | try | ||
3279 | { | ||
3280 | // Convert that to the PST timezone | ||
3281 | TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3282 | dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3283 | } | ||
3284 | catch | ||
3285 | { | ||
3286 | // No logging here, as it could be VERY spammy | ||
3287 | } | ||
3288 | |||
3289 | // And make it look local again to fool the unix time util | ||
3290 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3291 | |||
3292 | msg.timestamp = (uint)Util.ToUnixTime(dt); | ||
3293 | |||
3040 | //if (client != null) | 3294 | //if (client != null) |
3041 | //{ | 3295 | //{ |
3042 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3296 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3050,13 +3304,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3050 | msg.message = message.Substring(0, 1024); | 3304 | msg.message = message.Substring(0, 1024); |
3051 | else | 3305 | else |
3052 | msg.message = message; | 3306 | msg.message = message; |
3053 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3307 | msg.dialog = (byte)19; // MessageFromObject |
3054 | msg.fromGroup = false;// fromGroup; | 3308 | msg.fromGroup = false;// fromGroup; |
3055 | msg.offline = (byte)0; //offline; | 3309 | msg.offline = (byte)0; //offline; |
3056 | msg.ParentEstateID = 0; //ParentEstateID; | 3310 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3057 | msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); | 3311 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3058 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3312 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3059 | msg.binaryBucket = new byte[0];// binaryBucket; | 3313 | msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); |
3060 | 3314 | ||
3061 | if (m_TransferModule != null) | 3315 | if (m_TransferModule != null) |
3062 | { | 3316 | { |
@@ -3076,7 +3330,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3076 | } | 3330 | } |
3077 | 3331 | ||
3078 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3332 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3079 | ScriptSleep(20000); | 3333 | ScriptSleep(15000); |
3080 | } | 3334 | } |
3081 | 3335 | ||
3082 | public void llGetNextEmail(string address, string subject) | 3336 | public void llGetNextEmail(string address, string subject) |
@@ -3178,13 +3432,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3178 | m_host.AddScriptLPS(1); | 3432 | m_host.AddScriptLPS(1); |
3179 | } | 3433 | } |
3180 | 3434 | ||
3181 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3182 | { | ||
3183 | m_host.AddScriptLPS(1); | ||
3184 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3185 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3186 | } | ||
3187 | |||
3188 | public LSL_Integer llStringLength(string str) | 3435 | public LSL_Integer llStringLength(string str) |
3189 | { | 3436 | { |
3190 | m_host.AddScriptLPS(1); | 3437 | m_host.AddScriptLPS(1); |
@@ -3208,14 +3455,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3208 | 3455 | ||
3209 | TaskInventoryItem item; | 3456 | TaskInventoryItem item; |
3210 | 3457 | ||
3211 | lock (m_host.TaskInventory) | 3458 | m_host.TaskInventory.LockItemsForRead(true); |
3459 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3212 | { | 3460 | { |
3213 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3461 | m_host.TaskInventory.LockItemsForRead(false); |
3214 | return; | 3462 | return; |
3215 | else | ||
3216 | item = m_host.TaskInventory[InventorySelf()]; | ||
3217 | } | 3463 | } |
3218 | 3464 | else | |
3465 | { | ||
3466 | item = m_host.TaskInventory[InventorySelf()]; | ||
3467 | } | ||
3468 | m_host.TaskInventory.LockItemsForRead(false); | ||
3219 | if (item.PermsGranter == UUID.Zero) | 3469 | if (item.PermsGranter == UUID.Zero) |
3220 | return; | 3470 | return; |
3221 | 3471 | ||
@@ -3245,13 +3495,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3245 | 3495 | ||
3246 | TaskInventoryItem item; | 3496 | TaskInventoryItem item; |
3247 | 3497 | ||
3248 | lock (m_host.TaskInventory) | 3498 | m_host.TaskInventory.LockItemsForRead(true); |
3499 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3249 | { | 3500 | { |
3250 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3501 | m_host.TaskInventory.LockItemsForRead(false); |
3251 | return; | 3502 | return; |
3252 | else | 3503 | } |
3253 | item = m_host.TaskInventory[InventorySelf()]; | 3504 | else |
3505 | { | ||
3506 | item = m_host.TaskInventory[InventorySelf()]; | ||
3254 | } | 3507 | } |
3508 | m_host.TaskInventory.LockItemsForRead(false); | ||
3509 | |||
3255 | 3510 | ||
3256 | if (item.PermsGranter == UUID.Zero) | 3511 | if (item.PermsGranter == UUID.Zero) |
3257 | return; | 3512 | return; |
@@ -3322,10 +3577,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3322 | 3577 | ||
3323 | TaskInventoryItem item; | 3578 | TaskInventoryItem item; |
3324 | 3579 | ||
3325 | lock (m_host.TaskInventory) | 3580 | |
3581 | m_host.TaskInventory.LockItemsForRead(true); | ||
3582 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3583 | { | ||
3584 | m_host.TaskInventory.LockItemsForRead(false); | ||
3585 | return; | ||
3586 | } | ||
3587 | else | ||
3326 | { | 3588 | { |
3327 | item = m_host.TaskInventory[invItemID]; | 3589 | item = m_host.TaskInventory[invItemID]; |
3328 | } | 3590 | } |
3591 | m_host.TaskInventory.LockItemsForRead(false); | ||
3329 | 3592 | ||
3330 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3593 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3331 | { | 3594 | { |
@@ -3357,11 +3620,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3357 | 3620 | ||
3358 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3621 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3359 | { | 3622 | { |
3360 | lock (m_host.TaskInventory) | 3623 | m_host.TaskInventory.LockItemsForWrite(true); |
3361 | { | 3624 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3362 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3625 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3363 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3626 | m_host.TaskInventory.LockItemsForWrite(false); |
3364 | } | ||
3365 | 3627 | ||
3366 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3628 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3367 | "run_time_permissions", new Object[] { | 3629 | "run_time_permissions", new Object[] { |
@@ -3381,11 +3643,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3381 | 3643 | ||
3382 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3644 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3383 | { | 3645 | { |
3384 | lock (m_host.TaskInventory) | 3646 | m_host.TaskInventory.LockItemsForWrite(true); |
3385 | { | 3647 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3386 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3648 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3387 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3649 | m_host.TaskInventory.LockItemsForWrite(false); |
3388 | } | ||
3389 | 3650 | ||
3390 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3651 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3391 | "run_time_permissions", new Object[] { | 3652 | "run_time_permissions", new Object[] { |
@@ -3406,11 +3667,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3406 | 3667 | ||
3407 | if (!m_waitingForScriptAnswer) | 3668 | if (!m_waitingForScriptAnswer) |
3408 | { | 3669 | { |
3409 | lock (m_host.TaskInventory) | 3670 | m_host.TaskInventory.LockItemsForWrite(true); |
3410 | { | 3671 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3411 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3672 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3412 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3673 | m_host.TaskInventory.LockItemsForWrite(false); |
3413 | } | ||
3414 | 3674 | ||
3415 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3675 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3416 | m_waitingForScriptAnswer=true; | 3676 | m_waitingForScriptAnswer=true; |
@@ -3445,10 +3705,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3445 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3705 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3446 | llReleaseControls(); | 3706 | llReleaseControls(); |
3447 | 3707 | ||
3448 | lock (m_host.TaskInventory) | 3708 | |
3449 | { | 3709 | m_host.TaskInventory.LockItemsForWrite(true); |
3450 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3710 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3451 | } | 3711 | m_host.TaskInventory.LockItemsForWrite(false); |
3712 | |||
3452 | 3713 | ||
3453 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3714 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3454 | "run_time_permissions", new Object[] { | 3715 | "run_time_permissions", new Object[] { |
@@ -3460,16 +3721,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3460 | { | 3721 | { |
3461 | m_host.AddScriptLPS(1); | 3722 | m_host.AddScriptLPS(1); |
3462 | 3723 | ||
3463 | lock (m_host.TaskInventory) | 3724 | m_host.TaskInventory.LockItemsForRead(true); |
3725 | |||
3726 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3464 | { | 3727 | { |
3465 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3728 | if (item.Type == 10 && item.ItemID == m_itemID) |
3466 | { | 3729 | { |
3467 | if (item.Type == 10 && item.ItemID == m_itemID) | 3730 | m_host.TaskInventory.LockItemsForRead(false); |
3468 | { | 3731 | return item.PermsGranter.ToString(); |
3469 | return item.PermsGranter.ToString(); | ||
3470 | } | ||
3471 | } | 3732 | } |
3472 | } | 3733 | } |
3734 | m_host.TaskInventory.LockItemsForRead(false); | ||
3473 | 3735 | ||
3474 | return UUID.Zero.ToString(); | 3736 | return UUID.Zero.ToString(); |
3475 | } | 3737 | } |
@@ -3478,19 +3740,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3478 | { | 3740 | { |
3479 | m_host.AddScriptLPS(1); | 3741 | m_host.AddScriptLPS(1); |
3480 | 3742 | ||
3481 | lock (m_host.TaskInventory) | 3743 | m_host.TaskInventory.LockItemsForRead(true); |
3744 | |||
3745 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3482 | { | 3746 | { |
3483 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3747 | if (item.Type == 10 && item.ItemID == m_itemID) |
3484 | { | 3748 | { |
3485 | if (item.Type == 10 && item.ItemID == m_itemID) | 3749 | int perms = item.PermsMask; |
3486 | { | 3750 | if (m_automaticLinkPermission) |
3487 | int perms = item.PermsMask; | 3751 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3488 | if (m_automaticLinkPermission) | 3752 | m_host.TaskInventory.LockItemsForRead(false); |
3489 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3753 | return perms; |
3490 | return perms; | ||
3491 | } | ||
3492 | } | 3754 | } |
3493 | } | 3755 | } |
3756 | m_host.TaskInventory.LockItemsForRead(false); | ||
3494 | 3757 | ||
3495 | return 0; | 3758 | return 0; |
3496 | } | 3759 | } |
@@ -3512,9 +3775,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3512 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3775 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3513 | { | 3776 | { |
3514 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3777 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3515 | 3778 | if (parts.Count > 0) | |
3516 | foreach (SceneObjectPart part in parts) | 3779 | { |
3517 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3780 | try |
3781 | { | ||
3782 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3783 | foreach (SceneObjectPart part in parts) | ||
3784 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3785 | } | ||
3786 | finally | ||
3787 | { | ||
3788 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3789 | } | ||
3790 | } | ||
3518 | } | 3791 | } |
3519 | 3792 | ||
3520 | public void llCreateLink(string target, int parent) | 3793 | public void llCreateLink(string target, int parent) |
@@ -3527,11 +3800,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3527 | return; | 3800 | return; |
3528 | 3801 | ||
3529 | TaskInventoryItem item; | 3802 | TaskInventoryItem item; |
3530 | lock (m_host.TaskInventory) | 3803 | m_host.TaskInventory.LockItemsForRead(true); |
3531 | { | 3804 | item = m_host.TaskInventory[invItemID]; |
3532 | item = m_host.TaskInventory[invItemID]; | 3805 | m_host.TaskInventory.LockItemsForRead(false); |
3533 | } | 3806 | |
3534 | |||
3535 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3807 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3536 | && !m_automaticLinkPermission) | 3808 | && !m_automaticLinkPermission) |
3537 | { | 3809 | { |
@@ -3584,16 +3856,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3584 | m_host.AddScriptLPS(1); | 3856 | m_host.AddScriptLPS(1); |
3585 | UUID invItemID = InventorySelf(); | 3857 | UUID invItemID = InventorySelf(); |
3586 | 3858 | ||
3587 | lock (m_host.TaskInventory) | 3859 | m_host.TaskInventory.LockItemsForRead(true); |
3588 | { | ||
3589 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3860 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3590 | && !m_automaticLinkPermission) | 3861 | && !m_automaticLinkPermission) |
3591 | { | 3862 | { |
3592 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3863 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3864 | m_host.TaskInventory.LockItemsForRead(false); | ||
3593 | return; | 3865 | return; |
3594 | } | 3866 | } |
3595 | } | 3867 | m_host.TaskInventory.LockItemsForRead(false); |
3596 | 3868 | ||
3597 | if (linknum < ScriptBaseClass.LINK_THIS) | 3869 | if (linknum < ScriptBaseClass.LINK_THIS) |
3598 | return; | 3870 | return; |
3599 | 3871 | ||
@@ -3632,10 +3904,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3632 | // Restructuring Multiple Prims. | 3904 | // Restructuring Multiple Prims. |
3633 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 3905 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3634 | parts.Remove(parentPrim.RootPart); | 3906 | parts.Remove(parentPrim.RootPart); |
3635 | foreach (SceneObjectPart part in parts) | 3907 | if (parts.Count > 0) |
3636 | { | 3908 | { |
3637 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3909 | try |
3910 | { | ||
3911 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3912 | foreach (SceneObjectPart part in parts) | ||
3913 | { | ||
3914 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3915 | } | ||
3916 | } | ||
3917 | finally | ||
3918 | { | ||
3919 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3920 | } | ||
3638 | } | 3921 | } |
3922 | |||
3639 | parentPrim.HasGroupChanged = true; | 3923 | parentPrim.HasGroupChanged = true; |
3640 | parentPrim.ScheduleGroupForFullUpdate(); | 3924 | parentPrim.ScheduleGroupForFullUpdate(); |
3641 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3925 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3644,11 +3928,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3644 | { | 3928 | { |
3645 | SceneObjectPart newRoot = parts[0]; | 3929 | SceneObjectPart newRoot = parts[0]; |
3646 | parts.Remove(newRoot); | 3930 | parts.Remove(newRoot); |
3647 | foreach (SceneObjectPart part in parts) | 3931 | |
3932 | try | ||
3648 | { | 3933 | { |
3649 | part.UpdateFlag = 0; | 3934 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3650 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3935 | foreach (SceneObjectPart part in parts) |
3936 | { | ||
3937 | part.UpdateFlag = 0; | ||
3938 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3939 | } | ||
3651 | } | 3940 | } |
3941 | finally | ||
3942 | { | ||
3943 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3944 | } | ||
3945 | |||
3946 | |||
3652 | newRoot.ParentGroup.HasGroupChanged = true; | 3947 | newRoot.ParentGroup.HasGroupChanged = true; |
3653 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3948 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3654 | } | 3949 | } |
@@ -3694,6 +3989,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3694 | } | 3989 | } |
3695 | else | 3990 | else |
3696 | { | 3991 | { |
3992 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
3993 | { | ||
3994 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
3995 | |||
3996 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
3997 | if (avatars.Count > linknum) | ||
3998 | { | ||
3999 | return avatars[linknum].UUID.ToString(); | ||
4000 | } | ||
4001 | } | ||
3697 | return UUID.Zero.ToString(); | 4002 | return UUID.Zero.ToString(); |
3698 | } | 4003 | } |
3699 | } | 4004 | } |
@@ -3770,17 +4075,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3770 | m_host.AddScriptLPS(1); | 4075 | m_host.AddScriptLPS(1); |
3771 | int count = 0; | 4076 | int count = 0; |
3772 | 4077 | ||
3773 | lock (m_host.TaskInventory) | 4078 | m_host.TaskInventory.LockItemsForRead(true); |
4079 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3774 | { | 4080 | { |
3775 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4081 | if (inv.Value.Type == type || type == -1) |
3776 | { | 4082 | { |
3777 | if (inv.Value.Type == type || type == -1) | 4083 | count = count + 1; |
3778 | { | ||
3779 | count = count + 1; | ||
3780 | } | ||
3781 | } | 4084 | } |
3782 | } | 4085 | } |
3783 | 4086 | ||
4087 | m_host.TaskInventory.LockItemsForRead(false); | ||
3784 | return count; | 4088 | return count; |
3785 | } | 4089 | } |
3786 | 4090 | ||
@@ -3789,16 +4093,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3789 | m_host.AddScriptLPS(1); | 4093 | m_host.AddScriptLPS(1); |
3790 | ArrayList keys = new ArrayList(); | 4094 | ArrayList keys = new ArrayList(); |
3791 | 4095 | ||
3792 | lock (m_host.TaskInventory) | 4096 | m_host.TaskInventory.LockItemsForRead(true); |
4097 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3793 | { | 4098 | { |
3794 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4099 | if (inv.Value.Type == type || type == -1) |
3795 | { | 4100 | { |
3796 | if (inv.Value.Type == type || type == -1) | 4101 | keys.Add(inv.Value.Name); |
3797 | { | ||
3798 | keys.Add(inv.Value.Name); | ||
3799 | } | ||
3800 | } | 4102 | } |
3801 | } | 4103 | } |
4104 | m_host.TaskInventory.LockItemsForRead(false); | ||
3802 | 4105 | ||
3803 | if (keys.Count == 0) | 4106 | if (keys.Count == 0) |
3804 | { | 4107 | { |
@@ -3835,20 +4138,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3835 | } | 4138 | } |
3836 | 4139 | ||
3837 | // move the first object found with this inventory name | 4140 | // move the first object found with this inventory name |
3838 | lock (m_host.TaskInventory) | 4141 | m_host.TaskInventory.LockItemsForRead(true); |
4142 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3839 | { | 4143 | { |
3840 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4144 | if (inv.Value.Name == inventory) |
3841 | { | 4145 | { |
3842 | if (inv.Value.Name == inventory) | 4146 | found = true; |
3843 | { | 4147 | objId = inv.Key; |
3844 | found = true; | 4148 | assetType = inv.Value.Type; |
3845 | objId = inv.Key; | 4149 | objName = inv.Value.Name; |
3846 | assetType = inv.Value.Type; | 4150 | break; |
3847 | objName = inv.Value.Name; | ||
3848 | break; | ||
3849 | } | ||
3850 | } | 4151 | } |
3851 | } | 4152 | } |
4153 | m_host.TaskInventory.LockItemsForRead(false); | ||
3852 | 4154 | ||
3853 | if (!found) | 4155 | if (!found) |
3854 | { | 4156 | { |
@@ -3856,9 +4158,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3856 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4158 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3857 | } | 4159 | } |
3858 | 4160 | ||
3859 | // check if destination is an avatar | 4161 | // check if destination is an object |
3860 | if (World.GetScenePresence(destId) != null) | 4162 | if (World.GetSceneObjectPart(destId) != null) |
4163 | { | ||
4164 | // destination is an object | ||
4165 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4166 | } | ||
4167 | else | ||
3861 | { | 4168 | { |
4169 | ScenePresence presence = World.GetScenePresence(destId); | ||
4170 | |||
4171 | if (presence == null) | ||
4172 | { | ||
4173 | UserAccount account = | ||
4174 | World.UserAccountService.GetUserAccount( | ||
4175 | World.RegionInfo.ScopeID, | ||
4176 | destId); | ||
4177 | |||
4178 | if (account == null) | ||
4179 | { | ||
4180 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4181 | return; | ||
4182 | } | ||
4183 | } | ||
4184 | |||
3862 | // destination is an avatar | 4185 | // destination is an avatar |
3863 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4186 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3864 | 4187 | ||
@@ -3882,31 +4205,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3882 | 4205 | ||
3883 | if (m_TransferModule != null) | 4206 | if (m_TransferModule != null) |
3884 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4207 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4208 | |||
4209 | //This delay should only occur when giving inventory to avatars. | ||
4210 | ScriptSleep(3000); | ||
3885 | } | 4211 | } |
3886 | else | ||
3887 | { | ||
3888 | // destination is an object | ||
3889 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3890 | } | ||
3891 | ScriptSleep(3000); | ||
3892 | } | 4212 | } |
3893 | 4213 | ||
4214 | [DebuggerNonUserCode] | ||
3894 | public void llRemoveInventory(string name) | 4215 | public void llRemoveInventory(string name) |
3895 | { | 4216 | { |
3896 | m_host.AddScriptLPS(1); | 4217 | m_host.AddScriptLPS(1); |
3897 | 4218 | ||
3898 | lock (m_host.TaskInventory) | 4219 | List<TaskInventoryItem> inv; |
4220 | try | ||
3899 | { | 4221 | { |
3900 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4222 | m_host.TaskInventory.LockItemsForRead(true); |
4223 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | ||
4224 | } | ||
4225 | finally | ||
4226 | { | ||
4227 | m_host.TaskInventory.LockItemsForRead(false); | ||
4228 | } | ||
4229 | foreach (TaskInventoryItem item in inv) | ||
4230 | { | ||
4231 | if (item.Name == name) | ||
3901 | { | 4232 | { |
3902 | if (item.Name == name) | 4233 | if (item.ItemID == m_itemID) |
3903 | { | 4234 | throw new ScriptDeleteException(); |
3904 | if (item.ItemID == m_itemID) | 4235 | else |
3905 | throw new ScriptDeleteException(); | 4236 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3906 | else | 4237 | return; |
3907 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
3908 | return; | ||
3909 | } | ||
3910 | } | 4238 | } |
3911 | } | 4239 | } |
3912 | } | 4240 | } |
@@ -3972,6 +4300,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3972 | ce.time = Util.EnvironmentTickCount(); | 4300 | ce.time = Util.EnvironmentTickCount(); |
3973 | ce.account = account; | 4301 | ce.account = account; |
3974 | ce.pinfo = pinfo; | 4302 | ce.pinfo = pinfo; |
4303 | m_userInfoCache[uuid] = ce; | ||
3975 | } | 4304 | } |
3976 | else | 4305 | else |
3977 | { | 4306 | { |
@@ -4047,6 +4376,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4047 | { | 4376 | { |
4048 | m_host.AddScriptLPS(1); | 4377 | m_host.AddScriptLPS(1); |
4049 | 4378 | ||
4379 | //Clone is thread safe | ||
4050 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4380 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
4051 | 4381 | ||
4052 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4382 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4100,6 +4430,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4100 | ScenePresence presence = World.GetScenePresence(agentId); | 4430 | ScenePresence presence = World.GetScenePresence(agentId); |
4101 | if (presence != null) | 4431 | if (presence != null) |
4102 | { | 4432 | { |
4433 | // agent must not be a god | ||
4434 | if (presence.GodLevel >= 200) return; | ||
4435 | |||
4103 | // agent must be over the owners land | 4436 | // agent must be over the owners land |
4104 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4437 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4105 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4438 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4159,17 +4492,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4159 | UUID soundId = UUID.Zero; | 4492 | UUID soundId = UUID.Zero; |
4160 | if (!UUID.TryParse(impact_sound, out soundId)) | 4493 | if (!UUID.TryParse(impact_sound, out soundId)) |
4161 | { | 4494 | { |
4162 | lock (m_host.TaskInventory) | 4495 | m_host.TaskInventory.LockItemsForRead(true); |
4496 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4163 | { | 4497 | { |
4164 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4498 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4165 | { | 4499 | { |
4166 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4500 | soundId = item.AssetID; |
4167 | { | 4501 | break; |
4168 | soundId = item.AssetID; | ||
4169 | break; | ||
4170 | } | ||
4171 | } | 4502 | } |
4172 | } | 4503 | } |
4504 | m_host.TaskInventory.LockItemsForRead(false); | ||
4173 | } | 4505 | } |
4174 | m_host.CollisionSound = soundId; | 4506 | m_host.CollisionSound = soundId; |
4175 | m_host.CollisionSoundVolume = (float)impact_volume; | 4507 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4215,6 +4547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4215 | UUID partItemID; | 4547 | UUID partItemID; |
4216 | foreach (SceneObjectPart part in parts) | 4548 | foreach (SceneObjectPart part in parts) |
4217 | { | 4549 | { |
4550 | //Clone is thread safe | ||
4218 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4551 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4219 | 4552 | ||
4220 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4553 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4429,17 +4762,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4429 | 4762 | ||
4430 | m_host.AddScriptLPS(1); | 4763 | m_host.AddScriptLPS(1); |
4431 | 4764 | ||
4432 | lock (m_host.TaskInventory) | 4765 | m_host.TaskInventory.LockItemsForRead(true); |
4766 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4433 | { | 4767 | { |
4434 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4768 | if (item.Type == 10 && item.ItemID == m_itemID) |
4435 | { | 4769 | { |
4436 | if (item.Type == 10 && item.ItemID == m_itemID) | 4770 | result = item.Name!=null?item.Name:String.Empty; |
4437 | { | 4771 | break; |
4438 | result = item.Name != null ? item.Name : String.Empty; | ||
4439 | break; | ||
4440 | } | ||
4441 | } | 4772 | } |
4442 | } | 4773 | } |
4774 | m_host.TaskInventory.LockItemsForRead(false); | ||
4443 | 4775 | ||
4444 | return result; | 4776 | return result; |
4445 | } | 4777 | } |
@@ -4592,23 +4924,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4592 | { | 4924 | { |
4593 | m_host.AddScriptLPS(1); | 4925 | m_host.AddScriptLPS(1); |
4594 | 4926 | ||
4595 | lock (m_host.TaskInventory) | 4927 | m_host.TaskInventory.LockItemsForRead(true); |
4928 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4596 | { | 4929 | { |
4597 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4930 | if (inv.Value.Name == name) |
4598 | { | 4931 | { |
4599 | if (inv.Value.Name == name) | 4932 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4600 | { | 4933 | { |
4601 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4934 | m_host.TaskInventory.LockItemsForRead(false); |
4602 | { | 4935 | return inv.Value.AssetID.ToString(); |
4603 | return inv.Value.AssetID.ToString(); | 4936 | } |
4604 | } | 4937 | else |
4605 | else | 4938 | { |
4606 | { | 4939 | m_host.TaskInventory.LockItemsForRead(false); |
4607 | return UUID.Zero.ToString(); | 4940 | return UUID.Zero.ToString(); |
4608 | } | ||
4609 | } | 4941 | } |
4610 | } | 4942 | } |
4611 | } | 4943 | } |
4944 | m_host.TaskInventory.LockItemsForRead(false); | ||
4612 | 4945 | ||
4613 | return UUID.Zero.ToString(); | 4946 | return UUID.Zero.ToString(); |
4614 | } | 4947 | } |
@@ -4761,14 +5094,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4761 | { | 5094 | { |
4762 | m_host.AddScriptLPS(1); | 5095 | m_host.AddScriptLPS(1); |
4763 | 5096 | ||
4764 | if (src == null) | 5097 | return src.Length; |
4765 | { | ||
4766 | return 0; | ||
4767 | } | ||
4768 | else | ||
4769 | { | ||
4770 | return src.Length; | ||
4771 | } | ||
4772 | } | 5098 | } |
4773 | 5099 | ||
4774 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5100 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -4814,7 +5140,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4814 | else if (src.Data[index] is LSL_Float) | 5140 | else if (src.Data[index] is LSL_Float) |
4815 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5141 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
4816 | else if (src.Data[index] is LSL_String) | 5142 | else if (src.Data[index] is LSL_String) |
4817 | return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); | 5143 | { |
5144 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5145 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5146 | if (m != Match.Empty) | ||
5147 | { | ||
5148 | str = m.Value; | ||
5149 | double d = 0.0; | ||
5150 | if (!Double.TryParse(str, out d)) | ||
5151 | return 0.0; | ||
5152 | |||
5153 | return d; | ||
5154 | } | ||
5155 | return 0.0; | ||
5156 | } | ||
4818 | return Convert.ToDouble(src.Data[index]); | 5157 | return Convert.ToDouble(src.Data[index]); |
4819 | } | 5158 | } |
4820 | catch (FormatException) | 5159 | catch (FormatException) |
@@ -5499,7 +5838,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5499 | public void llSetSoundQueueing(int queue) | 5838 | public void llSetSoundQueueing(int queue) |
5500 | { | 5839 | { |
5501 | m_host.AddScriptLPS(1); | 5840 | m_host.AddScriptLPS(1); |
5502 | NotImplemented("llSetSoundQueueing"); | ||
5503 | } | 5841 | } |
5504 | 5842 | ||
5505 | public void llSetSoundRadius(double radius) | 5843 | public void llSetSoundRadius(double radius) |
@@ -5544,10 +5882,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5544 | m_host.AddScriptLPS(1); | 5882 | m_host.AddScriptLPS(1); |
5545 | 5883 | ||
5546 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5884 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5547 | 5885 | if (parts.Count > 0) | |
5548 | foreach (var part in parts) | ||
5549 | { | 5886 | { |
5550 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5887 | try |
5888 | { | ||
5889 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5890 | foreach (var part in parts) | ||
5891 | { | ||
5892 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5893 | } | ||
5894 | } | ||
5895 | finally | ||
5896 | { | ||
5897 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5898 | } | ||
5551 | } | 5899 | } |
5552 | } | 5900 | } |
5553 | 5901 | ||
@@ -5601,6 +5949,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5601 | ScriptSleep(5000); | 5949 | ScriptSleep(5000); |
5602 | } | 5950 | } |
5603 | 5951 | ||
5952 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5953 | { | ||
5954 | return ParseString2List(str, separators, in_spacers, false); | ||
5955 | } | ||
5956 | |||
5604 | public LSL_Integer llOverMyLand(string id) | 5957 | public LSL_Integer llOverMyLand(string id) |
5605 | { | 5958 | { |
5606 | m_host.AddScriptLPS(1); | 5959 | m_host.AddScriptLPS(1); |
@@ -5801,7 +6154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5801 | return m_host.ParentGroup.RootPart.AttachmentPoint; | 6154 | return m_host.ParentGroup.RootPart.AttachmentPoint; |
5802 | } | 6155 | } |
5803 | 6156 | ||
5804 | public LSL_Integer llGetFreeMemory() | 6157 | public virtual LSL_Integer llGetFreeMemory() |
5805 | { | 6158 | { |
5806 | m_host.AddScriptLPS(1); | 6159 | m_host.AddScriptLPS(1); |
5807 | // Make scripts designed for LSO happy | 6160 | // Make scripts designed for LSO happy |
@@ -6112,14 +6465,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6112 | 6465 | ||
6113 | protected UUID GetTaskInventoryItem(string name) | 6466 | protected UUID GetTaskInventoryItem(string name) |
6114 | { | 6467 | { |
6115 | lock (m_host.TaskInventory) | 6468 | m_host.TaskInventory.LockItemsForRead(true); |
6469 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6116 | { | 6470 | { |
6117 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6471 | if (inv.Value.Name == name) |
6118 | { | 6472 | { |
6119 | if (inv.Value.Name == name) | 6473 | m_host.TaskInventory.LockItemsForRead(false); |
6120 | return inv.Key; | 6474 | return inv.Key; |
6121 | } | 6475 | } |
6122 | } | 6476 | } |
6477 | m_host.TaskInventory.LockItemsForRead(false); | ||
6123 | 6478 | ||
6124 | return UUID.Zero; | 6479 | return UUID.Zero; |
6125 | } | 6480 | } |
@@ -6447,22 +6802,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6447 | } | 6802 | } |
6448 | 6803 | ||
6449 | // copy the first script found with this inventory name | 6804 | // copy the first script found with this inventory name |
6450 | lock (m_host.TaskInventory) | 6805 | m_host.TaskInventory.LockItemsForRead(true); |
6806 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6451 | { | 6807 | { |
6452 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6808 | if (inv.Value.Name == name) |
6453 | { | 6809 | { |
6454 | if (inv.Value.Name == name) | 6810 | // make sure the object is a script |
6811 | if (10 == inv.Value.Type) | ||
6455 | { | 6812 | { |
6456 | // make sure the object is a script | 6813 | found = true; |
6457 | if (10 == inv.Value.Type) | 6814 | srcId = inv.Key; |
6458 | { | 6815 | break; |
6459 | found = true; | ||
6460 | srcId = inv.Key; | ||
6461 | break; | ||
6462 | } | ||
6463 | } | 6816 | } |
6464 | } | 6817 | } |
6465 | } | 6818 | } |
6819 | m_host.TaskInventory.LockItemsForRead(false); | ||
6466 | 6820 | ||
6467 | if (!found) | 6821 | if (!found) |
6468 | { | 6822 | { |
@@ -6546,6 +6900,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6546 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6900 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6547 | { | 6901 | { |
6548 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6902 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6903 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6904 | return shapeBlock; | ||
6549 | 6905 | ||
6550 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6906 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6551 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6907 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6621,6 +6977,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6621 | 6977 | ||
6622 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6978 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6623 | { | 6979 | { |
6980 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6981 | return; | ||
6982 | |||
6624 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6983 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6625 | 6984 | ||
6626 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6985 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6670,6 +7029,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6670 | 7029 | ||
6671 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 7030 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6672 | { | 7031 | { |
7032 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7033 | return; | ||
7034 | |||
6673 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7035 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6674 | 7036 | ||
6675 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7037 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6712,6 +7074,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6712 | 7074 | ||
6713 | 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) | 7075 | 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) |
6714 | { | 7076 | { |
7077 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7078 | return; | ||
7079 | |||
6715 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7080 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6716 | 7081 | ||
6717 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7082 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6838,6 +7203,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6838 | 7203 | ||
6839 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7204 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6840 | { | 7205 | { |
7206 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7207 | return; | ||
7208 | |||
6841 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7209 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6842 | UUID sculptId; | 7210 | UUID sculptId; |
6843 | 7211 | ||
@@ -6853,13 +7221,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6853 | shapeBlock.PathScaleX = 100; | 7221 | shapeBlock.PathScaleX = 100; |
6854 | shapeBlock.PathScaleY = 150; | 7222 | shapeBlock.PathScaleY = 150; |
6855 | 7223 | ||
6856 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7224 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6857 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7225 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6858 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7226 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6859 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7227 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6860 | { | 7228 | { |
6861 | // default | 7229 | // default |
6862 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7230 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6863 | } | 7231 | } |
6864 | 7232 | ||
6865 | // retain pathcurve | 7233 | // retain pathcurve |
@@ -6878,25 +7246,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6878 | ScriptSleep(200); | 7246 | ScriptSleep(200); |
6879 | } | 7247 | } |
6880 | 7248 | ||
6881 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7249 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
6882 | { | 7250 | { |
6883 | m_host.AddScriptLPS(1); | 7251 | m_host.AddScriptLPS(1); |
6884 | 7252 | ||
6885 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7253 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
7254 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7255 | if (parts.Count>0) | ||
7256 | { | ||
7257 | try | ||
7258 | { | ||
7259 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7260 | foreach (SceneObjectPart part in parts) | ||
7261 | SetPrimParams(part, rules); | ||
7262 | } | ||
7263 | finally | ||
7264 | { | ||
7265 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7266 | } | ||
7267 | } | ||
7268 | if (avatars.Count > 0) | ||
7269 | { | ||
7270 | foreach (ScenePresence avatar in avatars) | ||
7271 | SetPrimParams(avatar, rules); | ||
7272 | } | ||
7273 | } | ||
6886 | 7274 | ||
6887 | foreach (SceneObjectPart part in parts) | 7275 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6888 | SetPrimParams(part, rules); | 7276 | { |
6889 | 7277 | llSetLinkPrimitiveParamsFast(linknumber, rules); | |
6890 | ScriptSleep(200); | 7278 | ScriptSleep(200); |
6891 | } | 7279 | } |
6892 | 7280 | ||
6893 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7281 | protected void SetPrimParams(ScenePresence av, LSL_List rules) |
6894 | { | 7282 | { |
6895 | llSetLinkPrimitiveParams(linknumber, rules); | 7283 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7284 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
7285 | |||
7286 | int idx = 0; | ||
7287 | |||
7288 | while (idx < rules.Length) | ||
7289 | { | ||
7290 | int code = rules.GetLSLIntegerItem(idx++); | ||
7291 | |||
7292 | int remain = rules.Length - idx; | ||
7293 | |||
7294 | |||
7295 | |||
7296 | switch (code) | ||
7297 | { | ||
7298 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7299 | if (remain < 1) | ||
7300 | return; | ||
7301 | LSL_Vector v; | ||
7302 | v = rules.GetVector3Item(idx++); | ||
7303 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7304 | av.SendFullUpdateToAllClients(); | ||
7305 | |||
7306 | break; | ||
7307 | |||
7308 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7309 | if (remain < 1) | ||
7310 | return; | ||
7311 | LSL_Rotation r; | ||
7312 | r = rules.GetQuaternionItem(idx++); | ||
7313 | av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7314 | av.SendFullUpdateToAllClients(); | ||
7315 | break; | ||
7316 | } | ||
7317 | } | ||
7318 | |||
6896 | } | 7319 | } |
6897 | 7320 | ||
6898 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7321 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6899 | { | 7322 | { |
7323 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7324 | return; | ||
7325 | |||
6900 | int idx = 0; | 7326 | int idx = 0; |
6901 | 7327 | ||
6902 | while (idx < rules.Length) | 7328 | while (idx < rules.Length) |
@@ -7413,13 +7839,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7413 | public LSL_Integer llGetNumberOfPrims() | 7839 | public LSL_Integer llGetNumberOfPrims() |
7414 | { | 7840 | { |
7415 | m_host.AddScriptLPS(1); | 7841 | m_host.AddScriptLPS(1); |
7416 | int avatarCount = 0; | 7842 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; |
7417 | World.ForEachScenePresence(delegate(ScenePresence presence) | 7843 | |
7418 | { | ||
7419 | if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | ||
7420 | avatarCount++; | ||
7421 | }); | ||
7422 | |||
7423 | return m_host.ParentGroup.PrimCount + avatarCount; | 7844 | return m_host.ParentGroup.PrimCount + avatarCount; |
7424 | } | 7845 | } |
7425 | 7846 | ||
@@ -7435,55 +7856,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7435 | m_host.AddScriptLPS(1); | 7856 | m_host.AddScriptLPS(1); |
7436 | UUID objID = UUID.Zero; | 7857 | UUID objID = UUID.Zero; |
7437 | LSL_List result = new LSL_List(); | 7858 | LSL_List result = new LSL_List(); |
7859 | |||
7860 | // If the ID is not valid, return null result | ||
7438 | if (!UUID.TryParse(obj, out objID)) | 7861 | if (!UUID.TryParse(obj, out objID)) |
7439 | { | 7862 | { |
7440 | result.Add(new LSL_Vector()); | 7863 | result.Add(new LSL_Vector()); |
7441 | result.Add(new LSL_Vector()); | 7864 | result.Add(new LSL_Vector()); |
7442 | return result; | 7865 | return result; |
7443 | } | 7866 | } |
7867 | |||
7868 | // Check if this is an attached prim. If so, replace | ||
7869 | // the UUID with the avatar UUID and report it's bounding box | ||
7870 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
7871 | if (part != null && part.ParentGroup.IsAttachment) | ||
7872 | objID = part.ParentGroup.RootPart.AttachedAvatar; | ||
7873 | |||
7874 | // Find out if this is an avatar ID. If so, return it's box | ||
7444 | ScenePresence presence = World.GetScenePresence(objID); | 7875 | ScenePresence presence = World.GetScenePresence(objID); |
7445 | if (presence != null) | 7876 | if (presence != null) |
7446 | { | 7877 | { |
7447 | if (presence.ParentID == 0) // not sat on an object | 7878 | // As per LSL Wiki, there is no difference between sitting |
7879 | // and standing avatar since server 1.36 | ||
7880 | LSL_Vector lower; | ||
7881 | LSL_Vector upper; | ||
7882 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
7883 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7448 | { | 7884 | { |
7449 | LSL_Vector lower; | 7885 | // This is for ground sitting avatars |
7450 | LSL_Vector upper; | 7886 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7451 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7887 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7452 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7888 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7453 | { | ||
7454 | // This is for ground sitting avatars | ||
7455 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7456 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7457 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7458 | } | ||
7459 | else | ||
7460 | { | ||
7461 | // This is for standing/flying avatars | ||
7462 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7463 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7464 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7465 | } | ||
7466 | result.Add(lower); | ||
7467 | result.Add(upper); | ||
7468 | return result; | ||
7469 | } | 7889 | } |
7470 | else | 7890 | else |
7471 | { | 7891 | { |
7472 | // sitting on an object so we need the bounding box of that | 7892 | // This is for standing/flying avatars |
7473 | // which should include the avatar so set the UUID to the | 7893 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7474 | // UUID of the object the avatar is sat on and allow it to fall through | 7894 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7475 | // to processing an object | 7895 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7476 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7477 | objID = p.UUID; | ||
7478 | } | 7896 | } |
7897 | |||
7898 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7899 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7900 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7901 | |||
7902 | if (lower.x > upper.x) | ||
7903 | lower.x = upper.x; | ||
7904 | if (lower.y > upper.y) | ||
7905 | lower.y = upper.y; | ||
7906 | if (lower.z > upper.z) | ||
7907 | lower.z = upper.z; | ||
7908 | |||
7909 | result.Add(lower); | ||
7910 | result.Add(upper); | ||
7911 | return result; | ||
7479 | } | 7912 | } |
7480 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 7913 | |
7914 | part = World.GetSceneObjectPart(objID); | ||
7481 | // Currently only works for single prims without a sitting avatar | 7915 | // Currently only works for single prims without a sitting avatar |
7482 | if (part != null) | 7916 | if (part != null) |
7483 | { | 7917 | { |
7484 | Vector3 halfSize = part.Scale / 2.0f; | 7918 | float minX; |
7485 | LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); | 7919 | float maxX; |
7486 | LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); | 7920 | float minY; |
7921 | float maxY; | ||
7922 | float minZ; | ||
7923 | float maxZ; | ||
7924 | |||
7925 | // This BBox is in sim coordinates, with the offset being | ||
7926 | // a contained point. | ||
7927 | Vector3[] offsets = World.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
7928 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
7929 | |||
7930 | minX -= offsets[0].X; | ||
7931 | maxX -= offsets[0].X; | ||
7932 | minY -= offsets[0].Y; | ||
7933 | maxY -= offsets[0].Y; | ||
7934 | minZ -= offsets[0].Z; | ||
7935 | maxZ -= offsets[0].Z; | ||
7936 | |||
7937 | LSL_Vector lower; | ||
7938 | LSL_Vector upper; | ||
7939 | |||
7940 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7941 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
7942 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
7943 | |||
7944 | if (lower.x > upper.x) | ||
7945 | lower.x = upper.x; | ||
7946 | if (lower.y > upper.y) | ||
7947 | lower.y = upper.y; | ||
7948 | if (lower.z > upper.z) | ||
7949 | lower.z = upper.z; | ||
7950 | |||
7487 | result.Add(lower); | 7951 | result.Add(lower); |
7488 | result.Add(upper); | 7952 | result.Add(upper); |
7489 | return result; | 7953 | return result; |
@@ -7728,24 +8192,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7728 | break; | 8192 | break; |
7729 | 8193 | ||
7730 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8194 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7731 | // TODO-------------- | ||
7732 | if (remain < 1) | 8195 | if (remain < 1) |
7733 | return res; | 8196 | return res; |
8197 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7734 | 8198 | ||
7735 | face=(int)rules.GetLSLIntegerItem(idx++); | 8199 | tex = part.Shape.Textures; |
7736 | 8200 | int shiny; | |
7737 | res.Add(new LSL_Integer(0)); | 8201 | if (face == ScriptBaseClass.ALL_SIDES) |
7738 | res.Add(new LSL_Integer(0)); | 8202 | { |
8203 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8204 | { | ||
8205 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8206 | if (shinyness == Shininess.High) | ||
8207 | { | ||
8208 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8209 | } | ||
8210 | else if (shinyness == Shininess.Medium) | ||
8211 | { | ||
8212 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8213 | } | ||
8214 | else if (shinyness == Shininess.Low) | ||
8215 | { | ||
8216 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8217 | } | ||
8218 | else | ||
8219 | { | ||
8220 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8221 | } | ||
8222 | res.Add(new LSL_Integer(shiny)); | ||
8223 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8224 | } | ||
8225 | } | ||
8226 | else | ||
8227 | { | ||
8228 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8229 | if (shinyness == Shininess.High) | ||
8230 | { | ||
8231 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8232 | } | ||
8233 | else if (shinyness == Shininess.Medium) | ||
8234 | { | ||
8235 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8236 | } | ||
8237 | else if (shinyness == Shininess.Low) | ||
8238 | { | ||
8239 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8240 | } | ||
8241 | else | ||
8242 | { | ||
8243 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8244 | } | ||
8245 | res.Add(new LSL_Integer(shiny)); | ||
8246 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8247 | } | ||
7739 | break; | 8248 | break; |
7740 | 8249 | ||
7741 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8250 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7742 | // TODO-------------- | ||
7743 | if (remain < 1) | 8251 | if (remain < 1) |
7744 | return res; | 8252 | return res; |
8253 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7745 | 8254 | ||
7746 | face=(int)rules.GetLSLIntegerItem(idx++); | 8255 | tex = part.Shape.Textures; |
7747 | 8256 | int fullbright; | |
7748 | res.Add(new LSL_Integer(0)); | 8257 | if (face == ScriptBaseClass.ALL_SIDES) |
8258 | { | ||
8259 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8260 | { | ||
8261 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8262 | { | ||
8263 | fullbright = ScriptBaseClass.TRUE; | ||
8264 | } | ||
8265 | else | ||
8266 | { | ||
8267 | fullbright = ScriptBaseClass.FALSE; | ||
8268 | } | ||
8269 | res.Add(new LSL_Integer(fullbright)); | ||
8270 | } | ||
8271 | } | ||
8272 | else | ||
8273 | { | ||
8274 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8275 | { | ||
8276 | fullbright = ScriptBaseClass.TRUE; | ||
8277 | } | ||
8278 | else | ||
8279 | { | ||
8280 | fullbright = ScriptBaseClass.FALSE; | ||
8281 | } | ||
8282 | res.Add(new LSL_Integer(fullbright)); | ||
8283 | } | ||
7749 | break; | 8284 | break; |
7750 | 8285 | ||
7751 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8286 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7766,14 +8301,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7766 | break; | 8301 | break; |
7767 | 8302 | ||
7768 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8303 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7769 | // TODO-------------- | ||
7770 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8304 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7771 | if (remain < 1) | 8305 | if (remain < 1) |
7772 | return res; | 8306 | return res; |
8307 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7773 | 8308 | ||
7774 | face=(int)rules.GetLSLIntegerItem(idx++); | 8309 | tex = part.Shape.Textures; |
7775 | 8310 | if (face == ScriptBaseClass.ALL_SIDES) | |
7776 | res.Add(new LSL_Integer(0)); | 8311 | { |
8312 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8313 | { | ||
8314 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8315 | { | ||
8316 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8317 | } | ||
8318 | else | ||
8319 | { | ||
8320 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8321 | } | ||
8322 | } | ||
8323 | } | ||
8324 | else | ||
8325 | { | ||
8326 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8327 | { | ||
8328 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8329 | } | ||
8330 | else | ||
8331 | { | ||
8332 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8333 | } | ||
8334 | } | ||
7777 | break; | 8335 | break; |
7778 | 8336 | ||
7779 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8337 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7792,13 +8350,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7792 | break; | 8350 | break; |
7793 | 8351 | ||
7794 | case (int)ScriptBaseClass.PRIM_GLOW: | 8352 | case (int)ScriptBaseClass.PRIM_GLOW: |
7795 | // TODO-------------- | ||
7796 | if (remain < 1) | 8353 | if (remain < 1) |
7797 | return res; | 8354 | return res; |
8355 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7798 | 8356 | ||
7799 | face=(int)rules.GetLSLIntegerItem(idx++); | 8357 | tex = part.Shape.Textures; |
7800 | 8358 | float primglow; | |
7801 | res.Add(new LSL_Float(0)); | 8359 | if (face == ScriptBaseClass.ALL_SIDES) |
8360 | { | ||
8361 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8362 | { | ||
8363 | primglow = tex.GetFace((uint)face).Glow; | ||
8364 | res.Add(new LSL_Float(primglow)); | ||
8365 | } | ||
8366 | } | ||
8367 | else | ||
8368 | { | ||
8369 | primglow = tex.GetFace((uint)face).Glow; | ||
8370 | res.Add(new LSL_Float(primglow)); | ||
8371 | } | ||
7802 | break; | 8372 | break; |
7803 | case (int)ScriptBaseClass.PRIM_TEXT: | 8373 | case (int)ScriptBaseClass.PRIM_TEXT: |
7804 | Color4 textColor = part.GetTextColor(); | 8374 | Color4 textColor = part.GetTextColor(); |
@@ -8339,8 +8909,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8339 | // The function returns an ordered list | 8909 | // The function returns an ordered list |
8340 | // representing the tokens found in the supplied | 8910 | // representing the tokens found in the supplied |
8341 | // sources string. If two successive tokenizers | 8911 | // sources string. If two successive tokenizers |
8342 | // are encountered, then a NULL entry is added | 8912 | // are encountered, then a null-string entry is |
8343 | // to the list. | 8913 | // added to the list. |
8344 | // | 8914 | // |
8345 | // It is a precondition that the source and | 8915 | // It is a precondition that the source and |
8346 | // toekizer lisst are non-null. If they are null, | 8916 | // toekizer lisst are non-null. If they are null, |
@@ -8348,7 +8918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8348 | // while their lengths are being determined. | 8918 | // while their lengths are being determined. |
8349 | // | 8919 | // |
8350 | // A small amount of working memoryis required | 8920 | // A small amount of working memoryis required |
8351 | // of approximately 8*#tokenizers. | 8921 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8352 | // | 8922 | // |
8353 | // There are many ways in which this function | 8923 | // There are many ways in which this function |
8354 | // can be implemented, this implementation is | 8924 | // can be implemented, this implementation is |
@@ -8364,155 +8934,111 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8364 | // and eliminates redundant tokenizers as soon | 8934 | // and eliminates redundant tokenizers as soon |
8365 | // as is possible. | 8935 | // as is possible. |
8366 | // | 8936 | // |
8367 | // The implementation tries to avoid any copying | 8937 | // The implementation tries to minimize temporary |
8368 | // of arrays or other objects. | 8938 | // garbage generation. |
8369 | // </remarks> | 8939 | // </remarks> |
8370 | 8940 | ||
8371 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 8941 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8372 | { | 8942 | { |
8373 | int beginning = 0; | 8943 | return ParseString2List(src, separators, spacers, true); |
8374 | int srclen = src.Length; | 8944 | } |
8375 | int seplen = separators.Length; | ||
8376 | object[] separray = separators.Data; | ||
8377 | int spclen = spacers.Length; | ||
8378 | object[] spcarray = spacers.Data; | ||
8379 | int mlen = seplen+spclen; | ||
8380 | |||
8381 | int[] offset = new int[mlen+1]; | ||
8382 | bool[] active = new bool[mlen]; | ||
8383 | |||
8384 | int best; | ||
8385 | int j; | ||
8386 | |||
8387 | // Initial capacity reduces resize cost | ||
8388 | |||
8389 | LSL_List tokens = new LSL_List(); | ||
8390 | |||
8391 | // All entries are initially valid | ||
8392 | |||
8393 | for (int i = 0; i < mlen; i++) | ||
8394 | active[i] = true; | ||
8395 | |||
8396 | offset[mlen] = srclen; | ||
8397 | 8945 | ||
8398 | while (beginning < srclen) | 8946 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8399 | { | 8947 | { |
8948 | int srclen = src.Length; | ||
8949 | int seplen = separators.Length; | ||
8950 | object[] separray = separators.Data; | ||
8951 | int spclen = spacers.Length; | ||
8952 | object[] spcarray = spacers.Data; | ||
8953 | int dellen = 0; | ||
8954 | string[] delarray = new string[seplen+spclen]; | ||
8400 | 8955 | ||
8401 | best = mlen; // as bad as it gets | 8956 | int outlen = 0; |
8957 | string[] outarray = new string[srclen*2+1]; | ||
8402 | 8958 | ||
8403 | // Scan for separators | 8959 | int i, j; |
8960 | string d; | ||
8404 | 8961 | ||
8405 | for (j = 0; j < seplen; j++) | 8962 | m_host.AddScriptLPS(1); |
8406 | { | ||
8407 | if (separray[j].ToString() == String.Empty) | ||
8408 | active[j] = false; | ||
8409 | 8963 | ||
8410 | if (active[j]) | 8964 | /* |
8411 | { | 8965 | * Convert separator and spacer lists to C# strings. |
8412 | // scan all of the markers | 8966 | * Also filter out null strings so we don't hang. |
8413 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 8967 | */ |
8414 | { | 8968 | for (i = 0; i < seplen; i ++) { |
8415 | // not present at all | 8969 | d = separray[i].ToString(); |
8416 | active[j] = false; | 8970 | if (d.Length > 0) { |
8417 | } | 8971 | delarray[dellen++] = d; |
8418 | else | ||
8419 | { | ||
8420 | // present and correct | ||
8421 | if (offset[j] < offset[best]) | ||
8422 | { | ||
8423 | // closest so far | ||
8424 | best = j; | ||
8425 | if (offset[best] == beginning) | ||
8426 | break; | ||
8427 | } | ||
8428 | } | ||
8429 | } | ||
8430 | } | 8972 | } |
8973 | } | ||
8974 | seplen = dellen; | ||
8431 | 8975 | ||
8432 | // Scan for spacers | 8976 | for (i = 0; i < spclen; i ++) { |
8977 | d = spcarray[i].ToString(); | ||
8978 | if (d.Length > 0) { | ||
8979 | delarray[dellen++] = d; | ||
8980 | } | ||
8981 | } | ||
8433 | 8982 | ||
8434 | if (offset[best] != beginning) | 8983 | /* |
8435 | { | 8984 | * Scan through source string from beginning to end. |
8436 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 8985 | */ |
8437 | { | 8986 | for (i = 0;;) { |
8438 | if (spcarray[j].ToString() == String.Empty) | ||
8439 | active[j] = false; | ||
8440 | 8987 | ||
8441 | if (active[j]) | 8988 | /* |
8442 | { | 8989 | * Find earliest delimeter in src starting at i (if any). |
8443 | // scan all of the markers | 8990 | */ |
8444 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | 8991 | int earliestDel = -1; |
8445 | { | 8992 | int earliestSrc = srclen; |
8446 | // not present at all | 8993 | string earliestStr = null; |
8447 | active[j] = false; | 8994 | for (j = 0; j < dellen; j ++) { |
8448 | } | 8995 | d = delarray[j]; |
8449 | else | 8996 | if (d != null) { |
8450 | { | 8997 | int index = src.IndexOf(d, i); |
8451 | // present and correct | 8998 | if (index < 0) { |
8452 | if (offset[j] < offset[best]) | 8999 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8453 | { | 9000 | } else if (index < earliestSrc) { |
8454 | // closest so far | 9001 | earliestSrc = index; // where delimeter starts in source string |
8455 | best = j; | 9002 | earliestDel = j; // where delimeter is in delarray[] |
8456 | } | 9003 | earliestStr = d; // the delimeter string from delarray[] |
8457 | } | 9004 | if (index == i) break; // can't do any better than found at beg of string |
8458 | } | 9005 | } |
8459 | } | 9006 | } |
8460 | } | 9007 | } |
8461 | 9008 | ||
8462 | // This is the normal exit from the scanning loop | 9009 | /* |
8463 | 9010 | * Output source string starting at i through start of earliest delimeter. | |
8464 | if (best == mlen) | 9011 | */ |
8465 | { | 9012 | if (keepNulls || (earliestSrc > i)) { |
8466 | // no markers were found on this pass | 9013 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8467 | // so we're pretty much done | ||
8468 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
8469 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8470 | break; | ||
8471 | } | 9014 | } |
8472 | 9015 | ||
8473 | // Otherwise we just add the newly delimited token | 9016 | /* |
8474 | // and recalculate where the search should continue. | 9017 | * If no delimeter found at or after i, we're done scanning. |
8475 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 9018 | */ |
8476 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 9019 | if (earliestDel < 0) break; |
8477 | 9020 | ||
8478 | if (best < seplen) | 9021 | /* |
8479 | { | 9022 | * If delimeter was a spacer, output the spacer. |
8480 | beginning = offset[best] + (separray[best].ToString()).Length; | 9023 | */ |
8481 | } | 9024 | if (earliestDel >= seplen) { |
8482 | else | 9025 | outarray[outlen++] = earliestStr; |
8483 | { | ||
8484 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8485 | string str = spcarray[best - seplen].ToString(); | ||
8486 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8487 | tokens.Add(new LSL_String(str)); | ||
8488 | } | 9026 | } |
8489 | } | ||
8490 | |||
8491 | // This an awkward an not very intuitive boundary case. If the | ||
8492 | // last substring is a tokenizer, then there is an implied trailing | ||
8493 | // null list entry. Hopefully the single comparison will not be too | ||
8494 | // arduous. Alternatively the 'break' could be replced with a return | ||
8495 | // but that's shabby programming. | ||
8496 | 9027 | ||
8497 | if ((beginning == srclen) && (keepNulls)) | 9028 | /* |
8498 | { | 9029 | * Look at rest of src string following delimeter. |
8499 | if (srclen != 0) | 9030 | */ |
8500 | tokens.Add(new LSL_String("")); | 9031 | i = earliestSrc + earliestStr.Length; |
8501 | } | 9032 | } |
8502 | 9033 | ||
8503 | return tokens; | 9034 | /* |
8504 | } | 9035 | * Make up an exact-sized output array suitable for an LSL_List object. |
8505 | 9036 | */ | |
8506 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | 9037 | object[] outlist = new object[outlen]; |
8507 | { | 9038 | for (i = 0; i < outlen; i ++) { |
8508 | m_host.AddScriptLPS(1); | 9039 | outlist[i] = new LSL_String(outarray[i]); |
8509 | return this.ParseString(src, separators, spacers, false); | 9040 | } |
8510 | } | 9041 | return new LSL_List(outlist); |
8511 | |||
8512 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8513 | { | ||
8514 | m_host.AddScriptLPS(1); | ||
8515 | return this.ParseString(src, separators, spacers, true); | ||
8516 | } | 9042 | } |
8517 | 9043 | ||
8518 | public LSL_Integer llGetObjectPermMask(int mask) | 9044 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -8589,28 +9115,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8589 | { | 9115 | { |
8590 | m_host.AddScriptLPS(1); | 9116 | m_host.AddScriptLPS(1); |
8591 | 9117 | ||
8592 | lock (m_host.TaskInventory) | 9118 | m_host.TaskInventory.LockItemsForRead(true); |
9119 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8593 | { | 9120 | { |
8594 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9121 | if (inv.Value.Name == item) |
8595 | { | 9122 | { |
8596 | if (inv.Value.Name == item) | 9123 | m_host.TaskInventory.LockItemsForRead(false); |
9124 | switch (mask) | ||
8597 | { | 9125 | { |
8598 | switch (mask) | 9126 | case 0: |
8599 | { | 9127 | return (int)inv.Value.BasePermissions; |
8600 | case 0: | 9128 | case 1: |
8601 | return (int)inv.Value.BasePermissions; | 9129 | return (int)inv.Value.CurrentPermissions; |
8602 | case 1: | 9130 | case 2: |
8603 | return (int)inv.Value.CurrentPermissions; | 9131 | return (int)inv.Value.GroupPermissions; |
8604 | case 2: | 9132 | case 3: |
8605 | return (int)inv.Value.GroupPermissions; | 9133 | return (int)inv.Value.EveryonePermissions; |
8606 | case 3: | 9134 | case 4: |
8607 | return (int)inv.Value.EveryonePermissions; | 9135 | return (int)inv.Value.NextPermissions; |
8608 | case 4: | ||
8609 | return (int)inv.Value.NextPermissions; | ||
8610 | } | ||
8611 | } | 9136 | } |
8612 | } | 9137 | } |
8613 | } | 9138 | } |
9139 | m_host.TaskInventory.LockItemsForRead(false); | ||
8614 | 9140 | ||
8615 | return -1; | 9141 | return -1; |
8616 | } | 9142 | } |
@@ -8657,16 +9183,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8657 | { | 9183 | { |
8658 | m_host.AddScriptLPS(1); | 9184 | m_host.AddScriptLPS(1); |
8659 | 9185 | ||
8660 | lock (m_host.TaskInventory) | 9186 | m_host.TaskInventory.LockItemsForRead(true); |
9187 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8661 | { | 9188 | { |
8662 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9189 | if (inv.Value.Name == item) |
8663 | { | 9190 | { |
8664 | if (inv.Value.Name == item) | 9191 | m_host.TaskInventory.LockItemsForRead(false); |
8665 | { | 9192 | return inv.Value.CreatorID.ToString(); |
8666 | return inv.Value.CreatorID.ToString(); | ||
8667 | } | ||
8668 | } | 9193 | } |
8669 | } | 9194 | } |
9195 | m_host.TaskInventory.LockItemsForRead(false); | ||
8670 | 9196 | ||
8671 | llSay(0, "No item name '" + item + "'"); | 9197 | llSay(0, "No item name '" + item + "'"); |
8672 | 9198 | ||
@@ -8717,8 +9243,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8717 | return UUID.Zero.ToString(); | 9243 | return UUID.Zero.ToString(); |
8718 | } | 9244 | } |
8719 | reply = new LSL_Vector( | 9245 | reply = new LSL_Vector( |
8720 | info.RegionLocX * Constants.RegionSize, | 9246 | info.RegionLocX, |
8721 | info.RegionLocY * Constants.RegionSize, | 9247 | info.RegionLocY, |
8722 | 0).ToString(); | 9248 | 0).ToString(); |
8723 | break; | 9249 | break; |
8724 | case 6: // DATA_SIM_STATUS | 9250 | case 6: // DATA_SIM_STATUS |
@@ -8931,17 +9457,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8931 | int width = 0; | 9457 | int width = 0; |
8932 | int height = 0; | 9458 | int height = 0; |
8933 | 9459 | ||
8934 | ParcelMediaCommandEnum? commandToSend = null; | 9460 | uint commandToSend = 0; |
8935 | float time = 0.0f; // default is from start | 9461 | float time = 0.0f; // default is from start |
8936 | 9462 | ||
8937 | ScenePresence presence = null; | 9463 | ScenePresence presence = null; |
8938 | 9464 | ||
8939 | for (int i = 0; i < commandList.Data.Length; i++) | 9465 | for (int i = 0; i < commandList.Data.Length; i++) |
8940 | { | 9466 | { |
8941 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9467 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8942 | switch (command) | 9468 | switch (command) |
8943 | { | 9469 | { |
8944 | case ParcelMediaCommandEnum.Agent: | 9470 | case (uint)ParcelMediaCommandEnum.Agent: |
8945 | // we send only to one agent | 9471 | // we send only to one agent |
8946 | if ((i + 1) < commandList.Length) | 9472 | if ((i + 1) < commandList.Length) |
8947 | { | 9473 | { |
@@ -8958,25 +9484,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8958 | } | 9484 | } |
8959 | break; | 9485 | break; |
8960 | 9486 | ||
8961 | case ParcelMediaCommandEnum.Loop: | 9487 | case (uint)ParcelMediaCommandEnum.Loop: |
8962 | loop = 1; | 9488 | loop = 1; |
8963 | commandToSend = command; | 9489 | commandToSend = command; |
8964 | update = true; //need to send the media update packet to set looping | 9490 | update = true; //need to send the media update packet to set looping |
8965 | break; | 9491 | break; |
8966 | 9492 | ||
8967 | case ParcelMediaCommandEnum.Play: | 9493 | case (uint)ParcelMediaCommandEnum.Play: |
8968 | loop = 0; | 9494 | loop = 0; |
8969 | commandToSend = command; | 9495 | commandToSend = command; |
8970 | update = true; //need to send the media update packet to make sure it doesn't loop | 9496 | update = true; //need to send the media update packet to make sure it doesn't loop |
8971 | break; | 9497 | break; |
8972 | 9498 | ||
8973 | case ParcelMediaCommandEnum.Pause: | 9499 | case (uint)ParcelMediaCommandEnum.Pause: |
8974 | case ParcelMediaCommandEnum.Stop: | 9500 | case (uint)ParcelMediaCommandEnum.Stop: |
8975 | case ParcelMediaCommandEnum.Unload: | 9501 | case (uint)ParcelMediaCommandEnum.Unload: |
8976 | commandToSend = command; | 9502 | commandToSend = command; |
8977 | break; | 9503 | break; |
8978 | 9504 | ||
8979 | case ParcelMediaCommandEnum.Url: | 9505 | case (uint)ParcelMediaCommandEnum.Url: |
8980 | if ((i + 1) < commandList.Length) | 9506 | if ((i + 1) < commandList.Length) |
8981 | { | 9507 | { |
8982 | if (commandList.Data[i + 1] is LSL_String) | 9508 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8989,7 +9515,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8989 | } | 9515 | } |
8990 | break; | 9516 | break; |
8991 | 9517 | ||
8992 | case ParcelMediaCommandEnum.Texture: | 9518 | case (uint)ParcelMediaCommandEnum.Texture: |
8993 | if ((i + 1) < commandList.Length) | 9519 | if ((i + 1) < commandList.Length) |
8994 | { | 9520 | { |
8995 | if (commandList.Data[i + 1] is LSL_String) | 9521 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9002,7 +9528,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9002 | } | 9528 | } |
9003 | break; | 9529 | break; |
9004 | 9530 | ||
9005 | case ParcelMediaCommandEnum.Time: | 9531 | case (uint)ParcelMediaCommandEnum.Time: |
9006 | if ((i + 1) < commandList.Length) | 9532 | if ((i + 1) < commandList.Length) |
9007 | { | 9533 | { |
9008 | if (commandList.Data[i + 1] is LSL_Float) | 9534 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9014,7 +9540,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9014 | } | 9540 | } |
9015 | break; | 9541 | break; |
9016 | 9542 | ||
9017 | case ParcelMediaCommandEnum.AutoAlign: | 9543 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9018 | if ((i + 1) < commandList.Length) | 9544 | if ((i + 1) < commandList.Length) |
9019 | { | 9545 | { |
9020 | if (commandList.Data[i + 1] is LSL_Integer) | 9546 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9028,7 +9554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9028 | } | 9554 | } |
9029 | break; | 9555 | break; |
9030 | 9556 | ||
9031 | case ParcelMediaCommandEnum.Type: | 9557 | case (uint)ParcelMediaCommandEnum.Type: |
9032 | if ((i + 1) < commandList.Length) | 9558 | if ((i + 1) < commandList.Length) |
9033 | { | 9559 | { |
9034 | if (commandList.Data[i + 1] is LSL_String) | 9560 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9041,7 +9567,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9041 | } | 9567 | } |
9042 | break; | 9568 | break; |
9043 | 9569 | ||
9044 | case ParcelMediaCommandEnum.Desc: | 9570 | case (uint)ParcelMediaCommandEnum.Desc: |
9045 | if ((i + 1) < commandList.Length) | 9571 | if ((i + 1) < commandList.Length) |
9046 | { | 9572 | { |
9047 | if (commandList.Data[i + 1] is LSL_String) | 9573 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9054,7 +9580,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9054 | } | 9580 | } |
9055 | break; | 9581 | break; |
9056 | 9582 | ||
9057 | case ParcelMediaCommandEnum.Size: | 9583 | case (uint)ParcelMediaCommandEnum.Size: |
9058 | if ((i + 2) < commandList.Length) | 9584 | if ((i + 2) < commandList.Length) |
9059 | { | 9585 | { |
9060 | if (commandList.Data[i + 1] is LSL_Integer) | 9586 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9124,7 +9650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9124 | } | 9650 | } |
9125 | } | 9651 | } |
9126 | 9652 | ||
9127 | if (commandToSend != null) | 9653 | if (commandToSend != 0) |
9128 | { | 9654 | { |
9129 | // the commandList contained a start/stop/... command, too | 9655 | // the commandList contained a start/stop/... command, too |
9130 | if (presence == null) | 9656 | if (presence == null) |
@@ -9161,7 +9687,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9161 | 9687 | ||
9162 | if (aList.Data[i] != null) | 9688 | if (aList.Data[i] != null) |
9163 | { | 9689 | { |
9164 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 9690 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9165 | { | 9691 | { |
9166 | case ParcelMediaCommandEnum.Url: | 9692 | case ParcelMediaCommandEnum.Url: |
9167 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 9693 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9204,16 +9730,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9204 | { | 9730 | { |
9205 | m_host.AddScriptLPS(1); | 9731 | m_host.AddScriptLPS(1); |
9206 | 9732 | ||
9207 | lock (m_host.TaskInventory) | 9733 | m_host.TaskInventory.LockItemsForRead(true); |
9734 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9208 | { | 9735 | { |
9209 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9736 | if (inv.Value.Name == name) |
9210 | { | 9737 | { |
9211 | if (inv.Value.Name == name) | 9738 | m_host.TaskInventory.LockItemsForRead(false); |
9212 | { | 9739 | return inv.Value.Type; |
9213 | return inv.Value.Type; | ||
9214 | } | ||
9215 | } | 9740 | } |
9216 | } | 9741 | } |
9742 | m_host.TaskInventory.LockItemsForRead(false); | ||
9217 | 9743 | ||
9218 | return -1; | 9744 | return -1; |
9219 | } | 9745 | } |
@@ -9224,15 +9750,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9224 | 9750 | ||
9225 | if (quick_pay_buttons.Data.Length < 4) | 9751 | if (quick_pay_buttons.Data.Length < 4) |
9226 | { | 9752 | { |
9227 | LSLError("List must have at least 4 elements"); | 9753 | int x; |
9228 | return; | 9754 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9755 | { | ||
9756 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9757 | } | ||
9229 | } | 9758 | } |
9230 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9759 | int[] nPrice = new int[5]; |
9231 | 9760 | nPrice[0]=price; | |
9232 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9761 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
9233 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9762 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
9234 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9763 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
9235 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9764 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9765 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9236 | m_host.ParentGroup.HasGroupChanged = true; | 9766 | m_host.ParentGroup.HasGroupChanged = true; |
9237 | } | 9767 | } |
9238 | 9768 | ||
@@ -9244,17 +9774,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9244 | if (invItemID == UUID.Zero) | 9774 | if (invItemID == UUID.Zero) |
9245 | return new LSL_Vector(); | 9775 | return new LSL_Vector(); |
9246 | 9776 | ||
9247 | lock (m_host.TaskInventory) | 9777 | m_host.TaskInventory.LockItemsForRead(true); |
9778 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9248 | { | 9779 | { |
9249 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9780 | m_host.TaskInventory.LockItemsForRead(false); |
9250 | return new LSL_Vector(); | 9781 | return new LSL_Vector(); |
9782 | } | ||
9251 | 9783 | ||
9252 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9784 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9253 | { | 9785 | { |
9254 | ShoutError("No permissions to track the camera"); | 9786 | ShoutError("No permissions to track the camera"); |
9255 | return new LSL_Vector(); | 9787 | m_host.TaskInventory.LockItemsForRead(false); |
9256 | } | 9788 | return new LSL_Vector(); |
9257 | } | 9789 | } |
9790 | m_host.TaskInventory.LockItemsForRead(false); | ||
9258 | 9791 | ||
9259 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9792 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9260 | if (presence != null) | 9793 | if (presence != null) |
@@ -9272,17 +9805,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9272 | if (invItemID == UUID.Zero) | 9805 | if (invItemID == UUID.Zero) |
9273 | return new LSL_Rotation(); | 9806 | return new LSL_Rotation(); |
9274 | 9807 | ||
9275 | lock (m_host.TaskInventory) | 9808 | m_host.TaskInventory.LockItemsForRead(true); |
9809 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9276 | { | 9810 | { |
9277 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9811 | m_host.TaskInventory.LockItemsForRead(false); |
9278 | return new LSL_Rotation(); | 9812 | return new LSL_Rotation(); |
9279 | 9813 | } | |
9280 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9814 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9281 | { | 9815 | { |
9282 | ShoutError("No permissions to track the camera"); | 9816 | ShoutError("No permissions to track the camera"); |
9283 | return new LSL_Rotation(); | 9817 | m_host.TaskInventory.LockItemsForRead(false); |
9284 | } | 9818 | return new LSL_Rotation(); |
9285 | } | 9819 | } |
9820 | m_host.TaskInventory.LockItemsForRead(false); | ||
9286 | 9821 | ||
9287 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9822 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9288 | if (presence != null) | 9823 | if (presence != null) |
@@ -9344,8 +9879,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9344 | { | 9879 | { |
9345 | m_host.AddScriptLPS(1); | 9880 | m_host.AddScriptLPS(1); |
9346 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9881 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9347 | if (detectedParams == null) return; // only works on the first detected avatar | 9882 | if (detectedParams == null) |
9348 | 9883 | { | |
9884 | if (m_host.IsAttachment == true) | ||
9885 | { | ||
9886 | detectedParams = new DetectParams(); | ||
9887 | detectedParams.Key = m_host.OwnerID; | ||
9888 | } | ||
9889 | else | ||
9890 | { | ||
9891 | return; | ||
9892 | } | ||
9893 | } | ||
9894 | |||
9349 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9895 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9350 | if (avatar != null) | 9896 | if (avatar != null) |
9351 | { | 9897 | { |
@@ -9353,6 +9899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9353 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9899 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9354 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9900 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9355 | } | 9901 | } |
9902 | |||
9356 | ScriptSleep(1000); | 9903 | ScriptSleep(1000); |
9357 | } | 9904 | } |
9358 | 9905 | ||
@@ -9432,14 +9979,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9432 | if (objectID == UUID.Zero) return; | 9979 | if (objectID == UUID.Zero) return; |
9433 | 9980 | ||
9434 | UUID agentID; | 9981 | UUID agentID; |
9435 | lock (m_host.TaskInventory) | 9982 | m_host.TaskInventory.LockItemsForRead(true); |
9436 | { | 9983 | // we need the permission first, to know which avatar we want to set the camera for |
9437 | // we need the permission first, to know which avatar we want to set the camera for | 9984 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9438 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9439 | 9985 | ||
9440 | if (agentID == UUID.Zero) return; | 9986 | if (agentID == UUID.Zero) |
9441 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9987 | { |
9988 | m_host.TaskInventory.LockItemsForRead(false); | ||
9989 | return; | ||
9990 | } | ||
9991 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9992 | { | ||
9993 | m_host.TaskInventory.LockItemsForRead(false); | ||
9994 | return; | ||
9442 | } | 9995 | } |
9996 | m_host.TaskInventory.LockItemsForRead(false); | ||
9443 | 9997 | ||
9444 | ScenePresence presence = World.GetScenePresence(agentID); | 9998 | ScenePresence presence = World.GetScenePresence(agentID); |
9445 | 9999 | ||
@@ -9489,12 +10043,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9489 | 10043 | ||
9490 | // we need the permission first, to know which avatar we want to clear the camera for | 10044 | // we need the permission first, to know which avatar we want to clear the camera for |
9491 | UUID agentID; | 10045 | UUID agentID; |
9492 | lock (m_host.TaskInventory) | 10046 | m_host.TaskInventory.LockItemsForRead(true); |
10047 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10048 | if (agentID == UUID.Zero) | ||
10049 | { | ||
10050 | m_host.TaskInventory.LockItemsForRead(false); | ||
10051 | return; | ||
10052 | } | ||
10053 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9493 | { | 10054 | { |
9494 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10055 | m_host.TaskInventory.LockItemsForRead(false); |
9495 | if (agentID == UUID.Zero) return; | 10056 | return; |
9496 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9497 | } | 10057 | } |
10058 | m_host.TaskInventory.LockItemsForRead(false); | ||
9498 | 10059 | ||
9499 | ScenePresence presence = World.GetScenePresence(agentID); | 10060 | ScenePresence presence = World.GetScenePresence(agentID); |
9500 | 10061 | ||
@@ -9561,19 +10122,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9561 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 10122 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
9562 | { | 10123 | { |
9563 | m_host.AddScriptLPS(1); | 10124 | m_host.AddScriptLPS(1); |
9564 | string ret = String.Empty; | 10125 | |
9565 | string src1 = llBase64ToString(str1); | 10126 | if (str1 == String.Empty) |
9566 | string src2 = llBase64ToString(str2); | 10127 | return String.Empty; |
9567 | int c = 0; | 10128 | if (str2 == String.Empty) |
9568 | for (int i = 0; i < src1.Length; i++) | 10129 | return str1; |
10130 | |||
10131 | byte[] data1 = Convert.FromBase64String(str1); | ||
10132 | byte[] data2 = Convert.FromBase64String(str2); | ||
10133 | |||
10134 | byte[] d2 = new Byte[data1.Length]; | ||
10135 | int pos = 0; | ||
10136 | |||
10137 | if (data1.Length <= data2.Length) | ||
9569 | { | 10138 | { |
9570 | ret += (char) (src1[i] ^ src2[c]); | 10139 | Array.Copy(data2, 0, d2, 0, data1.Length); |
10140 | } | ||
10141 | else | ||
10142 | { | ||
10143 | while (pos < data1.Length) | ||
10144 | { | ||
10145 | int len = data1.Length - pos; | ||
10146 | if (len > data2.Length) | ||
10147 | len = data2.Length; | ||
9571 | 10148 | ||
9572 | c++; | 10149 | Array.Copy(data2, 0, d2, pos, len); |
9573 | if (c >= src2.Length) | 10150 | pos += len; |
9574 | c = 0; | 10151 | } |
9575 | } | 10152 | } |
9576 | return llStringToBase64(ret); | 10153 | |
10154 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
10155 | data1[pos] ^= d2[pos]; | ||
10156 | |||
10157 | return Convert.ToBase64String(data1); | ||
9577 | } | 10158 | } |
9578 | 10159 | ||
9579 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 10160 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -9951,15 +10532,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9951 | 10532 | ||
9952 | internal UUID ScriptByName(string name) | 10533 | internal UUID ScriptByName(string name) |
9953 | { | 10534 | { |
9954 | lock (m_host.TaskInventory) | 10535 | m_host.TaskInventory.LockItemsForRead(true); |
10536 | |||
10537 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9955 | { | 10538 | { |
9956 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10539 | if (item.Type == 10 && item.Name == name) |
9957 | { | 10540 | { |
9958 | if (item.Type == 10 && item.Name == name) | 10541 | m_host.TaskInventory.LockItemsForRead(false); |
9959 | return item.ItemID; | 10542 | return item.ItemID; |
9960 | } | 10543 | } |
9961 | } | 10544 | } |
9962 | 10545 | ||
10546 | m_host.TaskInventory.LockItemsForRead(false); | ||
10547 | |||
9963 | return UUID.Zero; | 10548 | return UUID.Zero; |
9964 | } | 10549 | } |
9965 | 10550 | ||
@@ -10000,6 +10585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10000 | { | 10585 | { |
10001 | m_host.AddScriptLPS(1); | 10586 | m_host.AddScriptLPS(1); |
10002 | 10587 | ||
10588 | //Clone is thread safe | ||
10003 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10589 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10004 | 10590 | ||
10005 | UUID assetID = UUID.Zero; | 10591 | UUID assetID = UUID.Zero; |
@@ -10062,6 +10648,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10062 | { | 10648 | { |
10063 | m_host.AddScriptLPS(1); | 10649 | m_host.AddScriptLPS(1); |
10064 | 10650 | ||
10651 | //Clone is thread safe | ||
10065 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10652 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10066 | 10653 | ||
10067 | UUID assetID = UUID.Zero; | 10654 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8a98be7..5212e1b 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() |
@@ -767,18 +776,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
767 | if (target != null) | 776 | if (target != null) |
768 | { | 777 | { |
769 | UUID animID=UUID.Zero; | 778 | UUID animID=UUID.Zero; |
770 | lock (m_host.TaskInventory) | 779 | m_host.TaskInventory.LockItemsForRead(true); |
780 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
771 | { | 781 | { |
772 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 782 | if (inv.Value.Name == animation) |
773 | { | 783 | { |
774 | if (inv.Value.Name == animation) | 784 | if (inv.Value.Type == (int)AssetType.Animation) |
775 | { | 785 | animID = inv.Value.AssetID; |
776 | if (inv.Value.Type == (int)AssetType.Animation) | 786 | continue; |
777 | animID = inv.Value.AssetID; | ||
778 | continue; | ||
779 | } | ||
780 | } | 787 | } |
781 | } | 788 | } |
789 | m_host.TaskInventory.LockItemsForRead(false); | ||
782 | if (animID == UUID.Zero) | 790 | if (animID == UUID.Zero) |
783 | target.Animator.AddAnimation(animation, m_host.UUID); | 791 | target.Animator.AddAnimation(animation, m_host.UUID); |
784 | else | 792 | else |
@@ -800,18 +808,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
800 | if (target != null) | 808 | if (target != null) |
801 | { | 809 | { |
802 | UUID animID=UUID.Zero; | 810 | UUID animID=UUID.Zero; |
803 | lock (m_host.TaskInventory) | 811 | m_host.TaskInventory.LockItemsForRead(true); |
812 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
804 | { | 813 | { |
805 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 814 | if (inv.Value.Name == animation) |
806 | { | 815 | { |
807 | if (inv.Value.Name == animation) | 816 | if (inv.Value.Type == (int)AssetType.Animation) |
808 | { | 817 | animID = inv.Value.AssetID; |
809 | if (inv.Value.Type == (int)AssetType.Animation) | 818 | continue; |
810 | animID = inv.Value.AssetID; | ||
811 | continue; | ||
812 | } | ||
813 | } | 819 | } |
814 | } | 820 | } |
821 | m_host.TaskInventory.LockItemsForRead(false); | ||
815 | 822 | ||
816 | if (animID == UUID.Zero) | 823 | if (animID == UUID.Zero) |
817 | target.Animator.RemoveAnimation(animation); | 824 | target.Animator.RemoveAnimation(animation); |
@@ -1662,6 +1669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1662 | 1669 | ||
1663 | if (!UUID.TryParse(name, out assetID)) | 1670 | if (!UUID.TryParse(name, out assetID)) |
1664 | { | 1671 | { |
1672 | m_host.TaskInventory.LockItemsForRead(true); | ||
1665 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1673 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1666 | { | 1674 | { |
1667 | if (item.Type == 7 && item.Name == name) | 1675 | if (item.Type == 7 && item.Name == name) |
@@ -1669,6 +1677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1669 | assetID = item.AssetID; | 1677 | assetID = item.AssetID; |
1670 | } | 1678 | } |
1671 | } | 1679 | } |
1680 | m_host.TaskInventory.LockItemsForRead(false); | ||
1672 | } | 1681 | } |
1673 | 1682 | ||
1674 | if (assetID == UUID.Zero) | 1683 | if (assetID == UUID.Zero) |
@@ -1715,6 +1724,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1715 | 1724 | ||
1716 | if (!UUID.TryParse(name, out assetID)) | 1725 | if (!UUID.TryParse(name, out assetID)) |
1717 | { | 1726 | { |
1727 | m_host.TaskInventory.LockItemsForRead(true); | ||
1718 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1728 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1719 | { | 1729 | { |
1720 | if (item.Type == 7 && item.Name == name) | 1730 | if (item.Type == 7 && item.Name == name) |
@@ -1722,6 +1732,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1722 | assetID = item.AssetID; | 1732 | assetID = item.AssetID; |
1723 | } | 1733 | } |
1724 | } | 1734 | } |
1735 | m_host.TaskInventory.LockItemsForRead(false); | ||
1725 | } | 1736 | } |
1726 | 1737 | ||
1727 | if (assetID == UUID.Zero) | 1738 | if (assetID == UUID.Zero) |
@@ -1772,6 +1783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1772 | 1783 | ||
1773 | if (!UUID.TryParse(name, out assetID)) | 1784 | if (!UUID.TryParse(name, out assetID)) |
1774 | { | 1785 | { |
1786 | m_host.TaskInventory.LockItemsForRead(true); | ||
1775 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1787 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1776 | { | 1788 | { |
1777 | if (item.Type == 7 && item.Name == name) | 1789 | if (item.Type == 7 && item.Name == name) |
@@ -1779,6 +1791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1779 | assetID = item.AssetID; | 1791 | assetID = item.AssetID; |
1780 | } | 1792 | } |
1781 | } | 1793 | } |
1794 | m_host.TaskInventory.LockItemsForRead(false); | ||
1782 | } | 1795 | } |
1783 | 1796 | ||
1784 | if (assetID == UUID.Zero) | 1797 | if (assetID == UUID.Zero) |
@@ -2258,9 +2271,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2258 | { | 2271 | { |
2259 | if (avatar.IsChildAgent == false) | 2272 | if (avatar.IsChildAgent == false) |
2260 | { | 2273 | { |
2261 | result.Add(avatar.UUID); | 2274 | result.Add(new LSL_Key(avatar.UUID.ToString())); |
2262 | result.Add(avatar.AbsolutePosition); | 2275 | result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z)); |
2263 | result.Add(avatar.Name); | 2276 | result.Add(new LSL_String(avatar.Name)); |
2264 | } | 2277 | } |
2265 | } | 2278 | } |
2266 | }); | 2279 | }); |
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/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 630821b..fbf601a 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 5da6bb9..6e8435d 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..f14967e 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(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs index f8dbe03..8280ca5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs | |||
@@ -72,5 +72,20 @@ 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 | |||
76 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
77 | { | ||
78 | return m_LS_Functions.lsGetWindlightScene(rules); | ||
79 | } | ||
80 | |||
81 | public int cmSetWindlightScene(LSL_List rules) | ||
82 | { | ||
83 | return m_LS_Functions.lsSetWindlightScene(rules); | ||
84 | } | ||
85 | |||
86 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
87 | { | ||
88 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | ||
89 | } | ||
75 | } | 90 | } |
76 | } | 91 | } |
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); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6663aa5..623cb7d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -55,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
55 | { | 56 | { |
56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance | 57 | public class ScriptInstance : MarshalByRefObject, IScriptInstance |
57 | { | 58 | { |
58 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | 60 | ||
60 | private IScriptEngine m_Engine; | 61 | private IScriptEngine m_Engine; |
61 | private IScriptWorkItem m_CurrentResult = null; | 62 | private IScriptWorkItem m_CurrentResult = null; |
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
238 | 239 | ||
239 | if (part != null) | 240 | if (part != null) |
240 | { | 241 | { |
241 | lock (part.TaskInventory) | 242 | part.TaskInventory.LockItemsForRead(true); |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
242 | { | 244 | { |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
244 | { | ||
245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
246 | } | ||
247 | } | 246 | } |
247 | part.TaskInventory.LockItemsForRead(false); | ||
248 | } | 248 | } |
249 | 249 | ||
250 | ApiManager am = new ApiManager(); | 250 | ApiManager am = new ApiManager(); |
@@ -271,9 +271,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
271 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 271 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
272 | // lease.Register(this); | 272 | // lease.Register(this); |
273 | } | 273 | } |
274 | catch (Exception) | 274 | catch (Exception e) |
275 | { | 275 | { |
276 | // m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); | 276 | m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); |
277 | throw; | ||
277 | } | 278 | } |
278 | 279 | ||
279 | try | 280 | try |
@@ -429,14 +430,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
429 | { | 430 | { |
430 | int permsMask; | 431 | int permsMask; |
431 | UUID permsGranter; | 432 | UUID permsGranter; |
432 | lock (part.TaskInventory) | 433 | part.TaskInventory.LockItemsForRead(true); |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
433 | { | 435 | { |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 436 | part.TaskInventory.LockItemsForRead(false); |
435 | return; | 437 | return; |
436 | |||
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | } | 438 | } |
439 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
440 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
441 | part.TaskInventory.LockItemsForRead(false); | ||
440 | 442 | ||
441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 443 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
442 | { | 444 | { |
@@ -545,6 +547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
545 | return true; | 547 | return true; |
546 | } | 548 | } |
547 | 549 | ||
550 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
548 | public void SetState(string state) | 551 | public void SetState(string state) |
549 | { | 552 | { |
550 | if (state == State) | 553 | if (state == State) |
@@ -556,7 +559,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
556 | new DetectParams[0])); | 559 | new DetectParams[0])); |
557 | PostEvent(new EventParams("state_entry", new Object[0], | 560 | PostEvent(new EventParams("state_entry", new Object[0], |
558 | new DetectParams[0])); | 561 | new DetectParams[0])); |
559 | 562 | ||
560 | throw new EventAbortException(); | 563 | throw new EventAbortException(); |
561 | } | 564 | } |
562 | 565 | ||
@@ -639,14 +642,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | /// <returns></returns> | 642 | /// <returns></returns> |
640 | public object EventProcessor() | 643 | public object EventProcessor() |
641 | { | 644 | { |
642 | if (m_Suspended) | 645 | EventParams data = null; |
643 | return 0; | ||
644 | 646 | ||
645 | lock (m_Script) | 647 | lock (m_EventQueue) |
646 | { | 648 | { |
647 | EventParams data = null; | 649 | if (m_Suspended) |
650 | return 0; | ||
648 | 651 | ||
649 | lock (m_EventQueue) | 652 | lock (m_Script) |
650 | { | 653 | { |
651 | data = (EventParams) m_EventQueue.Dequeue(); | 654 | data = (EventParams) m_EventQueue.Dequeue(); |
652 | if (data == null) // Shouldn't happen | 655 | if (data == null) // Shouldn't happen |
@@ -672,6 +675,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
672 | if (data.EventName == "collision") | 675 | if (data.EventName == "collision") |
673 | m_CollisionInQueue = false; | 676 | m_CollisionInQueue = false; |
674 | } | 677 | } |
678 | } | ||
679 | lock(m_Script) | ||
680 | { | ||
675 | 681 | ||
676 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 682 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
677 | 683 | ||
@@ -828,6 +834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
828 | new Object[0], new DetectParams[0])); | 834 | new Object[0], new DetectParams[0])); |
829 | } | 835 | } |
830 | 836 | ||
837 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
831 | public void ApiResetScript() | 838 | public void ApiResetScript() |
832 | { | 839 | { |
833 | // bool running = Running; | 840 | // bool running = Running; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 91e03ac..a3a2fdf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -83,19 +83,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
83 | 83 | ||
84 | public override string ToString() | 84 | public override string ToString() |
85 | { | 85 | { |
86 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | 86 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); |
87 | return s; | 87 | return s; |
88 | } | 88 | } |
89 | 89 | ||
90 | public static explicit operator LSLString(Vector3 vec) | 90 | public static explicit operator LSLString(Vector3 vec) |
91 | { | 91 | { |
92 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 92 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
93 | return new LSLString(s); | 93 | return new LSLString(s); |
94 | } | 94 | } |
95 | 95 | ||
96 | public static explicit operator string(Vector3 vec) | 96 | public static explicit operator string(Vector3 vec) |
97 | { | 97 | { |
98 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 98 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
99 | return s; | 99 | return s; |
100 | } | 100 | } |
101 | 101 | ||
@@ -342,19 +342,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
342 | 342 | ||
343 | public override string ToString() | 343 | public override string ToString() |
344 | { | 344 | { |
345 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | 345 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); |
346 | return st; | 346 | return st; |
347 | } | 347 | } |
348 | 348 | ||
349 | public static explicit operator string(Quaternion r) | 349 | public static explicit operator string(Quaternion r) |
350 | { | 350 | { |
351 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 351 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
352 | return s; | 352 | return s; |
353 | } | 353 | } |
354 | 354 | ||
355 | public static explicit operator LSLString(Quaternion r) | 355 | public static explicit operator LSLString(Quaternion r) |
356 | { | 356 | { |
357 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 357 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
358 | return new LSLString(s); | 358 | return new LSLString(s); |
359 | } | 359 | } |
360 | 360 | ||
@@ -613,24 +613,16 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
613 | 613 | ||
614 | public static bool operator ==(list a, list b) | 614 | public static bool operator ==(list a, list b) |
615 | { | 615 | { |
616 | int la = -1; | 616 | int la = a.Length; |
617 | int lb = -1; | 617 | int lb = b.Length; |
618 | try { la = a.Length; } | ||
619 | catch (NullReferenceException) { } | ||
620 | try { lb = b.Length; } | ||
621 | catch (NullReferenceException) { } | ||
622 | 618 | ||
623 | return la == lb; | 619 | return la == lb; |
624 | } | 620 | } |
625 | 621 | ||
626 | public static bool operator !=(list a, list b) | 622 | public static bool operator !=(list a, list b) |
627 | { | 623 | { |
628 | int la = -1; | 624 | int la = a.Length; |
629 | int lb = -1; | 625 | int lb = b.Length; |
630 | try { la = a.Length; } | ||
631 | catch (NullReferenceException) { } | ||
632 | try {lb = b.Length;} | ||
633 | catch (NullReferenceException) { } | ||
634 | 626 | ||
635 | return la != lb; | 627 | return la != lb; |
636 | } | 628 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 8629674..35cc65b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -103,6 +104,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
103 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 104 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
104 | new Dictionary<UUID, IScriptInstance>(); | 105 | new Dictionary<UUID, IScriptInstance>(); |
105 | 106 | ||
107 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
108 | |||
106 | // Maps the asset ID to the assembly | 109 | // Maps the asset ID to the assembly |
107 | 110 | ||
108 | private Dictionary<UUID, string> m_Assemblies = | 111 | private Dictionary<UUID, string> m_Assemblies = |
@@ -125,6 +128,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
125 | IWorkItemResult m_CurrentCompile = null; | 128 | IWorkItemResult m_CurrentCompile = null; |
126 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); | 129 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); |
127 | 130 | ||
131 | private void lockScriptsForRead(bool locked) | ||
132 | { | ||
133 | if (locked) | ||
134 | { | ||
135 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
136 | { | ||
137 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
138 | m_scriptsLock.ExitReadLock(); | ||
139 | } | ||
140 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
141 | { | ||
142 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
143 | m_scriptsLock.ExitWriteLock(); | ||
144 | } | ||
145 | |||
146 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
147 | { | ||
148 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
149 | if (m_scriptsLock.IsWriteLockHeld) | ||
150 | { | ||
151 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
158 | { | ||
159 | m_scriptsLock.ExitReadLock(); | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | private void lockScriptsForWrite(bool locked) | ||
164 | { | ||
165 | if (locked) | ||
166 | { | ||
167 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
168 | { | ||
169 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
170 | m_scriptsLock.ExitReadLock(); | ||
171 | } | ||
172 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
173 | { | ||
174 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
175 | m_scriptsLock.ExitWriteLock(); | ||
176 | } | ||
177 | |||
178 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
179 | { | ||
180 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
181 | if (m_scriptsLock.IsWriteLockHeld) | ||
182 | { | ||
183 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
190 | { | ||
191 | m_scriptsLock.ExitWriteLock(); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | |||
128 | public string ScriptEngineName | 196 | public string ScriptEngineName |
129 | { | 197 | { |
130 | get { return "XEngine"; } | 198 | get { return "XEngine"; } |
@@ -270,43 +338,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
270 | 338 | ||
271 | public void RemoveRegion(Scene scene) | 339 | public void RemoveRegion(Scene scene) |
272 | { | 340 | { |
273 | lock (m_Scripts) | 341 | lockScriptsForRead(true); |
342 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
274 | { | 343 | { |
275 | foreach (IScriptInstance instance in m_Scripts.Values) | 344 | // Force a final state save |
345 | // | ||
346 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
276 | { | 347 | { |
277 | // Force a final state save | 348 | string assembly = m_Assemblies[instance.AssetID]; |
278 | // | 349 | instance.SaveState(assembly); |
279 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 350 | } |
280 | { | ||
281 | string assembly = m_Assemblies[instance.AssetID]; | ||
282 | instance.SaveState(assembly); | ||
283 | } | ||
284 | 351 | ||
285 | // Clear the event queue and abort the instance thread | 352 | // Clear the event queue and abort the instance thread |
286 | // | 353 | // |
287 | instance.ClearQueue(); | 354 | instance.ClearQueue(); |
288 | instance.Stop(0); | 355 | instance.Stop(0); |
289 | 356 | ||
290 | // Release events, timer, etc | 357 | // Release events, timer, etc |
291 | // | 358 | // |
292 | instance.DestroyScriptInstance(); | 359 | instance.DestroyScriptInstance(); |
293 | 360 | ||
294 | // Unload scripts and app domains | 361 | // Unload scripts and app domains |
295 | // Must be done explicitly because they have infinite | 362 | // Must be done explicitly because they have infinite |
296 | // lifetime | 363 | // lifetime |
297 | // | 364 | // |
298 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 365 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
299 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 366 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
300 | { | 367 | { |
301 | m_DomainScripts.Remove(instance.AppDomain); | 368 | m_DomainScripts.Remove(instance.AppDomain); |
302 | UnloadAppDomain(instance.AppDomain); | 369 | UnloadAppDomain(instance.AppDomain); |
303 | } | ||
304 | } | 370 | } |
305 | m_Scripts.Clear(); | ||
306 | m_PrimObjects.Clear(); | ||
307 | m_Assemblies.Clear(); | ||
308 | m_DomainScripts.Clear(); | ||
309 | } | 371 | } |
372 | lockScriptsForRead(false); | ||
373 | lockScriptsForWrite(true); | ||
374 | m_Scripts.Clear(); | ||
375 | lockScriptsForWrite(false); | ||
376 | m_PrimObjects.Clear(); | ||
377 | m_Assemblies.Clear(); | ||
378 | m_DomainScripts.Clear(); | ||
379 | |||
310 | lock (m_ScriptEngines) | 380 | lock (m_ScriptEngines) |
311 | { | 381 | { |
312 | m_ScriptEngines.Remove(this); | 382 | m_ScriptEngines.Remove(this); |
@@ -365,22 +435,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
365 | 435 | ||
366 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 436 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
367 | 437 | ||
368 | lock (m_Scripts) | 438 | lockScriptsForRead(true); |
369 | { | 439 | foreach (IScriptInstance instance in m_Scripts.Values) |
370 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
371 | instances.Add(instance); | 440 | instances.Add(instance); |
372 | } | 441 | lockScriptsForRead(false); |
373 | 442 | ||
374 | foreach (IScriptInstance i in instances) | 443 | foreach (IScriptInstance i in instances) |
375 | { | 444 | { |
376 | string assembly = String.Empty; | 445 | string assembly = String.Empty; |
377 | 446 | ||
378 | lock (m_Scripts) | 447 | |
379 | { | ||
380 | if (!m_Assemblies.ContainsKey(i.AssetID)) | 448 | if (!m_Assemblies.ContainsKey(i.AssetID)) |
381 | continue; | 449 | continue; |
382 | assembly = m_Assemblies[i.AssetID]; | 450 | assembly = m_Assemblies[i.AssetID]; |
383 | } | 451 | |
384 | 452 | ||
385 | i.SaveState(assembly); | 453 | i.SaveState(assembly); |
386 | } | 454 | } |
@@ -709,92 +777,95 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
709 | } | 777 | } |
710 | 778 | ||
711 | ScriptInstance instance = null; | 779 | ScriptInstance instance = null; |
712 | lock (m_Scripts) | 780 | // Create the object record |
781 | lockScriptsForRead(true); | ||
782 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
783 | (m_Scripts[itemID].AssetID != assetID)) | ||
713 | { | 784 | { |
714 | // Create the object record | 785 | lockScriptsForRead(false); |
715 | 786 | ||
716 | if ((!m_Scripts.ContainsKey(itemID)) || | 787 | UUID appDomain = assetID; |
717 | (m_Scripts[itemID].AssetID != assetID)) | ||
718 | { | ||
719 | UUID appDomain = assetID; | ||
720 | 788 | ||
721 | if (part.ParentGroup.IsAttachment) | 789 | if (part.ParentGroup.IsAttachment) |
722 | appDomain = part.ParentGroup.RootPart.UUID; | 790 | appDomain = part.ParentGroup.RootPart.UUID; |
723 | 791 | ||
724 | if (!m_AppDomains.ContainsKey(appDomain)) | 792 | if (!m_AppDomains.ContainsKey(appDomain)) |
793 | { | ||
794 | try | ||
725 | { | 795 | { |
726 | try | 796 | AppDomainSetup appSetup = new AppDomainSetup(); |
727 | { | 797 | appSetup.PrivateBinPath = Path.Combine( |
728 | AppDomainSetup appSetup = new AppDomainSetup(); | 798 | m_ScriptEnginesPath, |
729 | appSetup.PrivateBinPath = Path.Combine( | 799 | m_Scene.RegionInfo.RegionID.ToString()); |
730 | m_ScriptEnginesPath, | 800 | |
731 | m_Scene.RegionInfo.RegionID.ToString()); | 801 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
732 | 802 | Evidence evidence = new Evidence(baseEvidence); | |
733 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 803 | |
734 | Evidence evidence = new Evidence(baseEvidence); | 804 | AppDomain sandbox; |
735 | 805 | if (m_AppDomainLoading) | |
736 | AppDomain sandbox; | 806 | sandbox = AppDomain.CreateDomain( |
737 | if (m_AppDomainLoading) | 807 | m_Scene.RegionInfo.RegionID.ToString(), |
738 | sandbox = AppDomain.CreateDomain( | 808 | evidence, appSetup); |
739 | m_Scene.RegionInfo.RegionID.ToString(), | 809 | else |
740 | evidence, appSetup); | 810 | sandbox = AppDomain.CurrentDomain; |
741 | else | 811 | |
742 | sandbox = AppDomain.CurrentDomain; | 812 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
743 | 813 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | |
744 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 814 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
745 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 815 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
746 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 816 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
747 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 817 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; |
748 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 818 | //sandbox.SetAppDomainPolicy(sandboxPolicy); |
749 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 819 | |
750 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | 820 | m_AppDomains[appDomain] = sandbox; |
751 | 821 | ||
752 | m_AppDomains[appDomain] = sandbox; | 822 | m_AppDomains[appDomain].AssemblyResolve += |
753 | 823 | new ResolveEventHandler( | |
754 | m_AppDomains[appDomain].AssemblyResolve += | 824 | AssemblyResolver.OnAssemblyResolve); |
755 | new ResolveEventHandler( | 825 | m_DomainScripts[appDomain] = new List<UUID>(); |
756 | AssemblyResolver.OnAssemblyResolve); | 826 | } |
757 | m_DomainScripts[appDomain] = new List<UUID>(); | 827 | catch (Exception e) |
758 | } | 828 | { |
759 | catch (Exception e) | 829 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
830 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
831 | m_ScriptFailCount++; | ||
832 | lock (m_AddingAssemblies) | ||
760 | { | 833 | { |
761 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | 834 | m_AddingAssemblies[assembly]--; |
762 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
763 | m_ScriptFailCount++; | ||
764 | lock (m_AddingAssemblies) | ||
765 | { | ||
766 | m_AddingAssemblies[assembly]--; | ||
767 | } | ||
768 | return false; | ||
769 | } | 835 | } |
836 | return false; | ||
770 | } | 837 | } |
771 | m_DomainScripts[appDomain].Add(itemID); | 838 | } |
772 | 839 | m_DomainScripts[appDomain].Add(itemID); | |
773 | instance = new ScriptInstance(this, part, | 840 | |
774 | itemID, assetID, assembly, | 841 | instance = new ScriptInstance(this, part, |
775 | m_AppDomains[appDomain], | 842 | itemID, assetID, assembly, |
776 | part.ParentGroup.RootPart.Name, | 843 | m_AppDomains[appDomain], |
777 | item.Name, startParam, postOnRez, | 844 | part.ParentGroup.RootPart.Name, |
778 | stateSource, m_MaxScriptQueue); | 845 | item.Name, startParam, postOnRez, |
779 | 846 | stateSource, m_MaxScriptQueue); | |
780 | m_log.DebugFormat( | 847 | |
848 | m_log.DebugFormat( | ||
781 | "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | 849 | "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", |
782 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | 850 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, |
783 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 851 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
784 | 852 | ||
785 | if (presence != null) | 853 | if (presence != null) |
786 | { | 854 | { |
787 | ShowScriptSaveResponse(item.OwnerID, | 855 | ShowScriptSaveResponse(item.OwnerID, |
788 | assetID, "Compile successful", true); | 856 | assetID, "Compile successful", true); |
789 | } | ||
790 | |||
791 | instance.AppDomain = appDomain; | ||
792 | instance.LineMap = linemap; | ||
793 | |||
794 | m_Scripts[itemID] = instance; | ||
795 | } | 857 | } |
796 | } | ||
797 | 858 | ||
859 | instance.AppDomain = appDomain; | ||
860 | instance.LineMap = linemap; | ||
861 | lockScriptsForWrite(true); | ||
862 | m_Scripts[itemID] = instance; | ||
863 | lockScriptsForWrite(false); | ||
864 | } | ||
865 | else | ||
866 | { | ||
867 | lockScriptsForRead(false); | ||
868 | } | ||
798 | lock (m_PrimObjects) | 869 | lock (m_PrimObjects) |
799 | { | 870 | { |
800 | if (!m_PrimObjects.ContainsKey(localID)) | 871 | if (!m_PrimObjects.ContainsKey(localID)) |
@@ -813,9 +884,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
813 | m_AddingAssemblies[assembly]--; | 884 | m_AddingAssemblies[assembly]--; |
814 | } | 885 | } |
815 | 886 | ||
816 | if (instance != null) | 887 | if (instance!=null) |
817 | instance.Init(); | 888 | instance.Init(); |
818 | 889 | ||
819 | return true; | 890 | return true; |
820 | } | 891 | } |
821 | 892 | ||
@@ -828,20 +899,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
828 | m_CompileDict.Remove(itemID); | 899 | m_CompileDict.Remove(itemID); |
829 | } | 900 | } |
830 | 901 | ||
831 | IScriptInstance instance = null; | 902 | lockScriptsForRead(true); |
832 | 903 | // Do we even have it? | |
833 | lock (m_Scripts) | 904 | if (!m_Scripts.ContainsKey(itemID)) |
834 | { | 905 | { |
835 | // Do we even have it? | 906 | lockScriptsForRead(false); |
836 | if (!m_Scripts.ContainsKey(itemID)) | 907 | return; |
837 | return; | ||
838 | |||
839 | instance=m_Scripts[itemID]; | ||
840 | m_Scripts.Remove(itemID); | ||
841 | } | 908 | } |
909 | |||
842 | 910 | ||
911 | IScriptInstance instance=m_Scripts[itemID]; | ||
912 | lockScriptsForRead(false); | ||
913 | lockScriptsForWrite(true); | ||
914 | m_Scripts.Remove(itemID); | ||
915 | lockScriptsForWrite(false); | ||
843 | instance.ClearQueue(); | 916 | instance.ClearQueue(); |
844 | instance.Stop(0); | 917 | instance.Stop(0); |
918 | |||
845 | // bool objectRemoved = false; | 919 | // bool objectRemoved = false; |
846 | 920 | ||
847 | lock (m_PrimObjects) | 921 | lock (m_PrimObjects) |
@@ -877,11 +951,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
877 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 951 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
878 | if (handlerObjectRemoved != null) | 952 | if (handlerObjectRemoved != null) |
879 | { | 953 | { |
880 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | 954 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); |
881 | handlerObjectRemoved(part.UUID); | 955 | handlerObjectRemoved(part.UUID); |
882 | } | 956 | } |
883 | 957 | ||
884 | 958 | CleanAssemblies(); | |
959 | |||
885 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 960 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
886 | if (handlerScriptRemoved != null) | 961 | if (handlerScriptRemoved != null) |
887 | handlerScriptRemoved(itemID); | 962 | handlerScriptRemoved(itemID); |
@@ -1023,7 +1098,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1023 | return false; | 1098 | return false; |
1024 | 1099 | ||
1025 | uuids = m_PrimObjects[localID]; | 1100 | uuids = m_PrimObjects[localID]; |
1026 | } | 1101 | |
1027 | 1102 | ||
1028 | foreach (UUID itemID in uuids) | 1103 | foreach (UUID itemID in uuids) |
1029 | { | 1104 | { |
@@ -1041,6 +1116,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1041 | result = true; | 1116 | result = true; |
1042 | } | 1117 | } |
1043 | } | 1118 | } |
1119 | } | ||
1044 | 1120 | ||
1045 | return result; | 1121 | return result; |
1046 | } | 1122 | } |
@@ -1140,12 +1216,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1140 | private IScriptInstance GetInstance(UUID itemID) | 1216 | private IScriptInstance GetInstance(UUID itemID) |
1141 | { | 1217 | { |
1142 | IScriptInstance instance; | 1218 | IScriptInstance instance; |
1143 | lock (m_Scripts) | 1219 | lockScriptsForRead(true); |
1220 | if (!m_Scripts.ContainsKey(itemID)) | ||
1144 | { | 1221 | { |
1145 | if (!m_Scripts.ContainsKey(itemID)) | 1222 | lockScriptsForRead(false); |
1146 | return null; | 1223 | return null; |
1147 | instance = m_Scripts[itemID]; | ||
1148 | } | 1224 | } |
1225 | instance = m_Scripts[itemID]; | ||
1226 | lockScriptsForRead(false); | ||
1149 | return instance; | 1227 | return instance; |
1150 | } | 1228 | } |
1151 | 1229 | ||
@@ -1169,6 +1247,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1169 | return false; | 1247 | return false; |
1170 | } | 1248 | } |
1171 | 1249 | ||
1250 | [DebuggerNonUserCode] | ||
1172 | public void ApiResetScript(UUID itemID) | 1251 | public void ApiResetScript(UUID itemID) |
1173 | { | 1252 | { |
1174 | IScriptInstance instance = GetInstance(itemID); | 1253 | IScriptInstance instance = GetInstance(itemID); |
@@ -1220,6 +1299,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1220 | return UUID.Zero; | 1299 | return UUID.Zero; |
1221 | } | 1300 | } |
1222 | 1301 | ||
1302 | [DebuggerNonUserCode] | ||
1223 | public void SetState(UUID itemID, string newState) | 1303 | public void SetState(UUID itemID, string newState) |
1224 | { | 1304 | { |
1225 | IScriptInstance instance = GetInstance(itemID); | 1305 | IScriptInstance instance = GetInstance(itemID); |
@@ -1240,11 +1320,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1240 | { | 1320 | { |
1241 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1321 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1242 | 1322 | ||
1243 | lock (m_Scripts) | 1323 | lockScriptsForRead(true); |
1244 | { | 1324 | foreach (IScriptInstance instance in m_Scripts.Values) |
1245 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1246 | instances.Add(instance); | 1325 | instances.Add(instance); |
1247 | } | 1326 | lockScriptsForRead(false); |
1248 | 1327 | ||
1249 | foreach (IScriptInstance i in instances) | 1328 | foreach (IScriptInstance i in instances) |
1250 | { | 1329 | { |