diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
11 files changed, 1171 insertions, 643 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5941abd..f996ff4 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; |
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | get { return m_ScriptEngine.World; } | 152 | get { return m_ScriptEngine.World; } |
152 | } | 153 | } |
153 | 154 | ||
155 | [DebuggerNonUserCode] | ||
154 | public void state(string newState) | 156 | public void state(string newState) |
155 | { | 157 | { |
156 | m_ScriptEngine.SetState(m_itemID, newState); | 158 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | /// Reset the named script. The script must be present | 162 | /// Reset the named script. The script must be present |
161 | /// in the same prim. | 163 | /// in the same prim. |
162 | /// </summary> | 164 | /// </summary> |
165 | [DebuggerNonUserCode] | ||
163 | public void llResetScript() | 166 | public void llResetScript() |
164 | { | 167 | { |
165 | m_host.AddScriptLPS(1); | 168 | m_host.AddScriptLPS(1); |
@@ -216,9 +219,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
216 | } | 219 | } |
217 | } | 220 | } |
218 | 221 | ||
222 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
223 | { | ||
224 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
225 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
226 | return ret; | ||
227 | |||
228 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
229 | |||
230 | switch (linkType) | ||
231 | { | ||
232 | case ScriptBaseClass.LINK_SET: | ||
233 | return avs; | ||
234 | |||
235 | case ScriptBaseClass.LINK_ROOT: | ||
236 | return ret; | ||
237 | |||
238 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
239 | return avs; | ||
240 | |||
241 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
242 | return avs; | ||
243 | |||
244 | case ScriptBaseClass.LINK_THIS: | ||
245 | return ret; | ||
246 | |||
247 | default: | ||
248 | if (linkType < 0) | ||
249 | return ret; | ||
250 | |||
251 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
252 | |||
253 | if (linkType <= partCount) | ||
254 | { | ||
255 | return ret; | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | linkType = linkType - partCount; | ||
260 | if (linkType > avs.Count) | ||
261 | { | ||
262 | return ret; | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | ret.Add(avs[linkType-1]); | ||
267 | return ret; | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | } | ||
272 | |||
219 | public List<SceneObjectPart> GetLinkParts(int linkType) | 273 | public List<SceneObjectPart> GetLinkParts(int linkType) |
220 | { | 274 | { |
221 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 275 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
276 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
277 | return ret; | ||
222 | ret.Add(m_host); | 278 | ret.Add(m_host); |
223 | 279 | ||
224 | switch (linkType) | 280 | switch (linkType) |
@@ -272,40 +328,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 328 | protected UUID InventorySelf() |
273 | { | 329 | { |
274 | UUID invItemID = new UUID(); | 330 | UUID invItemID = new UUID(); |
275 | 331 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 332 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
333 | { | ||
334 | m_host.TaskInventory.LockItemsForRead(true); | ||
335 | unlock = true; | ||
336 | } | ||
337 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 338 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 339 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 340 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 341 | invItemID = inv.Key; |
281 | { | 342 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 343 | } |
286 | } | 344 | } |
287 | 345 | if (unlock) | |
346 | { | ||
347 | m_host.TaskInventory.LockItemsForRead(false); | ||
348 | } | ||
288 | return invItemID; | 349 | return invItemID; |
289 | } | 350 | } |
290 | 351 | ||
291 | protected UUID InventoryKey(string name, int type) | 352 | protected UUID InventoryKey(string name, int type) |
292 | { | 353 | { |
293 | m_host.AddScriptLPS(1); | 354 | m_host.AddScriptLPS(1); |
294 | 355 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 356 | |
357 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 358 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 359 | if (inv.Value.Name == name) |
298 | { | 360 | { |
299 | if (inv.Value.Name == name) | 361 | m_host.TaskInventory.LockItemsForRead(false); |
362 | |||
363 | if (inv.Value.Type != type) | ||
300 | { | 364 | { |
301 | if (inv.Value.Type != type) | 365 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 366 | } |
367 | |||
368 | return inv.Value.AssetID; | ||
306 | } | 369 | } |
307 | } | 370 | } |
308 | 371 | ||
372 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 373 | return UUID.Zero; |
310 | } | 374 | } |
311 | 375 | ||
@@ -313,17 +377,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 377 | { |
314 | m_host.AddScriptLPS(1); | 378 | m_host.AddScriptLPS(1); |
315 | 379 | ||
316 | lock (m_host.TaskInventory) | 380 | |
381 | m_host.TaskInventory.LockItemsForRead(true); | ||
382 | |||
383 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 384 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 385 | if (inv.Value.Name == name) |
319 | { | 386 | { |
320 | if (inv.Value.Name == name) | 387 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 388 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 389 | } |
325 | } | 390 | } |
326 | 391 | ||
392 | m_host.TaskInventory.LockItemsForRead(false); | ||
393 | |||
394 | |||
327 | return UUID.Zero; | 395 | return UUID.Zero; |
328 | } | 396 | } |
329 | 397 | ||
@@ -480,25 +548,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
480 | return remainder; | 548 | return remainder; |
481 | } | 549 | } |
482 | 550 | ||
483 | // Old implementation of llRot2Euler, now normalized | 551 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
484 | |||
485 | public LSL_Vector llRot2Euler(LSL_Rotation r) | ||
486 | { | 552 | { |
487 | m_host.AddScriptLPS(1); | 553 | m_host.AddScriptLPS(1); |
488 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | 554 | LSL_Vector eul = new LSL_Vector(); |
489 | LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | 555 | |
490 | double m = (t.x + t.y + t.z + t.s); | 556 | double sqw = q1.s*q1.s; |
491 | if (m == 0) return new LSL_Vector(); | 557 | double sqx = q1.x*q1.x; |
492 | double n = 2 * (r.y * r.s + r.x * r.z); | 558 | double sqy = q1.z*q1.z; |
493 | double p = m * m - n * n; | 559 | double sqz = q1.y*q1.y; |
494 | if (p > 0) | 560 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor |
495 | return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), | 561 | double test = q1.x*q1.z + q1.y*q1.s; |
496 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | 562 | if (test > 0.4999*unit) { // singularity at north pole |
497 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | 563 | eul.z = 2 * Math.Atan2(q1.x,q1.s); |
498 | else if (n > 0) | 564 | eul.y = Math.PI/2; |
499 | return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 565 | eul.x = 0; |
500 | else | 566 | return eul; |
501 | return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 567 | } |
568 | if (test < -0.4999*unit) { // singularity at south pole | ||
569 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
570 | eul.y = -Math.PI/2; | ||
571 | eul.x = 0; | ||
572 | return eul; | ||
573 | } | ||
574 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
575 | eul.y = Math.Asin(2*test/unit); | ||
576 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
577 | return eul; | ||
502 | } | 578 | } |
503 | 579 | ||
504 | /* From wiki: | 580 | /* From wiki: |
@@ -700,77 +776,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
700 | { | 776 | { |
701 | //A and B should both be normalized | 777 | //A and B should both be normalized |
702 | m_host.AddScriptLPS(1); | 778 | m_host.AddScriptLPS(1); |
703 | LSL_Rotation rotBetween; | 779 | /* This method is more accurate than the SL one, and thus causes problems |
704 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 780 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
705 | // continue calculation. | 781 | |
706 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 782 | double dotProduct = LSL_Vector.Dot(a, b); |
783 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
784 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
785 | double angle = Math.Acos(dotProduct / magProduct); | ||
786 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
787 | double s = Math.Sin(angle / 2); | ||
788 | |||
789 | double x = axis.x * s; | ||
790 | double y = axis.y * s; | ||
791 | double z = axis.z * s; | ||
792 | double w = Math.Cos(angle / 2); | ||
793 | |||
794 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
795 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
796 | |||
797 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
798 | */ | ||
799 | |||
800 | // This method mimics the 180 errors found in SL | ||
801 | // See www.euclideanspace.com... angleBetween | ||
802 | LSL_Vector vec_a = a; | ||
803 | LSL_Vector vec_b = b; | ||
804 | |||
805 | // Eliminate zero length | ||
806 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
807 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
808 | if (vec_a_mag < 0.00001 || | ||
809 | vec_b_mag < 0.00001) | ||
707 | { | 810 | { |
708 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 811 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
709 | } | 812 | } |
710 | else | 813 | |
814 | // Normalize | ||
815 | vec_a = llVecNorm(vec_a); | ||
816 | vec_b = llVecNorm(vec_b); | ||
817 | |||
818 | // Calculate axis and rotation angle | ||
819 | LSL_Vector axis = vec_a % vec_b; | ||
820 | LSL_Float cos_theta = vec_a * vec_b; | ||
821 | |||
822 | // Check if parallel | ||
823 | if (cos_theta > 0.99999) | ||
711 | { | 824 | { |
712 | a = LSL_Vector.Norm(a); | 825 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
713 | b = LSL_Vector.Norm(b); | 826 | } |
714 | double dotProduct = LSL_Vector.Dot(a, b); | 827 | |
715 | // There are two degenerate cases possible. These are for vectors 180 or | 828 | // Check if anti-parallel |
716 | // 0 degrees apart. These have to be detected and handled individually. | 829 | else if (cos_theta < -0.99999) |
717 | // | 830 | { |
718 | // Check for vectors 180 degrees apart. | 831 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
719 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 832 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
720 | if (dotProduct < -0.9999999f) | 833 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
721 | { | 834 | } |
722 | // First assume X axis is orthogonal to the vectors. | 835 | else // other rotation |
723 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 836 | { |
724 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 837 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
725 | // Check for near zero vector. A very small non-zero number here will create | 838 | axis = llVecNorm(axis); |
726 | // a rotation in an undesired direction. | 839 | double x, y, z, s, t; |
727 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 840 | s = Math.Cos(theta); |
728 | { | 841 | t = Math.Sin(theta); |
729 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 842 | x = axis.x * t; |
730 | } | 843 | y = axis.y * t; |
731 | // If the magnitude of the vector was near zero, then assume the X axis is not | 844 | z = axis.z * t; |
732 | // orthogonal and use the Z axis instead. | 845 | return new LSL_Rotation(x,y,z,s); |
733 | else | ||
734 | { | ||
735 | // Set 180 z rotation. | ||
736 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
737 | } | ||
738 | } | ||
739 | // Check for parallel vectors. | ||
740 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
741 | else if (dotProduct > 0.9999999f) | ||
742 | { | ||
743 | // Set zero rotation. | ||
744 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
745 | } | ||
746 | else | ||
747 | { | ||
748 | // All special checks have been performed so get the axis of rotation. | ||
749 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
750 | // Quarternion s value is the length of the unit vector + dot product. | ||
751 | double qs = 1.0 + dotProduct; | ||
752 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
753 | // Normalize the rotation. | ||
754 | double mag = LSL_Rotation.Mag(rotBetween); | ||
755 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
756 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
757 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
758 | // crossProduct vector should also not be zero. | ||
759 | rotBetween.x = rotBetween.x / mag; | ||
760 | rotBetween.y = rotBetween.y / mag; | ||
761 | rotBetween.z = rotBetween.z / mag; | ||
762 | rotBetween.s = rotBetween.s / mag; | ||
763 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
764 | // any longer since zero vectors are checked for at the top. | ||
765 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
766 | { | ||
767 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
768 | } | ||
769 | } | ||
770 | } | 846 | } |
771 | return rotBetween; | ||
772 | } | 847 | } |
773 | 848 | ||
774 | public void llWhisper(int channelID, string text) | 849 | public void llWhisper(int channelID, string text) |
775 | { | 850 | { |
776 | m_host.AddScriptLPS(1); | 851 | m_host.AddScriptLPS(1); |
@@ -1094,10 +1169,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1094 | return detectedParams.TouchUV; | 1169 | return detectedParams.TouchUV; |
1095 | } | 1170 | } |
1096 | 1171 | ||
1172 | [DebuggerNonUserCode] | ||
1097 | public virtual void llDie() | 1173 | public virtual void llDie() |
1098 | { | 1174 | { |
1099 | m_host.AddScriptLPS(1); | 1175 | m_host.AddScriptLPS(1); |
1100 | throw new SelfDeleteException(); | 1176 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1101 | } | 1177 | } |
1102 | 1178 | ||
1103 | public LSL_Float llGround(LSL_Vector offset) | 1179 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1170,6 +1246,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1170 | 1246 | ||
1171 | public void llSetStatus(int status, int value) | 1247 | public void llSetStatus(int status, int value) |
1172 | { | 1248 | { |
1249 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1250 | return; | ||
1173 | m_host.AddScriptLPS(1); | 1251 | m_host.AddScriptLPS(1); |
1174 | 1252 | ||
1175 | int statusrotationaxis = 0; | 1253 | int statusrotationaxis = 0; |
@@ -1399,6 +1477,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1399 | { | 1477 | { |
1400 | m_host.AddScriptLPS(1); | 1478 | m_host.AddScriptLPS(1); |
1401 | 1479 | ||
1480 | SetColor(m_host, color, face); | ||
1481 | } | ||
1482 | |||
1483 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1484 | { | ||
1485 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1486 | return; | ||
1487 | |||
1488 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1489 | Color4 texcolor; | ||
1490 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1491 | { | ||
1492 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1493 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1494 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1495 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1496 | tex.FaceTextures[face].RGBA = texcolor; | ||
1497 | part.UpdateTexture(tex); | ||
1498 | return; | ||
1499 | } | ||
1500 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1501 | { | ||
1502 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1503 | { | ||
1504 | if (tex.FaceTextures[i] != null) | ||
1505 | { | ||
1506 | texcolor = tex.FaceTextures[i].RGBA; | ||
1507 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1508 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1509 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1510 | tex.FaceTextures[i].RGBA = texcolor; | ||
1511 | } | ||
1512 | texcolor = tex.DefaultTexture.RGBA; | ||
1513 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1514 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1515 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1516 | tex.DefaultTexture.RGBA = texcolor; | ||
1517 | } | ||
1518 | part.UpdateTexture(tex); | ||
1519 | return; | ||
1520 | } | ||
1521 | |||
1402 | if (face == ScriptBaseClass.ALL_SIDES) | 1522 | if (face == ScriptBaseClass.ALL_SIDES) |
1403 | face = SceneObjectPart.ALL_SIDES; | 1523 | face = SceneObjectPart.ALL_SIDES; |
1404 | 1524 | ||
@@ -1407,6 +1527,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1407 | 1527 | ||
1408 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1528 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1409 | { | 1529 | { |
1530 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1531 | return; | ||
1532 | |||
1410 | Primitive.TextureEntry tex = part.Shape.Textures; | 1533 | Primitive.TextureEntry tex = part.Shape.Textures; |
1411 | MappingType textype; | 1534 | MappingType textype; |
1412 | textype = MappingType.Default; | 1535 | textype = MappingType.Default; |
@@ -1437,6 +1560,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1437 | 1560 | ||
1438 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1561 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1439 | { | 1562 | { |
1563 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1564 | return; | ||
1565 | |||
1440 | Primitive.TextureEntry tex = part.Shape.Textures; | 1566 | Primitive.TextureEntry tex = part.Shape.Textures; |
1441 | if (face >= 0 && face < GetNumberOfSides(part)) | 1567 | if (face >= 0 && face < GetNumberOfSides(part)) |
1442 | { | 1568 | { |
@@ -1462,6 +1588,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1462 | 1588 | ||
1463 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1589 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1464 | { | 1590 | { |
1591 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1592 | return; | ||
1465 | 1593 | ||
1466 | Shininess sval = new Shininess(); | 1594 | Shininess sval = new Shininess(); |
1467 | 1595 | ||
@@ -1512,6 +1640,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1512 | 1640 | ||
1513 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1641 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1514 | { | 1642 | { |
1643 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1644 | return; | ||
1645 | |||
1515 | Primitive.TextureEntry tex = part.Shape.Textures; | 1646 | Primitive.TextureEntry tex = part.Shape.Textures; |
1516 | if (face >= 0 && face < GetNumberOfSides(part)) | 1647 | if (face >= 0 && face < GetNumberOfSides(part)) |
1517 | { | 1648 | { |
@@ -1572,13 +1703,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1572 | m_host.AddScriptLPS(1); | 1703 | m_host.AddScriptLPS(1); |
1573 | 1704 | ||
1574 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1705 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1575 | 1706 | if (parts.Count > 0) | |
1576 | foreach (SceneObjectPart part in parts) | 1707 | { |
1577 | SetAlpha(part, alpha, face); | 1708 | try |
1709 | { | ||
1710 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1711 | foreach (SceneObjectPart part in parts) | ||
1712 | SetAlpha(part, alpha, face); | ||
1713 | } | ||
1714 | finally | ||
1715 | { | ||
1716 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1717 | } | ||
1718 | } | ||
1578 | } | 1719 | } |
1579 | 1720 | ||
1580 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1721 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1581 | { | 1722 | { |
1723 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1724 | return; | ||
1725 | |||
1582 | Primitive.TextureEntry tex = part.Shape.Textures; | 1726 | Primitive.TextureEntry tex = part.Shape.Textures; |
1583 | Color4 texcolor; | 1727 | Color4 texcolor; |
1584 | if (face >= 0 && face < GetNumberOfSides(part)) | 1728 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1624,7 +1768,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1624 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1768 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1625 | float wind, float tension, LSL_Vector Force) | 1769 | float wind, float tension, LSL_Vector Force) |
1626 | { | 1770 | { |
1627 | if (part == null) | 1771 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1628 | return; | 1772 | return; |
1629 | 1773 | ||
1630 | if (flexi) | 1774 | if (flexi) |
@@ -1659,7 +1803,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1659 | /// <param name="falloff"></param> | 1803 | /// <param name="falloff"></param> |
1660 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1804 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1661 | { | 1805 | { |
1662 | if (part == null) | 1806 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1663 | return; | 1807 | return; |
1664 | 1808 | ||
1665 | if (light) | 1809 | if (light) |
@@ -1736,15 +1880,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1736 | m_host.AddScriptLPS(1); | 1880 | m_host.AddScriptLPS(1); |
1737 | 1881 | ||
1738 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1882 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1739 | 1883 | if (parts.Count > 0) | |
1740 | foreach (SceneObjectPart part in parts) | 1884 | { |
1741 | SetTexture(part, texture, face); | 1885 | try |
1742 | 1886 | { | |
1887 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1888 | foreach (SceneObjectPart part in parts) | ||
1889 | SetTexture(part, texture, face); | ||
1890 | } | ||
1891 | finally | ||
1892 | { | ||
1893 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1894 | } | ||
1895 | } | ||
1743 | ScriptSleep(200); | 1896 | ScriptSleep(200); |
1744 | } | 1897 | } |
1745 | 1898 | ||
1746 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1899 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1747 | { | 1900 | { |
1901 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1902 | return; | ||
1903 | |||
1748 | UUID textureID=new UUID(); | 1904 | UUID textureID=new UUID(); |
1749 | 1905 | ||
1750 | if (!UUID.TryParse(texture, out textureID)) | 1906 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1790,6 +1946,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1790 | 1946 | ||
1791 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1947 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1792 | { | 1948 | { |
1949 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1950 | return; | ||
1951 | |||
1793 | Primitive.TextureEntry tex = part.Shape.Textures; | 1952 | Primitive.TextureEntry tex = part.Shape.Textures; |
1794 | if (face >= 0 && face < GetNumberOfSides(part)) | 1953 | if (face >= 0 && face < GetNumberOfSides(part)) |
1795 | { | 1954 | { |
@@ -1826,6 +1985,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1826 | 1985 | ||
1827 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1986 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1828 | { | 1987 | { |
1988 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1989 | return; | ||
1990 | |||
1829 | Primitive.TextureEntry tex = part.Shape.Textures; | 1991 | Primitive.TextureEntry tex = part.Shape.Textures; |
1830 | if (face >= 0 && face < GetNumberOfSides(part)) | 1992 | if (face >= 0 && face < GetNumberOfSides(part)) |
1831 | { | 1993 | { |
@@ -1862,6 +2024,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1862 | 2024 | ||
1863 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2025 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1864 | { | 2026 | { |
2027 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2028 | return; | ||
2029 | |||
1865 | Primitive.TextureEntry tex = part.Shape.Textures; | 2030 | Primitive.TextureEntry tex = part.Shape.Textures; |
1866 | if (face >= 0 && face < GetNumberOfSides(part)) | 2031 | if (face >= 0 && face < GetNumberOfSides(part)) |
1867 | { | 2032 | { |
@@ -1932,6 +2097,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1932 | 2097 | ||
1933 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2098 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1934 | { | 2099 | { |
2100 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2101 | return; | ||
2102 | |||
1935 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2103 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1936 | LSL_Vector currentPos = llGetLocalPos(); | 2104 | LSL_Vector currentPos = llGetLocalPos(); |
1937 | 2105 | ||
@@ -2018,6 +2186,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2018 | 2186 | ||
2019 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2187 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2020 | { | 2188 | { |
2189 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2190 | return; | ||
2191 | |||
2021 | part.UpdateRotation(rot); | 2192 | part.UpdateRotation(rot); |
2022 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2193 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2023 | 2194 | ||
@@ -2637,12 +2808,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2637 | 2808 | ||
2638 | m_host.AddScriptLPS(1); | 2809 | m_host.AddScriptLPS(1); |
2639 | 2810 | ||
2811 | m_host.TaskInventory.LockItemsForRead(true); | ||
2640 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2812 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2641 | 2813 | m_host.TaskInventory.LockItemsForRead(false); | |
2642 | lock (m_host.TaskInventory) | ||
2643 | { | ||
2644 | item = m_host.TaskInventory[invItemID]; | ||
2645 | } | ||
2646 | 2814 | ||
2647 | if (item.PermsGranter == UUID.Zero) | 2815 | if (item.PermsGranter == UUID.Zero) |
2648 | return 0; | 2816 | return 0; |
@@ -2717,6 +2885,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2717 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2885 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2718 | return; | 2886 | return; |
2719 | 2887 | ||
2888 | //Clone is thread-safe | ||
2720 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2889 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2721 | 2890 | ||
2722 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2891 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2779,6 +2948,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2779 | 2948 | ||
2780 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2949 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2781 | { | 2950 | { |
2951 | /* | ||
2782 | m_host.AddScriptLPS(1); | 2952 | m_host.AddScriptLPS(1); |
2783 | // Determine where we are looking from | 2953 | // Determine where we are looking from |
2784 | LSL_Vector from = llGetPos(); | 2954 | LSL_Vector from = llGetPos(); |
@@ -2798,10 +2968,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2798 | // the angles of rotation in radians into rotation value | 2968 | // the angles of rotation in radians into rotation value |
2799 | 2969 | ||
2800 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2970 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2801 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2971 | |
2802 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2972 | // This would only work if your physics system contains an APID controller: |
2973 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2974 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2975 | |||
2803 | // Orient the object to the angle calculated | 2976 | // Orient the object to the angle calculated |
2804 | //llSetRot(rot); | 2977 | llSetRot(rot); |
2978 | */ | ||
2979 | |||
2980 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2981 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2982 | // http://bugs.meta7.com/view.php?id=28 | ||
2983 | // - Tom | ||
2984 | |||
2985 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2986 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2987 | |||
2988 | } | ||
2989 | |||
2990 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2991 | { | ||
2992 | m_host.AddScriptLPS(1); | ||
2993 | // NotImplemented("llRotLookAt"); | ||
2994 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2995 | |||
2805 | } | 2996 | } |
2806 | 2997 | ||
2807 | public void llStopLookAt() | 2998 | public void llStopLookAt() |
@@ -2850,13 +3041,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2850 | { | 3041 | { |
2851 | TaskInventoryItem item; | 3042 | TaskInventoryItem item; |
2852 | 3043 | ||
2853 | lock (m_host.TaskInventory) | 3044 | m_host.TaskInventory.LockItemsForRead(true); |
3045 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2854 | { | 3046 | { |
2855 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3047 | m_host.TaskInventory.LockItemsForRead(false); |
2856 | return; | 3048 | return; |
2857 | else | ||
2858 | item = m_host.TaskInventory[InventorySelf()]; | ||
2859 | } | 3049 | } |
3050 | else | ||
3051 | { | ||
3052 | item = m_host.TaskInventory[InventorySelf()]; | ||
3053 | } | ||
3054 | m_host.TaskInventory.LockItemsForRead(false); | ||
2860 | 3055 | ||
2861 | if (item.PermsGranter != UUID.Zero) | 3056 | if (item.PermsGranter != UUID.Zero) |
2862 | { | 3057 | { |
@@ -2878,13 +3073,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2878 | { | 3073 | { |
2879 | TaskInventoryItem item; | 3074 | TaskInventoryItem item; |
2880 | 3075 | ||
3076 | m_host.TaskInventory.LockItemsForRead(true); | ||
2881 | lock (m_host.TaskInventory) | 3077 | lock (m_host.TaskInventory) |
2882 | { | 3078 | { |
3079 | |||
2883 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3080 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3081 | { | ||
3082 | m_host.TaskInventory.LockItemsForRead(false); | ||
2884 | return; | 3083 | return; |
3084 | } | ||
2885 | else | 3085 | else |
3086 | { | ||
2886 | item = m_host.TaskInventory[InventorySelf()]; | 3087 | item = m_host.TaskInventory[InventorySelf()]; |
3088 | } | ||
2887 | } | 3089 | } |
3090 | m_host.TaskInventory.LockItemsForRead(false); | ||
2888 | 3091 | ||
2889 | m_host.AddScriptLPS(1); | 3092 | m_host.AddScriptLPS(1); |
2890 | 3093 | ||
@@ -2916,18 +3119,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2916 | { | 3119 | { |
2917 | m_host.AddScriptLPS(1); | 3120 | m_host.AddScriptLPS(1); |
2918 | 3121 | ||
2919 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
2920 | return; | ||
2921 | |||
2922 | TaskInventoryItem item; | 3122 | TaskInventoryItem item; |
2923 | 3123 | ||
2924 | lock (m_host.TaskInventory) | 3124 | m_host.TaskInventory.LockItemsForRead(true); |
3125 | |||
3126 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2925 | { | 3127 | { |
2926 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3128 | m_host.TaskInventory.LockItemsForRead(false); |
2927 | return; | 3129 | return; |
2928 | else | ||
2929 | item = m_host.TaskInventory[InventorySelf()]; | ||
2930 | } | 3130 | } |
3131 | else | ||
3132 | { | ||
3133 | item = m_host.TaskInventory[InventorySelf()]; | ||
3134 | } | ||
3135 | |||
3136 | m_host.TaskInventory.LockItemsForRead(false); | ||
2931 | 3137 | ||
2932 | if (item.PermsGranter != m_host.OwnerID) | 3138 | if (item.PermsGranter != m_host.OwnerID) |
2933 | return; | 3139 | return; |
@@ -2938,11 +3144,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2938 | 3144 | ||
2939 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3145 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
2940 | 3146 | ||
3147 | /* | ||
2941 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3148 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
2942 | if (attachmentsModule != null) | 3149 | if (attachmentsModule != null) |
3150 | { | ||
2943 | attachmentsModule.AttachObject( | 3151 | attachmentsModule.AttachObject( |
2944 | presence.ControllingClient, grp.LocalId, | 3152 | presence.ControllingClient, grp.LocalId, |
2945 | (uint)attachment, Quaternion.Identity, Vector3.Zero, false); | 3153 | (uint)attachment, Quaternion.Identity, Vector3.Zero, false); |
3154 | } | ||
3155 | */ | ||
3156 | grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false); | ||
2946 | } | 3157 | } |
2947 | } | 3158 | } |
2948 | 3159 | ||
@@ -2955,13 +3166,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2955 | 3166 | ||
2956 | TaskInventoryItem item; | 3167 | TaskInventoryItem item; |
2957 | 3168 | ||
2958 | lock (m_host.TaskInventory) | 3169 | m_host.TaskInventory.LockItemsForRead(true); |
3170 | |||
3171 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2959 | { | 3172 | { |
2960 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3173 | m_host.TaskInventory.LockItemsForRead(false); |
2961 | return; | 3174 | return; |
2962 | else | 3175 | } |
2963 | item = m_host.TaskInventory[InventorySelf()]; | 3176 | else |
3177 | { | ||
3178 | item = m_host.TaskInventory[InventorySelf()]; | ||
2964 | } | 3179 | } |
3180 | m_host.TaskInventory.LockItemsForRead(false); | ||
3181 | |||
2965 | 3182 | ||
2966 | if (item.PermsGranter != m_host.OwnerID) | 3183 | if (item.PermsGranter != m_host.OwnerID) |
2967 | return; | 3184 | return; |
@@ -2998,8 +3215,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2998 | return m_host.OwnerID.ToString(); | 3215 | return m_host.OwnerID.ToString(); |
2999 | } | 3216 | } |
3000 | 3217 | ||
3218 | [DebuggerNonUserCode] | ||
3001 | public void llInstantMessage(string user, string message) | 3219 | public void llInstantMessage(string user, string message) |
3002 | { | 3220 | { |
3221 | UUID result; | ||
3222 | if (!UUID.TryParse(user, out result)) | ||
3223 | { | ||
3224 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3225 | return; | ||
3226 | } | ||
3227 | |||
3228 | |||
3003 | m_host.AddScriptLPS(1); | 3229 | m_host.AddScriptLPS(1); |
3004 | 3230 | ||
3005 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3231 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3014,14 +3240,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3014 | UUID friendTransactionID = UUID.Random(); | 3240 | UUID friendTransactionID = UUID.Random(); |
3015 | 3241 | ||
3016 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3242 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3017 | 3243 | ||
3018 | GridInstantMessage msg = new GridInstantMessage(); | 3244 | GridInstantMessage msg = new GridInstantMessage(); |
3019 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3245 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3020 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3246 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3021 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3247 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3022 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3248 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3023 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3249 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3024 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3250 | DateTime dt = DateTime.UtcNow; |
3251 | |||
3252 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3253 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3254 | |||
3255 | try | ||
3256 | { | ||
3257 | // Convert that to the PST timezone | ||
3258 | TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3259 | dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3260 | } | ||
3261 | catch | ||
3262 | { | ||
3263 | // No logging here, as it could be VERY spammy | ||
3264 | } | ||
3265 | |||
3266 | // And make it look local again to fool the unix time util | ||
3267 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3268 | |||
3269 | msg.timestamp = (uint)Util.ToUnixTime(dt); | ||
3270 | |||
3025 | //if (client != null) | 3271 | //if (client != null) |
3026 | //{ | 3272 | //{ |
3027 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3273 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3035,13 +3281,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3035 | msg.message = message.Substring(0, 1024); | 3281 | msg.message = message.Substring(0, 1024); |
3036 | else | 3282 | else |
3037 | msg.message = message; | 3283 | msg.message = message; |
3038 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3284 | msg.dialog = (byte)19; // MessageFromObject |
3039 | msg.fromGroup = false;// fromGroup; | 3285 | msg.fromGroup = false;// fromGroup; |
3040 | msg.offline = (byte)0; //offline; | 3286 | msg.offline = (byte)0; //offline; |
3041 | msg.ParentEstateID = 0; //ParentEstateID; | 3287 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3042 | msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); | 3288 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3043 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3289 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3044 | msg.binaryBucket = new byte[0];// binaryBucket; | 3290 | msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); |
3045 | 3291 | ||
3046 | if (m_TransferModule != null) | 3292 | if (m_TransferModule != null) |
3047 | { | 3293 | { |
@@ -3163,13 +3409,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3163 | m_host.AddScriptLPS(1); | 3409 | m_host.AddScriptLPS(1); |
3164 | } | 3410 | } |
3165 | 3411 | ||
3166 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3167 | { | ||
3168 | m_host.AddScriptLPS(1); | ||
3169 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3170 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3171 | } | ||
3172 | |||
3173 | public LSL_Integer llStringLength(string str) | 3412 | public LSL_Integer llStringLength(string str) |
3174 | { | 3413 | { |
3175 | m_host.AddScriptLPS(1); | 3414 | m_host.AddScriptLPS(1); |
@@ -3193,14 +3432,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3193 | 3432 | ||
3194 | TaskInventoryItem item; | 3433 | TaskInventoryItem item; |
3195 | 3434 | ||
3196 | lock (m_host.TaskInventory) | 3435 | m_host.TaskInventory.LockItemsForRead(true); |
3436 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3197 | { | 3437 | { |
3198 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3438 | m_host.TaskInventory.LockItemsForRead(false); |
3199 | return; | 3439 | return; |
3200 | else | ||
3201 | item = m_host.TaskInventory[InventorySelf()]; | ||
3202 | } | 3440 | } |
3203 | 3441 | else | |
3442 | { | ||
3443 | item = m_host.TaskInventory[InventorySelf()]; | ||
3444 | } | ||
3445 | m_host.TaskInventory.LockItemsForRead(false); | ||
3204 | if (item.PermsGranter == UUID.Zero) | 3446 | if (item.PermsGranter == UUID.Zero) |
3205 | return; | 3447 | return; |
3206 | 3448 | ||
@@ -3230,13 +3472,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3230 | 3472 | ||
3231 | TaskInventoryItem item; | 3473 | TaskInventoryItem item; |
3232 | 3474 | ||
3233 | lock (m_host.TaskInventory) | 3475 | m_host.TaskInventory.LockItemsForRead(true); |
3476 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3234 | { | 3477 | { |
3235 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3478 | m_host.TaskInventory.LockItemsForRead(false); |
3236 | return; | 3479 | return; |
3237 | else | 3480 | } |
3238 | item = m_host.TaskInventory[InventorySelf()]; | 3481 | else |
3482 | { | ||
3483 | item = m_host.TaskInventory[InventorySelf()]; | ||
3239 | } | 3484 | } |
3485 | m_host.TaskInventory.LockItemsForRead(false); | ||
3486 | |||
3240 | 3487 | ||
3241 | if (item.PermsGranter == UUID.Zero) | 3488 | if (item.PermsGranter == UUID.Zero) |
3242 | return; | 3489 | return; |
@@ -3313,10 +3560,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3313 | 3560 | ||
3314 | TaskInventoryItem item; | 3561 | TaskInventoryItem item; |
3315 | 3562 | ||
3316 | lock (m_host.TaskInventory) | 3563 | |
3564 | m_host.TaskInventory.LockItemsForRead(true); | ||
3565 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3566 | { | ||
3567 | m_host.TaskInventory.LockItemsForRead(false); | ||
3568 | return; | ||
3569 | } | ||
3570 | else | ||
3317 | { | 3571 | { |
3318 | item = m_host.TaskInventory[invItemID]; | 3572 | item = m_host.TaskInventory[invItemID]; |
3319 | } | 3573 | } |
3574 | m_host.TaskInventory.LockItemsForRead(false); | ||
3320 | 3575 | ||
3321 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3576 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3322 | { | 3577 | { |
@@ -3348,11 +3603,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3348 | 3603 | ||
3349 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3604 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3350 | { | 3605 | { |
3351 | lock (m_host.TaskInventory) | 3606 | m_host.TaskInventory.LockItemsForWrite(true); |
3352 | { | 3607 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3353 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3608 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3354 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3609 | m_host.TaskInventory.LockItemsForWrite(false); |
3355 | } | ||
3356 | 3610 | ||
3357 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3611 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3358 | "run_time_permissions", new Object[] { | 3612 | "run_time_permissions", new Object[] { |
@@ -3372,11 +3626,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3372 | 3626 | ||
3373 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3627 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3374 | { | 3628 | { |
3375 | lock (m_host.TaskInventory) | 3629 | m_host.TaskInventory.LockItemsForWrite(true); |
3376 | { | 3630 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3377 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3631 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3378 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3632 | m_host.TaskInventory.LockItemsForWrite(false); |
3379 | } | ||
3380 | 3633 | ||
3381 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3634 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3382 | "run_time_permissions", new Object[] { | 3635 | "run_time_permissions", new Object[] { |
@@ -3397,11 +3650,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3397 | 3650 | ||
3398 | if (!m_waitingForScriptAnswer) | 3651 | if (!m_waitingForScriptAnswer) |
3399 | { | 3652 | { |
3400 | lock (m_host.TaskInventory) | 3653 | m_host.TaskInventory.LockItemsForWrite(true); |
3401 | { | 3654 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3402 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3655 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3403 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3656 | m_host.TaskInventory.LockItemsForWrite(false); |
3404 | } | ||
3405 | 3657 | ||
3406 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3658 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3407 | m_waitingForScriptAnswer=true; | 3659 | m_waitingForScriptAnswer=true; |
@@ -3436,10 +3688,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3436 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3688 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3437 | llReleaseControls(); | 3689 | llReleaseControls(); |
3438 | 3690 | ||
3439 | lock (m_host.TaskInventory) | 3691 | |
3440 | { | 3692 | m_host.TaskInventory.LockItemsForWrite(true); |
3441 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3693 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3442 | } | 3694 | m_host.TaskInventory.LockItemsForWrite(false); |
3695 | |||
3443 | 3696 | ||
3444 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3697 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3445 | "run_time_permissions", new Object[] { | 3698 | "run_time_permissions", new Object[] { |
@@ -3451,16 +3704,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3451 | { | 3704 | { |
3452 | m_host.AddScriptLPS(1); | 3705 | m_host.AddScriptLPS(1); |
3453 | 3706 | ||
3454 | lock (m_host.TaskInventory) | 3707 | m_host.TaskInventory.LockItemsForRead(true); |
3708 | |||
3709 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3455 | { | 3710 | { |
3456 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3711 | if (item.Type == 10 && item.ItemID == m_itemID) |
3457 | { | 3712 | { |
3458 | if (item.Type == 10 && item.ItemID == m_itemID) | 3713 | m_host.TaskInventory.LockItemsForRead(false); |
3459 | { | 3714 | return item.PermsGranter.ToString(); |
3460 | return item.PermsGranter.ToString(); | ||
3461 | } | ||
3462 | } | 3715 | } |
3463 | } | 3716 | } |
3717 | m_host.TaskInventory.LockItemsForRead(false); | ||
3464 | 3718 | ||
3465 | return UUID.Zero.ToString(); | 3719 | return UUID.Zero.ToString(); |
3466 | } | 3720 | } |
@@ -3469,19 +3723,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3469 | { | 3723 | { |
3470 | m_host.AddScriptLPS(1); | 3724 | m_host.AddScriptLPS(1); |
3471 | 3725 | ||
3472 | lock (m_host.TaskInventory) | 3726 | m_host.TaskInventory.LockItemsForRead(true); |
3727 | |||
3728 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3473 | { | 3729 | { |
3474 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3730 | if (item.Type == 10 && item.ItemID == m_itemID) |
3475 | { | 3731 | { |
3476 | if (item.Type == 10 && item.ItemID == m_itemID) | 3732 | int perms = item.PermsMask; |
3477 | { | 3733 | if (m_automaticLinkPermission) |
3478 | int perms = item.PermsMask; | 3734 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3479 | if (m_automaticLinkPermission) | 3735 | m_host.TaskInventory.LockItemsForRead(false); |
3480 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3736 | return perms; |
3481 | return perms; | ||
3482 | } | ||
3483 | } | 3737 | } |
3484 | } | 3738 | } |
3739 | m_host.TaskInventory.LockItemsForRead(false); | ||
3485 | 3740 | ||
3486 | return 0; | 3741 | return 0; |
3487 | } | 3742 | } |
@@ -3503,9 +3758,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3503 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3758 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3504 | { | 3759 | { |
3505 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3760 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3506 | 3761 | if (parts.Count > 0) | |
3507 | foreach (SceneObjectPart part in parts) | 3762 | { |
3508 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3763 | try |
3764 | { | ||
3765 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3766 | foreach (SceneObjectPart part in parts) | ||
3767 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3768 | } | ||
3769 | finally | ||
3770 | { | ||
3771 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3772 | } | ||
3773 | } | ||
3509 | } | 3774 | } |
3510 | 3775 | ||
3511 | public void llCreateLink(string target, int parent) | 3776 | public void llCreateLink(string target, int parent) |
@@ -3514,11 +3779,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3514 | UUID invItemID = InventorySelf(); | 3779 | UUID invItemID = InventorySelf(); |
3515 | 3780 | ||
3516 | TaskInventoryItem item; | 3781 | TaskInventoryItem item; |
3517 | lock (m_host.TaskInventory) | 3782 | m_host.TaskInventory.LockItemsForRead(true); |
3518 | { | 3783 | item = m_host.TaskInventory[invItemID]; |
3519 | item = m_host.TaskInventory[invItemID]; | 3784 | m_host.TaskInventory.LockItemsForRead(false); |
3520 | } | 3785 | |
3521 | |||
3522 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3786 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3523 | && !m_automaticLinkPermission) | 3787 | && !m_automaticLinkPermission) |
3524 | { | 3788 | { |
@@ -3571,16 +3835,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3571 | m_host.AddScriptLPS(1); | 3835 | m_host.AddScriptLPS(1); |
3572 | UUID invItemID = InventorySelf(); | 3836 | UUID invItemID = InventorySelf(); |
3573 | 3837 | ||
3574 | lock (m_host.TaskInventory) | 3838 | m_host.TaskInventory.LockItemsForRead(true); |
3575 | { | ||
3576 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3839 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3577 | && !m_automaticLinkPermission) | 3840 | && !m_automaticLinkPermission) |
3578 | { | 3841 | { |
3579 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3842 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3843 | m_host.TaskInventory.LockItemsForRead(false); | ||
3580 | return; | 3844 | return; |
3581 | } | 3845 | } |
3582 | } | 3846 | m_host.TaskInventory.LockItemsForRead(false); |
3583 | 3847 | ||
3584 | if (linknum < ScriptBaseClass.LINK_THIS) | 3848 | if (linknum < ScriptBaseClass.LINK_THIS) |
3585 | return; | 3849 | return; |
3586 | 3850 | ||
@@ -3619,10 +3883,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3619 | // Restructuring Multiple Prims. | 3883 | // Restructuring Multiple Prims. |
3620 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3884 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3621 | parts.Remove(parentPrim.RootPart); | 3885 | parts.Remove(parentPrim.RootPart); |
3622 | foreach (SceneObjectPart part in parts) | 3886 | if (parts.Count > 0) |
3623 | { | 3887 | { |
3624 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3888 | try |
3889 | { | ||
3890 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3891 | foreach (SceneObjectPart part in parts) | ||
3892 | { | ||
3893 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3894 | } | ||
3895 | } | ||
3896 | finally | ||
3897 | { | ||
3898 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3899 | } | ||
3625 | } | 3900 | } |
3901 | |||
3626 | parentPrim.HasGroupChanged = true; | 3902 | parentPrim.HasGroupChanged = true; |
3627 | parentPrim.ScheduleGroupForFullUpdate(); | 3903 | parentPrim.ScheduleGroupForFullUpdate(); |
3628 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3904 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3631,11 +3907,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3631 | { | 3907 | { |
3632 | SceneObjectPart newRoot = parts[0]; | 3908 | SceneObjectPart newRoot = parts[0]; |
3633 | parts.Remove(newRoot); | 3909 | parts.Remove(newRoot); |
3634 | foreach (SceneObjectPart part in parts) | 3910 | |
3911 | try | ||
3635 | { | 3912 | { |
3636 | part.UpdateFlag = 0; | 3913 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3637 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3914 | foreach (SceneObjectPart part in parts) |
3915 | { | ||
3916 | part.UpdateFlag = 0; | ||
3917 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3918 | } | ||
3638 | } | 3919 | } |
3920 | finally | ||
3921 | { | ||
3922 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3923 | } | ||
3924 | |||
3925 | |||
3639 | newRoot.ParentGroup.HasGroupChanged = true; | 3926 | newRoot.ParentGroup.HasGroupChanged = true; |
3640 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3927 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3641 | } | 3928 | } |
@@ -3661,11 +3948,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3661 | 3948 | ||
3662 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3949 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3663 | parts.Remove(parentPrim.RootPart); | 3950 | parts.Remove(parentPrim.RootPart); |
3664 | 3951 | if (parts.Count > 0) | |
3665 | foreach (SceneObjectPart part in parts) | ||
3666 | { | 3952 | { |
3667 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3953 | try |
3668 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3954 | { |
3955 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3956 | foreach (SceneObjectPart part in parts) | ||
3957 | { | ||
3958 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3959 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | ||
3960 | } | ||
3961 | } | ||
3962 | finally | ||
3963 | { | ||
3964 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3965 | } | ||
3669 | } | 3966 | } |
3670 | parentPrim.HasGroupChanged = true; | 3967 | parentPrim.HasGroupChanged = true; |
3671 | parentPrim.ScheduleGroupForFullUpdate(); | 3968 | parentPrim.ScheduleGroupForFullUpdate(); |
@@ -3757,17 +4054,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3757 | m_host.AddScriptLPS(1); | 4054 | m_host.AddScriptLPS(1); |
3758 | int count = 0; | 4055 | int count = 0; |
3759 | 4056 | ||
3760 | lock (m_host.TaskInventory) | 4057 | m_host.TaskInventory.LockItemsForRead(true); |
4058 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3761 | { | 4059 | { |
3762 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4060 | if (inv.Value.Type == type || type == -1) |
3763 | { | 4061 | { |
3764 | if (inv.Value.Type == type || type == -1) | 4062 | count = count + 1; |
3765 | { | ||
3766 | count = count + 1; | ||
3767 | } | ||
3768 | } | 4063 | } |
3769 | } | 4064 | } |
3770 | 4065 | ||
4066 | m_host.TaskInventory.LockItemsForRead(false); | ||
3771 | return count; | 4067 | return count; |
3772 | } | 4068 | } |
3773 | 4069 | ||
@@ -3776,16 +4072,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3776 | m_host.AddScriptLPS(1); | 4072 | m_host.AddScriptLPS(1); |
3777 | ArrayList keys = new ArrayList(); | 4073 | ArrayList keys = new ArrayList(); |
3778 | 4074 | ||
3779 | lock (m_host.TaskInventory) | 4075 | m_host.TaskInventory.LockItemsForRead(true); |
4076 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3780 | { | 4077 | { |
3781 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4078 | if (inv.Value.Type == type || type == -1) |
3782 | { | 4079 | { |
3783 | if (inv.Value.Type == type || type == -1) | 4080 | keys.Add(inv.Value.Name); |
3784 | { | ||
3785 | keys.Add(inv.Value.Name); | ||
3786 | } | ||
3787 | } | 4081 | } |
3788 | } | 4082 | } |
4083 | m_host.TaskInventory.LockItemsForRead(false); | ||
3789 | 4084 | ||
3790 | if (keys.Count == 0) | 4085 | if (keys.Count == 0) |
3791 | { | 4086 | { |
@@ -3822,20 +4117,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3822 | } | 4117 | } |
3823 | 4118 | ||
3824 | // move the first object found with this inventory name | 4119 | // move the first object found with this inventory name |
3825 | lock (m_host.TaskInventory) | 4120 | m_host.TaskInventory.LockItemsForRead(true); |
4121 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3826 | { | 4122 | { |
3827 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4123 | if (inv.Value.Name == inventory) |
3828 | { | 4124 | { |
3829 | if (inv.Value.Name == inventory) | 4125 | found = true; |
3830 | { | 4126 | objId = inv.Key; |
3831 | found = true; | 4127 | assetType = inv.Value.Type; |
3832 | objId = inv.Key; | 4128 | objName = inv.Value.Name; |
3833 | assetType = inv.Value.Type; | 4129 | break; |
3834 | objName = inv.Value.Name; | ||
3835 | break; | ||
3836 | } | ||
3837 | } | 4130 | } |
3838 | } | 4131 | } |
4132 | m_host.TaskInventory.LockItemsForRead(false); | ||
3839 | 4133 | ||
3840 | if (!found) | 4134 | if (!found) |
3841 | { | 4135 | { |
@@ -3843,9 +4137,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3843 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4137 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3844 | } | 4138 | } |
3845 | 4139 | ||
3846 | // check if destination is an avatar | 4140 | // check if destination is an object |
3847 | if (World.GetScenePresence(destId) != null) | 4141 | if (World.GetSceneObjectPart(destId) != null) |
4142 | { | ||
4143 | // destination is an object | ||
4144 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4145 | } | ||
4146 | else | ||
3848 | { | 4147 | { |
4148 | ScenePresence presence = World.GetScenePresence(destId); | ||
4149 | |||
4150 | if (presence == null) | ||
4151 | { | ||
4152 | UserAccount account = | ||
4153 | World.UserAccountService.GetUserAccount( | ||
4154 | World.RegionInfo.ScopeID, | ||
4155 | destId); | ||
4156 | |||
4157 | if (account == null) | ||
4158 | { | ||
4159 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4160 | return; | ||
4161 | } | ||
4162 | } | ||
4163 | |||
3849 | // destination is an avatar | 4164 | // destination is an avatar |
3850 | InventoryItemBase agentItem = | 4165 | InventoryItemBase agentItem = |
3851 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4166 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
@@ -3871,33 +4186,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3871 | 4186 | ||
3872 | if (m_TransferModule != null) | 4187 | if (m_TransferModule != null) |
3873 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4188 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4189 | |||
4190 | //This delay should only occur when giving inventory to avatars. | ||
4191 | ScriptSleep(3000); | ||
3874 | } | 4192 | } |
3875 | else | ||
3876 | { | ||
3877 | // destination is an object | ||
3878 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3879 | } | ||
3880 | ScriptSleep(3000); | ||
3881 | } | 4193 | } |
3882 | 4194 | ||
4195 | [DebuggerNonUserCode] | ||
3883 | public void llRemoveInventory(string name) | 4196 | public void llRemoveInventory(string name) |
3884 | { | 4197 | { |
3885 | m_host.AddScriptLPS(1); | 4198 | m_host.AddScriptLPS(1); |
3886 | 4199 | ||
3887 | lock (m_host.TaskInventory) | 4200 | m_host.TaskInventory.LockItemsForRead(true); |
4201 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3888 | { | 4202 | { |
3889 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4203 | if (item.Name == name) |
3890 | { | 4204 | { |
3891 | if (item.Name == name) | 4205 | if (item.ItemID == m_itemID) |
3892 | { | 4206 | throw new ScriptDeleteException(); |
3893 | if (item.ItemID == m_itemID) | 4207 | else |
3894 | throw new ScriptDeleteException(); | 4208 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3895 | else | 4209 | |
3896 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4210 | m_host.TaskInventory.LockItemsForRead(false); |
3897 | return; | 4211 | return; |
3898 | } | ||
3899 | } | 4212 | } |
3900 | } | 4213 | } |
4214 | m_host.TaskInventory.LockItemsForRead(false); | ||
3901 | } | 4215 | } |
3902 | 4216 | ||
3903 | public void llSetText(string text, LSL_Vector color, double alpha) | 4217 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3933,22 +4247,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3933 | UUID uuid = (UUID)id; | 4247 | UUID uuid = (UUID)id; |
3934 | 4248 | ||
3935 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4249 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
4250 | if (account == null) | ||
4251 | return UUID.Zero.ToString(); | ||
4252 | |||
3936 | 4253 | ||
3937 | PresenceInfo pinfo = null; | 4254 | PresenceInfo pinfo = null; |
3938 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4255 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3939 | if (pinfos != null && pinfos.Length > 0) | 4256 | if (pinfos != null && pinfos.Length > 0) |
3940 | pinfo = pinfos[0]; | 4257 | pinfo = pinfos[0]; |
3941 | 4258 | ||
3942 | if (pinfo == null) | ||
3943 | return UUID.Zero.ToString(); | ||
3944 | |||
3945 | string reply = String.Empty; | 4259 | string reply = String.Empty; |
3946 | 4260 | ||
3947 | switch (data) | 4261 | switch (data) |
3948 | { | 4262 | { |
3949 | case 1: // DATA_ONLINE (0|1) | 4263 | case 1: // DATA_ONLINE (0|1) |
3950 | // TODO: implement fetching of this information | 4264 | if (pinfo != null && pinfo.RegionID != UUID.Zero) |
3951 | if (pinfo != null) | ||
3952 | reply = "1"; | 4265 | reply = "1"; |
3953 | else | 4266 | else |
3954 | reply = "0"; | 4267 | reply = "0"; |
@@ -3988,6 +4301,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3988 | { | 4301 | { |
3989 | m_host.AddScriptLPS(1); | 4302 | m_host.AddScriptLPS(1); |
3990 | 4303 | ||
4304 | //Clone is thread safe | ||
3991 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4305 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3992 | 4306 | ||
3993 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4307 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4041,6 +4355,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4041 | ScenePresence presence = World.GetScenePresence(agentId); | 4355 | ScenePresence presence = World.GetScenePresence(agentId); |
4042 | if (presence != null) | 4356 | if (presence != null) |
4043 | { | 4357 | { |
4358 | // agent must not be a god | ||
4359 | if (presence.GodLevel >= 200) return; | ||
4360 | |||
4044 | // agent must be over the owners land | 4361 | // agent must be over the owners land |
4045 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4362 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4046 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4363 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4101,17 +4418,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4101 | UUID soundId = UUID.Zero; | 4418 | UUID soundId = UUID.Zero; |
4102 | if (!UUID.TryParse(impact_sound, out soundId)) | 4419 | if (!UUID.TryParse(impact_sound, out soundId)) |
4103 | { | 4420 | { |
4104 | lock (m_host.TaskInventory) | 4421 | m_host.TaskInventory.LockItemsForRead(true); |
4422 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4105 | { | 4423 | { |
4106 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4424 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4107 | { | 4425 | { |
4108 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4426 | soundId = item.AssetID; |
4109 | { | 4427 | break; |
4110 | soundId = item.AssetID; | ||
4111 | break; | ||
4112 | } | ||
4113 | } | 4428 | } |
4114 | } | 4429 | } |
4430 | m_host.TaskInventory.LockItemsForRead(false); | ||
4115 | } | 4431 | } |
4116 | m_host.CollisionSound = soundId; | 4432 | m_host.CollisionSound = soundId; |
4117 | m_host.CollisionSoundVolume = (float)impact_volume; | 4433 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4157,6 +4473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4157 | UUID partItemID; | 4473 | UUID partItemID; |
4158 | foreach (SceneObjectPart part in parts) | 4474 | foreach (SceneObjectPart part in parts) |
4159 | { | 4475 | { |
4476 | //Clone is thread safe | ||
4160 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4477 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4161 | 4478 | ||
4162 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4479 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4371,17 +4688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4371 | 4688 | ||
4372 | m_host.AddScriptLPS(1); | 4689 | m_host.AddScriptLPS(1); |
4373 | 4690 | ||
4374 | lock (m_host.TaskInventory) | 4691 | m_host.TaskInventory.LockItemsForRead(true); |
4692 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4375 | { | 4693 | { |
4376 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4694 | if (item.Type == 10 && item.ItemID == m_itemID) |
4377 | { | 4695 | { |
4378 | if (item.Type == 10 && item.ItemID == m_itemID) | 4696 | result = item.Name!=null?item.Name:String.Empty; |
4379 | { | 4697 | break; |
4380 | result = item.Name != null ? item.Name : String.Empty; | ||
4381 | break; | ||
4382 | } | ||
4383 | } | 4698 | } |
4384 | } | 4699 | } |
4700 | m_host.TaskInventory.LockItemsForRead(false); | ||
4385 | 4701 | ||
4386 | return result; | 4702 | return result; |
4387 | } | 4703 | } |
@@ -4534,23 +4850,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4534 | { | 4850 | { |
4535 | m_host.AddScriptLPS(1); | 4851 | m_host.AddScriptLPS(1); |
4536 | 4852 | ||
4537 | lock (m_host.TaskInventory) | 4853 | m_host.TaskInventory.LockItemsForRead(true); |
4854 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4538 | { | 4855 | { |
4539 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4856 | if (inv.Value.Name == name) |
4540 | { | 4857 | { |
4541 | if (inv.Value.Name == name) | 4858 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4542 | { | 4859 | { |
4543 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4860 | m_host.TaskInventory.LockItemsForRead(false); |
4544 | { | 4861 | return inv.Value.AssetID.ToString(); |
4545 | return inv.Value.AssetID.ToString(); | 4862 | } |
4546 | } | 4863 | else |
4547 | else | 4864 | { |
4548 | { | 4865 | m_host.TaskInventory.LockItemsForRead(false); |
4549 | return UUID.Zero.ToString(); | 4866 | return UUID.Zero.ToString(); |
4550 | } | ||
4551 | } | 4867 | } |
4552 | } | 4868 | } |
4553 | } | 4869 | } |
4870 | m_host.TaskInventory.LockItemsForRead(false); | ||
4554 | 4871 | ||
4555 | return UUID.Zero.ToString(); | 4872 | return UUID.Zero.ToString(); |
4556 | } | 4873 | } |
@@ -5486,10 +5803,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5486 | m_host.AddScriptLPS(1); | 5803 | m_host.AddScriptLPS(1); |
5487 | 5804 | ||
5488 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5805 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5489 | 5806 | if (parts.Count > 0) | |
5490 | foreach (var part in parts) | ||
5491 | { | 5807 | { |
5492 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5808 | try |
5809 | { | ||
5810 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5811 | foreach (var part in parts) | ||
5812 | { | ||
5813 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5814 | } | ||
5815 | } | ||
5816 | finally | ||
5817 | { | ||
5818 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5819 | } | ||
5493 | } | 5820 | } |
5494 | } | 5821 | } |
5495 | 5822 | ||
@@ -5545,74 +5872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5545 | 5872 | ||
5546 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | 5873 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) |
5547 | { | 5874 | { |
5548 | m_host.AddScriptLPS(1); | 5875 | return ParseString2List(str, separators, in_spacers, false); |
5549 | LSL_List ret = new LSL_List(); | ||
5550 | LSL_List spacers = new LSL_List(); | ||
5551 | if (in_spacers.Length > 0 && separators.Length > 0) | ||
5552 | { | ||
5553 | for (int i = 0; i < in_spacers.Length; i++) | ||
5554 | { | ||
5555 | object s = in_spacers.Data[i]; | ||
5556 | for (int j = 0; j < separators.Length; j++) | ||
5557 | { | ||
5558 | if (separators.Data[j].ToString() == s.ToString()) | ||
5559 | { | ||
5560 | s = null; | ||
5561 | break; | ||
5562 | } | ||
5563 | } | ||
5564 | if (s != null) | ||
5565 | { | ||
5566 | spacers.Add(s); | ||
5567 | } | ||
5568 | } | ||
5569 | } | ||
5570 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
5571 | separators.Data.CopyTo(delimiters, 0); | ||
5572 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
5573 | bool dfound = false; | ||
5574 | do | ||
5575 | { | ||
5576 | dfound = false; | ||
5577 | int cindex = -1; | ||
5578 | string cdeli = ""; | ||
5579 | for (int i = 0; i < delimiters.Length; i++) | ||
5580 | { | ||
5581 | int index = str.IndexOf(delimiters[i].ToString()); | ||
5582 | bool found = index != -1; | ||
5583 | if (found && String.Empty != delimiters[i].ToString()) | ||
5584 | { | ||
5585 | if ((cindex > index) || (cindex == -1)) | ||
5586 | { | ||
5587 | cindex = index; | ||
5588 | cdeli = delimiters[i].ToString(); | ||
5589 | } | ||
5590 | dfound = dfound || found; | ||
5591 | } | ||
5592 | } | ||
5593 | if (cindex != -1) | ||
5594 | { | ||
5595 | if (cindex > 0) | ||
5596 | { | ||
5597 | ret.Add(new LSL_String(str.Substring(0, cindex))); | ||
5598 | } | ||
5599 | // Cannot use spacers.Contains() because spacers may be either type String or LSLString | ||
5600 | for (int j = 0; j < spacers.Length; j++) | ||
5601 | { | ||
5602 | if (spacers.Data[j].ToString() == cdeli) | ||
5603 | { | ||
5604 | ret.Add(new LSL_String(cdeli)); | ||
5605 | break; | ||
5606 | } | ||
5607 | } | ||
5608 | str = str.Substring(cindex + cdeli.Length); | ||
5609 | } | ||
5610 | } while (dfound); | ||
5611 | if (str != "") | ||
5612 | { | ||
5613 | ret.Add(new LSL_String(str)); | ||
5614 | } | ||
5615 | return ret; | ||
5616 | } | 5876 | } |
5617 | 5877 | ||
5618 | public LSL_Integer llOverMyLand(string id) | 5878 | public LSL_Integer llOverMyLand(string id) |
@@ -6068,6 +6328,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6068 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6328 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6069 | prules.OuterAngle = (float)tempf; | 6329 | prules.OuterAngle = (float)tempf; |
6070 | break; | 6330 | break; |
6331 | |||
6332 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6333 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6334 | prules.InnerAngle = (float)tempf; | ||
6335 | break; | ||
6336 | |||
6337 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6338 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6339 | prules.OuterAngle = (float)tempf; | ||
6340 | break; | ||
6071 | } | 6341 | } |
6072 | 6342 | ||
6073 | } | 6343 | } |
@@ -6106,14 +6376,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6106 | 6376 | ||
6107 | protected UUID GetTaskInventoryItem(string name) | 6377 | protected UUID GetTaskInventoryItem(string name) |
6108 | { | 6378 | { |
6109 | lock (m_host.TaskInventory) | 6379 | m_host.TaskInventory.LockItemsForRead(true); |
6380 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6110 | { | 6381 | { |
6111 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6382 | if (inv.Value.Name == name) |
6112 | { | 6383 | { |
6113 | if (inv.Value.Name == name) | 6384 | m_host.TaskInventory.LockItemsForRead(false); |
6114 | return inv.Key; | 6385 | return inv.Key; |
6115 | } | 6386 | } |
6116 | } | 6387 | } |
6388 | m_host.TaskInventory.LockItemsForRead(false); | ||
6117 | 6389 | ||
6118 | return UUID.Zero; | 6390 | return UUID.Zero; |
6119 | } | 6391 | } |
@@ -6441,22 +6713,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6441 | } | 6713 | } |
6442 | 6714 | ||
6443 | // copy the first script found with this inventory name | 6715 | // copy the first script found with this inventory name |
6444 | lock (m_host.TaskInventory) | 6716 | m_host.TaskInventory.LockItemsForRead(true); |
6717 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6445 | { | 6718 | { |
6446 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6719 | if (inv.Value.Name == name) |
6447 | { | 6720 | { |
6448 | if (inv.Value.Name == name) | 6721 | // make sure the object is a script |
6722 | if (10 == inv.Value.Type) | ||
6449 | { | 6723 | { |
6450 | // make sure the object is a script | 6724 | found = true; |
6451 | if (10 == inv.Value.Type) | 6725 | srcId = inv.Key; |
6452 | { | 6726 | break; |
6453 | found = true; | ||
6454 | srcId = inv.Key; | ||
6455 | break; | ||
6456 | } | ||
6457 | } | 6727 | } |
6458 | } | 6728 | } |
6459 | } | 6729 | } |
6730 | m_host.TaskInventory.LockItemsForRead(false); | ||
6460 | 6731 | ||
6461 | if (!found) | 6732 | if (!found) |
6462 | { | 6733 | { |
@@ -6540,6 +6811,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6540 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6811 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6541 | { | 6812 | { |
6542 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6813 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6814 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6815 | return shapeBlock; | ||
6543 | 6816 | ||
6544 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6817 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6545 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6818 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6615,6 +6888,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6615 | 6888 | ||
6616 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6889 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6617 | { | 6890 | { |
6891 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6892 | return; | ||
6893 | |||
6618 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6894 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6619 | 6895 | ||
6620 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6896 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6664,6 +6940,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6664 | 6940 | ||
6665 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6941 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6666 | { | 6942 | { |
6943 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6944 | return; | ||
6945 | |||
6667 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6946 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6668 | 6947 | ||
6669 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6948 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6706,6 +6985,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6706 | 6985 | ||
6707 | 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) | 6986 | 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) |
6708 | { | 6987 | { |
6988 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6989 | return; | ||
6990 | |||
6709 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6991 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6710 | 6992 | ||
6711 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6993 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6832,6 +7114,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6832 | 7114 | ||
6833 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7115 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6834 | { | 7116 | { |
7117 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7118 | return; | ||
7119 | |||
6835 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7120 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6836 | UUID sculptId; | 7121 | UUID sculptId; |
6837 | 7122 | ||
@@ -6847,13 +7132,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6847 | shapeBlock.PathScaleX = 100; | 7132 | shapeBlock.PathScaleX = 100; |
6848 | shapeBlock.PathScaleY = 150; | 7133 | shapeBlock.PathScaleY = 150; |
6849 | 7134 | ||
6850 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7135 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6851 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7136 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6852 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7137 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6853 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7138 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6854 | { | 7139 | { |
6855 | // default | 7140 | // default |
6856 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7141 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6857 | } | 7142 | } |
6858 | 7143 | ||
6859 | // retain pathcurve | 7144 | // retain pathcurve |
@@ -6872,12 +7157,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6872 | 7157 | ||
6873 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7158 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6874 | { | 7159 | { |
6875 | m_host.AddScriptLPS(1); | 7160 | m_host.AddScriptLPS(1); |
6876 | 7161 | ||
6877 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7162 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6878 | 7163 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | |
6879 | foreach (SceneObjectPart part in parts) | 7164 | if (parts.Count>0) |
6880 | SetPrimParams(part, rules); | 7165 | { |
7166 | try | ||
7167 | { | ||
7168 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7169 | foreach (SceneObjectPart part in parts) | ||
7170 | SetPrimParams(part, rules); | ||
7171 | } | ||
7172 | finally | ||
7173 | { | ||
7174 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7175 | } | ||
7176 | } | ||
7177 | if (avatars.Count > 0) | ||
7178 | { | ||
7179 | foreach (ScenePresence avatar in avatars) | ||
7180 | SetPrimParams(avatar, rules); | ||
7181 | } | ||
6881 | } | 7182 | } |
6882 | 7183 | ||
6883 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7184 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
@@ -6885,8 +7186,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6885 | llSetLinkPrimitiveParams(linknumber, rules); | 7186 | llSetLinkPrimitiveParams(linknumber, rules); |
6886 | } | 7187 | } |
6887 | 7188 | ||
7189 | protected void SetPrimParams(ScenePresence av, LSL_List rules) | ||
7190 | { | ||
7191 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
7192 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
7193 | |||
7194 | int idx = 0; | ||
7195 | |||
7196 | while (idx < rules.Length) | ||
7197 | { | ||
7198 | int code = rules.GetLSLIntegerItem(idx++); | ||
7199 | |||
7200 | int remain = rules.Length - idx; | ||
7201 | |||
7202 | |||
7203 | |||
7204 | switch (code) | ||
7205 | { | ||
7206 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7207 | if (remain < 1) | ||
7208 | return; | ||
7209 | LSL_Vector v; | ||
7210 | v = rules.GetVector3Item(idx++); | ||
7211 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7212 | av.SendFullUpdateToAllClients(); | ||
7213 | |||
7214 | break; | ||
7215 | |||
7216 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7217 | if (remain < 1) | ||
7218 | return; | ||
7219 | LSL_Rotation r; | ||
7220 | r = rules.GetQuaternionItem(idx++); | ||
7221 | av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7222 | av.SendFullUpdateToAllClients(); | ||
7223 | break; | ||
7224 | } | ||
7225 | } | ||
7226 | |||
7227 | } | ||
7228 | |||
6888 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7229 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6889 | { | 7230 | { |
7231 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7232 | return; | ||
7233 | |||
6890 | int idx = 0; | 7234 | int idx = 0; |
6891 | 7235 | ||
6892 | while (idx < rules.Length) | 7236 | while (idx < rules.Length) |
@@ -7718,24 +8062,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7718 | break; | 8062 | break; |
7719 | 8063 | ||
7720 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8064 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7721 | // TODO-------------- | ||
7722 | if (remain < 1) | 8065 | if (remain < 1) |
7723 | return res; | 8066 | return res; |
8067 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7724 | 8068 | ||
7725 | face=(int)rules.GetLSLIntegerItem(idx++); | 8069 | tex = part.Shape.Textures; |
7726 | 8070 | int shiny; | |
7727 | res.Add(new LSL_Integer(0)); | 8071 | if (face == ScriptBaseClass.ALL_SIDES) |
7728 | res.Add(new LSL_Integer(0)); | 8072 | { |
8073 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8074 | { | ||
8075 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8076 | if (shinyness == Shininess.High) | ||
8077 | { | ||
8078 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8079 | } | ||
8080 | else if (shinyness == Shininess.Medium) | ||
8081 | { | ||
8082 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8083 | } | ||
8084 | else if (shinyness == Shininess.Low) | ||
8085 | { | ||
8086 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8087 | } | ||
8088 | else | ||
8089 | { | ||
8090 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8091 | } | ||
8092 | res.Add(new LSL_Integer(shiny)); | ||
8093 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8094 | } | ||
8095 | } | ||
8096 | else | ||
8097 | { | ||
8098 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8099 | if (shinyness == Shininess.High) | ||
8100 | { | ||
8101 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8102 | } | ||
8103 | else if (shinyness == Shininess.Medium) | ||
8104 | { | ||
8105 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8106 | } | ||
8107 | else if (shinyness == Shininess.Low) | ||
8108 | { | ||
8109 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8110 | } | ||
8111 | else | ||
8112 | { | ||
8113 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8114 | } | ||
8115 | res.Add(new LSL_Integer(shiny)); | ||
8116 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8117 | } | ||
7729 | break; | 8118 | break; |
7730 | 8119 | ||
7731 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8120 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7732 | // TODO-------------- | ||
7733 | if (remain < 1) | 8121 | if (remain < 1) |
7734 | return res; | 8122 | return res; |
8123 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7735 | 8124 | ||
7736 | face=(int)rules.GetLSLIntegerItem(idx++); | 8125 | tex = part.Shape.Textures; |
7737 | 8126 | int fullbright; | |
7738 | res.Add(new LSL_Integer(0)); | 8127 | if (face == ScriptBaseClass.ALL_SIDES) |
8128 | { | ||
8129 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8130 | { | ||
8131 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8132 | { | ||
8133 | fullbright = ScriptBaseClass.TRUE; | ||
8134 | } | ||
8135 | else | ||
8136 | { | ||
8137 | fullbright = ScriptBaseClass.FALSE; | ||
8138 | } | ||
8139 | res.Add(new LSL_Integer(fullbright)); | ||
8140 | } | ||
8141 | } | ||
8142 | else | ||
8143 | { | ||
8144 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8145 | { | ||
8146 | fullbright = ScriptBaseClass.TRUE; | ||
8147 | } | ||
8148 | else | ||
8149 | { | ||
8150 | fullbright = ScriptBaseClass.FALSE; | ||
8151 | } | ||
8152 | res.Add(new LSL_Integer(fullbright)); | ||
8153 | } | ||
7739 | break; | 8154 | break; |
7740 | 8155 | ||
7741 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8156 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7756,14 +8171,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7756 | break; | 8171 | break; |
7757 | 8172 | ||
7758 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8173 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7759 | // TODO-------------- | ||
7760 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8174 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7761 | if (remain < 1) | 8175 | if (remain < 1) |
7762 | return res; | 8176 | return res; |
8177 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7763 | 8178 | ||
7764 | face=(int)rules.GetLSLIntegerItem(idx++); | 8179 | tex = part.Shape.Textures; |
7765 | 8180 | if (face == ScriptBaseClass.ALL_SIDES) | |
7766 | res.Add(new LSL_Integer(0)); | 8181 | { |
8182 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8183 | { | ||
8184 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8185 | { | ||
8186 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8187 | } | ||
8188 | else | ||
8189 | { | ||
8190 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8191 | } | ||
8192 | } | ||
8193 | } | ||
8194 | else | ||
8195 | { | ||
8196 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8197 | { | ||
8198 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8199 | } | ||
8200 | else | ||
8201 | { | ||
8202 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8203 | } | ||
8204 | } | ||
7767 | break; | 8205 | break; |
7768 | 8206 | ||
7769 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8207 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7782,13 +8220,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7782 | break; | 8220 | break; |
7783 | 8221 | ||
7784 | case (int)ScriptBaseClass.PRIM_GLOW: | 8222 | case (int)ScriptBaseClass.PRIM_GLOW: |
7785 | // TODO-------------- | ||
7786 | if (remain < 1) | 8223 | if (remain < 1) |
7787 | return res; | 8224 | return res; |
8225 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7788 | 8226 | ||
7789 | face=(int)rules.GetLSLIntegerItem(idx++); | 8227 | tex = part.Shape.Textures; |
7790 | 8228 | float primglow; | |
7791 | res.Add(new LSL_Float(0)); | 8229 | if (face == ScriptBaseClass.ALL_SIDES) |
8230 | { | ||
8231 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8232 | { | ||
8233 | primglow = tex.GetFace((uint)face).Glow; | ||
8234 | res.Add(new LSL_Float(primglow)); | ||
8235 | } | ||
8236 | } | ||
8237 | else | ||
8238 | { | ||
8239 | primglow = tex.GetFace((uint)face).Glow; | ||
8240 | res.Add(new LSL_Float(primglow)); | ||
8241 | } | ||
7792 | break; | 8242 | break; |
7793 | case (int)ScriptBaseClass.PRIM_TEXT: | 8243 | case (int)ScriptBaseClass.PRIM_TEXT: |
7794 | Color4 textColor = part.GetTextColor(); | 8244 | Color4 textColor = part.GetTextColor(); |
@@ -8094,8 +8544,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8094 | // The function returns an ordered list | 8544 | // The function returns an ordered list |
8095 | // representing the tokens found in the supplied | 8545 | // representing the tokens found in the supplied |
8096 | // sources string. If two successive tokenizers | 8546 | // sources string. If two successive tokenizers |
8097 | // are encountered, then a NULL entry is added | 8547 | // are encountered, then a null-string entry is |
8098 | // to the list. | 8548 | // added to the list. |
8099 | // | 8549 | // |
8100 | // It is a precondition that the source and | 8550 | // It is a precondition that the source and |
8101 | // toekizer lisst are non-null. If they are null, | 8551 | // toekizer lisst are non-null. If they are null, |
@@ -8103,7 +8553,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8103 | // while their lengths are being determined. | 8553 | // while their lengths are being determined. |
8104 | // | 8554 | // |
8105 | // A small amount of working memoryis required | 8555 | // A small amount of working memoryis required |
8106 | // of approximately 8*#tokenizers. | 8556 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8107 | // | 8557 | // |
8108 | // There are many ways in which this function | 8558 | // There are many ways in which this function |
8109 | // can be implemented, this implementation is | 8559 | // can be implemented, this implementation is |
@@ -8119,136 +8569,111 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8119 | // and eliminates redundant tokenizers as soon | 8569 | // and eliminates redundant tokenizers as soon |
8120 | // as is possible. | 8570 | // as is possible. |
8121 | // | 8571 | // |
8122 | // The implementation tries to avoid any copying | 8572 | // The implementation tries to minimize temporary |
8123 | // of arrays or other objects. | 8573 | // garbage generation. |
8124 | // </remarks> | 8574 | // </remarks> |
8125 | 8575 | ||
8126 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8576 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8127 | { | 8577 | { |
8128 | int beginning = 0; | 8578 | return ParseString2List(src, separators, spacers, true); |
8129 | int srclen = src.Length; | 8579 | } |
8130 | int seplen = separators.Length; | ||
8131 | object[] separray = separators.Data; | ||
8132 | int spclen = spacers.Length; | ||
8133 | object[] spcarray = spacers.Data; | ||
8134 | int mlen = seplen+spclen; | ||
8135 | |||
8136 | int[] offset = new int[mlen+1]; | ||
8137 | bool[] active = new bool[mlen]; | ||
8138 | 8580 | ||
8139 | int best; | 8581 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8140 | int j; | 8582 | { |
8583 | int srclen = src.Length; | ||
8584 | int seplen = separators.Length; | ||
8585 | object[] separray = separators.Data; | ||
8586 | int spclen = spacers.Length; | ||
8587 | object[] spcarray = spacers.Data; | ||
8588 | int dellen = 0; | ||
8589 | string[] delarray = new string[seplen+spclen]; | ||
8141 | 8590 | ||
8142 | // Initial capacity reduces resize cost | 8591 | int outlen = 0; |
8592 | string[] outarray = new string[srclen*2+1]; | ||
8143 | 8593 | ||
8144 | LSL_List tokens = new LSL_List(); | 8594 | int i, j; |
8595 | string d; | ||
8145 | 8596 | ||
8146 | m_host.AddScriptLPS(1); | 8597 | m_host.AddScriptLPS(1); |
8147 | 8598 | ||
8148 | // All entries are initially valid | 8599 | /* |
8149 | 8600 | * Convert separator and spacer lists to C# strings. | |
8150 | for (int i = 0; i < mlen; i++) | 8601 | * Also filter out null strings so we don't hang. |
8151 | active[i] = true; | 8602 | */ |
8152 | 8603 | for (i = 0; i < seplen; i ++) { | |
8153 | offset[mlen] = srclen; | 8604 | d = separray[i].ToString(); |
8154 | 8605 | if (d.Length > 0) { | |
8155 | while (beginning < srclen) | 8606 | delarray[dellen++] = d; |
8156 | { | 8607 | } |
8157 | 8608 | } | |
8158 | best = mlen; // as bad as it gets | 8609 | seplen = dellen; |
8159 | |||
8160 | // Scan for separators | ||
8161 | 8610 | ||
8162 | for (j = 0; j < seplen; j++) | 8611 | for (i = 0; i < spclen; i ++) { |
8163 | { | 8612 | d = spcarray[i].ToString(); |
8164 | if (active[j]) | 8613 | if (d.Length > 0) { |
8165 | { | 8614 | delarray[dellen++] = d; |
8166 | // scan all of the markers | ||
8167 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | ||
8168 | { | ||
8169 | // not present at all | ||
8170 | active[j] = false; | ||
8171 | } | ||
8172 | else | ||
8173 | { | ||
8174 | // present and correct | ||
8175 | if (offset[j] < offset[best]) | ||
8176 | { | ||
8177 | // closest so far | ||
8178 | best = j; | ||
8179 | if (offset[best] == beginning) | ||
8180 | break; | ||
8181 | } | ||
8182 | } | ||
8183 | } | ||
8184 | } | 8615 | } |
8616 | } | ||
8185 | 8617 | ||
8186 | // Scan for spacers | 8618 | /* |
8619 | * Scan through source string from beginning to end. | ||
8620 | */ | ||
8621 | for (i = 0;;) { | ||
8187 | 8622 | ||
8188 | if (offset[best] != beginning) | 8623 | /* |
8189 | { | 8624 | * Find earliest delimeter in src starting at i (if any). |
8190 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 8625 | */ |
8191 | { | 8626 | int earliestDel = -1; |
8192 | if (active[j]) | 8627 | int earliestSrc = srclen; |
8193 | { | 8628 | string earliestStr = null; |
8194 | // scan all of the markers | 8629 | for (j = 0; j < dellen; j ++) { |
8195 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | 8630 | d = delarray[j]; |
8196 | { | 8631 | if (d != null) { |
8197 | // not present at all | 8632 | int index = src.IndexOf(d, i); |
8198 | active[j] = false; | 8633 | if (index < 0) { |
8199 | } | 8634 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8200 | else | 8635 | } else if (index < earliestSrc) { |
8201 | { | 8636 | earliestSrc = index; // where delimeter starts in source string |
8202 | // present and correct | 8637 | earliestDel = j; // where delimeter is in delarray[] |
8203 | if (offset[j] < offset[best]) | 8638 | earliestStr = d; // the delimeter string from delarray[] |
8204 | { | 8639 | if (index == i) break; // can't do any better than found at beg of string |
8205 | // closest so far | ||
8206 | best = j; | ||
8207 | } | ||
8208 | } | ||
8209 | } | 8640 | } |
8210 | } | 8641 | } |
8211 | } | 8642 | } |
8212 | 8643 | ||
8213 | // This is the normal exit from the scanning loop | 8644 | /* |
8214 | 8645 | * Output source string starting at i through start of earliest delimeter. | |
8215 | if (best == mlen) | 8646 | */ |
8216 | { | 8647 | if (keepNulls || (earliestSrc > i)) { |
8217 | // no markers were found on this pass | 8648 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8218 | // so we're pretty much done | ||
8219 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8220 | break; | ||
8221 | } | 8649 | } |
8222 | 8650 | ||
8223 | // Otherwise we just add the newly delimited token | 8651 | /* |
8224 | // and recalculate where the search should continue. | 8652 | * If no delimeter found at or after i, we're done scanning. |
8225 | 8653 | */ | |
8226 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 8654 | if (earliestDel < 0) break; |
8227 | 8655 | ||
8228 | if (best < seplen) | 8656 | /* |
8229 | { | 8657 | * If delimeter was a spacer, output the spacer. |
8230 | beginning = offset[best] + (separray[best].ToString()).Length; | 8658 | */ |
8659 | if (earliestDel >= seplen) { | ||
8660 | outarray[outlen++] = earliestStr; | ||
8231 | } | 8661 | } |
8232 | else | ||
8233 | { | ||
8234 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8235 | tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); | ||
8236 | } | ||
8237 | } | ||
8238 | |||
8239 | // This an awkward an not very intuitive boundary case. If the | ||
8240 | // last substring is a tokenizer, then there is an implied trailing | ||
8241 | // null list entry. Hopefully the single comparison will not be too | ||
8242 | // arduous. Alternatively the 'break' could be replced with a return | ||
8243 | // but that's shabby programming. | ||
8244 | 8662 | ||
8245 | if (beginning == srclen) | 8663 | /* |
8246 | { | 8664 | * Look at rest of src string following delimeter. |
8247 | if (srclen != 0) | 8665 | */ |
8248 | tokens.Add(new LSL_String("")); | 8666 | i = earliestSrc + earliestStr.Length; |
8249 | } | 8667 | } |
8250 | 8668 | ||
8251 | return tokens; | 8669 | /* |
8670 | * Make up an exact-sized output array suitable for an LSL_List object. | ||
8671 | */ | ||
8672 | object[] outlist = new object[outlen]; | ||
8673 | for (i = 0; i < outlen; i ++) { | ||
8674 | outlist[i] = new LSL_String(outarray[i]); | ||
8675 | } | ||
8676 | return new LSL_List(outlist); | ||
8252 | } | 8677 | } |
8253 | 8678 | ||
8254 | public LSL_Integer llGetObjectPermMask(int mask) | 8679 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -8325,28 +8750,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8325 | { | 8750 | { |
8326 | m_host.AddScriptLPS(1); | 8751 | m_host.AddScriptLPS(1); |
8327 | 8752 | ||
8328 | lock (m_host.TaskInventory) | 8753 | m_host.TaskInventory.LockItemsForRead(true); |
8754 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8329 | { | 8755 | { |
8330 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8756 | if (inv.Value.Name == item) |
8331 | { | 8757 | { |
8332 | if (inv.Value.Name == item) | 8758 | m_host.TaskInventory.LockItemsForRead(false); |
8759 | switch (mask) | ||
8333 | { | 8760 | { |
8334 | switch (mask) | 8761 | case 0: |
8335 | { | 8762 | return (int)inv.Value.BasePermissions; |
8336 | case 0: | 8763 | case 1: |
8337 | return (int)inv.Value.BasePermissions; | 8764 | return (int)inv.Value.CurrentPermissions; |
8338 | case 1: | 8765 | case 2: |
8339 | return (int)inv.Value.CurrentPermissions; | 8766 | return (int)inv.Value.GroupPermissions; |
8340 | case 2: | 8767 | case 3: |
8341 | return (int)inv.Value.GroupPermissions; | 8768 | return (int)inv.Value.EveryonePermissions; |
8342 | case 3: | 8769 | case 4: |
8343 | return (int)inv.Value.EveryonePermissions; | 8770 | return (int)inv.Value.NextPermissions; |
8344 | case 4: | ||
8345 | return (int)inv.Value.NextPermissions; | ||
8346 | } | ||
8347 | } | 8771 | } |
8348 | } | 8772 | } |
8349 | } | 8773 | } |
8774 | m_host.TaskInventory.LockItemsForRead(false); | ||
8350 | 8775 | ||
8351 | return -1; | 8776 | return -1; |
8352 | } | 8777 | } |
@@ -8393,16 +8818,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8393 | { | 8818 | { |
8394 | m_host.AddScriptLPS(1); | 8819 | m_host.AddScriptLPS(1); |
8395 | 8820 | ||
8396 | lock (m_host.TaskInventory) | 8821 | m_host.TaskInventory.LockItemsForRead(true); |
8822 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8397 | { | 8823 | { |
8398 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8824 | if (inv.Value.Name == item) |
8399 | { | 8825 | { |
8400 | if (inv.Value.Name == item) | 8826 | m_host.TaskInventory.LockItemsForRead(false); |
8401 | { | 8827 | return inv.Value.CreatorID.ToString(); |
8402 | return inv.Value.CreatorID.ToString(); | ||
8403 | } | ||
8404 | } | 8828 | } |
8405 | } | 8829 | } |
8830 | m_host.TaskInventory.LockItemsForRead(false); | ||
8406 | 8831 | ||
8407 | llSay(0, "No item name '" + item + "'"); | 8832 | llSay(0, "No item name '" + item + "'"); |
8408 | 8833 | ||
@@ -8662,17 +9087,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8662 | int width = 0; | 9087 | int width = 0; |
8663 | int height = 0; | 9088 | int height = 0; |
8664 | 9089 | ||
8665 | ParcelMediaCommandEnum? commandToSend = null; | 9090 | uint commandToSend = 0; |
8666 | float time = 0.0f; // default is from start | 9091 | float time = 0.0f; // default is from start |
8667 | 9092 | ||
8668 | ScenePresence presence = null; | 9093 | ScenePresence presence = null; |
8669 | 9094 | ||
8670 | for (int i = 0; i < commandList.Data.Length; i++) | 9095 | for (int i = 0; i < commandList.Data.Length; i++) |
8671 | { | 9096 | { |
8672 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9097 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8673 | switch (command) | 9098 | switch (command) |
8674 | { | 9099 | { |
8675 | case ParcelMediaCommandEnum.Agent: | 9100 | case (uint)ParcelMediaCommandEnum.Agent: |
8676 | // we send only to one agent | 9101 | // we send only to one agent |
8677 | if ((i + 1) < commandList.Length) | 9102 | if ((i + 1) < commandList.Length) |
8678 | { | 9103 | { |
@@ -8689,25 +9114,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8689 | } | 9114 | } |
8690 | break; | 9115 | break; |
8691 | 9116 | ||
8692 | case ParcelMediaCommandEnum.Loop: | 9117 | case (uint)ParcelMediaCommandEnum.Loop: |
8693 | loop = 1; | 9118 | loop = 1; |
8694 | commandToSend = command; | 9119 | commandToSend = command; |
8695 | update = true; //need to send the media update packet to set looping | 9120 | update = true; //need to send the media update packet to set looping |
8696 | break; | 9121 | break; |
8697 | 9122 | ||
8698 | case ParcelMediaCommandEnum.Play: | 9123 | case (uint)ParcelMediaCommandEnum.Play: |
8699 | loop = 0; | 9124 | loop = 0; |
8700 | commandToSend = command; | 9125 | commandToSend = command; |
8701 | update = true; //need to send the media update packet to make sure it doesn't loop | 9126 | update = true; //need to send the media update packet to make sure it doesn't loop |
8702 | break; | 9127 | break; |
8703 | 9128 | ||
8704 | case ParcelMediaCommandEnum.Pause: | 9129 | case (uint)ParcelMediaCommandEnum.Pause: |
8705 | case ParcelMediaCommandEnum.Stop: | 9130 | case (uint)ParcelMediaCommandEnum.Stop: |
8706 | case ParcelMediaCommandEnum.Unload: | 9131 | case (uint)ParcelMediaCommandEnum.Unload: |
8707 | commandToSend = command; | 9132 | commandToSend = command; |
8708 | break; | 9133 | break; |
8709 | 9134 | ||
8710 | case ParcelMediaCommandEnum.Url: | 9135 | case (uint)ParcelMediaCommandEnum.Url: |
8711 | if ((i + 1) < commandList.Length) | 9136 | if ((i + 1) < commandList.Length) |
8712 | { | 9137 | { |
8713 | if (commandList.Data[i + 1] is LSL_String) | 9138 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8720,7 +9145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8720 | } | 9145 | } |
8721 | break; | 9146 | break; |
8722 | 9147 | ||
8723 | case ParcelMediaCommandEnum.Texture: | 9148 | case (uint)ParcelMediaCommandEnum.Texture: |
8724 | if ((i + 1) < commandList.Length) | 9149 | if ((i + 1) < commandList.Length) |
8725 | { | 9150 | { |
8726 | if (commandList.Data[i + 1] is LSL_String) | 9151 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8733,7 +9158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8733 | } | 9158 | } |
8734 | break; | 9159 | break; |
8735 | 9160 | ||
8736 | case ParcelMediaCommandEnum.Time: | 9161 | case (uint)ParcelMediaCommandEnum.Time: |
8737 | if ((i + 1) < commandList.Length) | 9162 | if ((i + 1) < commandList.Length) |
8738 | { | 9163 | { |
8739 | if (commandList.Data[i + 1] is LSL_Float) | 9164 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -8745,7 +9170,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8745 | } | 9170 | } |
8746 | break; | 9171 | break; |
8747 | 9172 | ||
8748 | case ParcelMediaCommandEnum.AutoAlign: | 9173 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
8749 | if ((i + 1) < commandList.Length) | 9174 | if ((i + 1) < commandList.Length) |
8750 | { | 9175 | { |
8751 | if (commandList.Data[i + 1] is LSL_Integer) | 9176 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8759,7 +9184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8759 | } | 9184 | } |
8760 | break; | 9185 | break; |
8761 | 9186 | ||
8762 | case ParcelMediaCommandEnum.Type: | 9187 | case (uint)ParcelMediaCommandEnum.Type: |
8763 | if ((i + 1) < commandList.Length) | 9188 | if ((i + 1) < commandList.Length) |
8764 | { | 9189 | { |
8765 | if (commandList.Data[i + 1] is LSL_String) | 9190 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8772,7 +9197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8772 | } | 9197 | } |
8773 | break; | 9198 | break; |
8774 | 9199 | ||
8775 | case ParcelMediaCommandEnum.Desc: | 9200 | case (uint)ParcelMediaCommandEnum.Desc: |
8776 | if ((i + 1) < commandList.Length) | 9201 | if ((i + 1) < commandList.Length) |
8777 | { | 9202 | { |
8778 | if (commandList.Data[i + 1] is LSL_String) | 9203 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8785,7 +9210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8785 | } | 9210 | } |
8786 | break; | 9211 | break; |
8787 | 9212 | ||
8788 | case ParcelMediaCommandEnum.Size: | 9213 | case (uint)ParcelMediaCommandEnum.Size: |
8789 | if ((i + 2) < commandList.Length) | 9214 | if ((i + 2) < commandList.Length) |
8790 | { | 9215 | { |
8791 | if (commandList.Data[i + 1] is LSL_Integer) | 9216 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8855,7 +9280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8855 | } | 9280 | } |
8856 | } | 9281 | } |
8857 | 9282 | ||
8858 | if (commandToSend != null) | 9283 | if (commandToSend != 0) |
8859 | { | 9284 | { |
8860 | // the commandList contained a start/stop/... command, too | 9285 | // the commandList contained a start/stop/... command, too |
8861 | if (presence == null) | 9286 | if (presence == null) |
@@ -8892,7 +9317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8892 | 9317 | ||
8893 | if (aList.Data[i] != null) | 9318 | if (aList.Data[i] != null) |
8894 | { | 9319 | { |
8895 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 9320 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
8896 | { | 9321 | { |
8897 | case ParcelMediaCommandEnum.Url: | 9322 | case ParcelMediaCommandEnum.Url: |
8898 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 9323 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -8935,16 +9360,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8935 | { | 9360 | { |
8936 | m_host.AddScriptLPS(1); | 9361 | m_host.AddScriptLPS(1); |
8937 | 9362 | ||
8938 | lock (m_host.TaskInventory) | 9363 | m_host.TaskInventory.LockItemsForRead(true); |
9364 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8939 | { | 9365 | { |
8940 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9366 | if (inv.Value.Name == name) |
8941 | { | 9367 | { |
8942 | if (inv.Value.Name == name) | 9368 | m_host.TaskInventory.LockItemsForRead(false); |
8943 | { | 9369 | return inv.Value.Type; |
8944 | return inv.Value.Type; | ||
8945 | } | ||
8946 | } | 9370 | } |
8947 | } | 9371 | } |
9372 | m_host.TaskInventory.LockItemsForRead(false); | ||
8948 | 9373 | ||
8949 | return -1; | 9374 | return -1; |
8950 | } | 9375 | } |
@@ -8955,15 +9380,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8955 | 9380 | ||
8956 | if (quick_pay_buttons.Data.Length < 4) | 9381 | if (quick_pay_buttons.Data.Length < 4) |
8957 | { | 9382 | { |
8958 | LSLError("List must have at least 4 elements"); | 9383 | int x; |
8959 | return; | 9384 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9385 | { | ||
9386 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9387 | } | ||
8960 | } | 9388 | } |
8961 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9389 | int[] nPrice = new int[5]; |
8962 | 9390 | nPrice[0]=price; | |
8963 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9391 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8964 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9392 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8965 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9393 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8966 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9394 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9395 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8967 | m_host.ParentGroup.HasGroupChanged = true; | 9396 | m_host.ParentGroup.HasGroupChanged = true; |
8968 | } | 9397 | } |
8969 | 9398 | ||
@@ -8975,17 +9404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8975 | if (invItemID == UUID.Zero) | 9404 | if (invItemID == UUID.Zero) |
8976 | return new LSL_Vector(); | 9405 | return new LSL_Vector(); |
8977 | 9406 | ||
8978 | lock (m_host.TaskInventory) | 9407 | m_host.TaskInventory.LockItemsForRead(true); |
9408 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8979 | { | 9409 | { |
8980 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9410 | m_host.TaskInventory.LockItemsForRead(false); |
8981 | return new LSL_Vector(); | 9411 | return new LSL_Vector(); |
9412 | } | ||
8982 | 9413 | ||
8983 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9414 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8984 | { | 9415 | { |
8985 | ShoutError("No permissions to track the camera"); | 9416 | ShoutError("No permissions to track the camera"); |
8986 | return new LSL_Vector(); | 9417 | m_host.TaskInventory.LockItemsForRead(false); |
8987 | } | 9418 | return new LSL_Vector(); |
8988 | } | 9419 | } |
9420 | m_host.TaskInventory.LockItemsForRead(false); | ||
8989 | 9421 | ||
8990 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9422 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8991 | if (presence != null) | 9423 | if (presence != null) |
@@ -9003,17 +9435,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9003 | if (invItemID == UUID.Zero) | 9435 | if (invItemID == UUID.Zero) |
9004 | return new LSL_Rotation(); | 9436 | return new LSL_Rotation(); |
9005 | 9437 | ||
9006 | lock (m_host.TaskInventory) | 9438 | m_host.TaskInventory.LockItemsForRead(true); |
9439 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9007 | { | 9440 | { |
9008 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9441 | m_host.TaskInventory.LockItemsForRead(false); |
9009 | return new LSL_Rotation(); | 9442 | return new LSL_Rotation(); |
9010 | 9443 | } | |
9011 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9444 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9012 | { | 9445 | { |
9013 | ShoutError("No permissions to track the camera"); | 9446 | ShoutError("No permissions to track the camera"); |
9014 | return new LSL_Rotation(); | 9447 | m_host.TaskInventory.LockItemsForRead(false); |
9015 | } | 9448 | return new LSL_Rotation(); |
9016 | } | 9449 | } |
9450 | m_host.TaskInventory.LockItemsForRead(false); | ||
9017 | 9451 | ||
9018 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9452 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9019 | if (presence != null) | 9453 | if (presence != null) |
@@ -9075,8 +9509,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9075 | { | 9509 | { |
9076 | m_host.AddScriptLPS(1); | 9510 | m_host.AddScriptLPS(1); |
9077 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9511 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9078 | if (detectedParams == null) return; // only works on the first detected avatar | 9512 | if (detectedParams == null) |
9079 | 9513 | { | |
9514 | if (m_host.IsAttachment == true) | ||
9515 | { | ||
9516 | detectedParams = new DetectParams(); | ||
9517 | detectedParams.Key = m_host.OwnerID; | ||
9518 | } | ||
9519 | else | ||
9520 | { | ||
9521 | return; | ||
9522 | } | ||
9523 | } | ||
9524 | |||
9080 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9525 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9081 | if (avatar != null) | 9526 | if (avatar != null) |
9082 | { | 9527 | { |
@@ -9084,6 +9529,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9084 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9529 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9085 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9530 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9086 | } | 9531 | } |
9532 | |||
9087 | ScriptSleep(1000); | 9533 | ScriptSleep(1000); |
9088 | } | 9534 | } |
9089 | 9535 | ||
@@ -9163,14 +9609,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9163 | if (objectID == UUID.Zero) return; | 9609 | if (objectID == UUID.Zero) return; |
9164 | 9610 | ||
9165 | UUID agentID; | 9611 | UUID agentID; |
9166 | lock (m_host.TaskInventory) | 9612 | m_host.TaskInventory.LockItemsForRead(true); |
9167 | { | 9613 | // we need the permission first, to know which avatar we want to set the camera for |
9168 | // we need the permission first, to know which avatar we want to set the camera for | 9614 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9169 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9170 | 9615 | ||
9171 | if (agentID == UUID.Zero) return; | 9616 | if (agentID == UUID.Zero) |
9172 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9617 | { |
9618 | m_host.TaskInventory.LockItemsForRead(false); | ||
9619 | return; | ||
9620 | } | ||
9621 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9622 | { | ||
9623 | m_host.TaskInventory.LockItemsForRead(false); | ||
9624 | return; | ||
9173 | } | 9625 | } |
9626 | m_host.TaskInventory.LockItemsForRead(false); | ||
9174 | 9627 | ||
9175 | ScenePresence presence = World.GetScenePresence(agentID); | 9628 | ScenePresence presence = World.GetScenePresence(agentID); |
9176 | 9629 | ||
@@ -9220,12 +9673,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9220 | 9673 | ||
9221 | // we need the permission first, to know which avatar we want to clear the camera for | 9674 | // we need the permission first, to know which avatar we want to clear the camera for |
9222 | UUID agentID; | 9675 | UUID agentID; |
9223 | lock (m_host.TaskInventory) | 9676 | m_host.TaskInventory.LockItemsForRead(true); |
9677 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9678 | if (agentID == UUID.Zero) | ||
9679 | { | ||
9680 | m_host.TaskInventory.LockItemsForRead(false); | ||
9681 | return; | ||
9682 | } | ||
9683 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9224 | { | 9684 | { |
9225 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9685 | m_host.TaskInventory.LockItemsForRead(false); |
9226 | if (agentID == UUID.Zero) return; | 9686 | return; |
9227 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9228 | } | 9687 | } |
9688 | m_host.TaskInventory.LockItemsForRead(false); | ||
9229 | 9689 | ||
9230 | ScenePresence presence = World.GetScenePresence(agentID); | 9690 | ScenePresence presence = World.GetScenePresence(agentID); |
9231 | 9691 | ||
@@ -9292,19 +9752,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9292 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 9752 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
9293 | { | 9753 | { |
9294 | m_host.AddScriptLPS(1); | 9754 | m_host.AddScriptLPS(1); |
9295 | string ret = String.Empty; | 9755 | |
9296 | string src1 = llBase64ToString(str1); | 9756 | if (str1 == String.Empty) |
9297 | string src2 = llBase64ToString(str2); | 9757 | return String.Empty; |
9298 | int c = 0; | 9758 | if (str2 == String.Empty) |
9299 | for (int i = 0; i < src1.Length; i++) | 9759 | return str1; |
9760 | |||
9761 | byte[] data1 = Convert.FromBase64String(str1); | ||
9762 | byte[] data2 = Convert.FromBase64String(str2); | ||
9763 | |||
9764 | byte[] d2 = new Byte[data1.Length]; | ||
9765 | int pos = 0; | ||
9766 | |||
9767 | if (data1.Length <= data2.Length) | ||
9300 | { | 9768 | { |
9301 | ret += (char) (src1[i] ^ src2[c]); | 9769 | Array.Copy(data2, 0, d2, 0, data1.Length); |
9770 | } | ||
9771 | else | ||
9772 | { | ||
9773 | while (pos < data1.Length) | ||
9774 | { | ||
9775 | int len = data1.Length - pos; | ||
9776 | if (len > data2.Length) | ||
9777 | len = data2.Length; | ||
9302 | 9778 | ||
9303 | c++; | 9779 | Array.Copy(data2, 0, d2, pos, len); |
9304 | if (c >= src2.Length) | 9780 | pos += len; |
9305 | c = 0; | 9781 | } |
9306 | } | 9782 | } |
9307 | return llStringToBase64(ret); | 9783 | |
9784 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
9785 | data1[pos] ^= d2[pos]; | ||
9786 | |||
9787 | return Convert.ToBase64String(data1); | ||
9308 | } | 9788 | } |
9309 | 9789 | ||
9310 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 9790 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -9682,15 +10162,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9682 | 10162 | ||
9683 | internal UUID ScriptByName(string name) | 10163 | internal UUID ScriptByName(string name) |
9684 | { | 10164 | { |
9685 | lock (m_host.TaskInventory) | 10165 | m_host.TaskInventory.LockItemsForRead(true); |
10166 | |||
10167 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9686 | { | 10168 | { |
9687 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10169 | if (item.Type == 10 && item.Name == name) |
9688 | { | 10170 | { |
9689 | if (item.Type == 10 && item.Name == name) | 10171 | m_host.TaskInventory.LockItemsForRead(false); |
9690 | return item.ItemID; | 10172 | return item.ItemID; |
9691 | } | 10173 | } |
9692 | } | 10174 | } |
9693 | 10175 | ||
10176 | m_host.TaskInventory.LockItemsForRead(false); | ||
10177 | |||
9694 | return UUID.Zero; | 10178 | return UUID.Zero; |
9695 | } | 10179 | } |
9696 | 10180 | ||
@@ -9731,6 +10215,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9731 | { | 10215 | { |
9732 | m_host.AddScriptLPS(1); | 10216 | m_host.AddScriptLPS(1); |
9733 | 10217 | ||
10218 | //Clone is thread safe | ||
9734 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10219 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9735 | 10220 | ||
9736 | UUID assetID = UUID.Zero; | 10221 | UUID assetID = UUID.Zero; |
@@ -9793,6 +10278,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9793 | { | 10278 | { |
9794 | m_host.AddScriptLPS(1); | 10279 | m_host.AddScriptLPS(1); |
9795 | 10280 | ||
10281 | //Clone is thread safe | ||
9796 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10282 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9797 | 10283 | ||
9798 | UUID assetID = UUID.Zero; | 10284 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index fe71ed5..1fa8c30 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -73,6 +73,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
73 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) | 73 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) |
74 | m_LSFunctionsEnabled = true; | 74 | m_LSFunctionsEnabled = true; |
75 | 75 | ||
76 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
77 | m_LSFunctionsEnabled = true; | ||
78 | |||
76 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | 79 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); |
77 | if (m_comms == null) | 80 | if (m_comms == null) |
78 | m_LSFunctionsEnabled = false; | 81 | m_LSFunctionsEnabled = false; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 01b64eb..db43902 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -769,18 +769,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
769 | if (target != null) | 769 | if (target != null) |
770 | { | 770 | { |
771 | UUID animID=UUID.Zero; | 771 | UUID animID=UUID.Zero; |
772 | lock (m_host.TaskInventory) | 772 | m_host.TaskInventory.LockItemsForRead(true); |
773 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
773 | { | 774 | { |
774 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 775 | if (inv.Value.Name == animation) |
775 | { | 776 | { |
776 | if (inv.Value.Name == animation) | 777 | if (inv.Value.Type == (int)AssetType.Animation) |
777 | { | 778 | animID = inv.Value.AssetID; |
778 | if (inv.Value.Type == (int)AssetType.Animation) | 779 | continue; |
779 | animID = inv.Value.AssetID; | ||
780 | continue; | ||
781 | } | ||
782 | } | 780 | } |
783 | } | 781 | } |
782 | m_host.TaskInventory.LockItemsForRead(false); | ||
784 | if (animID == UUID.Zero) | 783 | if (animID == UUID.Zero) |
785 | target.Animator.AddAnimation(animation, m_host.UUID); | 784 | target.Animator.AddAnimation(animation, m_host.UUID); |
786 | else | 785 | else |
@@ -802,18 +801,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
802 | if (target != null) | 801 | if (target != null) |
803 | { | 802 | { |
804 | UUID animID=UUID.Zero; | 803 | UUID animID=UUID.Zero; |
805 | lock (m_host.TaskInventory) | 804 | m_host.TaskInventory.LockItemsForRead(true); |
805 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
806 | { | 806 | { |
807 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 807 | if (inv.Value.Name == animation) |
808 | { | 808 | { |
809 | if (inv.Value.Name == animation) | 809 | if (inv.Value.Type == (int)AssetType.Animation) |
810 | { | 810 | animID = inv.Value.AssetID; |
811 | if (inv.Value.Type == (int)AssetType.Animation) | 811 | continue; |
812 | animID = inv.Value.AssetID; | ||
813 | continue; | ||
814 | } | ||
815 | } | 812 | } |
816 | } | 813 | } |
814 | m_host.TaskInventory.LockItemsForRead(false); | ||
817 | 815 | ||
818 | if (animID == UUID.Zero) | 816 | if (animID == UUID.Zero) |
819 | target.Animator.RemoveAnimation(animation); | 817 | target.Animator.RemoveAnimation(animation); |
@@ -1664,6 +1662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1664 | 1662 | ||
1665 | if (!UUID.TryParse(name, out assetID)) | 1663 | if (!UUID.TryParse(name, out assetID)) |
1666 | { | 1664 | { |
1665 | m_host.TaskInventory.LockItemsForRead(true); | ||
1667 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1666 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1668 | { | 1667 | { |
1669 | if (item.Type == 7 && item.Name == name) | 1668 | if (item.Type == 7 && item.Name == name) |
@@ -1671,6 +1670,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1671 | assetID = item.AssetID; | 1670 | assetID = item.AssetID; |
1672 | } | 1671 | } |
1673 | } | 1672 | } |
1673 | m_host.TaskInventory.LockItemsForRead(false); | ||
1674 | } | 1674 | } |
1675 | 1675 | ||
1676 | if (assetID == UUID.Zero) | 1676 | if (assetID == UUID.Zero) |
@@ -1717,6 +1717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1717 | 1717 | ||
1718 | if (!UUID.TryParse(name, out assetID)) | 1718 | if (!UUID.TryParse(name, out assetID)) |
1719 | { | 1719 | { |
1720 | m_host.TaskInventory.LockItemsForRead(true); | ||
1720 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1721 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1721 | { | 1722 | { |
1722 | if (item.Type == 7 && item.Name == name) | 1723 | if (item.Type == 7 && item.Name == name) |
@@ -1724,6 +1725,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1724 | assetID = item.AssetID; | 1725 | assetID = item.AssetID; |
1725 | } | 1726 | } |
1726 | } | 1727 | } |
1728 | m_host.TaskInventory.LockItemsForRead(false); | ||
1727 | } | 1729 | } |
1728 | 1730 | ||
1729 | if (assetID == UUID.Zero) | 1731 | if (assetID == UUID.Zero) |
@@ -1774,6 +1776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1774 | 1776 | ||
1775 | if (!UUID.TryParse(name, out assetID)) | 1777 | if (!UUID.TryParse(name, out assetID)) |
1776 | { | 1778 | { |
1779 | m_host.TaskInventory.LockItemsForRead(true); | ||
1777 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1780 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1778 | { | 1781 | { |
1779 | if (item.Type == 7 && item.Name == name) | 1782 | if (item.Type == 7 && item.Name == name) |
@@ -1781,6 +1784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1781 | assetID = item.AssetID; | 1784 | assetID = item.AssetID; |
1782 | } | 1785 | } |
1783 | } | 1786 | } |
1787 | m_host.TaskInventory.LockItemsForRead(false); | ||
1784 | } | 1788 | } |
1785 | 1789 | ||
1786 | if (assetID == UUID.Zero) | 1790 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 5c2abd5..a5b1124 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
204 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 204 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) | 205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) |
206 | { | 206 | { |
207 | sensedEntities.AddRange(doAgentSensor(ts)); | 207 | sensedEntities.AddRange(doAgentSensor(ts)); |
208 | } | 208 | } |
209 | 209 | ||
210 | // If SCRIPTED or PASSIVE or ACTIVE check objects | 210 | // If SCRIPTED or PASSIVE or ACTIVE check objects |
@@ -309,6 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
309 | // in mouselook. | 309 | // in mouselook. |
310 | 310 | ||
311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); |
312 | fromRegionPos = avatar.AbsolutePosition; | ||
312 | q = avatar.Rotation; | 313 | q = avatar.Rotation; |
313 | } | 314 | } |
314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 315 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -422,6 +423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
422 | SceneObjectPart SensePoint = ts.host; | 423 | SceneObjectPart SensePoint = ts.host; |
423 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 424 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
424 | Quaternion q = SensePoint.RotationOffset; | 425 | Quaternion q = SensePoint.RotationOffset; |
426 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | ||
427 | { | ||
428 | // In attachments, the sensor cone always orients with the | ||
429 | // avatar rotation. This may include a nonzero elevation if | ||
430 | // in mouselook. | ||
431 | |||
432 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | ||
433 | fromRegionPos = avatar.AbsolutePosition; | ||
434 | q = avatar.Rotation; | ||
435 | } | ||
425 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 436 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
426 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 437 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
427 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 438 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 78ee43c..c8f3623 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
81 | // Avatar Info Commands | 81 | // Avatar Info Commands |
82 | string osGetAgentIP(string agent); | 82 | string osGetAgentIP(string agent); |
83 | LSL_List osGetAgents(); | 83 | LSL_List osGetAgents(); |
84 | 84 | ||
85 | // Teleport commands | 85 | // Teleport commands |
86 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
87 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 87 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 9615315..943d7a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index dba6502..96f6486 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -274,6 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
274 | public const int CHANGED_ALLOWED_DROP = 64; | 274 | public const int CHANGED_ALLOWED_DROP = 64; |
275 | public const int CHANGED_OWNER = 128; | 275 | public const int CHANGED_OWNER = 128; |
276 | public const int CHANGED_REGION_RESTART = 256; | 276 | public const int CHANGED_REGION_RESTART = 256; |
277 | public const int CHANGED_REGION_START = 256; //LL Changed the constant from CHANGED_REGION_RESTART | ||
277 | public const int CHANGED_REGION = 512; | 278 | public const int CHANGED_REGION = 512; |
278 | public const int CHANGED_TELEPORT = 1024; | 279 | public const int CHANGED_TELEPORT = 1024; |
279 | public const int CHANGED_ANIMATION = 16384; | 280 | public const int CHANGED_ANIMATION = 16384; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 3339995..e86d08c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
309 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 310 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
310 | } | 311 | } |
311 | 312 | ||
313 | [DebuggerNonUserCode] | ||
312 | public void llDie() | 314 | public void llDie() |
313 | { | 315 | { |
314 | m_LSL_Functions.llDie(); | 316 | m_LSL_Functions.llDie(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs index f8dbe03..8280ca5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs | |||
@@ -72,5 +72,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
72 | { | 72 | { |
73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | 73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); |
74 | } | 74 | } |
75 | |||
76 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
77 | { | ||
78 | return m_LS_Functions.lsGetWindlightScene(rules); | ||
79 | } | ||
80 | |||
81 | public int cmSetWindlightScene(LSL_List rules) | ||
82 | { | ||
83 | return m_LS_Functions.lsSetWindlightScene(rules); | ||
84 | } | ||
85 | |||
86 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
87 | { | ||
88 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | ||
89 | } | ||
75 | } | 90 | } |
76 | } | 91 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |