diff options
Diffstat (limited to '')
15 files changed, 1511 insertions, 819 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 30fb252..59e905e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -81,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
81 | /// </summary> | 82 | /// </summary> |
82 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | 83 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi |
83 | { | 84 | { |
84 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 85 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
85 | protected IScriptEngine m_ScriptEngine; | 86 | protected IScriptEngine m_ScriptEngine; |
86 | protected SceneObjectPart m_host; | 87 | protected SceneObjectPart m_host; |
87 | protected uint m_localID; | 88 | protected uint m_localID; |
@@ -99,6 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
99 | protected int m_notecardLineReadCharsMax = 255; | 100 | protected int m_notecardLineReadCharsMax = 255; |
100 | protected int m_scriptConsoleChannel = 0; | 101 | protected int m_scriptConsoleChannel = 0; |
101 | protected bool m_scriptConsoleChannelEnabled = false; | 102 | protected bool m_scriptConsoleChannelEnabled = false; |
103 | protected bool m_debuggerSafe = false; | ||
102 | protected IUrlModule m_UrlModule = null; | 104 | protected IUrlModule m_UrlModule = null; |
103 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 105 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
104 | new Dictionary<UUID, UserInfoCacheEntry>(); | 106 | new Dictionary<UUID, UserInfoCacheEntry>(); |
@@ -109,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
109 | m_host = host; | 111 | m_host = host; |
110 | m_localID = localID; | 112 | m_localID = localID; |
111 | m_itemID = itemID; | 113 | m_itemID = itemID; |
114 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
112 | 115 | ||
113 | m_ScriptDelayFactor = | 116 | m_ScriptDelayFactor = |
114 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 117 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
@@ -161,6 +164,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
161 | get { return m_ScriptEngine.World; } | 164 | get { return m_ScriptEngine.World; } |
162 | } | 165 | } |
163 | 166 | ||
167 | [DebuggerNonUserCode] | ||
164 | public void state(string newState) | 168 | public void state(string newState) |
165 | { | 169 | { |
166 | m_ScriptEngine.SetState(m_itemID, newState); | 170 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -170,6 +174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
170 | /// Reset the named script. The script must be present | 174 | /// Reset the named script. The script must be present |
171 | /// in the same prim. | 175 | /// in the same prim. |
172 | /// </summary> | 176 | /// </summary> |
177 | [DebuggerNonUserCode] | ||
173 | public void llResetScript() | 178 | public void llResetScript() |
174 | { | 179 | { |
175 | m_host.AddScriptLPS(1); | 180 | m_host.AddScriptLPS(1); |
@@ -226,9 +231,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
226 | } | 231 | } |
227 | } | 232 | } |
228 | 233 | ||
234 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
235 | { | ||
236 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
237 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
238 | return ret; | ||
239 | |||
240 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
241 | |||
242 | switch (linkType) | ||
243 | { | ||
244 | case ScriptBaseClass.LINK_SET: | ||
245 | return avs; | ||
246 | |||
247 | case ScriptBaseClass.LINK_ROOT: | ||
248 | return ret; | ||
249 | |||
250 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
251 | return avs; | ||
252 | |||
253 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
254 | return avs; | ||
255 | |||
256 | case ScriptBaseClass.LINK_THIS: | ||
257 | return ret; | ||
258 | |||
259 | default: | ||
260 | if (linkType < 0) | ||
261 | return ret; | ||
262 | |||
263 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
264 | |||
265 | if (linkType <= partCount) | ||
266 | { | ||
267 | return ret; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | linkType = linkType - partCount; | ||
272 | if (linkType > avs.Count) | ||
273 | { | ||
274 | return ret; | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | ret.Add(avs[linkType-1]); | ||
279 | return ret; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | |||
229 | public List<SceneObjectPart> GetLinkParts(int linkType) | 285 | public List<SceneObjectPart> GetLinkParts(int linkType) |
230 | { | 286 | { |
231 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 287 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
288 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
289 | return ret; | ||
232 | ret.Add(m_host); | 290 | ret.Add(m_host); |
233 | 291 | ||
234 | switch (linkType) | 292 | switch (linkType) |
@@ -288,40 +346,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
288 | protected UUID InventorySelf() | 346 | protected UUID InventorySelf() |
289 | { | 347 | { |
290 | UUID invItemID = new UUID(); | 348 | UUID invItemID = new UUID(); |
291 | 349 | bool unlock = false; | |
292 | lock (m_host.TaskInventory) | 350 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
293 | { | 351 | { |
294 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 352 | m_host.TaskInventory.LockItemsForRead(true); |
353 | unlock = true; | ||
354 | } | ||
355 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
356 | { | ||
357 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
295 | { | 358 | { |
296 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 359 | invItemID = inv.Key; |
297 | { | 360 | break; |
298 | invItemID = inv.Key; | ||
299 | break; | ||
300 | } | ||
301 | } | 361 | } |
302 | } | 362 | } |
303 | 363 | if (unlock) | |
364 | { | ||
365 | m_host.TaskInventory.LockItemsForRead(false); | ||
366 | } | ||
304 | return invItemID; | 367 | return invItemID; |
305 | } | 368 | } |
306 | 369 | ||
307 | protected UUID InventoryKey(string name, int type) | 370 | protected UUID InventoryKey(string name, int type) |
308 | { | 371 | { |
309 | m_host.AddScriptLPS(1); | 372 | m_host.AddScriptLPS(1); |
310 | 373 | m_host.TaskInventory.LockItemsForRead(true); | |
311 | lock (m_host.TaskInventory) | 374 | |
375 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
312 | { | 376 | { |
313 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 377 | if (inv.Value.Name == name) |
314 | { | 378 | { |
315 | if (inv.Value.Name == name) | 379 | m_host.TaskInventory.LockItemsForRead(false); |
380 | |||
381 | if (inv.Value.Type != type) | ||
316 | { | 382 | { |
317 | if (inv.Value.Type != type) | 383 | return UUID.Zero; |
318 | return UUID.Zero; | ||
319 | |||
320 | return inv.Value.AssetID; | ||
321 | } | 384 | } |
385 | |||
386 | return inv.Value.AssetID; | ||
322 | } | 387 | } |
323 | } | 388 | } |
324 | 389 | ||
390 | m_host.TaskInventory.LockItemsForRead(false); | ||
325 | return UUID.Zero; | 391 | return UUID.Zero; |
326 | } | 392 | } |
327 | 393 | ||
@@ -329,17 +395,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | { | 395 | { |
330 | m_host.AddScriptLPS(1); | 396 | m_host.AddScriptLPS(1); |
331 | 397 | ||
332 | lock (m_host.TaskInventory) | 398 | |
399 | m_host.TaskInventory.LockItemsForRead(true); | ||
400 | |||
401 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
333 | { | 402 | { |
334 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 403 | if (inv.Value.Name == name) |
335 | { | 404 | { |
336 | if (inv.Value.Name == name) | 405 | m_host.TaskInventory.LockItemsForRead(false); |
337 | { | 406 | return inv.Value.AssetID; |
338 | return inv.Value.AssetID; | ||
339 | } | ||
340 | } | 407 | } |
341 | } | 408 | } |
342 | 409 | ||
410 | m_host.TaskInventory.LockItemsForRead(false); | ||
411 | |||
412 | |||
343 | return UUID.Zero; | 413 | return UUID.Zero; |
344 | } | 414 | } |
345 | 415 | ||
@@ -481,26 +551,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
481 | 551 | ||
482 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 552 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
483 | 553 | ||
484 | // Old implementation of llRot2Euler. Normalization not required as Atan2 function will | 554 | // Utility function for llRot2Euler |
485 | // only return values >= -PI (-180 degrees) and <= PI (180 degrees). | 555 | |
556 | // normalize an angle between -PI and PI (-180 to +180 degrees) | ||
557 | protected double NormalizeAngle(double angle) | ||
558 | { | ||
559 | if (angle > -Math.PI && angle < Math.PI) | ||
560 | return angle; | ||
561 | |||
562 | int numPis = (int)(Math.PI / angle); | ||
563 | double remainder = angle - Math.PI * numPis; | ||
564 | if (numPis % 2 == 1) | ||
565 | return Math.PI - angle; | ||
566 | return remainder; | ||
567 | } | ||
486 | 568 | ||
487 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 569 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
488 | { | 570 | { |
489 | m_host.AddScriptLPS(1); | 571 | m_host.AddScriptLPS(1); |
490 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | 572 | LSL_Vector eul = new LSL_Vector(); |
491 | LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | 573 | |
492 | double m = (t.x + t.y + t.z + t.s); | 574 | double sqw = q1.s*q1.s; |
493 | if (m == 0) return new LSL_Vector(); | 575 | double sqx = q1.x*q1.x; |
494 | double n = 2 * (r.y * r.s + r.x * r.z); | 576 | double sqy = q1.z*q1.z; |
495 | double p = m * m - n * n; | 577 | double sqz = q1.y*q1.y; |
496 | if (p > 0) | 578 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor |
497 | return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), | 579 | double test = q1.x*q1.z + q1.y*q1.s; |
498 | Math.Atan2(n, Math.Sqrt(p)), | 580 | if (test > 0.4999*unit) { // singularity at north pole |
499 | Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); | 581 | eul.z = 2 * Math.Atan2(q1.x,q1.s); |
500 | else if (n > 0) | 582 | eul.y = Math.PI/2; |
501 | return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); | 583 | eul.x = 0; |
502 | else | 584 | return eul; |
503 | return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); | 585 | } |
586 | if (test < -0.4999*unit) { // singularity at south pole | ||
587 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
588 | eul.y = -Math.PI/2; | ||
589 | eul.x = 0; | ||
590 | return eul; | ||
591 | } | ||
592 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
593 | eul.y = Math.Asin(2*test/unit); | ||
594 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
595 | return eul; | ||
504 | } | 596 | } |
505 | 597 | ||
506 | /* From wiki: | 598 | /* From wiki: |
@@ -702,77 +794,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
702 | { | 794 | { |
703 | //A and B should both be normalized | 795 | //A and B should both be normalized |
704 | m_host.AddScriptLPS(1); | 796 | m_host.AddScriptLPS(1); |
705 | LSL_Rotation rotBetween; | 797 | /* This method is more accurate than the SL one, and thus causes problems |
706 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 798 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
707 | // continue calculation. | 799 | |
708 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 800 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | { | 801 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 802 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
711 | } | 803 | double angle = Math.Acos(dotProduct / magProduct); |
712 | else | 804 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); |
713 | { | 805 | double s = Math.Sin(angle / 2); |
714 | a = LSL_Vector.Norm(a); | 806 | |
715 | b = LSL_Vector.Norm(b); | 807 | double x = axis.x * s; |
716 | double dotProduct = LSL_Vector.Dot(a, b); | 808 | double y = axis.y * s; |
717 | // There are two degenerate cases possible. These are for vectors 180 or | 809 | double z = axis.z * s; |
718 | // 0 degrees apart. These have to be detected and handled individually. | 810 | double w = Math.Cos(angle / 2); |
719 | // | 811 | |
720 | // Check for vectors 180 degrees apart. | 812 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) |
721 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 813 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | if (dotProduct < -0.9999999f) | 814 | |
723 | { | 815 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | // First assume X axis is orthogonal to the vectors. | 816 | */ |
725 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 817 | |
726 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 818 | // This method mimics the 180 errors found in SL |
727 | // Check for near zero vector. A very small non-zero number here will create | 819 | // See www.euclideanspace.com... angleBetween |
728 | // a rotation in an undesired direction. | 820 | LSL_Vector vec_a = a; |
729 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 821 | LSL_Vector vec_b = b; |
730 | { | 822 | |
731 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 823 | // Eliminate zero length |
732 | } | 824 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); |
733 | // If the magnitude of the vector was near zero, then assume the X axis is not | 825 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); |
734 | // orthogonal and use the Z axis instead. | 826 | if (vec_a_mag < 0.00001 || |
735 | else | 827 | vec_b_mag < 0.00001) |
736 | { | 828 | { |
737 | // Set 180 z rotation. | 829 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
738 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | 830 | } |
739 | } | 831 | |
740 | } | 832 | // Normalize |
741 | // Check for parallel vectors. | 833 | vec_a = llVecNorm(vec_a); |
742 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | 834 | vec_b = llVecNorm(vec_b); |
743 | else if (dotProduct > 0.9999999f) | 835 | |
744 | { | 836 | // Calculate axis and rotation angle |
745 | // Set zero rotation. | 837 | LSL_Vector axis = vec_a % vec_b; |
746 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 838 | LSL_Float cos_theta = vec_a * vec_b; |
747 | } | 839 | |
748 | else | 840 | // Check if parallel |
749 | { | 841 | if (cos_theta > 0.99999) |
750 | // All special checks have been performed so get the axis of rotation. | 842 | { |
751 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 843 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
752 | // Quarternion s value is the length of the unit vector + dot product. | 844 | } |
753 | double qs = 1.0 + dotProduct; | 845 | |
754 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | 846 | // Check if anti-parallel |
755 | // Normalize the rotation. | 847 | else if (cos_theta < -0.99999) |
756 | double mag = LSL_Rotation.Mag(rotBetween); | 848 | { |
757 | // We shouldn't have to worry about a divide by zero here. The qs value will be | 849 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
758 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | 850 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
759 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | 851 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
760 | // crossProduct vector should also not be zero. | 852 | } |
761 | rotBetween.x = rotBetween.x / mag; | 853 | else // other rotation |
762 | rotBetween.y = rotBetween.y / mag; | 854 | { |
763 | rotBetween.z = rotBetween.z / mag; | 855 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
764 | rotBetween.s = rotBetween.s / mag; | 856 | axis = llVecNorm(axis); |
765 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | 857 | double x, y, z, s, t; |
766 | // any longer since zero vectors are checked for at the top. | 858 | s = Math.Cos(theta); |
767 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | 859 | t = Math.Sin(theta); |
768 | { | 860 | x = axis.x * t; |
769 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 861 | y = axis.y * t; |
770 | } | 862 | z = axis.z * t; |
771 | } | 863 | return new LSL_Rotation(x,y,z,s); |
772 | } | 864 | } |
773 | return rotBetween; | 865 | } |
774 | } | 866 | |
775 | |||
776 | public void llWhisper(int channelID, string text) | 867 | public void llWhisper(int channelID, string text) |
777 | { | 868 | { |
778 | m_host.AddScriptLPS(1); | 869 | m_host.AddScriptLPS(1); |
@@ -1096,10 +1187,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1096 | return detectedParams.TouchUV; | 1187 | return detectedParams.TouchUV; |
1097 | } | 1188 | } |
1098 | 1189 | ||
1190 | [DebuggerNonUserCode] | ||
1099 | public virtual void llDie() | 1191 | public virtual void llDie() |
1100 | { | 1192 | { |
1101 | m_host.AddScriptLPS(1); | 1193 | m_host.AddScriptLPS(1); |
1102 | throw new SelfDeleteException(); | 1194 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1103 | } | 1195 | } |
1104 | 1196 | ||
1105 | public LSL_Float llGround(LSL_Vector offset) | 1197 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1172,6 +1264,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1172 | 1264 | ||
1173 | public void llSetStatus(int status, int value) | 1265 | public void llSetStatus(int status, int value) |
1174 | { | 1266 | { |
1267 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1268 | return; | ||
1175 | m_host.AddScriptLPS(1); | 1269 | m_host.AddScriptLPS(1); |
1176 | 1270 | ||
1177 | int statusrotationaxis = 0; | 1271 | int statusrotationaxis = 0; |
@@ -1402,6 +1496,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1402 | { | 1496 | { |
1403 | m_host.AddScriptLPS(1); | 1497 | m_host.AddScriptLPS(1); |
1404 | 1498 | ||
1499 | SetColor(m_host, color, face); | ||
1500 | } | ||
1501 | |||
1502 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1503 | { | ||
1504 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1505 | return; | ||
1506 | |||
1507 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1508 | Color4 texcolor; | ||
1509 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1510 | { | ||
1511 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1512 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1513 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1514 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1515 | tex.FaceTextures[face].RGBA = texcolor; | ||
1516 | part.UpdateTexture(tex); | ||
1517 | return; | ||
1518 | } | ||
1519 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1520 | { | ||
1521 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1522 | { | ||
1523 | if (tex.FaceTextures[i] != null) | ||
1524 | { | ||
1525 | texcolor = tex.FaceTextures[i].RGBA; | ||
1526 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1527 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1528 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1529 | tex.FaceTextures[i].RGBA = texcolor; | ||
1530 | } | ||
1531 | texcolor = tex.DefaultTexture.RGBA; | ||
1532 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1533 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1534 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1535 | tex.DefaultTexture.RGBA = texcolor; | ||
1536 | } | ||
1537 | part.UpdateTexture(tex); | ||
1538 | return; | ||
1539 | } | ||
1540 | |||
1405 | if (face == ScriptBaseClass.ALL_SIDES) | 1541 | if (face == ScriptBaseClass.ALL_SIDES) |
1406 | face = SceneObjectPart.ALL_SIDES; | 1542 | face = SceneObjectPart.ALL_SIDES; |
1407 | 1543 | ||
@@ -1410,6 +1546,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1410 | 1546 | ||
1411 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1547 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1412 | { | 1548 | { |
1549 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1550 | return; | ||
1551 | |||
1413 | Primitive.TextureEntry tex = part.Shape.Textures; | 1552 | Primitive.TextureEntry tex = part.Shape.Textures; |
1414 | MappingType textype; | 1553 | MappingType textype; |
1415 | textype = MappingType.Default; | 1554 | textype = MappingType.Default; |
@@ -1440,6 +1579,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1440 | 1579 | ||
1441 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1580 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1442 | { | 1581 | { |
1582 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1583 | return; | ||
1584 | |||
1443 | Primitive.TextureEntry tex = part.Shape.Textures; | 1585 | Primitive.TextureEntry tex = part.Shape.Textures; |
1444 | if (face >= 0 && face < GetNumberOfSides(part)) | 1586 | if (face >= 0 && face < GetNumberOfSides(part)) |
1445 | { | 1587 | { |
@@ -1465,6 +1607,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1465 | 1607 | ||
1466 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1608 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1467 | { | 1609 | { |
1610 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1611 | return; | ||
1468 | 1612 | ||
1469 | Shininess sval = new Shininess(); | 1613 | Shininess sval = new Shininess(); |
1470 | 1614 | ||
@@ -1515,6 +1659,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1515 | 1659 | ||
1516 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1660 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1517 | { | 1661 | { |
1662 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1663 | return; | ||
1664 | |||
1518 | Primitive.TextureEntry tex = part.Shape.Textures; | 1665 | Primitive.TextureEntry tex = part.Shape.Textures; |
1519 | if (face >= 0 && face < GetNumberOfSides(part)) | 1666 | if (face >= 0 && face < GetNumberOfSides(part)) |
1520 | { | 1667 | { |
@@ -1575,13 +1722,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1575 | m_host.AddScriptLPS(1); | 1722 | m_host.AddScriptLPS(1); |
1576 | 1723 | ||
1577 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1724 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1578 | 1725 | if (parts.Count > 0) | |
1579 | foreach (SceneObjectPart part in parts) | 1726 | { |
1580 | SetAlpha(part, alpha, face); | 1727 | try |
1728 | { | ||
1729 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1730 | foreach (SceneObjectPart part in parts) | ||
1731 | SetAlpha(part, alpha, face); | ||
1732 | } | ||
1733 | finally | ||
1734 | { | ||
1735 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1736 | } | ||
1737 | } | ||
1581 | } | 1738 | } |
1582 | 1739 | ||
1583 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1740 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1584 | { | 1741 | { |
1742 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1743 | return; | ||
1744 | |||
1585 | Primitive.TextureEntry tex = part.Shape.Textures; | 1745 | Primitive.TextureEntry tex = part.Shape.Textures; |
1586 | Color4 texcolor; | 1746 | Color4 texcolor; |
1587 | if (face >= 0 && face < GetNumberOfSides(part)) | 1747 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1627,7 +1787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1787 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1628 | float wind, float tension, LSL_Vector Force) | 1788 | float wind, float tension, LSL_Vector Force) |
1629 | { | 1789 | { |
1630 | if (part == null) | 1790 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1631 | return; | 1791 | return; |
1632 | 1792 | ||
1633 | if (flexi) | 1793 | if (flexi) |
@@ -1662,7 +1822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1662 | /// <param name="falloff"></param> | 1822 | /// <param name="falloff"></param> |
1663 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1823 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1664 | { | 1824 | { |
1665 | if (part == null) | 1825 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1666 | return; | 1826 | return; |
1667 | 1827 | ||
1668 | if (light) | 1828 | if (light) |
@@ -1739,15 +1899,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1739 | m_host.AddScriptLPS(1); | 1899 | m_host.AddScriptLPS(1); |
1740 | 1900 | ||
1741 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1901 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1742 | 1902 | if (parts.Count > 0) | |
1743 | foreach (SceneObjectPart part in parts) | 1903 | { |
1744 | SetTexture(part, texture, face); | 1904 | try |
1745 | 1905 | { | |
1906 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1907 | foreach (SceneObjectPart part in parts) | ||
1908 | SetTexture(part, texture, face); | ||
1909 | } | ||
1910 | finally | ||
1911 | { | ||
1912 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1913 | } | ||
1914 | } | ||
1746 | ScriptSleep(200); | 1915 | ScriptSleep(200); |
1747 | } | 1916 | } |
1748 | 1917 | ||
1749 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1918 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1750 | { | 1919 | { |
1920 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1921 | return; | ||
1922 | |||
1751 | UUID textureID=new UUID(); | 1923 | UUID textureID=new UUID(); |
1752 | 1924 | ||
1753 | if (!UUID.TryParse(texture, out textureID)) | 1925 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1793,6 +1965,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1793 | 1965 | ||
1794 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1966 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1795 | { | 1967 | { |
1968 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1969 | return; | ||
1970 | |||
1796 | Primitive.TextureEntry tex = part.Shape.Textures; | 1971 | Primitive.TextureEntry tex = part.Shape.Textures; |
1797 | if (face >= 0 && face < GetNumberOfSides(part)) | 1972 | if (face >= 0 && face < GetNumberOfSides(part)) |
1798 | { | 1973 | { |
@@ -1829,6 +2004,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1829 | 2004 | ||
1830 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2005 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1831 | { | 2006 | { |
2007 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2008 | return; | ||
2009 | |||
1832 | Primitive.TextureEntry tex = part.Shape.Textures; | 2010 | Primitive.TextureEntry tex = part.Shape.Textures; |
1833 | if (face >= 0 && face < GetNumberOfSides(part)) | 2011 | if (face >= 0 && face < GetNumberOfSides(part)) |
1834 | { | 2012 | { |
@@ -1865,6 +2043,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1865 | 2043 | ||
1866 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2044 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1867 | { | 2045 | { |
2046 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2047 | return; | ||
2048 | |||
1868 | Primitive.TextureEntry tex = part.Shape.Textures; | 2049 | Primitive.TextureEntry tex = part.Shape.Textures; |
1869 | if (face >= 0 && face < GetNumberOfSides(part)) | 2050 | if (face >= 0 && face < GetNumberOfSides(part)) |
1870 | { | 2051 | { |
@@ -1935,6 +2116,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1935 | 2116 | ||
1936 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2117 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1937 | { | 2118 | { |
2119 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2120 | return; | ||
2121 | |||
1938 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2122 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1939 | LSL_Vector currentPos = GetPartLocalPos(part); | 2123 | LSL_Vector currentPos = GetPartLocalPos(part); |
1940 | 2124 | ||
@@ -1951,7 +2135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1951 | } | 2135 | } |
1952 | else | 2136 | else |
1953 | { | 2137 | { |
1954 | LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); | 2138 | LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos); |
1955 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | 2139 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); |
1956 | SceneObjectGroup parent = part.ParentGroup; | 2140 | SceneObjectGroup parent = part.ParentGroup; |
1957 | parent.HasGroupChanged = true; | 2141 | parent.HasGroupChanged = true; |
@@ -2003,9 +2187,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2003 | m_host.AddScriptLPS(1); | 2187 | m_host.AddScriptLPS(1); |
2004 | 2188 | ||
2005 | // try to let this work as in SL... | 2189 | // try to let this work as in SL... |
2006 | if (m_host.ParentID == 0) | 2190 | if (m_host.LinkNum < 2) |
2007 | { | 2191 | { |
2008 | // special case: If we are root, rotate complete SOG to new rotation | 2192 | // Special case: If we are root, rotate complete SOG to new |
2193 | // rotation. | ||
2194 | // We are root if the link number is 0 (single prim) or 1 | ||
2195 | // (root prim). ParentID may be nonzero in attachments and | ||
2196 | // using it would cause attachments and HUDs to rotate | ||
2197 | // to the wrong positions. | ||
2009 | SetRot(m_host, Rot2Quaternion(rot)); | 2198 | SetRot(m_host, Rot2Quaternion(rot)); |
2010 | } | 2199 | } |
2011 | else | 2200 | else |
@@ -2034,6 +2223,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2034 | 2223 | ||
2035 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2224 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2036 | { | 2225 | { |
2226 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2227 | return; | ||
2228 | |||
2037 | part.UpdateRotation(rot); | 2229 | part.UpdateRotation(rot); |
2038 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2230 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2039 | 2231 | ||
@@ -2653,12 +2845,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2653 | 2845 | ||
2654 | m_host.AddScriptLPS(1); | 2846 | m_host.AddScriptLPS(1); |
2655 | 2847 | ||
2848 | m_host.TaskInventory.LockItemsForRead(true); | ||
2656 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2849 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2657 | 2850 | m_host.TaskInventory.LockItemsForRead(false); | |
2658 | lock (m_host.TaskInventory) | ||
2659 | { | ||
2660 | item = m_host.TaskInventory[invItemID]; | ||
2661 | } | ||
2662 | 2851 | ||
2663 | if (item.PermsGranter == UUID.Zero) | 2852 | if (item.PermsGranter == UUID.Zero) |
2664 | return 0; | 2853 | return 0; |
@@ -2733,6 +2922,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2733 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2922 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2734 | return; | 2923 | return; |
2735 | 2924 | ||
2925 | //Clone is thread-safe | ||
2736 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2926 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2737 | 2927 | ||
2738 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2928 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2795,6 +2985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2795 | 2985 | ||
2796 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2986 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2797 | { | 2987 | { |
2988 | /* | ||
2798 | m_host.AddScriptLPS(1); | 2989 | m_host.AddScriptLPS(1); |
2799 | // Determine where we are looking from | 2990 | // Determine where we are looking from |
2800 | LSL_Vector from = llGetPos(); | 2991 | LSL_Vector from = llGetPos(); |
@@ -2814,10 +3005,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2814 | // the angles of rotation in radians into rotation value | 3005 | // the angles of rotation in radians into rotation value |
2815 | 3006 | ||
2816 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 3007 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2817 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 3008 | |
2818 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 3009 | // This would only work if your physics system contains an APID controller: |
3010 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
3011 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
3012 | |||
2819 | // Orient the object to the angle calculated | 3013 | // Orient the object to the angle calculated |
2820 | //llSetRot(rot); | 3014 | llSetRot(rot); |
3015 | */ | ||
3016 | |||
3017 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
3018 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
3019 | // http://bugs.meta7.com/view.php?id=28 | ||
3020 | // - Tom | ||
3021 | |||
3022 | /* And the following does not do the job either. It has to be performed inside the ODE glue-code. -.- .._. | ||
3023 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
3024 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
3025 | */ | ||
3026 | if (m_host.PhysActor != null && !m_host.PhysActor.IsPhysical) | ||
3027 | { | ||
3028 | // Part is non-phys, convert this to a llSetRot() | ||
3029 | Vector3 tgt = new Vector3((float)target.x, (float)target.y, (float)target.z); | ||
3030 | Vector3 dir = tgt - m_host.GroupPosition; | ||
3031 | dir.Normalize(); | ||
3032 | float tzrot = (float)Math.Atan2(dir.Y, dir.X); | ||
3033 | float txy = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y)); | ||
3034 | float terot = (float)Math.Atan2(-dir.Z, txy); | ||
3035 | LSL_Vector az = new LSL_Vector(0.0f, 0.0f, tzrot); | ||
3036 | LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f); | ||
3037 | LSL_Types.Quaternion spin = llEuler2Rot(az); | ||
3038 | LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin; | ||
3039 | llSetRot(rot); | ||
3040 | } | ||
3041 | else | ||
3042 | { | ||
3043 | // Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. | ||
3044 | Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); | ||
3045 | m_host.RotLookAt(q, (float)strength, (float)damping); | ||
3046 | } | ||
3047 | |||
3048 | } | ||
3049 | |||
3050 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3051 | { | ||
3052 | m_host.AddScriptLPS(1); | ||
3053 | // NotImplemented("llRotLookAt"); | ||
3054 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3055 | |||
2821 | } | 3056 | } |
2822 | 3057 | ||
2823 | public void llStopLookAt() | 3058 | public void llStopLookAt() |
@@ -2866,13 +3101,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2866 | { | 3101 | { |
2867 | TaskInventoryItem item; | 3102 | TaskInventoryItem item; |
2868 | 3103 | ||
2869 | lock (m_host.TaskInventory) | 3104 | m_host.TaskInventory.LockItemsForRead(true); |
3105 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2870 | { | 3106 | { |
2871 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3107 | m_host.TaskInventory.LockItemsForRead(false); |
2872 | return; | 3108 | return; |
2873 | else | 3109 | } |
2874 | item = m_host.TaskInventory[InventorySelf()]; | 3110 | else |
3111 | { | ||
3112 | item = m_host.TaskInventory[InventorySelf()]; | ||
2875 | } | 3113 | } |
3114 | m_host.TaskInventory.LockItemsForRead(false); | ||
2876 | 3115 | ||
2877 | if (item.PermsGranter != UUID.Zero) | 3116 | if (item.PermsGranter != UUID.Zero) |
2878 | { | 3117 | { |
@@ -2894,13 +3133,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2894 | { | 3133 | { |
2895 | TaskInventoryItem item; | 3134 | TaskInventoryItem item; |
2896 | 3135 | ||
3136 | m_host.TaskInventory.LockItemsForRead(true); | ||
2897 | lock (m_host.TaskInventory) | 3137 | lock (m_host.TaskInventory) |
2898 | { | 3138 | { |
3139 | |||
2899 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3140 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3141 | { | ||
3142 | m_host.TaskInventory.LockItemsForRead(false); | ||
2900 | return; | 3143 | return; |
3144 | } | ||
2901 | else | 3145 | else |
3146 | { | ||
2902 | item = m_host.TaskInventory[InventorySelf()]; | 3147 | item = m_host.TaskInventory[InventorySelf()]; |
3148 | } | ||
2903 | } | 3149 | } |
3150 | m_host.TaskInventory.LockItemsForRead(false); | ||
2904 | 3151 | ||
2905 | m_host.AddScriptLPS(1); | 3152 | m_host.AddScriptLPS(1); |
2906 | 3153 | ||
@@ -2932,19 +3179,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2932 | { | 3179 | { |
2933 | m_host.AddScriptLPS(1); | 3180 | m_host.AddScriptLPS(1); |
2934 | 3181 | ||
2935 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
2936 | return; | ||
2937 | |||
2938 | TaskInventoryItem item; | 3182 | TaskInventoryItem item; |
2939 | 3183 | ||
2940 | lock (m_host.TaskInventory) | 3184 | m_host.TaskInventory.LockItemsForRead(true); |
3185 | |||
3186 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2941 | { | 3187 | { |
2942 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3188 | m_host.TaskInventory.LockItemsForRead(false); |
2943 | return; | 3189 | return; |
2944 | else | 3190 | } |
2945 | item = m_host.TaskInventory[InventorySelf()]; | 3191 | else |
3192 | { | ||
3193 | item = m_host.TaskInventory[InventorySelf()]; | ||
2946 | } | 3194 | } |
2947 | 3195 | ||
3196 | m_host.TaskInventory.LockItemsForRead(false); | ||
3197 | |||
2948 | if (item.PermsGranter != m_host.OwnerID) | 3198 | if (item.PermsGranter != m_host.OwnerID) |
2949 | return; | 3199 | return; |
2950 | 3200 | ||
@@ -2954,10 +3204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2954 | 3204 | ||
2955 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3205 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
2956 | 3206 | ||
2957 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3207 | 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 | } | 3208 | } |
2962 | } | 3209 | } |
2963 | 3210 | ||
@@ -2970,13 +3217,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2970 | 3217 | ||
2971 | TaskInventoryItem item; | 3218 | TaskInventoryItem item; |
2972 | 3219 | ||
2973 | lock (m_host.TaskInventory) | 3220 | m_host.TaskInventory.LockItemsForRead(true); |
3221 | |||
3222 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2974 | { | 3223 | { |
2975 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3224 | m_host.TaskInventory.LockItemsForRead(false); |
2976 | return; | 3225 | return; |
2977 | else | 3226 | } |
2978 | item = m_host.TaskInventory[InventorySelf()]; | 3227 | else |
3228 | { | ||
3229 | item = m_host.TaskInventory[InventorySelf()]; | ||
2979 | } | 3230 | } |
3231 | m_host.TaskInventory.LockItemsForRead(false); | ||
3232 | |||
2980 | 3233 | ||
2981 | if (item.PermsGranter != m_host.OwnerID) | 3234 | if (item.PermsGranter != m_host.OwnerID) |
2982 | return; | 3235 | return; |
@@ -3023,6 +3276,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3023 | 3276 | ||
3024 | public void llInstantMessage(string user, string message) | 3277 | public void llInstantMessage(string user, string message) |
3025 | { | 3278 | { |
3279 | UUID result; | ||
3280 | if (!UUID.TryParse(user, out result)) | ||
3281 | { | ||
3282 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3283 | ScriptSleep(2000); | ||
3284 | return; | ||
3285 | } | ||
3286 | |||
3287 | |||
3026 | m_host.AddScriptLPS(1); | 3288 | m_host.AddScriptLPS(1); |
3027 | 3289 | ||
3028 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3290 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3037,14 +3299,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3037 | UUID friendTransactionID = UUID.Random(); | 3299 | UUID friendTransactionID = UUID.Random(); |
3038 | 3300 | ||
3039 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3301 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3040 | 3302 | ||
3041 | GridInstantMessage msg = new GridInstantMessage(); | 3303 | GridInstantMessage msg = new GridInstantMessage(); |
3042 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3304 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3043 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3305 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3044 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3306 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3045 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3307 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3046 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3308 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3047 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3309 | // DateTime dt = DateTime.UtcNow; |
3310 | // | ||
3311 | // // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3312 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3313 | // | ||
3314 | // try | ||
3315 | // { | ||
3316 | // // Convert that to the PST timezone | ||
3317 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3318 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3319 | // } | ||
3320 | // catch | ||
3321 | // { | ||
3322 | // // No logging here, as it could be VERY spammy | ||
3323 | // } | ||
3324 | // | ||
3325 | // // And make it look local again to fool the unix time util | ||
3326 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3327 | |||
3328 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
3329 | |||
3048 | //if (client != null) | 3330 | //if (client != null) |
3049 | //{ | 3331 | //{ |
3050 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3332 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3058,13 +3340,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3058 | msg.message = message.Substring(0, 1024); | 3340 | msg.message = message.Substring(0, 1024); |
3059 | else | 3341 | else |
3060 | msg.message = message; | 3342 | msg.message = message; |
3061 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3343 | msg.dialog = (byte)19; // MessageFromObject |
3062 | msg.fromGroup = false;// fromGroup; | 3344 | msg.fromGroup = false;// fromGroup; |
3063 | msg.offline = (byte)0; //offline; | 3345 | msg.offline = (byte)0; //offline; |
3064 | msg.ParentEstateID = 0; //ParentEstateID; | 3346 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3065 | msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); | 3347 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3066 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3348 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3067 | msg.binaryBucket = new byte[0];// binaryBucket; | 3349 | msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); |
3068 | 3350 | ||
3069 | if (m_TransferModule != null) | 3351 | if (m_TransferModule != null) |
3070 | { | 3352 | { |
@@ -3084,7 +3366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3084 | } | 3366 | } |
3085 | 3367 | ||
3086 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3368 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3087 | ScriptSleep(20000); | 3369 | ScriptSleep(15000); |
3088 | } | 3370 | } |
3089 | 3371 | ||
3090 | public void llGetNextEmail(string address, string subject) | 3372 | public void llGetNextEmail(string address, string subject) |
@@ -3186,13 +3468,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3186 | m_host.AddScriptLPS(1); | 3468 | m_host.AddScriptLPS(1); |
3187 | } | 3469 | } |
3188 | 3470 | ||
3189 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3190 | { | ||
3191 | m_host.AddScriptLPS(1); | ||
3192 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3193 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3194 | } | ||
3195 | |||
3196 | public LSL_Integer llStringLength(string str) | 3471 | public LSL_Integer llStringLength(string str) |
3197 | { | 3472 | { |
3198 | m_host.AddScriptLPS(1); | 3473 | m_host.AddScriptLPS(1); |
@@ -3216,14 +3491,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3216 | 3491 | ||
3217 | TaskInventoryItem item; | 3492 | TaskInventoryItem item; |
3218 | 3493 | ||
3219 | lock (m_host.TaskInventory) | 3494 | m_host.TaskInventory.LockItemsForRead(true); |
3495 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3220 | { | 3496 | { |
3221 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3497 | m_host.TaskInventory.LockItemsForRead(false); |
3222 | return; | 3498 | return; |
3223 | else | ||
3224 | item = m_host.TaskInventory[InventorySelf()]; | ||
3225 | } | 3499 | } |
3226 | 3500 | else | |
3501 | { | ||
3502 | item = m_host.TaskInventory[InventorySelf()]; | ||
3503 | } | ||
3504 | m_host.TaskInventory.LockItemsForRead(false); | ||
3227 | if (item.PermsGranter == UUID.Zero) | 3505 | if (item.PermsGranter == UUID.Zero) |
3228 | return; | 3506 | return; |
3229 | 3507 | ||
@@ -3253,13 +3531,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3253 | 3531 | ||
3254 | TaskInventoryItem item; | 3532 | TaskInventoryItem item; |
3255 | 3533 | ||
3256 | lock (m_host.TaskInventory) | 3534 | m_host.TaskInventory.LockItemsForRead(true); |
3535 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3257 | { | 3536 | { |
3258 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3537 | m_host.TaskInventory.LockItemsForRead(false); |
3259 | return; | 3538 | return; |
3260 | else | 3539 | } |
3261 | item = m_host.TaskInventory[InventorySelf()]; | 3540 | else |
3541 | { | ||
3542 | item = m_host.TaskInventory[InventorySelf()]; | ||
3262 | } | 3543 | } |
3544 | m_host.TaskInventory.LockItemsForRead(false); | ||
3545 | |||
3263 | 3546 | ||
3264 | if (item.PermsGranter == UUID.Zero) | 3547 | if (item.PermsGranter == UUID.Zero) |
3265 | return; | 3548 | return; |
@@ -3330,10 +3613,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3330 | 3613 | ||
3331 | TaskInventoryItem item; | 3614 | TaskInventoryItem item; |
3332 | 3615 | ||
3333 | lock (m_host.TaskInventory) | 3616 | |
3617 | m_host.TaskInventory.LockItemsForRead(true); | ||
3618 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3619 | { | ||
3620 | m_host.TaskInventory.LockItemsForRead(false); | ||
3621 | return; | ||
3622 | } | ||
3623 | else | ||
3334 | { | 3624 | { |
3335 | item = m_host.TaskInventory[invItemID]; | 3625 | item = m_host.TaskInventory[invItemID]; |
3336 | } | 3626 | } |
3627 | m_host.TaskInventory.LockItemsForRead(false); | ||
3337 | 3628 | ||
3338 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3629 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3339 | { | 3630 | { |
@@ -3365,11 +3656,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3365 | 3656 | ||
3366 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3657 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3367 | { | 3658 | { |
3368 | lock (m_host.TaskInventory) | 3659 | m_host.TaskInventory.LockItemsForWrite(true); |
3369 | { | 3660 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3370 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3661 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3371 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3662 | m_host.TaskInventory.LockItemsForWrite(false); |
3372 | } | ||
3373 | 3663 | ||
3374 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3664 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3375 | "run_time_permissions", new Object[] { | 3665 | "run_time_permissions", new Object[] { |
@@ -3389,11 +3679,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3389 | 3679 | ||
3390 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3680 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3391 | { | 3681 | { |
3392 | lock (m_host.TaskInventory) | 3682 | m_host.TaskInventory.LockItemsForWrite(true); |
3393 | { | 3683 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3394 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3684 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3395 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3685 | m_host.TaskInventory.LockItemsForWrite(false); |
3396 | } | ||
3397 | 3686 | ||
3398 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3687 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3399 | "run_time_permissions", new Object[] { | 3688 | "run_time_permissions", new Object[] { |
@@ -3414,11 +3703,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3414 | 3703 | ||
3415 | if (!m_waitingForScriptAnswer) | 3704 | if (!m_waitingForScriptAnswer) |
3416 | { | 3705 | { |
3417 | lock (m_host.TaskInventory) | 3706 | m_host.TaskInventory.LockItemsForWrite(true); |
3418 | { | 3707 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3419 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3708 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3420 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3709 | m_host.TaskInventory.LockItemsForWrite(false); |
3421 | } | ||
3422 | 3710 | ||
3423 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3711 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3424 | m_waitingForScriptAnswer=true; | 3712 | m_waitingForScriptAnswer=true; |
@@ -3453,10 +3741,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3453 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3741 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3454 | llReleaseControls(); | 3742 | llReleaseControls(); |
3455 | 3743 | ||
3456 | lock (m_host.TaskInventory) | 3744 | |
3457 | { | 3745 | m_host.TaskInventory.LockItemsForWrite(true); |
3458 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3746 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3459 | } | 3747 | m_host.TaskInventory.LockItemsForWrite(false); |
3748 | |||
3460 | 3749 | ||
3461 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3750 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3462 | "run_time_permissions", new Object[] { | 3751 | "run_time_permissions", new Object[] { |
@@ -3468,16 +3757,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3468 | { | 3757 | { |
3469 | m_host.AddScriptLPS(1); | 3758 | m_host.AddScriptLPS(1); |
3470 | 3759 | ||
3471 | lock (m_host.TaskInventory) | 3760 | m_host.TaskInventory.LockItemsForRead(true); |
3761 | |||
3762 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3472 | { | 3763 | { |
3473 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3764 | if (item.Type == 10 && item.ItemID == m_itemID) |
3474 | { | 3765 | { |
3475 | if (item.Type == 10 && item.ItemID == m_itemID) | 3766 | m_host.TaskInventory.LockItemsForRead(false); |
3476 | { | 3767 | return item.PermsGranter.ToString(); |
3477 | return item.PermsGranter.ToString(); | ||
3478 | } | ||
3479 | } | 3768 | } |
3480 | } | 3769 | } |
3770 | m_host.TaskInventory.LockItemsForRead(false); | ||
3481 | 3771 | ||
3482 | return UUID.Zero.ToString(); | 3772 | return UUID.Zero.ToString(); |
3483 | } | 3773 | } |
@@ -3486,19 +3776,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3486 | { | 3776 | { |
3487 | m_host.AddScriptLPS(1); | 3777 | m_host.AddScriptLPS(1); |
3488 | 3778 | ||
3489 | lock (m_host.TaskInventory) | 3779 | m_host.TaskInventory.LockItemsForRead(true); |
3780 | |||
3781 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3490 | { | 3782 | { |
3491 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3783 | if (item.Type == 10 && item.ItemID == m_itemID) |
3492 | { | 3784 | { |
3493 | if (item.Type == 10 && item.ItemID == m_itemID) | 3785 | int perms = item.PermsMask; |
3494 | { | 3786 | if (m_automaticLinkPermission) |
3495 | int perms = item.PermsMask; | 3787 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3496 | if (m_automaticLinkPermission) | 3788 | m_host.TaskInventory.LockItemsForRead(false); |
3497 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3789 | return perms; |
3498 | return perms; | ||
3499 | } | ||
3500 | } | 3790 | } |
3501 | } | 3791 | } |
3792 | m_host.TaskInventory.LockItemsForRead(false); | ||
3502 | 3793 | ||
3503 | return 0; | 3794 | return 0; |
3504 | } | 3795 | } |
@@ -3520,9 +3811,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3520 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3811 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3521 | { | 3812 | { |
3522 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3813 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3523 | 3814 | if (parts.Count > 0) | |
3524 | foreach (SceneObjectPart part in parts) | 3815 | { |
3525 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3816 | try |
3817 | { | ||
3818 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3819 | foreach (SceneObjectPart part in parts) | ||
3820 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3821 | } | ||
3822 | finally | ||
3823 | { | ||
3824 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3825 | } | ||
3826 | } | ||
3526 | } | 3827 | } |
3527 | 3828 | ||
3528 | public void llCreateLink(string target, int parent) | 3829 | public void llCreateLink(string target, int parent) |
@@ -3535,11 +3836,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3535 | return; | 3836 | return; |
3536 | 3837 | ||
3537 | TaskInventoryItem item; | 3838 | TaskInventoryItem item; |
3538 | lock (m_host.TaskInventory) | 3839 | m_host.TaskInventory.LockItemsForRead(true); |
3539 | { | 3840 | item = m_host.TaskInventory[invItemID]; |
3540 | item = m_host.TaskInventory[invItemID]; | 3841 | m_host.TaskInventory.LockItemsForRead(false); |
3541 | } | 3842 | |
3542 | |||
3543 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3843 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3544 | && !m_automaticLinkPermission) | 3844 | && !m_automaticLinkPermission) |
3545 | { | 3845 | { |
@@ -3560,7 +3860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3560 | 3860 | ||
3561 | if (targetPart != null) | 3861 | if (targetPart != null) |
3562 | { | 3862 | { |
3563 | if (parent != 0) { | 3863 | if (parent != 0) |
3864 | { | ||
3564 | parentPrim = m_host.ParentGroup; | 3865 | parentPrim = m_host.ParentGroup; |
3565 | childPrim = targetPart.ParentGroup; | 3866 | childPrim = targetPart.ParentGroup; |
3566 | } | 3867 | } |
@@ -3592,16 +3893,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3592 | m_host.AddScriptLPS(1); | 3893 | m_host.AddScriptLPS(1); |
3593 | UUID invItemID = InventorySelf(); | 3894 | UUID invItemID = InventorySelf(); |
3594 | 3895 | ||
3595 | lock (m_host.TaskInventory) | 3896 | m_host.TaskInventory.LockItemsForRead(true); |
3596 | { | ||
3597 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3897 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3598 | && !m_automaticLinkPermission) | 3898 | && !m_automaticLinkPermission) |
3599 | { | 3899 | { |
3600 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3900 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3901 | m_host.TaskInventory.LockItemsForRead(false); | ||
3601 | return; | 3902 | return; |
3602 | } | 3903 | } |
3603 | } | 3904 | m_host.TaskInventory.LockItemsForRead(false); |
3604 | 3905 | ||
3605 | if (linknum < ScriptBaseClass.LINK_THIS) | 3906 | if (linknum < ScriptBaseClass.LINK_THIS) |
3606 | return; | 3907 | return; |
3607 | 3908 | ||
@@ -3640,10 +3941,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3640 | // Restructuring Multiple Prims. | 3941 | // Restructuring Multiple Prims. |
3641 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 3942 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3642 | parts.Remove(parentPrim.RootPart); | 3943 | parts.Remove(parentPrim.RootPart); |
3643 | foreach (SceneObjectPart part in parts) | 3944 | if (parts.Count > 0) |
3644 | { | 3945 | { |
3645 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3946 | try |
3947 | { | ||
3948 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3949 | foreach (SceneObjectPart part in parts) | ||
3950 | { | ||
3951 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3952 | } | ||
3953 | } | ||
3954 | finally | ||
3955 | { | ||
3956 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3957 | } | ||
3646 | } | 3958 | } |
3959 | |||
3647 | parentPrim.HasGroupChanged = true; | 3960 | parentPrim.HasGroupChanged = true; |
3648 | parentPrim.ScheduleGroupForFullUpdate(); | 3961 | parentPrim.ScheduleGroupForFullUpdate(); |
3649 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3962 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3652,11 +3965,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3652 | { | 3965 | { |
3653 | SceneObjectPart newRoot = parts[0]; | 3966 | SceneObjectPart newRoot = parts[0]; |
3654 | parts.Remove(newRoot); | 3967 | parts.Remove(newRoot); |
3655 | foreach (SceneObjectPart part in parts) | 3968 | |
3969 | try | ||
3656 | { | 3970 | { |
3657 | part.UpdateFlag = 0; | 3971 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3658 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3972 | foreach (SceneObjectPart part in parts) |
3973 | { | ||
3974 | part.UpdateFlag = 0; | ||
3975 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3976 | } | ||
3659 | } | 3977 | } |
3978 | finally | ||
3979 | { | ||
3980 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3981 | } | ||
3982 | |||
3983 | |||
3660 | newRoot.ParentGroup.HasGroupChanged = true; | 3984 | newRoot.ParentGroup.HasGroupChanged = true; |
3661 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3985 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3662 | } | 3986 | } |
@@ -3702,6 +4026,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3702 | } | 4026 | } |
3703 | else | 4027 | else |
3704 | { | 4028 | { |
4029 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
4030 | { | ||
4031 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4032 | |||
4033 | if (linknum < 0) | ||
4034 | return UUID.Zero.ToString(); | ||
4035 | |||
4036 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
4037 | if (avatars.Count > linknum) | ||
4038 | { | ||
4039 | return avatars[linknum].UUID.ToString(); | ||
4040 | } | ||
4041 | } | ||
3705 | return UUID.Zero.ToString(); | 4042 | return UUID.Zero.ToString(); |
3706 | } | 4043 | } |
3707 | } | 4044 | } |
@@ -3778,17 +4115,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3778 | m_host.AddScriptLPS(1); | 4115 | m_host.AddScriptLPS(1); |
3779 | int count = 0; | 4116 | int count = 0; |
3780 | 4117 | ||
3781 | lock (m_host.TaskInventory) | 4118 | m_host.TaskInventory.LockItemsForRead(true); |
4119 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3782 | { | 4120 | { |
3783 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4121 | if (inv.Value.Type == type || type == -1) |
3784 | { | 4122 | { |
3785 | if (inv.Value.Type == type || type == -1) | 4123 | count = count + 1; |
3786 | { | ||
3787 | count = count + 1; | ||
3788 | } | ||
3789 | } | 4124 | } |
3790 | } | 4125 | } |
3791 | 4126 | ||
4127 | m_host.TaskInventory.LockItemsForRead(false); | ||
3792 | return count; | 4128 | return count; |
3793 | } | 4129 | } |
3794 | 4130 | ||
@@ -3797,16 +4133,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3797 | m_host.AddScriptLPS(1); | 4133 | m_host.AddScriptLPS(1); |
3798 | ArrayList keys = new ArrayList(); | 4134 | ArrayList keys = new ArrayList(); |
3799 | 4135 | ||
3800 | lock (m_host.TaskInventory) | 4136 | m_host.TaskInventory.LockItemsForRead(true); |
4137 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3801 | { | 4138 | { |
3802 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4139 | if (inv.Value.Type == type || type == -1) |
3803 | { | 4140 | { |
3804 | if (inv.Value.Type == type || type == -1) | 4141 | keys.Add(inv.Value.Name); |
3805 | { | ||
3806 | keys.Add(inv.Value.Name); | ||
3807 | } | ||
3808 | } | 4142 | } |
3809 | } | 4143 | } |
4144 | m_host.TaskInventory.LockItemsForRead(false); | ||
3810 | 4145 | ||
3811 | if (keys.Count == 0) | 4146 | if (keys.Count == 0) |
3812 | { | 4147 | { |
@@ -3843,20 +4178,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3843 | } | 4178 | } |
3844 | 4179 | ||
3845 | // move the first object found with this inventory name | 4180 | // move the first object found with this inventory name |
3846 | lock (m_host.TaskInventory) | 4181 | m_host.TaskInventory.LockItemsForRead(true); |
4182 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3847 | { | 4183 | { |
3848 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4184 | if (inv.Value.Name == inventory) |
3849 | { | 4185 | { |
3850 | if (inv.Value.Name == inventory) | 4186 | found = true; |
3851 | { | 4187 | objId = inv.Key; |
3852 | found = true; | 4188 | assetType = inv.Value.Type; |
3853 | objId = inv.Key; | 4189 | objName = inv.Value.Name; |
3854 | assetType = inv.Value.Type; | 4190 | break; |
3855 | objName = inv.Value.Name; | ||
3856 | break; | ||
3857 | } | ||
3858 | } | 4191 | } |
3859 | } | 4192 | } |
4193 | m_host.TaskInventory.LockItemsForRead(false); | ||
3860 | 4194 | ||
3861 | if (!found) | 4195 | if (!found) |
3862 | { | 4196 | { |
@@ -3864,9 +4198,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3864 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4198 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3865 | } | 4199 | } |
3866 | 4200 | ||
3867 | // check if destination is an avatar | 4201 | // check if destination is an object |
3868 | if (World.GetScenePresence(destId) != null) | 4202 | if (World.GetSceneObjectPart(destId) != null) |
4203 | { | ||
4204 | // destination is an object | ||
4205 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4206 | } | ||
4207 | else | ||
3869 | { | 4208 | { |
4209 | ScenePresence presence = World.GetScenePresence(destId); | ||
4210 | |||
4211 | if (presence == null) | ||
4212 | { | ||
4213 | UserAccount account = | ||
4214 | World.UserAccountService.GetUserAccount( | ||
4215 | World.RegionInfo.ScopeID, | ||
4216 | destId); | ||
4217 | |||
4218 | if (account == null) | ||
4219 | { | ||
4220 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4221 | return; | ||
4222 | } | ||
4223 | } | ||
4224 | |||
3870 | // destination is an avatar | 4225 | // destination is an avatar |
3871 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4226 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3872 | 4227 | ||
@@ -3890,31 +4245,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3890 | 4245 | ||
3891 | if (m_TransferModule != null) | 4246 | if (m_TransferModule != null) |
3892 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4247 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4248 | |||
4249 | //This delay should only occur when giving inventory to avatars. | ||
4250 | ScriptSleep(3000); | ||
3893 | } | 4251 | } |
3894 | else | ||
3895 | { | ||
3896 | // destination is an object | ||
3897 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3898 | } | ||
3899 | ScriptSleep(3000); | ||
3900 | } | 4252 | } |
3901 | 4253 | ||
4254 | [DebuggerNonUserCode] | ||
3902 | public void llRemoveInventory(string name) | 4255 | public void llRemoveInventory(string name) |
3903 | { | 4256 | { |
3904 | m_host.AddScriptLPS(1); | 4257 | m_host.AddScriptLPS(1); |
3905 | 4258 | ||
3906 | lock (m_host.TaskInventory) | 4259 | List<TaskInventoryItem> inv; |
4260 | try | ||
3907 | { | 4261 | { |
3908 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4262 | m_host.TaskInventory.LockItemsForRead(true); |
4263 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | ||
4264 | } | ||
4265 | finally | ||
4266 | { | ||
4267 | m_host.TaskInventory.LockItemsForRead(false); | ||
4268 | } | ||
4269 | foreach (TaskInventoryItem item in inv) | ||
4270 | { | ||
4271 | if (item.Name == name) | ||
3909 | { | 4272 | { |
3910 | if (item.Name == name) | 4273 | if (item.ItemID == m_itemID) |
3911 | { | 4274 | throw new ScriptDeleteException(); |
3912 | if (item.ItemID == m_itemID) | 4275 | else |
3913 | throw new ScriptDeleteException(); | 4276 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3914 | else | 4277 | return; |
3915 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
3916 | return; | ||
3917 | } | ||
3918 | } | 4278 | } |
3919 | } | 4279 | } |
3920 | } | 4280 | } |
@@ -3949,112 +4309,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3949 | { | 4309 | { |
3950 | m_host.AddScriptLPS(1); | 4310 | m_host.AddScriptLPS(1); |
3951 | 4311 | ||
3952 | UUID uuid = (UUID)id; | 4312 | UUID uuid; |
3953 | PresenceInfo pinfo = null; | 4313 | if (UUID.TryParse(id, out uuid)) |
3954 | UserAccount account; | ||
3955 | |||
3956 | UserInfoCacheEntry ce; | ||
3957 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
3958 | { | 4314 | { |
3959 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4315 | PresenceInfo pinfo = null; |
3960 | if (account == null) | 4316 | UserAccount account; |
4317 | |||
4318 | UserInfoCacheEntry ce; | ||
4319 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
3961 | { | 4320 | { |
3962 | m_userInfoCache[uuid] = null; // Cache negative | 4321 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
3963 | return UUID.Zero.ToString(); | 4322 | if (account == null) |
3964 | } | 4323 | { |
4324 | m_userInfoCache[uuid] = null; // Cache negative | ||
4325 | return UUID.Zero.ToString(); | ||
4326 | } | ||
3965 | 4327 | ||
3966 | 4328 | ||
3967 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4329 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3968 | if (pinfos != null && pinfos.Length > 0) | 4330 | if (pinfos != null && pinfos.Length > 0) |
3969 | { | ||
3970 | foreach (PresenceInfo p in pinfos) | ||
3971 | { | 4331 | { |
3972 | if (p.RegionID != UUID.Zero) | 4332 | foreach (PresenceInfo p in pinfos) |
3973 | { | 4333 | { |
3974 | pinfo = p; | 4334 | if (p.RegionID != UUID.Zero) |
4335 | { | ||
4336 | pinfo = p; | ||
4337 | } | ||
3975 | } | 4338 | } |
3976 | } | 4339 | } |
3977 | } | ||
3978 | 4340 | ||
3979 | ce = new UserInfoCacheEntry(); | 4341 | ce = new UserInfoCacheEntry(); |
3980 | ce.time = Util.EnvironmentTickCount(); | 4342 | ce.time = Util.EnvironmentTickCount(); |
3981 | ce.account = account; | 4343 | ce.account = account; |
3982 | ce.pinfo = pinfo; | 4344 | ce.pinfo = pinfo; |
3983 | } | 4345 | m_userInfoCache[uuid] = ce; |
3984 | else | 4346 | } |
3985 | { | 4347 | else |
3986 | if (ce == null) | 4348 | { |
3987 | return UUID.Zero.ToString(); | 4349 | if (ce == null) |
4350 | return UUID.Zero.ToString(); | ||
3988 | 4351 | ||
3989 | account = ce.account; | 4352 | account = ce.account; |
3990 | pinfo = ce.pinfo; | 4353 | pinfo = ce.pinfo; |
3991 | } | 4354 | } |
3992 | 4355 | ||
3993 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 4356 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
3994 | { | ||
3995 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
3996 | if (pinfos != null && pinfos.Length > 0) | ||
3997 | { | 4357 | { |
3998 | foreach (PresenceInfo p in pinfos) | 4358 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4359 | if (pinfos != null && pinfos.Length > 0) | ||
3999 | { | 4360 | { |
4000 | if (p.RegionID != UUID.Zero) | 4361 | foreach (PresenceInfo p in pinfos) |
4001 | { | 4362 | { |
4002 | pinfo = p; | 4363 | if (p.RegionID != UUID.Zero) |
4364 | { | ||
4365 | pinfo = p; | ||
4366 | } | ||
4003 | } | 4367 | } |
4004 | } | 4368 | } |
4005 | } | 4369 | else |
4006 | else | 4370 | pinfo = null; |
4007 | pinfo = null; | ||
4008 | 4371 | ||
4009 | ce.time = Util.EnvironmentTickCount(); | 4372 | ce.time = Util.EnvironmentTickCount(); |
4010 | ce.pinfo = pinfo; | 4373 | ce.pinfo = pinfo; |
4011 | } | 4374 | } |
4012 | 4375 | ||
4013 | string reply = String.Empty; | 4376 | string reply = String.Empty; |
4014 | 4377 | ||
4015 | switch (data) | 4378 | switch (data) |
4016 | { | 4379 | { |
4017 | case 1: // DATA_ONLINE (0|1) | 4380 | case 1: // DATA_ONLINE (0|1) |
4018 | if (pinfo != null && pinfo.RegionID != UUID.Zero) | 4381 | if (pinfo != null && pinfo.RegionID != UUID.Zero) |
4019 | reply = "1"; | 4382 | reply = "1"; |
4020 | else | 4383 | else |
4021 | reply = "0"; | 4384 | reply = "0"; |
4022 | break; | 4385 | break; |
4023 | case 2: // DATA_NAME (First Last) | 4386 | case 2: // DATA_NAME (First Last) |
4024 | reply = account.FirstName + " " + account.LastName; | 4387 | reply = account.FirstName + " " + account.LastName; |
4025 | break; | 4388 | break; |
4026 | case 3: // DATA_BORN (YYYY-MM-DD) | 4389 | case 3: // DATA_BORN (YYYY-MM-DD) |
4027 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | 4390 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); |
4028 | born = born.AddSeconds(account.Created); | 4391 | born = born.AddSeconds(account.Created); |
4029 | reply = born.ToString("yyyy-MM-dd"); | 4392 | reply = born.ToString("yyyy-MM-dd"); |
4030 | break; | 4393 | break; |
4031 | case 4: // DATA_RATING (0,0,0,0,0,0) | 4394 | case 4: // DATA_RATING (0,0,0,0,0,0) |
4032 | reply = "0,0,0,0,0,0"; | 4395 | reply = "0,0,0,0,0,0"; |
4033 | break; | 4396 | break; |
4034 | case 8: // DATA_PAYINFO (0|1|2|3) | 4397 | case 8: // DATA_PAYINFO (0|1|2|3) |
4035 | reply = "0"; | 4398 | reply = "0"; |
4036 | break; | 4399 | break; |
4037 | default: | 4400 | default: |
4038 | return UUID.Zero.ToString(); // Raise no event | 4401 | return UUID.Zero.ToString(); // Raise no event |
4039 | } | 4402 | } |
4040 | 4403 | ||
4041 | UUID rq = UUID.Random(); | 4404 | UUID rq = UUID.Random(); |
4042 | 4405 | ||
4043 | UUID tid = AsyncCommands. | 4406 | UUID tid = AsyncCommands. |
4044 | DataserverPlugin.RegisterRequest(m_localID, | 4407 | DataserverPlugin.RegisterRequest(m_localID, |
4045 | m_itemID, rq.ToString()); | 4408 | m_itemID, rq.ToString()); |
4046 | 4409 | ||
4047 | AsyncCommands. | 4410 | AsyncCommands. |
4048 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4411 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
4049 | 4412 | ||
4050 | ScriptSleep(100); | 4413 | ScriptSleep(100); |
4051 | return tid.ToString(); | 4414 | return tid.ToString(); |
4415 | } | ||
4416 | else | ||
4417 | { | ||
4418 | ShoutError("Invalid UUID passed to llRequestAgentData."); | ||
4419 | } | ||
4420 | return ""; | ||
4052 | } | 4421 | } |
4053 | 4422 | ||
4054 | public LSL_String llRequestInventoryData(string name) | 4423 | public LSL_String llRequestInventoryData(string name) |
4055 | { | 4424 | { |
4056 | m_host.AddScriptLPS(1); | 4425 | m_host.AddScriptLPS(1); |
4057 | 4426 | ||
4427 | //Clone is thread safe | ||
4058 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4428 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
4059 | 4429 | ||
4060 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4430 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4108,6 +4478,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4108 | ScenePresence presence = World.GetScenePresence(agentId); | 4478 | ScenePresence presence = World.GetScenePresence(agentId); |
4109 | if (presence != null) | 4479 | if (presence != null) |
4110 | { | 4480 | { |
4481 | // agent must not be a god | ||
4482 | if (presence.GodLevel >= 200) return; | ||
4483 | |||
4111 | // agent must be over the owners land | 4484 | // agent must be over the owners land |
4112 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4485 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4113 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4486 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4130,7 +4503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4130 | UUID av = new UUID(); | 4503 | UUID av = new UUID(); |
4131 | if (!UUID.TryParse(agent,out av)) | 4504 | if (!UUID.TryParse(agent,out av)) |
4132 | { | 4505 | { |
4133 | LSLError("First parameter to llDialog needs to be a key"); | 4506 | //LSLError("First parameter to llDialog needs to be a key"); |
4134 | return; | 4507 | return; |
4135 | } | 4508 | } |
4136 | 4509 | ||
@@ -4167,17 +4540,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4167 | UUID soundId = UUID.Zero; | 4540 | UUID soundId = UUID.Zero; |
4168 | if (!UUID.TryParse(impact_sound, out soundId)) | 4541 | if (!UUID.TryParse(impact_sound, out soundId)) |
4169 | { | 4542 | { |
4170 | lock (m_host.TaskInventory) | 4543 | m_host.TaskInventory.LockItemsForRead(true); |
4544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4171 | { | 4545 | { |
4172 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4546 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4173 | { | 4547 | { |
4174 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4548 | soundId = item.AssetID; |
4175 | { | 4549 | break; |
4176 | soundId = item.AssetID; | ||
4177 | break; | ||
4178 | } | ||
4179 | } | 4550 | } |
4180 | } | 4551 | } |
4552 | m_host.TaskInventory.LockItemsForRead(false); | ||
4181 | } | 4553 | } |
4182 | m_host.CollisionSound = soundId; | 4554 | m_host.CollisionSound = soundId; |
4183 | m_host.CollisionSoundVolume = (float)impact_volume; | 4555 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4223,6 +4595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4223 | UUID partItemID; | 4595 | UUID partItemID; |
4224 | foreach (SceneObjectPart part in parts) | 4596 | foreach (SceneObjectPart part in parts) |
4225 | { | 4597 | { |
4598 | //Clone is thread safe | ||
4226 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4599 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4227 | 4600 | ||
4228 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4601 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4437,17 +4810,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4437 | 4810 | ||
4438 | m_host.AddScriptLPS(1); | 4811 | m_host.AddScriptLPS(1); |
4439 | 4812 | ||
4440 | lock (m_host.TaskInventory) | 4813 | m_host.TaskInventory.LockItemsForRead(true); |
4814 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4441 | { | 4815 | { |
4442 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4816 | if (item.Type == 10 && item.ItemID == m_itemID) |
4443 | { | 4817 | { |
4444 | if (item.Type == 10 && item.ItemID == m_itemID) | 4818 | result = item.Name!=null?item.Name:String.Empty; |
4445 | { | 4819 | break; |
4446 | result = item.Name != null ? item.Name : String.Empty; | ||
4447 | break; | ||
4448 | } | ||
4449 | } | 4820 | } |
4450 | } | 4821 | } |
4822 | m_host.TaskInventory.LockItemsForRead(false); | ||
4451 | 4823 | ||
4452 | return result; | 4824 | return result; |
4453 | } | 4825 | } |
@@ -4600,23 +4972,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4600 | { | 4972 | { |
4601 | m_host.AddScriptLPS(1); | 4973 | m_host.AddScriptLPS(1); |
4602 | 4974 | ||
4603 | lock (m_host.TaskInventory) | 4975 | m_host.TaskInventory.LockItemsForRead(true); |
4976 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4604 | { | 4977 | { |
4605 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4978 | if (inv.Value.Name == name) |
4606 | { | 4979 | { |
4607 | if (inv.Value.Name == name) | 4980 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4608 | { | 4981 | { |
4609 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4982 | m_host.TaskInventory.LockItemsForRead(false); |
4610 | { | 4983 | return inv.Value.AssetID.ToString(); |
4611 | return inv.Value.AssetID.ToString(); | 4984 | } |
4612 | } | 4985 | else |
4613 | else | 4986 | { |
4614 | { | 4987 | m_host.TaskInventory.LockItemsForRead(false); |
4615 | return UUID.Zero.ToString(); | 4988 | return UUID.Zero.ToString(); |
4616 | } | ||
4617 | } | 4989 | } |
4618 | } | 4990 | } |
4619 | } | 4991 | } |
4992 | m_host.TaskInventory.LockItemsForRead(false); | ||
4620 | 4993 | ||
4621 | return UUID.Zero.ToString(); | 4994 | return UUID.Zero.ToString(); |
4622 | } | 4995 | } |
@@ -4769,14 +5142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4769 | { | 5142 | { |
4770 | m_host.AddScriptLPS(1); | 5143 | m_host.AddScriptLPS(1); |
4771 | 5144 | ||
4772 | if (src == null) | 5145 | return src.Length; |
4773 | { | ||
4774 | return 0; | ||
4775 | } | ||
4776 | else | ||
4777 | { | ||
4778 | return src.Length; | ||
4779 | } | ||
4780 | } | 5146 | } |
4781 | 5147 | ||
4782 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5148 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -4822,7 +5188,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4822 | else if (src.Data[index] is LSL_Float) | 5188 | else if (src.Data[index] is LSL_Float) |
4823 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5189 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
4824 | else if (src.Data[index] is LSL_String) | 5190 | else if (src.Data[index] is LSL_String) |
4825 | return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); | 5191 | { |
5192 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5193 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5194 | if (m != Match.Empty) | ||
5195 | { | ||
5196 | str = m.Value; | ||
5197 | double d = 0.0; | ||
5198 | if (!Double.TryParse(str, out d)) | ||
5199 | return 0.0; | ||
5200 | |||
5201 | return d; | ||
5202 | } | ||
5203 | return 0.0; | ||
5204 | } | ||
4826 | return Convert.ToDouble(src.Data[index]); | 5205 | return Convert.ToDouble(src.Data[index]); |
4827 | } | 5206 | } |
4828 | catch (FormatException) | 5207 | catch (FormatException) |
@@ -5095,7 +5474,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5095 | } | 5474 | } |
5096 | } | 5475 | } |
5097 | } | 5476 | } |
5098 | else { | 5477 | else |
5478 | { | ||
5099 | object[] array = new object[src.Length]; | 5479 | object[] array = new object[src.Length]; |
5100 | Array.Copy(src.Data, 0, array, 0, src.Length); | 5480 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5101 | result = new LSL_List(array); | 5481 | result = new LSL_List(array); |
@@ -5507,7 +5887,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5507 | public void llSetSoundQueueing(int queue) | 5887 | public void llSetSoundQueueing(int queue) |
5508 | { | 5888 | { |
5509 | m_host.AddScriptLPS(1); | 5889 | m_host.AddScriptLPS(1); |
5510 | NotImplemented("llSetSoundQueueing"); | ||
5511 | } | 5890 | } |
5512 | 5891 | ||
5513 | public void llSetSoundRadius(double radius) | 5892 | public void llSetSoundRadius(double radius) |
@@ -5552,10 +5931,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5552 | m_host.AddScriptLPS(1); | 5931 | m_host.AddScriptLPS(1); |
5553 | 5932 | ||
5554 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5933 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5555 | 5934 | if (parts.Count > 0) | |
5556 | foreach (var part in parts) | ||
5557 | { | 5935 | { |
5558 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5936 | try |
5937 | { | ||
5938 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5939 | foreach (var part in parts) | ||
5940 | { | ||
5941 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5942 | } | ||
5943 | } | ||
5944 | finally | ||
5945 | { | ||
5946 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5947 | } | ||
5559 | } | 5948 | } |
5560 | } | 5949 | } |
5561 | 5950 | ||
@@ -5609,6 +5998,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5609 | ScriptSleep(5000); | 5998 | ScriptSleep(5000); |
5610 | } | 5999 | } |
5611 | 6000 | ||
6001 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
6002 | { | ||
6003 | return ParseString2List(str, separators, in_spacers, false); | ||
6004 | } | ||
6005 | |||
5612 | public LSL_Integer llOverMyLand(string id) | 6006 | public LSL_Integer llOverMyLand(string id) |
5613 | { | 6007 | { |
5614 | m_host.AddScriptLPS(1); | 6008 | m_host.AddScriptLPS(1); |
@@ -5809,7 +6203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5809 | return m_host.ParentGroup.RootPart.AttachmentPoint; | 6203 | return m_host.ParentGroup.RootPart.AttachmentPoint; |
5810 | } | 6204 | } |
5811 | 6205 | ||
5812 | public LSL_Integer llGetFreeMemory() | 6206 | public virtual LSL_Integer llGetFreeMemory() |
5813 | { | 6207 | { |
5814 | m_host.AddScriptLPS(1); | 6208 | m_host.AddScriptLPS(1); |
5815 | // Make scripts designed for LSO happy | 6209 | // Make scripts designed for LSO happy |
@@ -5926,7 +6320,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5926 | SetParticleSystem(m_host, rules); | 6320 | SetParticleSystem(m_host, rules); |
5927 | } | 6321 | } |
5928 | 6322 | ||
5929 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { | 6323 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) |
6324 | { | ||
5930 | 6325 | ||
5931 | 6326 | ||
5932 | if (rules.Length == 0) | 6327 | if (rules.Length == 0) |
@@ -6120,14 +6515,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6120 | 6515 | ||
6121 | protected UUID GetTaskInventoryItem(string name) | 6516 | protected UUID GetTaskInventoryItem(string name) |
6122 | { | 6517 | { |
6123 | lock (m_host.TaskInventory) | 6518 | m_host.TaskInventory.LockItemsForRead(true); |
6519 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6124 | { | 6520 | { |
6125 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6521 | if (inv.Value.Name == name) |
6126 | { | 6522 | { |
6127 | if (inv.Value.Name == name) | 6523 | m_host.TaskInventory.LockItemsForRead(false); |
6128 | return inv.Key; | 6524 | return inv.Key; |
6129 | } | 6525 | } |
6130 | } | 6526 | } |
6527 | m_host.TaskInventory.LockItemsForRead(false); | ||
6131 | 6528 | ||
6132 | return UUID.Zero; | 6529 | return UUID.Zero; |
6133 | } | 6530 | } |
@@ -6377,13 +6774,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6377 | UUID av = new UUID(); | 6774 | UUID av = new UUID(); |
6378 | if (!UUID.TryParse(avatar,out av)) | 6775 | if (!UUID.TryParse(avatar,out av)) |
6379 | { | 6776 | { |
6380 | LSLError("First parameter to llDialog needs to be a key"); | 6777 | //LSLError("First parameter to llDialog needs to be a key"); |
6381 | return; | 6778 | return; |
6382 | } | 6779 | } |
6383 | if (buttons.Length < 1) | 6780 | if (buttons.Length < 1) |
6384 | { | 6781 | { |
6385 | LSLError("No less than 1 button can be shown"); | 6782 | buttons.Add("OK"); |
6386 | return; | ||
6387 | } | 6783 | } |
6388 | if (buttons.Length > 12) | 6784 | if (buttons.Length > 12) |
6389 | { | 6785 | { |
@@ -6400,7 +6796,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6400 | } | 6796 | } |
6401 | if (buttons.Data[i].ToString().Length > 24) | 6797 | if (buttons.Data[i].ToString().Length > 24) |
6402 | { | 6798 | { |
6403 | LSLError("button label cannot be longer than 24 characters"); | 6799 | llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); |
6404 | return; | 6800 | return; |
6405 | } | 6801 | } |
6406 | buts[i] = buttons.Data[i].ToString(); | 6802 | buts[i] = buttons.Data[i].ToString(); |
@@ -6464,22 +6860,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6464 | } | 6860 | } |
6465 | 6861 | ||
6466 | // copy the first script found with this inventory name | 6862 | // copy the first script found with this inventory name |
6467 | lock (m_host.TaskInventory) | 6863 | m_host.TaskInventory.LockItemsForRead(true); |
6864 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6468 | { | 6865 | { |
6469 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6866 | if (inv.Value.Name == name) |
6470 | { | 6867 | { |
6471 | if (inv.Value.Name == name) | 6868 | // make sure the object is a script |
6869 | if (10 == inv.Value.Type) | ||
6472 | { | 6870 | { |
6473 | // make sure the object is a script | 6871 | found = true; |
6474 | if (10 == inv.Value.Type) | 6872 | srcId = inv.Key; |
6475 | { | 6873 | break; |
6476 | found = true; | ||
6477 | srcId = inv.Key; | ||
6478 | break; | ||
6479 | } | ||
6480 | } | 6874 | } |
6481 | } | 6875 | } |
6482 | } | 6876 | } |
6877 | m_host.TaskInventory.LockItemsForRead(false); | ||
6483 | 6878 | ||
6484 | if (!found) | 6879 | if (!found) |
6485 | { | 6880 | { |
@@ -6551,18 +6946,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6551 | public LSL_String llMD5String(string src, int nonce) | 6946 | public LSL_String llMD5String(string src, int nonce) |
6552 | { | 6947 | { |
6553 | m_host.AddScriptLPS(1); | 6948 | m_host.AddScriptLPS(1); |
6554 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 6949 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
6555 | } | 6950 | } |
6556 | 6951 | ||
6557 | public LSL_String llSHA1String(string src) | 6952 | public LSL_String llSHA1String(string src) |
6558 | { | 6953 | { |
6559 | m_host.AddScriptLPS(1); | 6954 | m_host.AddScriptLPS(1); |
6560 | return Util.SHA1Hash(src).ToLower(); | 6955 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
6561 | } | 6956 | } |
6562 | 6957 | ||
6563 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6958 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6564 | { | 6959 | { |
6565 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6960 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6961 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6962 | return shapeBlock; | ||
6566 | 6963 | ||
6567 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6964 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6568 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6965 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6638,6 +7035,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6638 | 7035 | ||
6639 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 7036 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6640 | { | 7037 | { |
7038 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7039 | return; | ||
7040 | |||
6641 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7041 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6642 | 7042 | ||
6643 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7043 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6687,6 +7087,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6687 | 7087 | ||
6688 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 7088 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6689 | { | 7089 | { |
7090 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7091 | return; | ||
7092 | |||
6690 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7093 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6691 | 7094 | ||
6692 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7095 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6729,6 +7132,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6729 | 7132 | ||
6730 | 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) | 7133 | 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) |
6731 | { | 7134 | { |
7135 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7136 | return; | ||
7137 | |||
6732 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7138 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6733 | 7139 | ||
6734 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7140 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6855,6 +7261,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6855 | 7261 | ||
6856 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7262 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6857 | { | 7263 | { |
7264 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7265 | return; | ||
7266 | |||
6858 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7267 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6859 | UUID sculptId; | 7268 | UUID sculptId; |
6860 | 7269 | ||
@@ -6870,13 +7279,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6870 | shapeBlock.PathScaleX = 100; | 7279 | shapeBlock.PathScaleX = 100; |
6871 | shapeBlock.PathScaleY = 150; | 7280 | shapeBlock.PathScaleY = 150; |
6872 | 7281 | ||
6873 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7282 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6874 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7283 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6875 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7284 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6876 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7285 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6877 | { | 7286 | { |
6878 | // default | 7287 | // default |
6879 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7288 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6880 | } | 7289 | } |
6881 | 7290 | ||
6882 | // retain pathcurve | 7291 | // retain pathcurve |
@@ -6895,30 +7304,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6895 | ScriptSleep(200); | 7304 | ScriptSleep(200); |
6896 | } | 7305 | } |
6897 | 7306 | ||
6898 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7307 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
6899 | { | 7308 | { |
6900 | m_host.AddScriptLPS(1); | 7309 | m_host.AddScriptLPS(1); |
6901 | 7310 | ||
6902 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7311 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
7312 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7313 | if (parts.Count>0) | ||
7314 | { | ||
7315 | try | ||
7316 | { | ||
7317 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7318 | foreach (SceneObjectPart part in parts) | ||
7319 | SetPrimParams(part, rules); | ||
7320 | } | ||
7321 | finally | ||
7322 | { | ||
7323 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7324 | } | ||
7325 | } | ||
7326 | if (avatars.Count > 0) | ||
7327 | { | ||
7328 | foreach (ScenePresence avatar in avatars) | ||
7329 | SetPrimParams(avatar, rules); | ||
7330 | } | ||
7331 | } | ||
6903 | 7332 | ||
6904 | foreach (SceneObjectPart part in parts) | 7333 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6905 | SetPrimParams(part, rules); | 7334 | { |
6906 | 7335 | llSetLinkPrimitiveParamsFast(linknumber, rules); | |
6907 | ScriptSleep(200); | 7336 | ScriptSleep(200); |
6908 | } | 7337 | } |
6909 | 7338 | ||
6910 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7339 | protected void SetPrimParams(ScenePresence av, LSL_List rules) |
6911 | { | 7340 | { |
6912 | m_host.AddScriptLPS(1); | 7341 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7342 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
6913 | 7343 | ||
6914 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7344 | int idx = 0; |
6915 | 7345 | ||
6916 | foreach (SceneObjectPart part in parts) | 7346 | while (idx < rules.Length) |
6917 | SetPrimParams(part, rules); | 7347 | { |
7348 | int code = rules.GetLSLIntegerItem(idx++); | ||
7349 | |||
7350 | int remain = rules.Length - idx; | ||
7351 | |||
7352 | |||
7353 | |||
7354 | switch (code) | ||
7355 | { | ||
7356 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7357 | if (remain < 1) | ||
7358 | return; | ||
7359 | LSL_Vector v; | ||
7360 | v = rules.GetVector3Item(idx++); | ||
7361 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7362 | av.SendAvatarDataToAllAgents(); | ||
7363 | |||
7364 | break; | ||
7365 | |||
7366 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7367 | if (remain < 1) | ||
7368 | return; | ||
7369 | LSL_Rotation r; | ||
7370 | r = rules.GetQuaternionItem(idx++); | ||
7371 | av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7372 | av.SendAvatarDataToAllAgents(); | ||
7373 | break; | ||
7374 | } | ||
7375 | } | ||
6918 | } | 7376 | } |
6919 | 7377 | ||
6920 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7378 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6921 | { | 7379 | { |
7380 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7381 | return; | ||
7382 | |||
6922 | int idx = 0; | 7383 | int idx = 0; |
6923 | 7384 | ||
6924 | while (idx < rules.Length) | 7385 | while (idx < rules.Length) |
@@ -7453,13 +7914,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7453 | public LSL_Integer llGetNumberOfPrims() | 7914 | public LSL_Integer llGetNumberOfPrims() |
7454 | { | 7915 | { |
7455 | m_host.AddScriptLPS(1); | 7916 | m_host.AddScriptLPS(1); |
7456 | int avatarCount = 0; | 7917 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; |
7457 | World.ForEachScenePresence(delegate(ScenePresence presence) | 7918 | |
7458 | { | ||
7459 | if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | ||
7460 | avatarCount++; | ||
7461 | }); | ||
7462 | |||
7463 | return m_host.ParentGroup.PrimCount + avatarCount; | 7919 | return m_host.ParentGroup.PrimCount + avatarCount; |
7464 | } | 7920 | } |
7465 | 7921 | ||
@@ -7475,55 +7931,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7475 | m_host.AddScriptLPS(1); | 7931 | m_host.AddScriptLPS(1); |
7476 | UUID objID = UUID.Zero; | 7932 | UUID objID = UUID.Zero; |
7477 | LSL_List result = new LSL_List(); | 7933 | LSL_List result = new LSL_List(); |
7934 | |||
7935 | // If the ID is not valid, return null result | ||
7478 | if (!UUID.TryParse(obj, out objID)) | 7936 | if (!UUID.TryParse(obj, out objID)) |
7479 | { | 7937 | { |
7480 | result.Add(new LSL_Vector()); | 7938 | result.Add(new LSL_Vector()); |
7481 | result.Add(new LSL_Vector()); | 7939 | result.Add(new LSL_Vector()); |
7482 | return result; | 7940 | return result; |
7483 | } | 7941 | } |
7942 | |||
7943 | // Check if this is an attached prim. If so, replace | ||
7944 | // the UUID with the avatar UUID and report it's bounding box | ||
7945 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
7946 | if (part != null && part.ParentGroup.IsAttachment) | ||
7947 | objID = part.ParentGroup.RootPart.AttachedAvatar; | ||
7948 | |||
7949 | // Find out if this is an avatar ID. If so, return it's box | ||
7484 | ScenePresence presence = World.GetScenePresence(objID); | 7950 | ScenePresence presence = World.GetScenePresence(objID); |
7485 | if (presence != null) | 7951 | if (presence != null) |
7486 | { | 7952 | { |
7487 | if (presence.ParentID == 0) // not sat on an object | 7953 | // As per LSL Wiki, there is no difference between sitting |
7954 | // and standing avatar since server 1.36 | ||
7955 | LSL_Vector lower; | ||
7956 | LSL_Vector upper; | ||
7957 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
7958 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7488 | { | 7959 | { |
7489 | LSL_Vector lower; | 7960 | // This is for ground sitting avatars |
7490 | LSL_Vector upper; | 7961 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7491 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7962 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7492 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7963 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7493 | { | ||
7494 | // This is for ground sitting avatars | ||
7495 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7496 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7497 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7498 | } | ||
7499 | else | ||
7500 | { | ||
7501 | // This is for standing/flying avatars | ||
7502 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7503 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7504 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7505 | } | ||
7506 | result.Add(lower); | ||
7507 | result.Add(upper); | ||
7508 | return result; | ||
7509 | } | 7964 | } |
7510 | else | 7965 | else |
7511 | { | 7966 | { |
7512 | // sitting on an object so we need the bounding box of that | 7967 | // This is for standing/flying avatars |
7513 | // which should include the avatar so set the UUID to the | 7968 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7514 | // UUID of the object the avatar is sat on and allow it to fall through | 7969 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7515 | // to processing an object | 7970 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7516 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7517 | objID = p.UUID; | ||
7518 | } | 7971 | } |
7972 | |||
7973 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7974 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7975 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7976 | |||
7977 | if (lower.x > upper.x) | ||
7978 | lower.x = upper.x; | ||
7979 | if (lower.y > upper.y) | ||
7980 | lower.y = upper.y; | ||
7981 | if (lower.z > upper.z) | ||
7982 | lower.z = upper.z; | ||
7983 | |||
7984 | result.Add(lower); | ||
7985 | result.Add(upper); | ||
7986 | return result; | ||
7519 | } | 7987 | } |
7520 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 7988 | |
7989 | part = World.GetSceneObjectPart(objID); | ||
7521 | // Currently only works for single prims without a sitting avatar | 7990 | // Currently only works for single prims without a sitting avatar |
7522 | if (part != null) | 7991 | if (part != null) |
7523 | { | 7992 | { |
7524 | Vector3 halfSize = part.Scale / 2.0f; | 7993 | float minX; |
7525 | LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); | 7994 | float maxX; |
7526 | LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); | 7995 | float minY; |
7996 | float maxY; | ||
7997 | float minZ; | ||
7998 | float maxZ; | ||
7999 | |||
8000 | // This BBox is in sim coordinates, with the offset being | ||
8001 | // a contained point. | ||
8002 | Vector3[] offsets = World.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
8003 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
8004 | |||
8005 | minX -= offsets[0].X; | ||
8006 | maxX -= offsets[0].X; | ||
8007 | minY -= offsets[0].Y; | ||
8008 | maxY -= offsets[0].Y; | ||
8009 | minZ -= offsets[0].Z; | ||
8010 | maxZ -= offsets[0].Z; | ||
8011 | |||
8012 | LSL_Vector lower; | ||
8013 | LSL_Vector upper; | ||
8014 | |||
8015 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8016 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
8017 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
8018 | |||
8019 | if (lower.x > upper.x) | ||
8020 | lower.x = upper.x; | ||
8021 | if (lower.y > upper.y) | ||
8022 | lower.y = upper.y; | ||
8023 | if (lower.z > upper.z) | ||
8024 | lower.z = upper.z; | ||
8025 | |||
7527 | result.Add(lower); | 8026 | result.Add(lower); |
7528 | result.Add(upper); | 8027 | result.Add(upper); |
7529 | return result; | 8028 | return result; |
@@ -7603,13 +8102,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7603 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, | 8102 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
7604 | part.AbsolutePosition.Y, | 8103 | part.AbsolutePosition.Y, |
7605 | part.AbsolutePosition.Z); | 8104 | part.AbsolutePosition.Z); |
7606 | // For some reason, the part.AbsolutePosition.* values do not change if the | ||
7607 | // linkset is rotated; they always reflect the child prim's world position | ||
7608 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
7609 | // implementation, so will break scripts imported from there (not to mention it | ||
7610 | // makes it more difficult to determine a child prim's actual inworld position). | ||
7611 | if (part.ParentID != 0) | ||
7612 | v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); | ||
7613 | res.Add(v); | 8105 | res.Add(v); |
7614 | break; | 8106 | break; |
7615 | 8107 | ||
@@ -7770,56 +8262,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7770 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8262 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7771 | if (remain < 1) | 8263 | if (remain < 1) |
7772 | return res; | 8264 | return res; |
7773 | 8265 | face = (int)rules.GetLSLIntegerItem(idx++); | |
7774 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
7775 | 8266 | ||
7776 | tex = part.Shape.Textures; | 8267 | tex = part.Shape.Textures; |
8268 | int shiny; | ||
7777 | if (face == ScriptBaseClass.ALL_SIDES) | 8269 | if (face == ScriptBaseClass.ALL_SIDES) |
7778 | { | 8270 | { |
7779 | for (face = 0; face < GetNumberOfSides(part); face++) | 8271 | for (face = 0; face < GetNumberOfSides(part); face++) |
7780 | { | 8272 | { |
7781 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8273 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
7782 | // Convert Shininess to PRIM_SHINY_* | 8274 | if (shinyness == Shininess.High) |
7783 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 8275 | { |
7784 | // PRIM_BUMP_* | 8276 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
7785 | res.Add(new LSL_Integer((int)texface.Bump)); | 8277 | } |
8278 | else if (shinyness == Shininess.Medium) | ||
8279 | { | ||
8280 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8281 | } | ||
8282 | else if (shinyness == Shininess.Low) | ||
8283 | { | ||
8284 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8285 | } | ||
8286 | else | ||
8287 | { | ||
8288 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8289 | } | ||
8290 | res.Add(new LSL_Integer(shiny)); | ||
8291 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7786 | } | 8292 | } |
7787 | } | 8293 | } |
7788 | else | 8294 | else |
7789 | { | 8295 | { |
7790 | if (face >= 0 && face < GetNumberOfSides(part)) | 8296 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
8297 | if (shinyness == Shininess.High) | ||
7791 | { | 8298 | { |
7792 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8299 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
7793 | // Convert Shininess to PRIM_SHINY_* | 8300 | } |
7794 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 8301 | else if (shinyness == Shininess.Medium) |
7795 | // PRIM_BUMP_* | 8302 | { |
7796 | res.Add(new LSL_Integer((int)texface.Bump)); | 8303 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; |
8304 | } | ||
8305 | else if (shinyness == Shininess.Low) | ||
8306 | { | ||
8307 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8308 | } | ||
8309 | else | ||
8310 | { | ||
8311 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7797 | } | 8312 | } |
8313 | res.Add(new LSL_Integer(shiny)); | ||
8314 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7798 | } | 8315 | } |
7799 | break; | 8316 | break; |
7800 | 8317 | ||
7801 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8318 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7802 | if (remain < 1) | 8319 | if (remain < 1) |
7803 | return res; | 8320 | return res; |
7804 | 8321 | face = (int)rules.GetLSLIntegerItem(idx++); | |
7805 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
7806 | 8322 | ||
7807 | tex = part.Shape.Textures; | 8323 | tex = part.Shape.Textures; |
8324 | int fullbright; | ||
7808 | if (face == ScriptBaseClass.ALL_SIDES) | 8325 | if (face == ScriptBaseClass.ALL_SIDES) |
7809 | { | 8326 | { |
7810 | for (face = 0; face < GetNumberOfSides(part); face++) | 8327 | for (face = 0; face < GetNumberOfSides(part); face++) |
7811 | { | 8328 | { |
7812 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8329 | if (tex.GetFace((uint)face).Fullbright == true) |
7813 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 8330 | { |
8331 | fullbright = ScriptBaseClass.TRUE; | ||
8332 | } | ||
8333 | else | ||
8334 | { | ||
8335 | fullbright = ScriptBaseClass.FALSE; | ||
8336 | } | ||
8337 | res.Add(new LSL_Integer(fullbright)); | ||
7814 | } | 8338 | } |
7815 | } | 8339 | } |
7816 | else | 8340 | else |
7817 | { | 8341 | { |
7818 | if (face >= 0 && face < GetNumberOfSides(part)) | 8342 | if (tex.GetFace((uint)face).Fullbright == true) |
7819 | { | 8343 | { |
7820 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8344 | fullbright = ScriptBaseClass.TRUE; |
7821 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 8345 | } |
8346 | else | ||
8347 | { | ||
8348 | fullbright = ScriptBaseClass.FALSE; | ||
7822 | } | 8349 | } |
8350 | res.Add(new LSL_Integer(fullbright)); | ||
7823 | } | 8351 | } |
7824 | break; | 8352 | break; |
7825 | 8353 | ||
@@ -7841,27 +8369,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7841 | break; | 8369 | break; |
7842 | 8370 | ||
7843 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8371 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
8372 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
7844 | if (remain < 1) | 8373 | if (remain < 1) |
7845 | return res; | 8374 | return res; |
7846 | 8375 | face = (int)rules.GetLSLIntegerItem(idx++); | |
7847 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
7848 | 8376 | ||
7849 | tex = part.Shape.Textures; | 8377 | tex = part.Shape.Textures; |
7850 | if (face == ScriptBaseClass.ALL_SIDES) | 8378 | if (face == ScriptBaseClass.ALL_SIDES) |
7851 | { | 8379 | { |
7852 | for (face = 0; face < GetNumberOfSides(part); face++) | 8380 | for (face = 0; face < GetNumberOfSides(part); face++) |
7853 | { | 8381 | { |
7854 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 8382 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
7855 | // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. | 8383 | { |
7856 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 8384 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
8385 | } | ||
8386 | else | ||
8387 | { | ||
8388 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8389 | } | ||
7857 | } | 8390 | } |
7858 | } | 8391 | } |
7859 | else | 8392 | else |
7860 | { | 8393 | { |
7861 | if (face >= 0 && face < GetNumberOfSides(part)) | 8394 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8395 | { | ||
8396 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8397 | } | ||
8398 | else | ||
7862 | { | 8399 | { |
7863 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 8400 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); |
7864 | res.Add(new LSL_Integer((uint)texgen >> 1)); | ||
7865 | } | 8401 | } |
7866 | } | 8402 | } |
7867 | break; | 8403 | break; |
@@ -7884,28 +8420,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7884 | case (int)ScriptBaseClass.PRIM_GLOW: | 8420 | case (int)ScriptBaseClass.PRIM_GLOW: |
7885 | if (remain < 1) | 8421 | if (remain < 1) |
7886 | return res; | 8422 | return res; |
7887 | 8423 | face = (int)rules.GetLSLIntegerItem(idx++); | |
7888 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
7889 | 8424 | ||
7890 | tex = part.Shape.Textures; | 8425 | tex = part.Shape.Textures; |
8426 | float primglow; | ||
7891 | if (face == ScriptBaseClass.ALL_SIDES) | 8427 | if (face == ScriptBaseClass.ALL_SIDES) |
7892 | { | 8428 | { |
7893 | for (face = 0; face < GetNumberOfSides(part); face++) | 8429 | for (face = 0; face < GetNumberOfSides(part); face++) |
7894 | { | 8430 | { |
7895 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8431 | primglow = tex.GetFace((uint)face).Glow; |
7896 | res.Add(new LSL_Float(texface.Glow)); | 8432 | res.Add(new LSL_Float(primglow)); |
7897 | } | 8433 | } |
7898 | } | 8434 | } |
7899 | else | 8435 | else |
7900 | { | 8436 | { |
7901 | if (face >= 0 && face < GetNumberOfSides(part)) | 8437 | primglow = tex.GetFace((uint)face).Glow; |
7902 | { | 8438 | res.Add(new LSL_Float(primglow)); |
7903 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
7904 | res.Add(new LSL_Float(texface.Glow)); | ||
7905 | } | ||
7906 | } | 8439 | } |
7907 | break; | 8440 | break; |
7908 | |||
7909 | case (int)ScriptBaseClass.PRIM_TEXT: | 8441 | case (int)ScriptBaseClass.PRIM_TEXT: |
7910 | Color4 textColor = part.GetTextColor(); | 8442 | Color4 textColor = part.GetTextColor(); |
7911 | res.Add(part.Text); | 8443 | res.Add(part.Text); |
@@ -8454,8 +8986,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8454 | // The function returns an ordered list | 8986 | // The function returns an ordered list |
8455 | // representing the tokens found in the supplied | 8987 | // representing the tokens found in the supplied |
8456 | // sources string. If two successive tokenizers | 8988 | // sources string. If two successive tokenizers |
8457 | // are encountered, then a NULL entry is added | 8989 | // are encountered, then a null-string entry is |
8458 | // to the list. | 8990 | // added to the list. |
8459 | // | 8991 | // |
8460 | // It is a precondition that the source and | 8992 | // It is a precondition that the source and |
8461 | // toekizer lisst are non-null. If they are null, | 8993 | // toekizer lisst are non-null. If they are null, |
@@ -8463,7 +8995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8463 | // while their lengths are being determined. | 8995 | // while their lengths are being determined. |
8464 | // | 8996 | // |
8465 | // A small amount of working memoryis required | 8997 | // A small amount of working memoryis required |
8466 | // of approximately 8*#tokenizers. | 8998 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8467 | // | 8999 | // |
8468 | // There are many ways in which this function | 9000 | // There are many ways in which this function |
8469 | // can be implemented, this implementation is | 9001 | // can be implemented, this implementation is |
@@ -8479,155 +9011,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8479 | // and eliminates redundant tokenizers as soon | 9011 | // and eliminates redundant tokenizers as soon |
8480 | // as is possible. | 9012 | // as is possible. |
8481 | // | 9013 | // |
8482 | // The implementation tries to avoid any copying | 9014 | // The implementation tries to minimize temporary |
8483 | // of arrays or other objects. | 9015 | // garbage generation. |
8484 | // </remarks> | 9016 | // </remarks> |
8485 | 9017 | ||
8486 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 9018 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8487 | { | 9019 | { |
8488 | int beginning = 0; | 9020 | return ParseString2List(src, separators, spacers, true); |
8489 | int srclen = src.Length; | 9021 | } |
8490 | int seplen = separators.Length; | ||
8491 | object[] separray = separators.Data; | ||
8492 | int spclen = spacers.Length; | ||
8493 | object[] spcarray = spacers.Data; | ||
8494 | int mlen = seplen+spclen; | ||
8495 | |||
8496 | int[] offset = new int[mlen+1]; | ||
8497 | bool[] active = new bool[mlen]; | ||
8498 | |||
8499 | int best; | ||
8500 | int j; | ||
8501 | |||
8502 | // Initial capacity reduces resize cost | ||
8503 | 9022 | ||
8504 | LSL_List tokens = new LSL_List(); | 9023 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
9024 | { | ||
9025 | int srclen = src.Length; | ||
9026 | int seplen = separators.Length; | ||
9027 | object[] separray = separators.Data; | ||
9028 | int spclen = spacers.Length; | ||
9029 | object[] spcarray = spacers.Data; | ||
9030 | int dellen = 0; | ||
9031 | string[] delarray = new string[seplen+spclen]; | ||
8505 | 9032 | ||
8506 | // All entries are initially valid | 9033 | int outlen = 0; |
9034 | string[] outarray = new string[srclen*2+1]; | ||
8507 | 9035 | ||
8508 | for (int i = 0; i < mlen; i++) | 9036 | int i, j; |
8509 | active[i] = true; | 9037 | string d; |
8510 | 9038 | ||
8511 | offset[mlen] = srclen; | 9039 | m_host.AddScriptLPS(1); |
8512 | 9040 | ||
8513 | while (beginning < srclen) | 9041 | /* |
9042 | * Convert separator and spacer lists to C# strings. | ||
9043 | * Also filter out null strings so we don't hang. | ||
9044 | */ | ||
9045 | for (i = 0; i < seplen; i ++) | ||
8514 | { | 9046 | { |
9047 | d = separray[i].ToString(); | ||
9048 | if (d.Length > 0) | ||
9049 | { | ||
9050 | delarray[dellen++] = d; | ||
9051 | } | ||
9052 | } | ||
9053 | seplen = dellen; | ||
8515 | 9054 | ||
8516 | best = mlen; // as bad as it gets | 9055 | for (i = 0; i < spclen; i ++) |
9056 | { | ||
9057 | d = spcarray[i].ToString(); | ||
9058 | if (d.Length > 0) | ||
9059 | { | ||
9060 | delarray[dellen++] = d; | ||
9061 | } | ||
9062 | } | ||
8517 | 9063 | ||
8518 | // Scan for separators | 9064 | /* |
9065 | * Scan through source string from beginning to end. | ||
9066 | */ | ||
9067 | for (i = 0;;) | ||
9068 | { | ||
8519 | 9069 | ||
8520 | for (j = 0; j < seplen; j++) | 9070 | /* |
9071 | * Find earliest delimeter in src starting at i (if any). | ||
9072 | */ | ||
9073 | int earliestDel = -1; | ||
9074 | int earliestSrc = srclen; | ||
9075 | string earliestStr = null; | ||
9076 | for (j = 0; j < dellen; j ++) | ||
8521 | { | 9077 | { |
8522 | if (separray[j].ToString() == String.Empty) | 9078 | d = delarray[j]; |
8523 | active[j] = false; | 9079 | if (d != null) |
8524 | |||
8525 | if (active[j]) | ||
8526 | { | 9080 | { |
8527 | // scan all of the markers | 9081 | int index = src.IndexOf(d, i); |
8528 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 9082 | if (index < 0) |
8529 | { | 9083 | { |
8530 | // not present at all | 9084 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8531 | active[j] = false; | ||
8532 | } | 9085 | } |
8533 | else | 9086 | else if (index < earliestSrc) |
8534 | { | 9087 | { |
8535 | // present and correct | 9088 | earliestSrc = index; // where delimeter starts in source string |
8536 | if (offset[j] < offset[best]) | 9089 | earliestDel = j; // where delimeter is in delarray[] |
8537 | { | 9090 | earliestStr = d; // the delimeter string from delarray[] |
8538 | // closest so far | 9091 | if (index == i) break; // can't do any better than found at beg of string |
8539 | best = j; | ||
8540 | if (offset[best] == beginning) | ||
8541 | break; | ||
8542 | } | ||
8543 | } | 9092 | } |
8544 | } | 9093 | } |
8545 | } | 9094 | } |
8546 | 9095 | ||
8547 | // Scan for spacers | 9096 | /* |
8548 | 9097 | * Output source string starting at i through start of earliest delimeter. | |
8549 | if (offset[best] != beginning) | 9098 | */ |
9099 | if (keepNulls || (earliestSrc > i)) | ||
8550 | { | 9100 | { |
8551 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 9101 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8552 | { | ||
8553 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
8554 | active[j] = false; | ||
8555 | |||
8556 | if (active[j]) | ||
8557 | { | ||
8558 | // scan all of the markers | ||
8559 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
8560 | { | ||
8561 | // not present at all | ||
8562 | active[j] = false; | ||
8563 | } | ||
8564 | else | ||
8565 | { | ||
8566 | // present and correct | ||
8567 | if (offset[j] < offset[best]) | ||
8568 | { | ||
8569 | // closest so far | ||
8570 | best = j; | ||
8571 | } | ||
8572 | } | ||
8573 | } | ||
8574 | } | ||
8575 | } | 9102 | } |
8576 | 9103 | ||
8577 | // This is the normal exit from the scanning loop | 9104 | /* |
9105 | * If no delimeter found at or after i, we're done scanning. | ||
9106 | */ | ||
9107 | if (earliestDel < 0) break; | ||
8578 | 9108 | ||
8579 | if (best == mlen) | 9109 | /* |
9110 | * If delimeter was a spacer, output the spacer. | ||
9111 | */ | ||
9112 | if (earliestDel >= seplen) | ||
8580 | { | 9113 | { |
8581 | // no markers were found on this pass | 9114 | outarray[outlen++] = earliestStr; |
8582 | // so we're pretty much done | ||
8583 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
8584 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8585 | break; | ||
8586 | } | 9115 | } |
8587 | 9116 | ||
8588 | // Otherwise we just add the newly delimited token | 9117 | /* |
8589 | // and recalculate where the search should continue. | 9118 | * Look at rest of src string following delimeter. |
8590 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 9119 | */ |
8591 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 9120 | i = earliestSrc + earliestStr.Length; |
8592 | |||
8593 | if (best < seplen) | ||
8594 | { | ||
8595 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
8596 | } | ||
8597 | else | ||
8598 | { | ||
8599 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8600 | string str = spcarray[best - seplen].ToString(); | ||
8601 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8602 | tokens.Add(new LSL_String(str)); | ||
8603 | } | ||
8604 | } | 9121 | } |
8605 | 9122 | ||
8606 | // This an awkward an not very intuitive boundary case. If the | 9123 | /* |
8607 | // last substring is a tokenizer, then there is an implied trailing | 9124 | * Make up an exact-sized output array suitable for an LSL_List object. |
8608 | // null list entry. Hopefully the single comparison will not be too | 9125 | */ |
8609 | // arduous. Alternatively the 'break' could be replced with a return | 9126 | object[] outlist = new object[outlen]; |
8610 | // but that's shabby programming. | 9127 | for (i = 0; i < outlen; i ++) |
8611 | |||
8612 | if ((beginning == srclen) && (keepNulls)) | ||
8613 | { | 9128 | { |
8614 | if (srclen != 0) | 9129 | outlist[i] = new LSL_String(outarray[i]); |
8615 | tokens.Add(new LSL_String("")); | ||
8616 | } | 9130 | } |
8617 | 9131 | return new LSL_List(outlist); | |
8618 | return tokens; | ||
8619 | } | ||
8620 | |||
8621 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8622 | { | ||
8623 | m_host.AddScriptLPS(1); | ||
8624 | return this.ParseString(src, separators, spacers, false); | ||
8625 | } | ||
8626 | |||
8627 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8628 | { | ||
8629 | m_host.AddScriptLPS(1); | ||
8630 | return this.ParseString(src, separators, spacers, true); | ||
8631 | } | 9132 | } |
8632 | 9133 | ||
8633 | public LSL_Integer llGetObjectPermMask(int mask) | 9134 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -8704,28 +9205,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8704 | { | 9205 | { |
8705 | m_host.AddScriptLPS(1); | 9206 | m_host.AddScriptLPS(1); |
8706 | 9207 | ||
8707 | lock (m_host.TaskInventory) | 9208 | m_host.TaskInventory.LockItemsForRead(true); |
9209 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8708 | { | 9210 | { |
8709 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9211 | if (inv.Value.Name == item) |
8710 | { | 9212 | { |
8711 | if (inv.Value.Name == item) | 9213 | m_host.TaskInventory.LockItemsForRead(false); |
9214 | switch (mask) | ||
8712 | { | 9215 | { |
8713 | switch (mask) | 9216 | case 0: |
8714 | { | 9217 | return (int)inv.Value.BasePermissions; |
8715 | case 0: | 9218 | case 1: |
8716 | return (int)inv.Value.BasePermissions; | 9219 | return (int)inv.Value.CurrentPermissions; |
8717 | case 1: | 9220 | case 2: |
8718 | return (int)inv.Value.CurrentPermissions; | 9221 | return (int)inv.Value.GroupPermissions; |
8719 | case 2: | 9222 | case 3: |
8720 | return (int)inv.Value.GroupPermissions; | 9223 | return (int)inv.Value.EveryonePermissions; |
8721 | case 3: | 9224 | case 4: |
8722 | return (int)inv.Value.EveryonePermissions; | 9225 | return (int)inv.Value.NextPermissions; |
8723 | case 4: | ||
8724 | return (int)inv.Value.NextPermissions; | ||
8725 | } | ||
8726 | } | 9226 | } |
8727 | } | 9227 | } |
8728 | } | 9228 | } |
9229 | m_host.TaskInventory.LockItemsForRead(false); | ||
8729 | 9230 | ||
8730 | return -1; | 9231 | return -1; |
8731 | } | 9232 | } |
@@ -8772,16 +9273,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8772 | { | 9273 | { |
8773 | m_host.AddScriptLPS(1); | 9274 | m_host.AddScriptLPS(1); |
8774 | 9275 | ||
8775 | lock (m_host.TaskInventory) | 9276 | m_host.TaskInventory.LockItemsForRead(true); |
9277 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8776 | { | 9278 | { |
8777 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9279 | if (inv.Value.Name == item) |
8778 | { | 9280 | { |
8779 | if (inv.Value.Name == item) | 9281 | m_host.TaskInventory.LockItemsForRead(false); |
8780 | { | 9282 | return inv.Value.CreatorID.ToString(); |
8781 | return inv.Value.CreatorID.ToString(); | ||
8782 | } | ||
8783 | } | 9283 | } |
8784 | } | 9284 | } |
9285 | m_host.TaskInventory.LockItemsForRead(false); | ||
8785 | 9286 | ||
8786 | llSay(0, "No item name '" + item + "'"); | 9287 | llSay(0, "No item name '" + item + "'"); |
8787 | 9288 | ||
@@ -8929,7 +9430,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8929 | } | 9430 | } |
8930 | 9431 | ||
8931 | /// <summary> | 9432 | /// <summary> |
8932 | /// illListReplaceList removes the sub-list defined by the inclusive indices | 9433 | /// llListReplaceList removes the sub-list defined by the inclusive indices |
8933 | /// start and end and inserts the src list in its place. The inclusive | 9434 | /// start and end and inserts the src list in its place. The inclusive |
8934 | /// nature of the indices means that at least one element must be deleted | 9435 | /// nature of the indices means that at least one element must be deleted |
8935 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | 9436 | /// if the indices are within the bounds of the existing list. I.e. 2,2 |
@@ -8986,16 +9487,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8986 | // based upon end. Note that if end exceeds the upper | 9487 | // based upon end. Note that if end exceeds the upper |
8987 | // bound in this case, the entire destination list | 9488 | // bound in this case, the entire destination list |
8988 | // is removed. | 9489 | // is removed. |
8989 | else | 9490 | else if (start == 0) |
8990 | { | 9491 | { |
8991 | if (end + 1 < dest.Length) | 9492 | if (end + 1 < dest.Length) |
8992 | { | ||
8993 | return src + dest.GetSublist(end + 1, -1); | 9493 | return src + dest.GetSublist(end + 1, -1); |
8994 | } | ||
8995 | else | 9494 | else |
8996 | { | ||
8997 | return src; | 9495 | return src; |
8998 | } | 9496 | } |
9497 | else // Start < 0 | ||
9498 | { | ||
9499 | if (end + 1 < dest.Length) | ||
9500 | return dest.GetSublist(end + 1, -1); | ||
9501 | else | ||
9502 | return new LSL_List(); | ||
8999 | } | 9503 | } |
9000 | } | 9504 | } |
9001 | // Finally, if start > end, we strip away a prefix and | 9505 | // Finally, if start > end, we strip away a prefix and |
@@ -9046,17 +9550,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9046 | int width = 0; | 9550 | int width = 0; |
9047 | int height = 0; | 9551 | int height = 0; |
9048 | 9552 | ||
9049 | ParcelMediaCommandEnum? commandToSend = null; | 9553 | uint commandToSend = 0; |
9050 | float time = 0.0f; // default is from start | 9554 | float time = 0.0f; // default is from start |
9051 | 9555 | ||
9052 | ScenePresence presence = null; | 9556 | ScenePresence presence = null; |
9053 | 9557 | ||
9054 | for (int i = 0; i < commandList.Data.Length; i++) | 9558 | for (int i = 0; i < commandList.Data.Length; i++) |
9055 | { | 9559 | { |
9056 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9560 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
9057 | switch (command) | 9561 | switch (command) |
9058 | { | 9562 | { |
9059 | case ParcelMediaCommandEnum.Agent: | 9563 | case (uint)ParcelMediaCommandEnum.Agent: |
9060 | // we send only to one agent | 9564 | // we send only to one agent |
9061 | if ((i + 1) < commandList.Length) | 9565 | if ((i + 1) < commandList.Length) |
9062 | { | 9566 | { |
@@ -9073,25 +9577,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9073 | } | 9577 | } |
9074 | break; | 9578 | break; |
9075 | 9579 | ||
9076 | case ParcelMediaCommandEnum.Loop: | 9580 | case (uint)ParcelMediaCommandEnum.Loop: |
9077 | loop = 1; | 9581 | loop = 1; |
9078 | commandToSend = command; | 9582 | commandToSend = command; |
9079 | update = true; //need to send the media update packet to set looping | 9583 | update = true; //need to send the media update packet to set looping |
9080 | break; | 9584 | break; |
9081 | 9585 | ||
9082 | case ParcelMediaCommandEnum.Play: | 9586 | case (uint)ParcelMediaCommandEnum.Play: |
9083 | loop = 0; | 9587 | loop = 0; |
9084 | commandToSend = command; | 9588 | commandToSend = command; |
9085 | update = true; //need to send the media update packet to make sure it doesn't loop | 9589 | update = true; //need to send the media update packet to make sure it doesn't loop |
9086 | break; | 9590 | break; |
9087 | 9591 | ||
9088 | case ParcelMediaCommandEnum.Pause: | 9592 | case (uint)ParcelMediaCommandEnum.Pause: |
9089 | case ParcelMediaCommandEnum.Stop: | 9593 | case (uint)ParcelMediaCommandEnum.Stop: |
9090 | case ParcelMediaCommandEnum.Unload: | 9594 | case (uint)ParcelMediaCommandEnum.Unload: |
9091 | commandToSend = command; | 9595 | commandToSend = command; |
9092 | break; | 9596 | break; |
9093 | 9597 | ||
9094 | case ParcelMediaCommandEnum.Url: | 9598 | case (uint)ParcelMediaCommandEnum.Url: |
9095 | if ((i + 1) < commandList.Length) | 9599 | if ((i + 1) < commandList.Length) |
9096 | { | 9600 | { |
9097 | if (commandList.Data[i + 1] is LSL_String) | 9601 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9104,7 +9608,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9104 | } | 9608 | } |
9105 | break; | 9609 | break; |
9106 | 9610 | ||
9107 | case ParcelMediaCommandEnum.Texture: | 9611 | case (uint)ParcelMediaCommandEnum.Texture: |
9108 | if ((i + 1) < commandList.Length) | 9612 | if ((i + 1) < commandList.Length) |
9109 | { | 9613 | { |
9110 | if (commandList.Data[i + 1] is LSL_String) | 9614 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9117,7 +9621,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9117 | } | 9621 | } |
9118 | break; | 9622 | break; |
9119 | 9623 | ||
9120 | case ParcelMediaCommandEnum.Time: | 9624 | case (uint)ParcelMediaCommandEnum.Time: |
9121 | if ((i + 1) < commandList.Length) | 9625 | if ((i + 1) < commandList.Length) |
9122 | { | 9626 | { |
9123 | if (commandList.Data[i + 1] is LSL_Float) | 9627 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9129,7 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9129 | } | 9633 | } |
9130 | break; | 9634 | break; |
9131 | 9635 | ||
9132 | case ParcelMediaCommandEnum.AutoAlign: | 9636 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9133 | if ((i + 1) < commandList.Length) | 9637 | if ((i + 1) < commandList.Length) |
9134 | { | 9638 | { |
9135 | if (commandList.Data[i + 1] is LSL_Integer) | 9639 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9143,7 +9647,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9143 | } | 9647 | } |
9144 | break; | 9648 | break; |
9145 | 9649 | ||
9146 | case ParcelMediaCommandEnum.Type: | 9650 | case (uint)ParcelMediaCommandEnum.Type: |
9147 | if ((i + 1) < commandList.Length) | 9651 | if ((i + 1) < commandList.Length) |
9148 | { | 9652 | { |
9149 | if (commandList.Data[i + 1] is LSL_String) | 9653 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9156,7 +9660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9156 | } | 9660 | } |
9157 | break; | 9661 | break; |
9158 | 9662 | ||
9159 | case ParcelMediaCommandEnum.Desc: | 9663 | case (uint)ParcelMediaCommandEnum.Desc: |
9160 | if ((i + 1) < commandList.Length) | 9664 | if ((i + 1) < commandList.Length) |
9161 | { | 9665 | { |
9162 | if (commandList.Data[i + 1] is LSL_String) | 9666 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9169,7 +9673,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9169 | } | 9673 | } |
9170 | break; | 9674 | break; |
9171 | 9675 | ||
9172 | case ParcelMediaCommandEnum.Size: | 9676 | case (uint)ParcelMediaCommandEnum.Size: |
9173 | if ((i + 2) < commandList.Length) | 9677 | if ((i + 2) < commandList.Length) |
9174 | { | 9678 | { |
9175 | if (commandList.Data[i + 1] is LSL_Integer) | 9679 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9239,7 +9743,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9239 | } | 9743 | } |
9240 | } | 9744 | } |
9241 | 9745 | ||
9242 | if (commandToSend != null) | 9746 | if (commandToSend != 0) |
9243 | { | 9747 | { |
9244 | // the commandList contained a start/stop/... command, too | 9748 | // the commandList contained a start/stop/... command, too |
9245 | if (presence == null) | 9749 | if (presence == null) |
@@ -9276,7 +9780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9276 | 9780 | ||
9277 | if (aList.Data[i] != null) | 9781 | if (aList.Data[i] != null) |
9278 | { | 9782 | { |
9279 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 9783 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9280 | { | 9784 | { |
9281 | case ParcelMediaCommandEnum.Url: | 9785 | case ParcelMediaCommandEnum.Url: |
9282 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 9786 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9319,16 +9823,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9319 | { | 9823 | { |
9320 | m_host.AddScriptLPS(1); | 9824 | m_host.AddScriptLPS(1); |
9321 | 9825 | ||
9322 | lock (m_host.TaskInventory) | 9826 | m_host.TaskInventory.LockItemsForRead(true); |
9827 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9323 | { | 9828 | { |
9324 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9829 | if (inv.Value.Name == name) |
9325 | { | 9830 | { |
9326 | if (inv.Value.Name == name) | 9831 | m_host.TaskInventory.LockItemsForRead(false); |
9327 | { | 9832 | return inv.Value.Type; |
9328 | return inv.Value.Type; | ||
9329 | } | ||
9330 | } | 9833 | } |
9331 | } | 9834 | } |
9835 | m_host.TaskInventory.LockItemsForRead(false); | ||
9332 | 9836 | ||
9333 | return -1; | 9837 | return -1; |
9334 | } | 9838 | } |
@@ -9339,15 +9843,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9339 | 9843 | ||
9340 | if (quick_pay_buttons.Data.Length < 4) | 9844 | if (quick_pay_buttons.Data.Length < 4) |
9341 | { | 9845 | { |
9342 | LSLError("List must have at least 4 elements"); | 9846 | int x; |
9343 | return; | 9847 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9848 | { | ||
9849 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9850 | } | ||
9344 | } | 9851 | } |
9345 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9852 | int[] nPrice = new int[5]; |
9346 | 9853 | nPrice[0] = price; | |
9347 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9854 | nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); |
9348 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9855 | nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); |
9349 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9856 | nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); |
9350 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9857 | nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); |
9858 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9351 | m_host.ParentGroup.HasGroupChanged = true; | 9859 | m_host.ParentGroup.HasGroupChanged = true; |
9352 | } | 9860 | } |
9353 | 9861 | ||
@@ -9359,17 +9867,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9359 | if (invItemID == UUID.Zero) | 9867 | if (invItemID == UUID.Zero) |
9360 | return new LSL_Vector(); | 9868 | return new LSL_Vector(); |
9361 | 9869 | ||
9362 | lock (m_host.TaskInventory) | 9870 | m_host.TaskInventory.LockItemsForRead(true); |
9871 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9363 | { | 9872 | { |
9364 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9873 | m_host.TaskInventory.LockItemsForRead(false); |
9365 | return new LSL_Vector(); | 9874 | return new LSL_Vector(); |
9875 | } | ||
9366 | 9876 | ||
9367 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9877 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9368 | { | 9878 | { |
9369 | ShoutError("No permissions to track the camera"); | 9879 | ShoutError("No permissions to track the camera"); |
9370 | return new LSL_Vector(); | 9880 | m_host.TaskInventory.LockItemsForRead(false); |
9371 | } | 9881 | return new LSL_Vector(); |
9372 | } | 9882 | } |
9883 | m_host.TaskInventory.LockItemsForRead(false); | ||
9373 | 9884 | ||
9374 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9885 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9375 | if (presence != null) | 9886 | if (presence != null) |
@@ -9387,17 +9898,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9387 | if (invItemID == UUID.Zero) | 9898 | if (invItemID == UUID.Zero) |
9388 | return new LSL_Rotation(); | 9899 | return new LSL_Rotation(); |
9389 | 9900 | ||
9390 | lock (m_host.TaskInventory) | 9901 | m_host.TaskInventory.LockItemsForRead(true); |
9902 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9391 | { | 9903 | { |
9392 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9904 | m_host.TaskInventory.LockItemsForRead(false); |
9393 | return new LSL_Rotation(); | 9905 | return new LSL_Rotation(); |
9394 | 9906 | } | |
9395 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9907 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9396 | { | 9908 | { |
9397 | ShoutError("No permissions to track the camera"); | 9909 | ShoutError("No permissions to track the camera"); |
9398 | return new LSL_Rotation(); | 9910 | m_host.TaskInventory.LockItemsForRead(false); |
9399 | } | 9911 | return new LSL_Rotation(); |
9400 | } | 9912 | } |
9913 | m_host.TaskInventory.LockItemsForRead(false); | ||
9401 | 9914 | ||
9402 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9915 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9403 | if (presence != null) | 9916 | if (presence != null) |
@@ -9459,8 +9972,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9459 | { | 9972 | { |
9460 | m_host.AddScriptLPS(1); | 9973 | m_host.AddScriptLPS(1); |
9461 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9974 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9462 | if (detectedParams == null) return; // only works on the first detected avatar | 9975 | if (detectedParams == null) |
9463 | 9976 | { | |
9977 | if (m_host.IsAttachment == true) | ||
9978 | { | ||
9979 | detectedParams = new DetectParams(); | ||
9980 | detectedParams.Key = m_host.OwnerID; | ||
9981 | } | ||
9982 | else | ||
9983 | { | ||
9984 | return; | ||
9985 | } | ||
9986 | } | ||
9987 | |||
9464 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9988 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9465 | if (avatar != null) | 9989 | if (avatar != null) |
9466 | { | 9990 | { |
@@ -9468,6 +9992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9468 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9992 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9469 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9993 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9470 | } | 9994 | } |
9995 | |||
9471 | ScriptSleep(1000); | 9996 | ScriptSleep(1000); |
9472 | } | 9997 | } |
9473 | 9998 | ||
@@ -9560,14 +10085,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9560 | if (objectID == UUID.Zero) return; | 10085 | if (objectID == UUID.Zero) return; |
9561 | 10086 | ||
9562 | UUID agentID; | 10087 | UUID agentID; |
9563 | lock (m_host.TaskInventory) | 10088 | m_host.TaskInventory.LockItemsForRead(true); |
9564 | { | 10089 | // we need the permission first, to know which avatar we want to set the camera for |
9565 | // we need the permission first, to know which avatar we want to set the camera for | 10090 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9566 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9567 | 10091 | ||
9568 | if (agentID == UUID.Zero) return; | 10092 | if (agentID == UUID.Zero) |
9569 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 10093 | { |
10094 | m_host.TaskInventory.LockItemsForRead(false); | ||
10095 | return; | ||
10096 | } | ||
10097 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
10098 | { | ||
10099 | m_host.TaskInventory.LockItemsForRead(false); | ||
10100 | return; | ||
9570 | } | 10101 | } |
10102 | m_host.TaskInventory.LockItemsForRead(false); | ||
9571 | 10103 | ||
9572 | ScenePresence presence = World.GetScenePresence(agentID); | 10104 | ScenePresence presence = World.GetScenePresence(agentID); |
9573 | 10105 | ||
@@ -9576,12 +10108,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9576 | 10108 | ||
9577 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | 10109 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); |
9578 | object[] data = rules.Data; | 10110 | object[] data = rules.Data; |
9579 | for (int i = 0; i < data.Length; ++i) { | 10111 | for (int i = 0; i < data.Length; ++i) |
10112 | { | ||
9580 | int type = Convert.ToInt32(data[i++].ToString()); | 10113 | int type = Convert.ToInt32(data[i++].ToString()); |
9581 | if (i >= data.Length) break; // odd number of entries => ignore the last | 10114 | if (i >= data.Length) break; // odd number of entries => ignore the last |
9582 | 10115 | ||
9583 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 10116 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
9584 | switch (type) { | 10117 | switch (type) |
10118 | { | ||
9585 | case ScriptBaseClass.CAMERA_FOCUS: | 10119 | case ScriptBaseClass.CAMERA_FOCUS: |
9586 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | 10120 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: |
9587 | case ScriptBaseClass.CAMERA_POSITION: | 10121 | case ScriptBaseClass.CAMERA_POSITION: |
@@ -9617,12 +10151,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9617 | 10151 | ||
9618 | // we need the permission first, to know which avatar we want to clear the camera for | 10152 | // we need the permission first, to know which avatar we want to clear the camera for |
9619 | UUID agentID; | 10153 | UUID agentID; |
9620 | lock (m_host.TaskInventory) | 10154 | m_host.TaskInventory.LockItemsForRead(true); |
10155 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10156 | if (agentID == UUID.Zero) | ||
10157 | { | ||
10158 | m_host.TaskInventory.LockItemsForRead(false); | ||
10159 | return; | ||
10160 | } | ||
10161 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9621 | { | 10162 | { |
9622 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10163 | m_host.TaskInventory.LockItemsForRead(false); |
9623 | if (agentID == UUID.Zero) return; | 10164 | return; |
9624 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9625 | } | 10165 | } |
10166 | m_host.TaskInventory.LockItemsForRead(false); | ||
9626 | 10167 | ||
9627 | ScenePresence presence = World.GetScenePresence(agentID); | 10168 | ScenePresence presence = World.GetScenePresence(agentID); |
9628 | 10169 | ||
@@ -9689,19 +10230,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9689 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 10230 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
9690 | { | 10231 | { |
9691 | m_host.AddScriptLPS(1); | 10232 | m_host.AddScriptLPS(1); |
9692 | string ret = String.Empty; | 10233 | |
9693 | string src1 = llBase64ToString(str1); | 10234 | if (str1 == String.Empty) |
9694 | string src2 = llBase64ToString(str2); | 10235 | return String.Empty; |
9695 | int c = 0; | 10236 | if (str2 == String.Empty) |
9696 | for (int i = 0; i < src1.Length; i++) | 10237 | return str1; |
10238 | |||
10239 | int len = str2.Length; | ||
10240 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
9697 | { | 10241 | { |
9698 | ret += (char) (src1[i] ^ src2[c]); | 10242 | while (str2.EndsWith("=")) |
10243 | str2 = str2.Substring(0, str2.Length - 1); | ||
10244 | |||
10245 | len = str2.Length; | ||
10246 | int mod = len % 4; | ||
9699 | 10247 | ||
9700 | c++; | 10248 | if (mod == 1) |
9701 | if (c >= src2.Length) | 10249 | str2 = str2.Substring(0, str2.Length - 1); |
9702 | c = 0; | 10250 | else if (mod == 2) |
10251 | str2 += "=="; | ||
10252 | else if (mod == 3) | ||
10253 | str2 += "="; | ||
10254 | } | ||
10255 | |||
10256 | byte[] data1; | ||
10257 | byte[] data2; | ||
10258 | try | ||
10259 | { | ||
10260 | data1 = Convert.FromBase64String(str1); | ||
10261 | data2 = Convert.FromBase64String(str2); | ||
10262 | } | ||
10263 | catch (Exception) | ||
10264 | { | ||
10265 | return new LSL_String(String.Empty); | ||
9703 | } | 10266 | } |
9704 | return llStringToBase64(ret); | 10267 | |
10268 | byte[] d2 = new Byte[data1.Length]; | ||
10269 | int pos = 0; | ||
10270 | |||
10271 | if (data1.Length <= data2.Length) | ||
10272 | { | ||
10273 | Array.Copy(data2, 0, d2, 0, data1.Length); | ||
10274 | } | ||
10275 | else | ||
10276 | { | ||
10277 | while (pos < data1.Length) | ||
10278 | { | ||
10279 | len = data1.Length - pos; | ||
10280 | if (len > data2.Length) | ||
10281 | len = data2.Length; | ||
10282 | |||
10283 | Array.Copy(data2, 0, d2, pos, len); | ||
10284 | pos += len; | ||
10285 | } | ||
10286 | } | ||
10287 | |||
10288 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
10289 | data1[pos] ^= d2[pos]; | ||
10290 | |||
10291 | return Convert.ToBase64String(data1); | ||
9705 | } | 10292 | } |
9706 | 10293 | ||
9707 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 10294 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -9760,12 +10347,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9760 | Regex r = new Regex(authregex); | 10347 | Regex r = new Regex(authregex); |
9761 | int[] gnums = r.GetGroupNumbers(); | 10348 | int[] gnums = r.GetGroupNumbers(); |
9762 | Match m = r.Match(url); | 10349 | Match m = r.Match(url); |
9763 | if (m.Success) { | 10350 | if (m.Success) |
9764 | for (int i = 1; i < gnums.Length; i++) { | 10351 | { |
10352 | for (int i = 1; i < gnums.Length; i++) | ||
10353 | { | ||
9765 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 10354 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
9766 | //CaptureCollection cc = g.Captures; | 10355 | //CaptureCollection cc = g.Captures; |
9767 | } | 10356 | } |
9768 | if (m.Groups.Count == 5) { | 10357 | if (m.Groups.Count == 5) |
10358 | { | ||
9769 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 10359 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
9770 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 10360 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
9771 | } | 10361 | } |
@@ -10082,15 +10672,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10082 | 10672 | ||
10083 | internal UUID ScriptByName(string name) | 10673 | internal UUID ScriptByName(string name) |
10084 | { | 10674 | { |
10085 | lock (m_host.TaskInventory) | 10675 | m_host.TaskInventory.LockItemsForRead(true); |
10676 | |||
10677 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
10086 | { | 10678 | { |
10087 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10679 | if (item.Type == 10 && item.Name == name) |
10088 | { | 10680 | { |
10089 | if (item.Type == 10 && item.Name == name) | 10681 | m_host.TaskInventory.LockItemsForRead(false); |
10090 | return item.ItemID; | 10682 | return item.ItemID; |
10091 | } | 10683 | } |
10092 | } | 10684 | } |
10093 | 10685 | ||
10686 | m_host.TaskInventory.LockItemsForRead(false); | ||
10687 | |||
10094 | return UUID.Zero; | 10688 | return UUID.Zero; |
10095 | } | 10689 | } |
10096 | 10690 | ||
@@ -10131,6 +10725,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10131 | { | 10725 | { |
10132 | m_host.AddScriptLPS(1); | 10726 | m_host.AddScriptLPS(1); |
10133 | 10727 | ||
10728 | //Clone is thread safe | ||
10134 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10729 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10135 | 10730 | ||
10136 | UUID assetID = UUID.Zero; | 10731 | UUID assetID = UUID.Zero; |
@@ -10193,6 +10788,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10193 | { | 10788 | { |
10194 | m_host.AddScriptLPS(1); | 10789 | m_host.AddScriptLPS(1); |
10195 | 10790 | ||
10791 | //Clone is thread safe | ||
10196 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10792 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10197 | 10793 | ||
10198 | UUID assetID = UUID.Zero; | 10794 | UUID assetID = UUID.Zero; |
@@ -10272,6 +10868,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10272 | 10868 | ||
10273 | return GetLinkPrimitiveParams(obj, rules); | 10869 | return GetLinkPrimitiveParams(obj, rules); |
10274 | } | 10870 | } |
10871 | |||
10872 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | ||
10873 | { | ||
10874 | List<SceneObjectPart> parts = GetLinkParts(link); | ||
10875 | if (parts.Count < 1) | ||
10876 | return 0; | ||
10877 | |||
10878 | return GetNumberOfSides(parts[0]); | ||
10879 | } | ||
10275 | } | 10880 | } |
10276 | 10881 | ||
10277 | public class NotecardCache | 10882 | public class NotecardCache |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c0c790d..cf059b3 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() |
@@ -835,18 +844,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
835 | if (target != null) | 844 | if (target != null) |
836 | { | 845 | { |
837 | UUID animID=UUID.Zero; | 846 | UUID animID=UUID.Zero; |
838 | lock (m_host.TaskInventory) | 847 | m_host.TaskInventory.LockItemsForRead(true); |
848 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
839 | { | 849 | { |
840 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 850 | if (inv.Value.Name == animation) |
841 | { | 851 | { |
842 | if (inv.Value.Name == animation) | 852 | if (inv.Value.Type == (int)AssetType.Animation) |
843 | { | 853 | animID = inv.Value.AssetID; |
844 | if (inv.Value.Type == (int)AssetType.Animation) | 854 | continue; |
845 | animID = inv.Value.AssetID; | ||
846 | continue; | ||
847 | } | ||
848 | } | 855 | } |
849 | } | 856 | } |
857 | m_host.TaskInventory.LockItemsForRead(false); | ||
850 | if (animID == UUID.Zero) | 858 | if (animID == UUID.Zero) |
851 | target.Animator.AddAnimation(animation, m_host.UUID); | 859 | target.Animator.AddAnimation(animation, m_host.UUID); |
852 | else | 860 | else |
@@ -868,18 +876,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
868 | if (target != null) | 876 | if (target != null) |
869 | { | 877 | { |
870 | UUID animID=UUID.Zero; | 878 | UUID animID=UUID.Zero; |
871 | lock (m_host.TaskInventory) | 879 | m_host.TaskInventory.LockItemsForRead(true); |
880 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
872 | { | 881 | { |
873 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 882 | if (inv.Value.Name == animation) |
874 | { | 883 | { |
875 | if (inv.Value.Name == animation) | 884 | if (inv.Value.Type == (int)AssetType.Animation) |
876 | { | 885 | animID = inv.Value.AssetID; |
877 | if (inv.Value.Type == (int)AssetType.Animation) | 886 | continue; |
878 | animID = inv.Value.AssetID; | ||
879 | continue; | ||
880 | } | ||
881 | } | 887 | } |
882 | } | 888 | } |
889 | m_host.TaskInventory.LockItemsForRead(false); | ||
883 | 890 | ||
884 | if (animID == UUID.Zero) | 891 | if (animID == UUID.Zero) |
885 | target.Animator.RemoveAnimation(animation); | 892 | target.Animator.RemoveAnimation(animation); |
@@ -1772,6 +1779,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1772 | 1779 | ||
1773 | if (!UUID.TryParse(name, out assetID)) | 1780 | if (!UUID.TryParse(name, out assetID)) |
1774 | { | 1781 | { |
1782 | m_host.TaskInventory.LockItemsForRead(true); | ||
1775 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1783 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1776 | { | 1784 | { |
1777 | if (item.Type == 7 && item.Name == name) | 1785 | if (item.Type == 7 && item.Name == name) |
@@ -1779,6 +1787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1779 | assetID = item.AssetID; | 1787 | assetID = item.AssetID; |
1780 | } | 1788 | } |
1781 | } | 1789 | } |
1790 | m_host.TaskInventory.LockItemsForRead(false); | ||
1782 | } | 1791 | } |
1783 | 1792 | ||
1784 | if (assetID == UUID.Zero) | 1793 | if (assetID == UUID.Zero) |
@@ -1825,6 +1834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1825 | 1834 | ||
1826 | if (!UUID.TryParse(name, out assetID)) | 1835 | if (!UUID.TryParse(name, out assetID)) |
1827 | { | 1836 | { |
1837 | m_host.TaskInventory.LockItemsForRead(true); | ||
1828 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1838 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1829 | { | 1839 | { |
1830 | if (item.Type == 7 && item.Name == name) | 1840 | if (item.Type == 7 && item.Name == name) |
@@ -1832,6 +1842,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1832 | assetID = item.AssetID; | 1842 | assetID = item.AssetID; |
1833 | } | 1843 | } |
1834 | } | 1844 | } |
1845 | m_host.TaskInventory.LockItemsForRead(false); | ||
1835 | } | 1846 | } |
1836 | 1847 | ||
1837 | if (assetID == UUID.Zero) | 1848 | if (assetID == UUID.Zero) |
@@ -1882,6 +1893,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1882 | 1893 | ||
1883 | if (!UUID.TryParse(name, out assetID)) | 1894 | if (!UUID.TryParse(name, out assetID)) |
1884 | { | 1895 | { |
1896 | m_host.TaskInventory.LockItemsForRead(true); | ||
1885 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1897 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1886 | { | 1898 | { |
1887 | if (item.Type == 7 && item.Name == name) | 1899 | if (item.Type == 7 && item.Name == name) |
@@ -1889,6 +1901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1889 | assetID = item.AssetID; | 1901 | assetID = item.AssetID; |
1890 | } | 1902 | } |
1891 | } | 1903 | } |
1904 | m_host.TaskInventory.LockItemsForRead(false); | ||
1892 | } | 1905 | } |
1893 | 1906 | ||
1894 | if (assetID == UUID.Zero) | 1907 | if (assetID == UUID.Zero) |
@@ -2368,9 +2381,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2368 | { | 2381 | { |
2369 | if (avatar.IsChildAgent == false) | 2382 | if (avatar.IsChildAgent == false) |
2370 | { | 2383 | { |
2371 | result.Add(avatar.UUID); | 2384 | result.Add(new LSL_Key(avatar.UUID.ToString())); |
2372 | result.Add(avatar.AbsolutePosition); | 2385 | result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z)); |
2373 | result.Add(avatar.Name); | 2386 | result.Add(new LSL_String(avatar.Name)); |
2374 | } | 2387 | } |
2375 | } | 2388 | } |
2376 | }); | 2389 | }); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fefbb35..c4f90d2 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 |
@@ -301,7 +301,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
301 | float dy; | 301 | float dy; |
302 | float dz; | 302 | float dz; |
303 | 303 | ||
304 | Quaternion q = SensePoint.RotationOffset; | 304 | // Quaternion q = SensePoint.RotationOffset; |
305 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | ||
305 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | 306 | if (SensePoint.ParentGroup.RootPart.IsAttachment) |
306 | { | 307 | { |
307 | // In attachments, the sensor cone always orients with the | 308 | // In attachments, the sensor cone always orients with the |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
309 | // in mouselook. | 310 | // in mouselook. |
310 | 311 | ||
311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 312 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); |
313 | fromRegionPos = avatar.AbsolutePosition; | ||
312 | q = avatar.Rotation; | 314 | q = avatar.Rotation; |
313 | } | 315 | } |
314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 316 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -422,6 +424,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
422 | SceneObjectPart SensePoint = ts.host; | 424 | SceneObjectPart SensePoint = ts.host; |
423 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 425 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
424 | Quaternion q = SensePoint.RotationOffset; | 426 | Quaternion q = SensePoint.RotationOffset; |
427 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | ||
428 | { | ||
429 | // In attachments, the sensor cone always orients with the | ||
430 | // avatar rotation. This may include a nonzero elevation if | ||
431 | // in mouselook. | ||
432 | |||
433 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | ||
434 | fromRegionPos = avatar.AbsolutePosition; | ||
435 | q = avatar.Rotation; | ||
436 | } | ||
425 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 437 | 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); | 438 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
427 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 439 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 561e3b3..bae7d4b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -398,6 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
398 | LSL_Vector llWind(LSL_Vector offset); | 398 | LSL_Vector llWind(LSL_Vector offset); |
399 | LSL_String llXorBase64Strings(string str1, string str2); | 399 | LSL_String llXorBase64Strings(string str1, string str2); |
400 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 400 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
401 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); | ||
401 | 402 | ||
402 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 403 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
403 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 404 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 63007c6..c08ad3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
83 | // Avatar Info Commands | 83 | // Avatar Info Commands |
84 | string osGetAgentIP(string agent); | 84 | string osGetAgentIP(string agent); |
85 | LSL_List osGetAgents(); | 85 | LSL_List osGetAgents(); |
86 | 86 | ||
87 | // Teleport commands | 87 | // Teleport commands |
88 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 88 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
89 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 89 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 9615315..943d7a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index b3c4d95..93d544b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -279,6 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
280 | public const int CHANGED_MEDIA = 2048; | 280 | public const int CHANGED_MEDIA = 2048; |
281 | public const int CHANGED_ANIMATION = 16384; | 281 | public const int CHANGED_ANIMATION = 16384; |
282 | public const int CHANGED_POSITION = 32768; | ||
282 | public const int TYPE_INVALID = 0; | 283 | public const int TYPE_INVALID = 0; |
283 | public const int TYPE_INTEGER = 1; | 284 | public const int TYPE_INTEGER = 1; |
284 | public const int TYPE_FLOAT = 2; | 285 | public const int TYPE_FLOAT = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 451163f..7c26824 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
309 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 310 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
310 | } | 311 | } |
311 | 312 | ||
313 | [DebuggerNonUserCode] | ||
312 | public void llDie() | 314 | public void llDie() |
313 | { | 315 | { |
314 | m_LSL_Functions.llDie(); | 316 | m_LSL_Functions.llDie(); |
@@ -1847,5 +1849,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1847 | { | 1849 | { |
1848 | return m_LSL_Functions.llClearPrimMedia(face); | 1850 | return m_LSL_Functions.llClearPrimMedia(face); |
1849 | } | 1851 | } |
1852 | |||
1853 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | ||
1854 | { | ||
1855 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | ||
1856 | } | ||
1850 | } | 1857 | } |
1851 | } | 1858 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs index 143b497..2e27f16 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs | |||
@@ -72,9 +72,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
72 | { | 72 | { |
73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | 73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); |
74 | } | 74 | } |
75 | |||
75 | public void lsClearWindlightScene() | 76 | public void lsClearWindlightScene() |
76 | { | 77 | { |
77 | m_LS_Functions.lsClearWindlightScene(); | 78 | m_LS_Functions.lsClearWindlightScene(); |
78 | } | 79 | } |
80 | |||
81 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
82 | { | ||
83 | return m_LS_Functions.lsGetWindlightScene(rules); | ||
84 | } | ||
85 | |||
86 | public int cmSetWindlightScene(LSL_List rules) | ||
87 | { | ||
88 | return m_LS_Functions.lsSetWindlightScene(rules); | ||
89 | } | ||
90 | |||
91 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
92 | { | ||
93 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | ||
94 | } | ||
95 | |||
96 | public void cmClearWindlightScene() | ||
97 | { | ||
98 | m_LS_Functions.lsClearWindlightScene(); | ||
99 | } | ||
79 | } | 100 | } |
80 | } | 101 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 3575889..e9edf6c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -35,6 +35,7 @@ using OpenMetaverse; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.CoreModules; | 36 | using OpenSim.Region.CoreModules; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.ScriptEngine.Shared | 40 | namespace OpenSim.Region.ScriptEngine.Shared |
40 | { | 41 | { |
@@ -95,6 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
95 | Type = 0; | 96 | Type = 0; |
96 | Velocity = new LSL_Types.Vector3(); | 97 | Velocity = new LSL_Types.Vector3(); |
97 | initializeSurfaceTouch(); | 98 | initializeSurfaceTouch(); |
99 | Country = String.Empty; | ||
98 | } | 100 | } |
99 | 101 | ||
100 | public UUID Key; | 102 | public UUID Key; |
@@ -126,6 +128,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
126 | private int touchFace; | 128 | private int touchFace; |
127 | public int TouchFace { get { return touchFace; } } | 129 | public int TouchFace { get { return touchFace; } } |
128 | 130 | ||
131 | public string Country; | ||
132 | |||
129 | // This can be done in two places including the constructor | 133 | // This can be done in two places including the constructor |
130 | // so be carefull what gets added here | 134 | // so be carefull what gets added here |
131 | private void initializeSurfaceTouch() | 135 | private void initializeSurfaceTouch() |
@@ -173,6 +177,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
173 | return; | 177 | return; |
174 | 178 | ||
175 | Name = presence.Firstname + " " + presence.Lastname; | 179 | Name = presence.Firstname + " " + presence.Lastname; |
180 | UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, Key); | ||
181 | if (account != null) | ||
182 | Country = account.UserCountry; | ||
183 | |||
176 | Owner = Key; | 184 | Owner = Key; |
177 | Position = new LSL_Types.Vector3( | 185 | Position = new LSL_Types.Vector3( |
178 | presence.AbsolutePosition.X, | 186 | presence.AbsolutePosition.X, |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 783791f..9548253 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 |
@@ -434,14 +435,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
434 | { | 435 | { |
435 | int permsMask; | 436 | int permsMask; |
436 | UUID permsGranter; | 437 | UUID permsGranter; |
437 | lock (part.TaskInventory) | 438 | part.TaskInventory.LockItemsForRead(true); |
439 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
438 | { | 440 | { |
439 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 441 | part.TaskInventory.LockItemsForRead(false); |
440 | return; | 442 | return; |
441 | |||
442 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
443 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
444 | } | 443 | } |
444 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
445 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
446 | part.TaskInventory.LockItemsForRead(false); | ||
445 | 447 | ||
446 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 448 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
447 | { | 449 | { |
@@ -550,6 +552,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
550 | return true; | 552 | return true; |
551 | } | 553 | } |
552 | 554 | ||
555 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
553 | public void SetState(string state) | 556 | public void SetState(string state) |
554 | { | 557 | { |
555 | if (state == State) | 558 | if (state == State) |
@@ -561,7 +564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
561 | new DetectParams[0])); | 564 | new DetectParams[0])); |
562 | PostEvent(new EventParams("state_entry", new Object[0], | 565 | PostEvent(new EventParams("state_entry", new Object[0], |
563 | new DetectParams[0])); | 566 | new DetectParams[0])); |
564 | 567 | ||
565 | throw new EventAbortException(); | 568 | throw new EventAbortException(); |
566 | } | 569 | } |
567 | 570 | ||
@@ -644,14 +647,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
644 | /// <returns></returns> | 647 | /// <returns></returns> |
645 | public object EventProcessor() | 648 | public object EventProcessor() |
646 | { | 649 | { |
647 | if (m_Suspended) | 650 | EventParams data = null; |
648 | return 0; | ||
649 | 651 | ||
650 | lock (m_Script) | 652 | lock (m_EventQueue) |
651 | { | 653 | { |
652 | EventParams data = null; | 654 | if (m_Suspended) |
655 | return 0; | ||
653 | 656 | ||
654 | lock (m_EventQueue) | 657 | lock (m_Script) |
655 | { | 658 | { |
656 | data = (EventParams) m_EventQueue.Dequeue(); | 659 | data = (EventParams) m_EventQueue.Dequeue(); |
657 | if (data == null) // Shouldn't happen | 660 | if (data == null) // Shouldn't happen |
@@ -677,6 +680,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
677 | if (data.EventName == "collision") | 680 | if (data.EventName == "collision") |
678 | m_CollisionInQueue = false; | 681 | m_CollisionInQueue = false; |
679 | } | 682 | } |
683 | } | ||
684 | lock(m_Script) | ||
685 | { | ||
680 | 686 | ||
681 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 687 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
682 | 688 | ||
@@ -833,6 +839,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
833 | new Object[0], new DetectParams[0])); | 839 | new Object[0], new DetectParams[0])); |
834 | } | 840 | } |
835 | 841 | ||
842 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
836 | public void ApiResetScript() | 843 | public void ApiResetScript() |
837 | { | 844 | { |
838 | // bool running = Running; | 845 | // bool running = Running; |
@@ -864,10 +871,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
864 | 871 | ||
865 | public Dictionary<string, object> GetVars() | 872 | public Dictionary<string, object> GetVars() |
866 | { | 873 | { |
867 | if (m_Script != null) | 874 | return m_Script.GetVars(); |
868 | return m_Script.GetVars(); | ||
869 | else | ||
870 | return new Dictionary<string, object>(); | ||
871 | } | 875 | } |
872 | 876 | ||
873 | public void SetVars(Dictionary<string, object> vars) | 877 | public void SetVars(Dictionary<string, object> vars) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 298d664..f810fd8 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 | ||
@@ -459,6 +459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
459 | size += 64; | 459 | size += 64; |
460 | else if (o is int) | 460 | else if (o is int) |
461 | size += 4; | 461 | size += 4; |
462 | else if (o is uint) | ||
463 | size += 4; | ||
462 | else if (o is string) | 464 | else if (o is string) |
463 | size += ((string)o).Length; | 465 | size += ((string)o).Length; |
464 | else if (o is float) | 466 | else if (o is float) |
@@ -613,24 +615,16 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
613 | 615 | ||
614 | public static bool operator ==(list a, list b) | 616 | public static bool operator ==(list a, list b) |
615 | { | 617 | { |
616 | int la = -1; | 618 | int la = a.Length; |
617 | int lb = -1; | 619 | int lb = b.Length; |
618 | try { la = a.Length; } | ||
619 | catch (NullReferenceException) { } | ||
620 | try { lb = b.Length; } | ||
621 | catch (NullReferenceException) { } | ||
622 | 620 | ||
623 | return la == lb; | 621 | return la == lb; |
624 | } | 622 | } |
625 | 623 | ||
626 | public static bool operator !=(list a, list b) | 624 | public static bool operator !=(list a, list b) |
627 | { | 625 | { |
628 | int la = -1; | 626 | int la = a.Length; |
629 | int lb = -1; | 627 | int lb = b.Length; |
630 | try { la = a.Length; } | ||
631 | catch (NullReferenceException) { } | ||
632 | try {lb = b.Length;} | ||
633 | catch (NullReferenceException) { } | ||
634 | 628 | ||
635 | return la != lb; | 629 | return la != lb; |
636 | } | 630 | } |