diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
14 files changed, 1759 insertions, 1202 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index ee32755..61e4934 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -248,6 +248,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
248 | 248 | ||
249 | } | 249 | } |
250 | 250 | ||
251 | public static void StateChange(IScriptEngine engine, uint localID, UUID itemID) | ||
252 | { | ||
253 | // Remove a specific script | ||
254 | |||
255 | // Remove dataserver events | ||
256 | m_Dataserver[engine].RemoveEvents(localID, itemID); | ||
257 | |||
258 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | ||
259 | if (comms != null) | ||
260 | comms.DeleteListener(itemID); | ||
261 | |||
262 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | ||
263 | xmlrpc.DeleteChannels(itemID); | ||
264 | xmlrpc.CancelSRDRequests(itemID); | ||
265 | |||
266 | // Remove Sensors | ||
267 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | ||
268 | |||
269 | } | ||
270 | |||
251 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) | 271 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) |
252 | { | 272 | { |
253 | List<Object> data = new List<Object>(); | 273 | List<Object> data = new List<Object>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d38fe9f..97dd2e1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -81,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
81 | /// </summary> | 82 | /// </summary> |
82 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi | 83 | public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi |
83 | { | 84 | { |
84 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 85 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
85 | protected IScriptEngine m_ScriptEngine; | 86 | protected IScriptEngine m_ScriptEngine; |
86 | protected SceneObjectPart m_host; | 87 | protected SceneObjectPart m_host; |
87 | protected uint m_localID; | 88 | protected uint m_localID; |
@@ -99,6 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
99 | protected int m_notecardLineReadCharsMax = 255; | 100 | protected int m_notecardLineReadCharsMax = 255; |
100 | protected int m_scriptConsoleChannel = 0; | 101 | protected int m_scriptConsoleChannel = 0; |
101 | protected bool m_scriptConsoleChannelEnabled = false; | 102 | protected bool m_scriptConsoleChannelEnabled = false; |
103 | protected bool m_debuggerSafe = false; | ||
102 | protected IUrlModule m_UrlModule = null; | 104 | protected IUrlModule m_UrlModule = null; |
103 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 105 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
104 | new Dictionary<UUID, UserInfoCacheEntry>(); | 106 | new Dictionary<UUID, UserInfoCacheEntry>(); |
@@ -109,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
109 | m_host = host; | 111 | m_host = host; |
110 | m_localID = localID; | 112 | m_localID = localID; |
111 | m_itemID = itemID; | 113 | m_itemID = itemID; |
114 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
112 | 115 | ||
113 | m_ScriptDelayFactor = | 116 | m_ScriptDelayFactor = |
114 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 117 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
@@ -161,6 +164,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
161 | get { return m_ScriptEngine.World; } | 164 | get { return m_ScriptEngine.World; } |
162 | } | 165 | } |
163 | 166 | ||
167 | [DebuggerNonUserCode] | ||
164 | public void state(string newState) | 168 | public void state(string newState) |
165 | { | 169 | { |
166 | m_ScriptEngine.SetState(m_itemID, newState); | 170 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -170,6 +174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
170 | /// Reset the named script. The script must be present | 174 | /// Reset the named script. The script must be present |
171 | /// in the same prim. | 175 | /// in the same prim. |
172 | /// </summary> | 176 | /// </summary> |
177 | [DebuggerNonUserCode] | ||
173 | public void llResetScript() | 178 | public void llResetScript() |
174 | { | 179 | { |
175 | m_host.AddScriptLPS(1); | 180 | m_host.AddScriptLPS(1); |
@@ -226,9 +231,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
226 | } | 231 | } |
227 | } | 232 | } |
228 | 233 | ||
234 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
235 | { | ||
236 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
237 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
238 | return ret; | ||
239 | |||
240 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
241 | |||
242 | switch (linkType) | ||
243 | { | ||
244 | case ScriptBaseClass.LINK_SET: | ||
245 | return avs; | ||
246 | |||
247 | case ScriptBaseClass.LINK_ROOT: | ||
248 | return ret; | ||
249 | |||
250 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
251 | return avs; | ||
252 | |||
253 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
254 | return avs; | ||
255 | |||
256 | case ScriptBaseClass.LINK_THIS: | ||
257 | return ret; | ||
258 | |||
259 | default: | ||
260 | if (linkType < 0) | ||
261 | return ret; | ||
262 | |||
263 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
264 | |||
265 | if (linkType <= partCount) | ||
266 | { | ||
267 | return ret; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | linkType = linkType - partCount; | ||
272 | if (linkType > avs.Count) | ||
273 | { | ||
274 | return ret; | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | ret.Add(avs[linkType-1]); | ||
279 | return ret; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | |||
229 | public List<SceneObjectPart> GetLinkParts(int linkType) | 285 | public List<SceneObjectPart> GetLinkParts(int linkType) |
230 | { | 286 | { |
231 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 287 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
288 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
289 | return ret; | ||
232 | ret.Add(m_host); | 290 | ret.Add(m_host); |
233 | 291 | ||
234 | switch (linkType) | 292 | switch (linkType) |
@@ -282,40 +340,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
282 | protected UUID InventorySelf() | 340 | protected UUID InventorySelf() |
283 | { | 341 | { |
284 | UUID invItemID = new UUID(); | 342 | UUID invItemID = new UUID(); |
285 | 343 | bool unlock = false; | |
286 | lock (m_host.TaskInventory) | 344 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
345 | { | ||
346 | m_host.TaskInventory.LockItemsForRead(true); | ||
347 | unlock = true; | ||
348 | } | ||
349 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
287 | { | 350 | { |
288 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 351 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
289 | { | 352 | { |
290 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 353 | invItemID = inv.Key; |
291 | { | 354 | break; |
292 | invItemID = inv.Key; | ||
293 | break; | ||
294 | } | ||
295 | } | 355 | } |
296 | } | 356 | } |
297 | 357 | if (unlock) | |
358 | { | ||
359 | m_host.TaskInventory.LockItemsForRead(false); | ||
360 | } | ||
298 | return invItemID; | 361 | return invItemID; |
299 | } | 362 | } |
300 | 363 | ||
301 | protected UUID InventoryKey(string name, int type) | 364 | protected UUID InventoryKey(string name, int type) |
302 | { | 365 | { |
303 | m_host.AddScriptLPS(1); | 366 | m_host.AddScriptLPS(1); |
304 | 367 | m_host.TaskInventory.LockItemsForRead(true); | |
305 | lock (m_host.TaskInventory) | 368 | |
369 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
306 | { | 370 | { |
307 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 371 | if (inv.Value.Name == name) |
308 | { | 372 | { |
309 | if (inv.Value.Name == name) | 373 | m_host.TaskInventory.LockItemsForRead(false); |
374 | |||
375 | if (inv.Value.Type != type) | ||
310 | { | 376 | { |
311 | if (inv.Value.Type != type) | 377 | return UUID.Zero; |
312 | return UUID.Zero; | ||
313 | |||
314 | return inv.Value.AssetID; | ||
315 | } | 378 | } |
379 | |||
380 | return inv.Value.AssetID; | ||
316 | } | 381 | } |
317 | } | 382 | } |
318 | 383 | ||
384 | m_host.TaskInventory.LockItemsForRead(false); | ||
319 | return UUID.Zero; | 385 | return UUID.Zero; |
320 | } | 386 | } |
321 | 387 | ||
@@ -323,17 +389,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
323 | { | 389 | { |
324 | m_host.AddScriptLPS(1); | 390 | m_host.AddScriptLPS(1); |
325 | 391 | ||
326 | lock (m_host.TaskInventory) | 392 | |
393 | m_host.TaskInventory.LockItemsForRead(true); | ||
394 | |||
395 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
327 | { | 396 | { |
328 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 397 | if (inv.Value.Name == name) |
329 | { | 398 | { |
330 | if (inv.Value.Name == name) | 399 | m_host.TaskInventory.LockItemsForRead(false); |
331 | { | 400 | return inv.Value.AssetID; |
332 | return inv.Value.AssetID; | ||
333 | } | ||
334 | } | 401 | } |
335 | } | 402 | } |
336 | 403 | ||
404 | m_host.TaskInventory.LockItemsForRead(false); | ||
405 | |||
406 | |||
337 | return UUID.Zero; | 407 | return UUID.Zero; |
338 | } | 408 | } |
339 | 409 | ||
@@ -475,26 +545,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
475 | 545 | ||
476 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 546 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
477 | 547 | ||
478 | // Old implementation of llRot2Euler. Normalization not required as Atan2 function will | 548 | // Utility function for llRot2Euler |
479 | // only return values >= -PI (-180 degrees) and <= PI (180 degrees). | ||
480 | 549 | ||
481 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 550 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
551 | protected double NormalizeAngle(double angle) | ||
552 | { | ||
553 | if (angle > -Math.PI && angle < Math.PI) | ||
554 | return angle; | ||
555 | |||
556 | int numPis = (int)(Math.PI / angle); | ||
557 | double remainder = angle - Math.PI * numPis; | ||
558 | if (numPis % 2 == 1) | ||
559 | return Math.PI - angle; | ||
560 | return remainder; | ||
561 | } | ||
562 | |||
563 | public LSL_Vector llRot2Euler(LSL_Rotation q1) | ||
482 | { | 564 | { |
483 | m_host.AddScriptLPS(1); | 565 | m_host.AddScriptLPS(1); |
484 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | 566 | LSL_Vector eul = new LSL_Vector(); |
485 | LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | 567 | |
486 | double m = (t.x + t.y + t.z + t.s); | 568 | double sqw = q1.s*q1.s; |
487 | if (m == 0) return new LSL_Vector(); | 569 | double sqx = q1.x*q1.x; |
488 | double n = 2 * (r.y * r.s + r.x * r.z); | 570 | double sqy = q1.z*q1.z; |
489 | double p = m * m - n * n; | 571 | double sqz = q1.y*q1.y; |
490 | if (p > 0) | 572 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor |
491 | return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), | 573 | double test = q1.x*q1.z + q1.y*q1.s; |
492 | Math.Atan2(n, Math.Sqrt(p)), | 574 | if (test > 0.4999*unit) { // singularity at north pole |
493 | Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); | 575 | eul.z = 2 * Math.Atan2(q1.x,q1.s); |
494 | else if (n > 0) | 576 | eul.y = Math.PI/2; |
495 | return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); | 577 | eul.x = 0; |
496 | else | 578 | return eul; |
497 | return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); | 579 | } |
580 | if (test < -0.4999*unit) { // singularity at south pole | ||
581 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
582 | eul.y = -Math.PI/2; | ||
583 | eul.x = 0; | ||
584 | return eul; | ||
585 | } | ||
586 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
587 | eul.y = Math.Asin(2*test/unit); | ||
588 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
589 | return eul; | ||
498 | } | 590 | } |
499 | 591 | ||
500 | /* From wiki: | 592 | /* From wiki: |
@@ -696,77 +788,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
696 | { | 788 | { |
697 | //A and B should both be normalized | 789 | //A and B should both be normalized |
698 | m_host.AddScriptLPS(1); | 790 | m_host.AddScriptLPS(1); |
699 | LSL_Rotation rotBetween; | 791 | /* This method is more accurate than the SL one, and thus causes problems |
700 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 792 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
701 | // continue calculation. | 793 | |
702 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 794 | double dotProduct = LSL_Vector.Dot(a, b); |
795 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
796 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
797 | double angle = Math.Acos(dotProduct / magProduct); | ||
798 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
799 | double s = Math.Sin(angle / 2); | ||
800 | |||
801 | double x = axis.x * s; | ||
802 | double y = axis.y * s; | ||
803 | double z = axis.z * s; | ||
804 | double w = Math.Cos(angle / 2); | ||
805 | |||
806 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
807 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
808 | |||
809 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
810 | */ | ||
811 | |||
812 | // This method mimics the 180 errors found in SL | ||
813 | // See www.euclideanspace.com... angleBetween | ||
814 | LSL_Vector vec_a = a; | ||
815 | LSL_Vector vec_b = b; | ||
816 | |||
817 | // Eliminate zero length | ||
818 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
819 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
820 | if (vec_a_mag < 0.00001 || | ||
821 | vec_b_mag < 0.00001) | ||
703 | { | 822 | { |
704 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 823 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
705 | } | 824 | } |
706 | else | 825 | |
826 | // Normalize | ||
827 | vec_a = llVecNorm(vec_a); | ||
828 | vec_b = llVecNorm(vec_b); | ||
829 | |||
830 | // Calculate axis and rotation angle | ||
831 | LSL_Vector axis = vec_a % vec_b; | ||
832 | LSL_Float cos_theta = vec_a * vec_b; | ||
833 | |||
834 | // Check if parallel | ||
835 | if (cos_theta > 0.99999) | ||
707 | { | 836 | { |
708 | a = LSL_Vector.Norm(a); | 837 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
709 | b = LSL_Vector.Norm(b); | 838 | } |
710 | double dotProduct = LSL_Vector.Dot(a, b); | 839 | |
711 | // There are two degenerate cases possible. These are for vectors 180 or | 840 | // Check if anti-parallel |
712 | // 0 degrees apart. These have to be detected and handled individually. | 841 | else if (cos_theta < -0.99999) |
713 | // | 842 | { |
714 | // Check for vectors 180 degrees apart. | 843 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
715 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 844 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
716 | if (dotProduct < -0.9999999f) | 845 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
717 | { | 846 | } |
718 | // First assume X axis is orthogonal to the vectors. | 847 | else // other rotation |
719 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 848 | { |
720 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 849 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
721 | // Check for near zero vector. A very small non-zero number here will create | 850 | axis = llVecNorm(axis); |
722 | // a rotation in an undesired direction. | 851 | double x, y, z, s, t; |
723 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 852 | s = Math.Cos(theta); |
724 | { | 853 | t = Math.Sin(theta); |
725 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 854 | x = axis.x * t; |
726 | } | 855 | y = axis.y * t; |
727 | // If the magnitude of the vector was near zero, then assume the X axis is not | 856 | z = axis.z * t; |
728 | // orthogonal and use the Z axis instead. | 857 | return new LSL_Rotation(x,y,z,s); |
729 | else | ||
730 | { | ||
731 | // Set 180 z rotation. | ||
732 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
733 | } | ||
734 | } | ||
735 | // Check for parallel vectors. | ||
736 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
737 | else if (dotProduct > 0.9999999f) | ||
738 | { | ||
739 | // Set zero rotation. | ||
740 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
741 | } | ||
742 | else | ||
743 | { | ||
744 | // All special checks have been performed so get the axis of rotation. | ||
745 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
746 | // Quarternion s value is the length of the unit vector + dot product. | ||
747 | double qs = 1.0 + dotProduct; | ||
748 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
749 | // Normalize the rotation. | ||
750 | double mag = LSL_Rotation.Mag(rotBetween); | ||
751 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
752 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
753 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
754 | // crossProduct vector should also not be zero. | ||
755 | rotBetween.x = rotBetween.x / mag; | ||
756 | rotBetween.y = rotBetween.y / mag; | ||
757 | rotBetween.z = rotBetween.z / mag; | ||
758 | rotBetween.s = rotBetween.s / mag; | ||
759 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
760 | // any longer since zero vectors are checked for at the top. | ||
761 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
762 | { | ||
763 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
764 | } | ||
765 | } | ||
766 | } | 858 | } |
767 | return rotBetween; | ||
768 | } | 859 | } |
769 | 860 | ||
770 | public void llWhisper(int channelID, string text) | 861 | public void llWhisper(int channelID, string text) |
771 | { | 862 | { |
772 | m_host.AddScriptLPS(1); | 863 | m_host.AddScriptLPS(1); |
@@ -1090,10 +1181,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1090 | return detectedParams.TouchUV; | 1181 | return detectedParams.TouchUV; |
1091 | } | 1182 | } |
1092 | 1183 | ||
1184 | [DebuggerNonUserCode] | ||
1093 | public virtual void llDie() | 1185 | public virtual void llDie() |
1094 | { | 1186 | { |
1095 | m_host.AddScriptLPS(1); | 1187 | m_host.AddScriptLPS(1); |
1096 | throw new SelfDeleteException(); | 1188 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1097 | } | 1189 | } |
1098 | 1190 | ||
1099 | public LSL_Float llGround(LSL_Vector offset) | 1191 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1166,6 +1258,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1166 | 1258 | ||
1167 | public void llSetStatus(int status, int value) | 1259 | public void llSetStatus(int status, int value) |
1168 | { | 1260 | { |
1261 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1262 | return; | ||
1169 | m_host.AddScriptLPS(1); | 1263 | m_host.AddScriptLPS(1); |
1170 | 1264 | ||
1171 | int statusrotationaxis = 0; | 1265 | int statusrotationaxis = 0; |
@@ -1395,6 +1489,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1395 | { | 1489 | { |
1396 | m_host.AddScriptLPS(1); | 1490 | m_host.AddScriptLPS(1); |
1397 | 1491 | ||
1492 | SetColor(m_host, color, face); | ||
1493 | } | ||
1494 | |||
1495 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1496 | { | ||
1497 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1498 | return; | ||
1499 | |||
1500 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1501 | Color4 texcolor; | ||
1502 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1503 | { | ||
1504 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1505 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1506 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1507 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1508 | tex.FaceTextures[face].RGBA = texcolor; | ||
1509 | part.UpdateTexture(tex); | ||
1510 | return; | ||
1511 | } | ||
1512 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1513 | { | ||
1514 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1515 | { | ||
1516 | if (tex.FaceTextures[i] != null) | ||
1517 | { | ||
1518 | texcolor = tex.FaceTextures[i].RGBA; | ||
1519 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1520 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1521 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1522 | tex.FaceTextures[i].RGBA = texcolor; | ||
1523 | } | ||
1524 | texcolor = tex.DefaultTexture.RGBA; | ||
1525 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1526 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1527 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1528 | tex.DefaultTexture.RGBA = texcolor; | ||
1529 | } | ||
1530 | part.UpdateTexture(tex); | ||
1531 | return; | ||
1532 | } | ||
1533 | |||
1398 | if (face == ScriptBaseClass.ALL_SIDES) | 1534 | if (face == ScriptBaseClass.ALL_SIDES) |
1399 | face = SceneObjectPart.ALL_SIDES; | 1535 | face = SceneObjectPart.ALL_SIDES; |
1400 | 1536 | ||
@@ -1403,6 +1539,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1403 | 1539 | ||
1404 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1540 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1405 | { | 1541 | { |
1542 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1543 | return; | ||
1544 | |||
1406 | Primitive.TextureEntry tex = part.Shape.Textures; | 1545 | Primitive.TextureEntry tex = part.Shape.Textures; |
1407 | MappingType textype; | 1546 | MappingType textype; |
1408 | textype = MappingType.Default; | 1547 | textype = MappingType.Default; |
@@ -1433,6 +1572,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1433 | 1572 | ||
1434 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1573 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1435 | { | 1574 | { |
1575 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1576 | return; | ||
1577 | |||
1436 | Primitive.TextureEntry tex = part.Shape.Textures; | 1578 | Primitive.TextureEntry tex = part.Shape.Textures; |
1437 | if (face >= 0 && face < GetNumberOfSides(part)) | 1579 | if (face >= 0 && face < GetNumberOfSides(part)) |
1438 | { | 1580 | { |
@@ -1458,6 +1600,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1458 | 1600 | ||
1459 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1601 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1460 | { | 1602 | { |
1603 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1604 | return; | ||
1461 | 1605 | ||
1462 | Shininess sval = new Shininess(); | 1606 | Shininess sval = new Shininess(); |
1463 | 1607 | ||
@@ -1508,6 +1652,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1508 | 1652 | ||
1509 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1653 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1510 | { | 1654 | { |
1655 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1656 | return; | ||
1657 | |||
1511 | Primitive.TextureEntry tex = part.Shape.Textures; | 1658 | Primitive.TextureEntry tex = part.Shape.Textures; |
1512 | if (face >= 0 && face < GetNumberOfSides(part)) | 1659 | if (face >= 0 && face < GetNumberOfSides(part)) |
1513 | { | 1660 | { |
@@ -1568,13 +1715,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1568 | m_host.AddScriptLPS(1); | 1715 | m_host.AddScriptLPS(1); |
1569 | 1716 | ||
1570 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1717 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1571 | 1718 | if (parts.Count > 0) | |
1572 | foreach (SceneObjectPart part in parts) | 1719 | { |
1573 | SetAlpha(part, alpha, face); | 1720 | try |
1721 | { | ||
1722 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1723 | foreach (SceneObjectPart part in parts) | ||
1724 | SetAlpha(part, alpha, face); | ||
1725 | } | ||
1726 | finally | ||
1727 | { | ||
1728 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1729 | } | ||
1730 | } | ||
1574 | } | 1731 | } |
1575 | 1732 | ||
1576 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1733 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1577 | { | 1734 | { |
1735 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1736 | return; | ||
1737 | |||
1578 | Primitive.TextureEntry tex = part.Shape.Textures; | 1738 | Primitive.TextureEntry tex = part.Shape.Textures; |
1579 | Color4 texcolor; | 1739 | Color4 texcolor; |
1580 | if (face >= 0 && face < GetNumberOfSides(part)) | 1740 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1620,7 +1780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1620 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1780 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1621 | float wind, float tension, LSL_Vector Force) | 1781 | float wind, float tension, LSL_Vector Force) |
1622 | { | 1782 | { |
1623 | if (part == null) | 1783 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1624 | return; | 1784 | return; |
1625 | 1785 | ||
1626 | if (flexi) | 1786 | if (flexi) |
@@ -1655,7 +1815,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1655 | /// <param name="falloff"></param> | 1815 | /// <param name="falloff"></param> |
1656 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1816 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1657 | { | 1817 | { |
1658 | if (part == null) | 1818 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1659 | return; | 1819 | return; |
1660 | 1820 | ||
1661 | if (light) | 1821 | if (light) |
@@ -1732,15 +1892,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1732 | m_host.AddScriptLPS(1); | 1892 | m_host.AddScriptLPS(1); |
1733 | 1893 | ||
1734 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1894 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1735 | 1895 | if (parts.Count > 0) | |
1736 | foreach (SceneObjectPart part in parts) | 1896 | { |
1737 | SetTexture(part, texture, face); | 1897 | try |
1738 | 1898 | { | |
1899 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1900 | foreach (SceneObjectPart part in parts) | ||
1901 | SetTexture(part, texture, face); | ||
1902 | } | ||
1903 | finally | ||
1904 | { | ||
1905 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1906 | } | ||
1907 | } | ||
1739 | ScriptSleep(200); | 1908 | ScriptSleep(200); |
1740 | } | 1909 | } |
1741 | 1910 | ||
1742 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1911 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1743 | { | 1912 | { |
1913 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1914 | return; | ||
1915 | |||
1744 | UUID textureID=new UUID(); | 1916 | UUID textureID=new UUID(); |
1745 | 1917 | ||
1746 | if (!UUID.TryParse(texture, out textureID)) | 1918 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1786,6 +1958,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1786 | 1958 | ||
1787 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1959 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1788 | { | 1960 | { |
1961 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1962 | return; | ||
1963 | |||
1789 | Primitive.TextureEntry tex = part.Shape.Textures; | 1964 | Primitive.TextureEntry tex = part.Shape.Textures; |
1790 | if (face >= 0 && face < GetNumberOfSides(part)) | 1965 | if (face >= 0 && face < GetNumberOfSides(part)) |
1791 | { | 1966 | { |
@@ -1822,6 +1997,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1822 | 1997 | ||
1823 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1998 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1824 | { | 1999 | { |
2000 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2001 | return; | ||
2002 | |||
1825 | Primitive.TextureEntry tex = part.Shape.Textures; | 2003 | Primitive.TextureEntry tex = part.Shape.Textures; |
1826 | if (face >= 0 && face < GetNumberOfSides(part)) | 2004 | if (face >= 0 && face < GetNumberOfSides(part)) |
1827 | { | 2005 | { |
@@ -1858,6 +2036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1858 | 2036 | ||
1859 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2037 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1860 | { | 2038 | { |
2039 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2040 | return; | ||
2041 | |||
1861 | Primitive.TextureEntry tex = part.Shape.Textures; | 2042 | Primitive.TextureEntry tex = part.Shape.Textures; |
1862 | if (face >= 0 && face < GetNumberOfSides(part)) | 2043 | if (face >= 0 && face < GetNumberOfSides(part)) |
1863 | { | 2044 | { |
@@ -1928,6 +2109,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1928 | 2109 | ||
1929 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2110 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1930 | { | 2111 | { |
2112 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2113 | return; | ||
2114 | |||
1931 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2115 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1932 | LSL_Vector currentPos = GetPartLocalPos(part); | 2116 | LSL_Vector currentPos = GetPartLocalPos(part); |
1933 | 2117 | ||
@@ -1944,7 +2128,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1944 | } | 2128 | } |
1945 | else | 2129 | else |
1946 | { | 2130 | { |
1947 | LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); | 2131 | LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos); |
1948 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | 2132 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); |
1949 | SceneObjectGroup parent = part.ParentGroup; | 2133 | SceneObjectGroup parent = part.ParentGroup; |
1950 | parent.HasGroupChanged = true; | 2134 | parent.HasGroupChanged = true; |
@@ -2018,6 +2202,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2018 | 2202 | ||
2019 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2203 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2020 | { | 2204 | { |
2205 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2206 | return; | ||
2207 | |||
2021 | part.UpdateRotation(rot); | 2208 | part.UpdateRotation(rot); |
2022 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2209 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2023 | 2210 | ||
@@ -2637,12 +2824,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2637 | 2824 | ||
2638 | m_host.AddScriptLPS(1); | 2825 | m_host.AddScriptLPS(1); |
2639 | 2826 | ||
2827 | m_host.TaskInventory.LockItemsForRead(true); | ||
2640 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2828 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2641 | 2829 | m_host.TaskInventory.LockItemsForRead(false); | |
2642 | lock (m_host.TaskInventory) | ||
2643 | { | ||
2644 | item = m_host.TaskInventory[invItemID]; | ||
2645 | } | ||
2646 | 2830 | ||
2647 | if (item.PermsGranter == UUID.Zero) | 2831 | if (item.PermsGranter == UUID.Zero) |
2648 | return 0; | 2832 | return 0; |
@@ -2717,6 +2901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2717 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2901 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2718 | return; | 2902 | return; |
2719 | 2903 | ||
2904 | //Clone is thread-safe | ||
2720 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2905 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2721 | 2906 | ||
2722 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2907 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2779,6 +2964,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2779 | 2964 | ||
2780 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2965 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2781 | { | 2966 | { |
2967 | /* | ||
2782 | m_host.AddScriptLPS(1); | 2968 | m_host.AddScriptLPS(1); |
2783 | // Determine where we are looking from | 2969 | // Determine where we are looking from |
2784 | LSL_Vector from = llGetPos(); | 2970 | LSL_Vector from = llGetPos(); |
@@ -2798,10 +2984,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2798 | // the angles of rotation in radians into rotation value | 2984 | // the angles of rotation in radians into rotation value |
2799 | 2985 | ||
2800 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2986 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2801 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2987 | |
2802 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2988 | // This would only work if your physics system contains an APID controller: |
2989 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2990 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2991 | |||
2803 | // Orient the object to the angle calculated | 2992 | // Orient the object to the angle calculated |
2804 | //llSetRot(rot); | 2993 | llSetRot(rot); |
2994 | */ | ||
2995 | |||
2996 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2997 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2998 | // http://bugs.meta7.com/view.php?id=28 | ||
2999 | // - Tom | ||
3000 | |||
3001 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
3002 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
3003 | |||
3004 | } | ||
3005 | |||
3006 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3007 | { | ||
3008 | m_host.AddScriptLPS(1); | ||
3009 | // NotImplemented("llRotLookAt"); | ||
3010 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3011 | |||
2805 | } | 3012 | } |
2806 | 3013 | ||
2807 | public void llStopLookAt() | 3014 | public void llStopLookAt() |
@@ -2850,13 +3057,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2850 | { | 3057 | { |
2851 | TaskInventoryItem item; | 3058 | TaskInventoryItem item; |
2852 | 3059 | ||
2853 | lock (m_host.TaskInventory) | 3060 | m_host.TaskInventory.LockItemsForRead(true); |
3061 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2854 | { | 3062 | { |
2855 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3063 | m_host.TaskInventory.LockItemsForRead(false); |
2856 | return; | 3064 | return; |
2857 | else | 3065 | } |
2858 | item = m_host.TaskInventory[InventorySelf()]; | 3066 | else |
3067 | { | ||
3068 | item = m_host.TaskInventory[InventorySelf()]; | ||
2859 | } | 3069 | } |
3070 | m_host.TaskInventory.LockItemsForRead(false); | ||
2860 | 3071 | ||
2861 | if (item.PermsGranter != UUID.Zero) | 3072 | if (item.PermsGranter != UUID.Zero) |
2862 | { | 3073 | { |
@@ -2878,13 +3089,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2878 | { | 3089 | { |
2879 | TaskInventoryItem item; | 3090 | TaskInventoryItem item; |
2880 | 3091 | ||
3092 | m_host.TaskInventory.LockItemsForRead(true); | ||
2881 | lock (m_host.TaskInventory) | 3093 | lock (m_host.TaskInventory) |
2882 | { | 3094 | { |
3095 | |||
2883 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3096 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3097 | { | ||
3098 | m_host.TaskInventory.LockItemsForRead(false); | ||
2884 | return; | 3099 | return; |
3100 | } | ||
2885 | else | 3101 | else |
3102 | { | ||
2886 | item = m_host.TaskInventory[InventorySelf()]; | 3103 | item = m_host.TaskInventory[InventorySelf()]; |
3104 | } | ||
2887 | } | 3105 | } |
3106 | m_host.TaskInventory.LockItemsForRead(false); | ||
2888 | 3107 | ||
2889 | m_host.AddScriptLPS(1); | 3108 | m_host.AddScriptLPS(1); |
2890 | 3109 | ||
@@ -2916,18 +3135,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2916 | { | 3135 | { |
2917 | m_host.AddScriptLPS(1); | 3136 | m_host.AddScriptLPS(1); |
2918 | 3137 | ||
2919 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
2920 | return; | ||
2921 | |||
2922 | TaskInventoryItem item; | 3138 | TaskInventoryItem item; |
2923 | 3139 | ||
2924 | lock (m_host.TaskInventory) | 3140 | m_host.TaskInventory.LockItemsForRead(true); |
3141 | |||
3142 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2925 | { | 3143 | { |
2926 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3144 | m_host.TaskInventory.LockItemsForRead(false); |
2927 | return; | 3145 | return; |
2928 | else | ||
2929 | item = m_host.TaskInventory[InventorySelf()]; | ||
2930 | } | 3146 | } |
3147 | else | ||
3148 | { | ||
3149 | item = m_host.TaskInventory[InventorySelf()]; | ||
3150 | } | ||
3151 | |||
3152 | m_host.TaskInventory.LockItemsForRead(false); | ||
2931 | 3153 | ||
2932 | if (item.PermsGranter != m_host.OwnerID) | 3154 | if (item.PermsGranter != m_host.OwnerID) |
2933 | return; | 3155 | return; |
@@ -2938,10 +3160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2938 | 3160 | ||
2939 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3161 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
2940 | 3162 | ||
2941 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3163 | grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false); |
2942 | if (attachmentsModule != null) | ||
2943 | attachmentsModule.AttachObject(presence.ControllingClient, | ||
2944 | grp, (uint)attachment, false); | ||
2945 | } | 3164 | } |
2946 | } | 3165 | } |
2947 | 3166 | ||
@@ -2954,13 +3173,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2954 | 3173 | ||
2955 | TaskInventoryItem item; | 3174 | TaskInventoryItem item; |
2956 | 3175 | ||
2957 | lock (m_host.TaskInventory) | 3176 | m_host.TaskInventory.LockItemsForRead(true); |
3177 | |||
3178 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2958 | { | 3179 | { |
2959 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3180 | m_host.TaskInventory.LockItemsForRead(false); |
2960 | return; | 3181 | return; |
2961 | else | ||
2962 | item = m_host.TaskInventory[InventorySelf()]; | ||
2963 | } | 3182 | } |
3183 | else | ||
3184 | { | ||
3185 | item = m_host.TaskInventory[InventorySelf()]; | ||
3186 | } | ||
3187 | m_host.TaskInventory.LockItemsForRead(false); | ||
3188 | |||
2964 | 3189 | ||
2965 | if (item.PermsGranter != m_host.OwnerID) | 3190 | if (item.PermsGranter != m_host.OwnerID) |
2966 | return; | 3191 | return; |
@@ -2999,6 +3224,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2999 | 3224 | ||
3000 | public void llInstantMessage(string user, string message) | 3225 | public void llInstantMessage(string user, string message) |
3001 | { | 3226 | { |
3227 | UUID result; | ||
3228 | if (!UUID.TryParse(user, out result)) | ||
3229 | { | ||
3230 | if (!m_debuggerSafe) | ||
3231 | { | ||
3232 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3233 | } | ||
3234 | return; | ||
3235 | } | ||
3236 | |||
3237 | |||
3002 | m_host.AddScriptLPS(1); | 3238 | m_host.AddScriptLPS(1); |
3003 | 3239 | ||
3004 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3240 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3013,14 +3249,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3013 | UUID friendTransactionID = UUID.Random(); | 3249 | UUID friendTransactionID = UUID.Random(); |
3014 | 3250 | ||
3015 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3251 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3016 | 3252 | ||
3017 | GridInstantMessage msg = new GridInstantMessage(); | 3253 | GridInstantMessage msg = new GridInstantMessage(); |
3018 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3254 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3019 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3255 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3020 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3256 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3021 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3257 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3022 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3258 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3023 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3259 | DateTime dt = DateTime.UtcNow; |
3260 | |||
3261 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3262 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3263 | |||
3264 | try | ||
3265 | { | ||
3266 | // Convert that to the PST timezone | ||
3267 | TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3268 | dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3269 | } | ||
3270 | catch | ||
3271 | { | ||
3272 | // No logging here, as it could be VERY spammy | ||
3273 | } | ||
3274 | |||
3275 | // And make it look local again to fool the unix time util | ||
3276 | dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3277 | |||
3278 | msg.timestamp = (uint)Util.ToUnixTime(dt); | ||
3279 | |||
3024 | //if (client != null) | 3280 | //if (client != null) |
3025 | //{ | 3281 | //{ |
3026 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3282 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3034,13 +3290,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3034 | msg.message = message.Substring(0, 1024); | 3290 | msg.message = message.Substring(0, 1024); |
3035 | else | 3291 | else |
3036 | msg.message = message; | 3292 | msg.message = message; |
3037 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3293 | msg.dialog = (byte)19; // MessageFromObject |
3038 | msg.fromGroup = false;// fromGroup; | 3294 | msg.fromGroup = false;// fromGroup; |
3039 | msg.offline = (byte)0; //offline; | 3295 | msg.offline = (byte)0; //offline; |
3040 | msg.ParentEstateID = 0; //ParentEstateID; | 3296 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3041 | msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); | 3297 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3042 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3298 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3043 | msg.binaryBucket = new byte[0];// binaryBucket; | 3299 | msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); |
3044 | 3300 | ||
3045 | if (m_TransferModule != null) | 3301 | if (m_TransferModule != null) |
3046 | { | 3302 | { |
@@ -3060,7 +3316,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3060 | } | 3316 | } |
3061 | 3317 | ||
3062 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3318 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3063 | ScriptSleep(20000); | 3319 | ScriptSleep(15000); |
3064 | } | 3320 | } |
3065 | 3321 | ||
3066 | public void llGetNextEmail(string address, string subject) | 3322 | public void llGetNextEmail(string address, string subject) |
@@ -3162,13 +3418,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3162 | m_host.AddScriptLPS(1); | 3418 | m_host.AddScriptLPS(1); |
3163 | } | 3419 | } |
3164 | 3420 | ||
3165 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3166 | { | ||
3167 | m_host.AddScriptLPS(1); | ||
3168 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3169 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3170 | } | ||
3171 | |||
3172 | public LSL_Integer llStringLength(string str) | 3421 | public LSL_Integer llStringLength(string str) |
3173 | { | 3422 | { |
3174 | m_host.AddScriptLPS(1); | 3423 | m_host.AddScriptLPS(1); |
@@ -3192,14 +3441,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3192 | 3441 | ||
3193 | TaskInventoryItem item; | 3442 | TaskInventoryItem item; |
3194 | 3443 | ||
3195 | lock (m_host.TaskInventory) | 3444 | m_host.TaskInventory.LockItemsForRead(true); |
3445 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3196 | { | 3446 | { |
3197 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3447 | m_host.TaskInventory.LockItemsForRead(false); |
3198 | return; | 3448 | return; |
3199 | else | ||
3200 | item = m_host.TaskInventory[InventorySelf()]; | ||
3201 | } | 3449 | } |
3202 | 3450 | else | |
3451 | { | ||
3452 | item = m_host.TaskInventory[InventorySelf()]; | ||
3453 | } | ||
3454 | m_host.TaskInventory.LockItemsForRead(false); | ||
3203 | if (item.PermsGranter == UUID.Zero) | 3455 | if (item.PermsGranter == UUID.Zero) |
3204 | return; | 3456 | return; |
3205 | 3457 | ||
@@ -3229,13 +3481,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3229 | 3481 | ||
3230 | TaskInventoryItem item; | 3482 | TaskInventoryItem item; |
3231 | 3483 | ||
3232 | lock (m_host.TaskInventory) | 3484 | m_host.TaskInventory.LockItemsForRead(true); |
3485 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3233 | { | 3486 | { |
3234 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3487 | m_host.TaskInventory.LockItemsForRead(false); |
3235 | return; | 3488 | return; |
3236 | else | 3489 | } |
3237 | item = m_host.TaskInventory[InventorySelf()]; | 3490 | else |
3491 | { | ||
3492 | item = m_host.TaskInventory[InventorySelf()]; | ||
3238 | } | 3493 | } |
3494 | m_host.TaskInventory.LockItemsForRead(false); | ||
3495 | |||
3239 | 3496 | ||
3240 | if (item.PermsGranter == UUID.Zero) | 3497 | if (item.PermsGranter == UUID.Zero) |
3241 | return; | 3498 | return; |
@@ -3306,10 +3563,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3306 | 3563 | ||
3307 | TaskInventoryItem item; | 3564 | TaskInventoryItem item; |
3308 | 3565 | ||
3309 | lock (m_host.TaskInventory) | 3566 | |
3567 | m_host.TaskInventory.LockItemsForRead(true); | ||
3568 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3569 | { | ||
3570 | m_host.TaskInventory.LockItemsForRead(false); | ||
3571 | return; | ||
3572 | } | ||
3573 | else | ||
3310 | { | 3574 | { |
3311 | item = m_host.TaskInventory[invItemID]; | 3575 | item = m_host.TaskInventory[invItemID]; |
3312 | } | 3576 | } |
3577 | m_host.TaskInventory.LockItemsForRead(false); | ||
3313 | 3578 | ||
3314 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3579 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3315 | { | 3580 | { |
@@ -3341,11 +3606,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3341 | 3606 | ||
3342 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3607 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3343 | { | 3608 | { |
3344 | lock (m_host.TaskInventory) | 3609 | m_host.TaskInventory.LockItemsForWrite(true); |
3345 | { | 3610 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3346 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3611 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3347 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3612 | m_host.TaskInventory.LockItemsForWrite(false); |
3348 | } | ||
3349 | 3613 | ||
3350 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3614 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3351 | "run_time_permissions", new Object[] { | 3615 | "run_time_permissions", new Object[] { |
@@ -3365,11 +3629,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3365 | 3629 | ||
3366 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3630 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3367 | { | 3631 | { |
3368 | lock (m_host.TaskInventory) | 3632 | m_host.TaskInventory.LockItemsForWrite(true); |
3369 | { | 3633 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3370 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3634 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3371 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3635 | m_host.TaskInventory.LockItemsForWrite(false); |
3372 | } | ||
3373 | 3636 | ||
3374 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3637 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3375 | "run_time_permissions", new Object[] { | 3638 | "run_time_permissions", new Object[] { |
@@ -3390,11 +3653,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3390 | 3653 | ||
3391 | if (!m_waitingForScriptAnswer) | 3654 | if (!m_waitingForScriptAnswer) |
3392 | { | 3655 | { |
3393 | lock (m_host.TaskInventory) | 3656 | m_host.TaskInventory.LockItemsForWrite(true); |
3394 | { | 3657 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3395 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3658 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3396 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3659 | m_host.TaskInventory.LockItemsForWrite(false); |
3397 | } | ||
3398 | 3660 | ||
3399 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3661 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3400 | m_waitingForScriptAnswer=true; | 3662 | m_waitingForScriptAnswer=true; |
@@ -3429,10 +3691,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3429 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3691 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3430 | llReleaseControls(); | 3692 | llReleaseControls(); |
3431 | 3693 | ||
3432 | lock (m_host.TaskInventory) | 3694 | |
3433 | { | 3695 | m_host.TaskInventory.LockItemsForWrite(true); |
3434 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3696 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3435 | } | 3697 | m_host.TaskInventory.LockItemsForWrite(false); |
3698 | |||
3436 | 3699 | ||
3437 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3700 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3438 | "run_time_permissions", new Object[] { | 3701 | "run_time_permissions", new Object[] { |
@@ -3444,16 +3707,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3444 | { | 3707 | { |
3445 | m_host.AddScriptLPS(1); | 3708 | m_host.AddScriptLPS(1); |
3446 | 3709 | ||
3447 | lock (m_host.TaskInventory) | 3710 | m_host.TaskInventory.LockItemsForRead(true); |
3711 | |||
3712 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3448 | { | 3713 | { |
3449 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3714 | if (item.Type == 10 && item.ItemID == m_itemID) |
3450 | { | 3715 | { |
3451 | if (item.Type == 10 && item.ItemID == m_itemID) | 3716 | m_host.TaskInventory.LockItemsForRead(false); |
3452 | { | 3717 | return item.PermsGranter.ToString(); |
3453 | return item.PermsGranter.ToString(); | ||
3454 | } | ||
3455 | } | 3718 | } |
3456 | } | 3719 | } |
3720 | m_host.TaskInventory.LockItemsForRead(false); | ||
3457 | 3721 | ||
3458 | return UUID.Zero.ToString(); | 3722 | return UUID.Zero.ToString(); |
3459 | } | 3723 | } |
@@ -3462,19 +3726,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3462 | { | 3726 | { |
3463 | m_host.AddScriptLPS(1); | 3727 | m_host.AddScriptLPS(1); |
3464 | 3728 | ||
3465 | lock (m_host.TaskInventory) | 3729 | m_host.TaskInventory.LockItemsForRead(true); |
3730 | |||
3731 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3466 | { | 3732 | { |
3467 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3733 | if (item.Type == 10 && item.ItemID == m_itemID) |
3468 | { | 3734 | { |
3469 | if (item.Type == 10 && item.ItemID == m_itemID) | 3735 | int perms = item.PermsMask; |
3470 | { | 3736 | if (m_automaticLinkPermission) |
3471 | int perms = item.PermsMask; | 3737 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3472 | if (m_automaticLinkPermission) | 3738 | m_host.TaskInventory.LockItemsForRead(false); |
3473 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3739 | return perms; |
3474 | return perms; | ||
3475 | } | ||
3476 | } | 3740 | } |
3477 | } | 3741 | } |
3742 | m_host.TaskInventory.LockItemsForRead(false); | ||
3478 | 3743 | ||
3479 | return 0; | 3744 | return 0; |
3480 | } | 3745 | } |
@@ -3496,9 +3761,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3496 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3761 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3497 | { | 3762 | { |
3498 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3763 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3499 | 3764 | if (parts.Count > 0) | |
3500 | foreach (SceneObjectPart part in parts) | 3765 | { |
3501 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3766 | try |
3767 | { | ||
3768 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3769 | foreach (SceneObjectPart part in parts) | ||
3770 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3771 | } | ||
3772 | finally | ||
3773 | { | ||
3774 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3775 | } | ||
3776 | } | ||
3502 | } | 3777 | } |
3503 | 3778 | ||
3504 | public void llCreateLink(string target, int parent) | 3779 | public void llCreateLink(string target, int parent) |
@@ -3511,11 +3786,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3511 | return; | 3786 | return; |
3512 | 3787 | ||
3513 | TaskInventoryItem item; | 3788 | TaskInventoryItem item; |
3514 | lock (m_host.TaskInventory) | 3789 | m_host.TaskInventory.LockItemsForRead(true); |
3515 | { | 3790 | item = m_host.TaskInventory[invItemID]; |
3516 | item = m_host.TaskInventory[invItemID]; | 3791 | m_host.TaskInventory.LockItemsForRead(false); |
3517 | } | 3792 | |
3518 | |||
3519 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3793 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3520 | && !m_automaticLinkPermission) | 3794 | && !m_automaticLinkPermission) |
3521 | { | 3795 | { |
@@ -3568,16 +3842,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3568 | m_host.AddScriptLPS(1); | 3842 | m_host.AddScriptLPS(1); |
3569 | UUID invItemID = InventorySelf(); | 3843 | UUID invItemID = InventorySelf(); |
3570 | 3844 | ||
3571 | lock (m_host.TaskInventory) | 3845 | m_host.TaskInventory.LockItemsForRead(true); |
3572 | { | ||
3573 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3846 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3574 | && !m_automaticLinkPermission) | 3847 | && !m_automaticLinkPermission) |
3575 | { | 3848 | { |
3576 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3849 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3850 | m_host.TaskInventory.LockItemsForRead(false); | ||
3577 | return; | 3851 | return; |
3578 | } | 3852 | } |
3579 | } | 3853 | m_host.TaskInventory.LockItemsForRead(false); |
3580 | 3854 | ||
3581 | if (linknum < ScriptBaseClass.LINK_THIS) | 3855 | if (linknum < ScriptBaseClass.LINK_THIS) |
3582 | return; | 3856 | return; |
3583 | 3857 | ||
@@ -3616,10 +3890,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3616 | // Restructuring Multiple Prims. | 3890 | // Restructuring Multiple Prims. |
3617 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3891 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3618 | parts.Remove(parentPrim.RootPart); | 3892 | parts.Remove(parentPrim.RootPart); |
3619 | foreach (SceneObjectPart part in parts) | 3893 | if (parts.Count > 0) |
3620 | { | 3894 | { |
3621 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3895 | try |
3896 | { | ||
3897 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3898 | foreach (SceneObjectPart part in parts) | ||
3899 | { | ||
3900 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3901 | } | ||
3902 | } | ||
3903 | finally | ||
3904 | { | ||
3905 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3906 | } | ||
3622 | } | 3907 | } |
3908 | |||
3623 | parentPrim.HasGroupChanged = true; | 3909 | parentPrim.HasGroupChanged = true; |
3624 | parentPrim.ScheduleGroupForFullUpdate(); | 3910 | parentPrim.ScheduleGroupForFullUpdate(); |
3625 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3911 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3628,11 +3914,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3628 | { | 3914 | { |
3629 | SceneObjectPart newRoot = parts[0]; | 3915 | SceneObjectPart newRoot = parts[0]; |
3630 | parts.Remove(newRoot); | 3916 | parts.Remove(newRoot); |
3631 | foreach (SceneObjectPart part in parts) | 3917 | |
3918 | try | ||
3632 | { | 3919 | { |
3633 | part.UpdateFlag = 0; | 3920 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3634 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3921 | foreach (SceneObjectPart part in parts) |
3922 | { | ||
3923 | part.UpdateFlag = 0; | ||
3924 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3925 | } | ||
3635 | } | 3926 | } |
3927 | finally | ||
3928 | { | ||
3929 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3930 | } | ||
3931 | |||
3932 | |||
3636 | newRoot.ParentGroup.HasGroupChanged = true; | 3933 | newRoot.ParentGroup.HasGroupChanged = true; |
3637 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3934 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3638 | } | 3935 | } |
@@ -3658,11 +3955,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3658 | 3955 | ||
3659 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3956 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3660 | parts.Remove(parentPrim.RootPart); | 3957 | parts.Remove(parentPrim.RootPart); |
3661 | 3958 | if (parts.Count > 0) | |
3662 | foreach (SceneObjectPart part in parts) | ||
3663 | { | 3959 | { |
3664 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3960 | try |
3665 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3961 | { |
3962 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3963 | foreach (SceneObjectPart part in parts) | ||
3964 | { | ||
3965 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3966 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | ||
3967 | } | ||
3968 | } | ||
3969 | finally | ||
3970 | { | ||
3971 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3972 | } | ||
3666 | } | 3973 | } |
3667 | parentPrim.HasGroupChanged = true; | 3974 | parentPrim.HasGroupChanged = true; |
3668 | parentPrim.ScheduleGroupForFullUpdate(); | 3975 | parentPrim.ScheduleGroupForFullUpdate(); |
@@ -3754,17 +4061,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3754 | m_host.AddScriptLPS(1); | 4061 | m_host.AddScriptLPS(1); |
3755 | int count = 0; | 4062 | int count = 0; |
3756 | 4063 | ||
3757 | lock (m_host.TaskInventory) | 4064 | m_host.TaskInventory.LockItemsForRead(true); |
4065 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3758 | { | 4066 | { |
3759 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4067 | if (inv.Value.Type == type || type == -1) |
3760 | { | 4068 | { |
3761 | if (inv.Value.Type == type || type == -1) | 4069 | count = count + 1; |
3762 | { | ||
3763 | count = count + 1; | ||
3764 | } | ||
3765 | } | 4070 | } |
3766 | } | 4071 | } |
3767 | 4072 | ||
4073 | m_host.TaskInventory.LockItemsForRead(false); | ||
3768 | return count; | 4074 | return count; |
3769 | } | 4075 | } |
3770 | 4076 | ||
@@ -3773,16 +4079,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3773 | m_host.AddScriptLPS(1); | 4079 | m_host.AddScriptLPS(1); |
3774 | ArrayList keys = new ArrayList(); | 4080 | ArrayList keys = new ArrayList(); |
3775 | 4081 | ||
3776 | lock (m_host.TaskInventory) | 4082 | m_host.TaskInventory.LockItemsForRead(true); |
4083 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3777 | { | 4084 | { |
3778 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4085 | if (inv.Value.Type == type || type == -1) |
3779 | { | 4086 | { |
3780 | if (inv.Value.Type == type || type == -1) | 4087 | keys.Add(inv.Value.Name); |
3781 | { | ||
3782 | keys.Add(inv.Value.Name); | ||
3783 | } | ||
3784 | } | 4088 | } |
3785 | } | 4089 | } |
4090 | m_host.TaskInventory.LockItemsForRead(false); | ||
3786 | 4091 | ||
3787 | if (keys.Count == 0) | 4092 | if (keys.Count == 0) |
3788 | { | 4093 | { |
@@ -3819,20 +4124,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3819 | } | 4124 | } |
3820 | 4125 | ||
3821 | // move the first object found with this inventory name | 4126 | // move the first object found with this inventory name |
3822 | lock (m_host.TaskInventory) | 4127 | m_host.TaskInventory.LockItemsForRead(true); |
4128 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3823 | { | 4129 | { |
3824 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4130 | if (inv.Value.Name == inventory) |
3825 | { | 4131 | { |
3826 | if (inv.Value.Name == inventory) | 4132 | found = true; |
3827 | { | 4133 | objId = inv.Key; |
3828 | found = true; | 4134 | assetType = inv.Value.Type; |
3829 | objId = inv.Key; | 4135 | objName = inv.Value.Name; |
3830 | assetType = inv.Value.Type; | 4136 | break; |
3831 | objName = inv.Value.Name; | ||
3832 | break; | ||
3833 | } | ||
3834 | } | 4137 | } |
3835 | } | 4138 | } |
4139 | m_host.TaskInventory.LockItemsForRead(false); | ||
3836 | 4140 | ||
3837 | if (!found) | 4141 | if (!found) |
3838 | { | 4142 | { |
@@ -3840,9 +4144,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3840 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4144 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3841 | } | 4145 | } |
3842 | 4146 | ||
3843 | // check if destination is an avatar | 4147 | // check if destination is an object |
3844 | if (World.GetScenePresence(destId) != null) | 4148 | if (World.GetSceneObjectPart(destId) != null) |
4149 | { | ||
4150 | // destination is an object | ||
4151 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4152 | } | ||
4153 | else | ||
3845 | { | 4154 | { |
4155 | ScenePresence presence = World.GetScenePresence(destId); | ||
4156 | |||
4157 | if (presence == null) | ||
4158 | { | ||
4159 | UserAccount account = | ||
4160 | World.UserAccountService.GetUserAccount( | ||
4161 | World.RegionInfo.ScopeID, | ||
4162 | destId); | ||
4163 | |||
4164 | if (account == null) | ||
4165 | { | ||
4166 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4167 | return; | ||
4168 | } | ||
4169 | } | ||
4170 | |||
3846 | // destination is an avatar | 4171 | // destination is an avatar |
3847 | InventoryItemBase agentItem = | 4172 | InventoryItemBase agentItem = |
3848 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4173 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
@@ -3852,7 +4177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3852 | 4177 | ||
3853 | byte[] bucket = new byte[17]; | 4178 | byte[] bucket = new byte[17]; |
3854 | bucket[0] = (byte)assetType; | 4179 | bucket[0] = (byte)assetType; |
3855 | byte[] objBytes = objId.GetBytes(); | 4180 | byte[] objBytes = agentItem.ID.GetBytes(); |
3856 | Array.Copy(objBytes, 0, bucket, 1, 16); | 4181 | Array.Copy(objBytes, 0, bucket, 1, 16); |
3857 | 4182 | ||
3858 | Console.WriteLine("Giving inventory"); | 4183 | Console.WriteLine("Giving inventory"); |
@@ -3868,31 +4193,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3868 | 4193 | ||
3869 | if (m_TransferModule != null) | 4194 | if (m_TransferModule != null) |
3870 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4195 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4196 | |||
4197 | //This delay should only occur when giving inventory to avatars. | ||
4198 | ScriptSleep(3000); | ||
3871 | } | 4199 | } |
3872 | else | ||
3873 | { | ||
3874 | // destination is an object | ||
3875 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3876 | } | ||
3877 | ScriptSleep(3000); | ||
3878 | } | 4200 | } |
3879 | 4201 | ||
4202 | [DebuggerNonUserCode] | ||
3880 | public void llRemoveInventory(string name) | 4203 | public void llRemoveInventory(string name) |
3881 | { | 4204 | { |
3882 | m_host.AddScriptLPS(1); | 4205 | m_host.AddScriptLPS(1); |
3883 | 4206 | ||
3884 | lock (m_host.TaskInventory) | 4207 | List<TaskInventoryItem> inv; |
4208 | try | ||
3885 | { | 4209 | { |
3886 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4210 | m_host.TaskInventory.LockItemsForRead(true); |
4211 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | ||
4212 | } | ||
4213 | finally | ||
4214 | { | ||
4215 | m_host.TaskInventory.LockItemsForRead(false); | ||
4216 | } | ||
4217 | foreach (TaskInventoryItem item in inv) | ||
4218 | { | ||
4219 | if (item.Name == name) | ||
3887 | { | 4220 | { |
3888 | if (item.Name == name) | 4221 | if (item.ItemID == m_itemID) |
3889 | { | 4222 | throw new ScriptDeleteException(); |
3890 | if (item.ItemID == m_itemID) | 4223 | else |
3891 | throw new ScriptDeleteException(); | 4224 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3892 | else | 4225 | return; |
3893 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
3894 | return; | ||
3895 | } | ||
3896 | } | 4226 | } |
3897 | } | 4227 | } |
3898 | } | 4228 | } |
@@ -3950,6 +4280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3950 | ce.time = Util.EnvironmentTickCount(); | 4280 | ce.time = Util.EnvironmentTickCount(); |
3951 | ce.account = account; | 4281 | ce.account = account; |
3952 | ce.pinfo = pinfo; | 4282 | ce.pinfo = pinfo; |
4283 | m_userInfoCache[uuid] = ce; | ||
3953 | } | 4284 | } |
3954 | else | 4285 | else |
3955 | { | 4286 | { |
@@ -4017,6 +4348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4017 | { | 4348 | { |
4018 | m_host.AddScriptLPS(1); | 4349 | m_host.AddScriptLPS(1); |
4019 | 4350 | ||
4351 | //Clone is thread safe | ||
4020 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4352 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
4021 | 4353 | ||
4022 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4354 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4070,6 +4402,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4070 | ScenePresence presence = World.GetScenePresence(agentId); | 4402 | ScenePresence presence = World.GetScenePresence(agentId); |
4071 | if (presence != null) | 4403 | if (presence != null) |
4072 | { | 4404 | { |
4405 | // agent must not be a god | ||
4406 | if (presence.GodLevel >= 200) return; | ||
4407 | |||
4073 | // agent must be over the owners land | 4408 | // agent must be over the owners land |
4074 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4409 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4075 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4410 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4129,17 +4464,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4129 | UUID soundId = UUID.Zero; | 4464 | UUID soundId = UUID.Zero; |
4130 | if (!UUID.TryParse(impact_sound, out soundId)) | 4465 | if (!UUID.TryParse(impact_sound, out soundId)) |
4131 | { | 4466 | { |
4132 | lock (m_host.TaskInventory) | 4467 | m_host.TaskInventory.LockItemsForRead(true); |
4468 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4133 | { | 4469 | { |
4134 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4470 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4135 | { | 4471 | { |
4136 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4472 | soundId = item.AssetID; |
4137 | { | 4473 | break; |
4138 | soundId = item.AssetID; | ||
4139 | break; | ||
4140 | } | ||
4141 | } | 4474 | } |
4142 | } | 4475 | } |
4476 | m_host.TaskInventory.LockItemsForRead(false); | ||
4143 | } | 4477 | } |
4144 | m_host.CollisionSound = soundId; | 4478 | m_host.CollisionSound = soundId; |
4145 | m_host.CollisionSoundVolume = (float)impact_volume; | 4479 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4185,6 +4519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4185 | UUID partItemID; | 4519 | UUID partItemID; |
4186 | foreach (SceneObjectPart part in parts) | 4520 | foreach (SceneObjectPart part in parts) |
4187 | { | 4521 | { |
4522 | //Clone is thread safe | ||
4188 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4523 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4189 | 4524 | ||
4190 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4525 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4399,17 +4734,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4399 | 4734 | ||
4400 | m_host.AddScriptLPS(1); | 4735 | m_host.AddScriptLPS(1); |
4401 | 4736 | ||
4402 | lock (m_host.TaskInventory) | 4737 | m_host.TaskInventory.LockItemsForRead(true); |
4738 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4403 | { | 4739 | { |
4404 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4740 | if (item.Type == 10 && item.ItemID == m_itemID) |
4405 | { | 4741 | { |
4406 | if (item.Type == 10 && item.ItemID == m_itemID) | 4742 | result = item.Name!=null?item.Name:String.Empty; |
4407 | { | 4743 | break; |
4408 | result = item.Name != null ? item.Name : String.Empty; | ||
4409 | break; | ||
4410 | } | ||
4411 | } | 4744 | } |
4412 | } | 4745 | } |
4746 | m_host.TaskInventory.LockItemsForRead(false); | ||
4413 | 4747 | ||
4414 | return result; | 4748 | return result; |
4415 | } | 4749 | } |
@@ -4562,23 +4896,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4562 | { | 4896 | { |
4563 | m_host.AddScriptLPS(1); | 4897 | m_host.AddScriptLPS(1); |
4564 | 4898 | ||
4565 | lock (m_host.TaskInventory) | 4899 | m_host.TaskInventory.LockItemsForRead(true); |
4900 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4566 | { | 4901 | { |
4567 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4902 | if (inv.Value.Name == name) |
4568 | { | 4903 | { |
4569 | if (inv.Value.Name == name) | 4904 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4570 | { | 4905 | { |
4571 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4906 | m_host.TaskInventory.LockItemsForRead(false); |
4572 | { | 4907 | return inv.Value.AssetID.ToString(); |
4573 | return inv.Value.AssetID.ToString(); | 4908 | } |
4574 | } | 4909 | else |
4575 | else | 4910 | { |
4576 | { | 4911 | m_host.TaskInventory.LockItemsForRead(false); |
4577 | return UUID.Zero.ToString(); | 4912 | return UUID.Zero.ToString(); |
4578 | } | ||
4579 | } | 4913 | } |
4580 | } | 4914 | } |
4581 | } | 4915 | } |
4916 | m_host.TaskInventory.LockItemsForRead(false); | ||
4582 | 4917 | ||
4583 | return UUID.Zero.ToString(); | 4918 | return UUID.Zero.ToString(); |
4584 | } | 4919 | } |
@@ -4731,14 +5066,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4731 | { | 5066 | { |
4732 | m_host.AddScriptLPS(1); | 5067 | m_host.AddScriptLPS(1); |
4733 | 5068 | ||
4734 | if (src == null) | 5069 | return src.Length; |
4735 | { | ||
4736 | return 0; | ||
4737 | } | ||
4738 | else | ||
4739 | { | ||
4740 | return src.Length; | ||
4741 | } | ||
4742 | } | 5070 | } |
4743 | 5071 | ||
4744 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5072 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -4784,7 +5112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4784 | else if (src.Data[index] is LSL_Float) | 5112 | else if (src.Data[index] is LSL_Float) |
4785 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5113 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
4786 | else if (src.Data[index] is LSL_String) | 5114 | else if (src.Data[index] is LSL_String) |
4787 | return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); | 5115 | return Convert.ToDouble(Regex.Replace(((LSL_String)src.Data[index]).m_string, "[^0-9]", "")); |
4788 | return Convert.ToDouble(src.Data[index]); | 5116 | return Convert.ToDouble(src.Data[index]); |
4789 | } | 5117 | } |
4790 | catch (FormatException) | 5118 | catch (FormatException) |
@@ -5514,10 +5842,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5514 | m_host.AddScriptLPS(1); | 5842 | m_host.AddScriptLPS(1); |
5515 | 5843 | ||
5516 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5844 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5517 | 5845 | if (parts.Count > 0) | |
5518 | foreach (var part in parts) | ||
5519 | { | 5846 | { |
5520 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5847 | try |
5848 | { | ||
5849 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5850 | foreach (var part in parts) | ||
5851 | { | ||
5852 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5853 | } | ||
5854 | } | ||
5855 | finally | ||
5856 | { | ||
5857 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5858 | } | ||
5521 | } | 5859 | } |
5522 | } | 5860 | } |
5523 | 5861 | ||
@@ -5573,74 +5911,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5573 | 5911 | ||
5574 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | 5912 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) |
5575 | { | 5913 | { |
5576 | m_host.AddScriptLPS(1); | 5914 | return ParseString2List(str, separators, in_spacers, false); |
5577 | LSL_List ret = new LSL_List(); | ||
5578 | LSL_List spacers = new LSL_List(); | ||
5579 | if (in_spacers.Length > 0 && separators.Length > 0) | ||
5580 | { | ||
5581 | for (int i = 0; i < in_spacers.Length; i++) | ||
5582 | { | ||
5583 | object s = in_spacers.Data[i]; | ||
5584 | for (int j = 0; j < separators.Length; j++) | ||
5585 | { | ||
5586 | if (separators.Data[j].ToString() == s.ToString()) | ||
5587 | { | ||
5588 | s = null; | ||
5589 | break; | ||
5590 | } | ||
5591 | } | ||
5592 | if (s != null) | ||
5593 | { | ||
5594 | spacers.Add(s); | ||
5595 | } | ||
5596 | } | ||
5597 | } | ||
5598 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
5599 | separators.Data.CopyTo(delimiters, 0); | ||
5600 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
5601 | bool dfound = false; | ||
5602 | do | ||
5603 | { | ||
5604 | dfound = false; | ||
5605 | int cindex = -1; | ||
5606 | string cdeli = ""; | ||
5607 | for (int i = 0; i < delimiters.Length; i++) | ||
5608 | { | ||
5609 | int index = str.IndexOf(delimiters[i].ToString()); | ||
5610 | bool found = index != -1; | ||
5611 | if (found && String.Empty != delimiters[i].ToString()) | ||
5612 | { | ||
5613 | if ((cindex > index) || (cindex == -1)) | ||
5614 | { | ||
5615 | cindex = index; | ||
5616 | cdeli = delimiters[i].ToString(); | ||
5617 | } | ||
5618 | dfound = dfound || found; | ||
5619 | } | ||
5620 | } | ||
5621 | if (cindex != -1) | ||
5622 | { | ||
5623 | if (cindex > 0) | ||
5624 | { | ||
5625 | ret.Add(new LSL_String(str.Substring(0, cindex))); | ||
5626 | } | ||
5627 | // Cannot use spacers.Contains() because spacers may be either type String or LSLString | ||
5628 | for (int j = 0; j < spacers.Length; j++) | ||
5629 | { | ||
5630 | if (spacers.Data[j].ToString() == cdeli) | ||
5631 | { | ||
5632 | ret.Add(new LSL_String(cdeli)); | ||
5633 | break; | ||
5634 | } | ||
5635 | } | ||
5636 | str = str.Substring(cindex + cdeli.Length); | ||
5637 | } | ||
5638 | } while (dfound); | ||
5639 | if (str != "") | ||
5640 | { | ||
5641 | ret.Add(new LSL_String(str)); | ||
5642 | } | ||
5643 | return ret; | ||
5644 | } | 5915 | } |
5645 | 5916 | ||
5646 | public LSL_Integer llOverMyLand(string id) | 5917 | public LSL_Integer llOverMyLand(string id) |
@@ -5843,7 +6114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5843 | return m_host.ParentGroup.RootPart.AttachmentPoint; | 6114 | return m_host.ParentGroup.RootPart.AttachmentPoint; |
5844 | } | 6115 | } |
5845 | 6116 | ||
5846 | public LSL_Integer llGetFreeMemory() | 6117 | public virtual LSL_Integer llGetFreeMemory() |
5847 | { | 6118 | { |
5848 | m_host.AddScriptLPS(1); | 6119 | m_host.AddScriptLPS(1); |
5849 | // Make scripts designed for LSO happy | 6120 | // Make scripts designed for LSO happy |
@@ -6154,14 +6425,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6154 | 6425 | ||
6155 | protected UUID GetTaskInventoryItem(string name) | 6426 | protected UUID GetTaskInventoryItem(string name) |
6156 | { | 6427 | { |
6157 | lock (m_host.TaskInventory) | 6428 | m_host.TaskInventory.LockItemsForRead(true); |
6429 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6158 | { | 6430 | { |
6159 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6431 | if (inv.Value.Name == name) |
6160 | { | 6432 | { |
6161 | if (inv.Value.Name == name) | 6433 | m_host.TaskInventory.LockItemsForRead(false); |
6162 | return inv.Key; | 6434 | return inv.Key; |
6163 | } | 6435 | } |
6164 | } | 6436 | } |
6437 | m_host.TaskInventory.LockItemsForRead(false); | ||
6165 | 6438 | ||
6166 | return UUID.Zero; | 6439 | return UUID.Zero; |
6167 | } | 6440 | } |
@@ -6489,22 +6762,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6489 | } | 6762 | } |
6490 | 6763 | ||
6491 | // copy the first script found with this inventory name | 6764 | // copy the first script found with this inventory name |
6492 | lock (m_host.TaskInventory) | 6765 | m_host.TaskInventory.LockItemsForRead(true); |
6766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6493 | { | 6767 | { |
6494 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6768 | if (inv.Value.Name == name) |
6495 | { | 6769 | { |
6496 | if (inv.Value.Name == name) | 6770 | // make sure the object is a script |
6771 | if (10 == inv.Value.Type) | ||
6497 | { | 6772 | { |
6498 | // make sure the object is a script | 6773 | found = true; |
6499 | if (10 == inv.Value.Type) | 6774 | srcId = inv.Key; |
6500 | { | 6775 | break; |
6501 | found = true; | ||
6502 | srcId = inv.Key; | ||
6503 | break; | ||
6504 | } | ||
6505 | } | 6776 | } |
6506 | } | 6777 | } |
6507 | } | 6778 | } |
6779 | m_host.TaskInventory.LockItemsForRead(false); | ||
6508 | 6780 | ||
6509 | if (!found) | 6781 | if (!found) |
6510 | { | 6782 | { |
@@ -6588,6 +6860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6588 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6860 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6589 | { | 6861 | { |
6590 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6862 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6863 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6864 | return shapeBlock; | ||
6591 | 6865 | ||
6592 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6866 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6593 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6867 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6663,6 +6937,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6663 | 6937 | ||
6664 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6938 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6665 | { | 6939 | { |
6940 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6941 | return; | ||
6942 | |||
6666 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6943 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6667 | 6944 | ||
6668 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6945 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6712,6 +6989,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6712 | 6989 | ||
6713 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6990 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6714 | { | 6991 | { |
6992 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6993 | return; | ||
6994 | |||
6715 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6995 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6716 | 6996 | ||
6717 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6997 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6754,6 +7034,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6754 | 7034 | ||
6755 | 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) | 7035 | 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) |
6756 | { | 7036 | { |
7037 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7038 | return; | ||
7039 | |||
6757 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7040 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6758 | 7041 | ||
6759 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7042 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6880,6 +7163,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6880 | 7163 | ||
6881 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7164 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6882 | { | 7165 | { |
7166 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7167 | return; | ||
7168 | |||
6883 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7169 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6884 | UUID sculptId; | 7170 | UUID sculptId; |
6885 | 7171 | ||
@@ -6895,13 +7181,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6895 | shapeBlock.PathScaleX = 100; | 7181 | shapeBlock.PathScaleX = 100; |
6896 | shapeBlock.PathScaleY = 150; | 7182 | shapeBlock.PathScaleY = 150; |
6897 | 7183 | ||
6898 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7184 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6899 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7185 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6900 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7186 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6901 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7187 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6902 | { | 7188 | { |
6903 | // default | 7189 | // default |
6904 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7190 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6905 | } | 7191 | } |
6906 | 7192 | ||
6907 | // retain pathcurve | 7193 | // retain pathcurve |
@@ -6918,23 +7204,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6918 | SetPrimParams(m_host, rules); | 7204 | SetPrimParams(m_host, rules); |
6919 | } | 7205 | } |
6920 | 7206 | ||
6921 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7207 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
6922 | { | 7208 | { |
6923 | m_host.AddScriptLPS(1); | 7209 | m_host.AddScriptLPS(1); |
6924 | 7210 | ||
6925 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7211 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
7212 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7213 | if (parts.Count>0) | ||
7214 | { | ||
7215 | try | ||
7216 | { | ||
7217 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7218 | foreach (SceneObjectPart part in parts) | ||
7219 | SetPrimParams(part, rules); | ||
7220 | } | ||
7221 | finally | ||
7222 | { | ||
7223 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7224 | } | ||
7225 | } | ||
7226 | if (avatars.Count > 0) | ||
7227 | { | ||
7228 | foreach (ScenePresence avatar in avatars) | ||
7229 | SetPrimParams(avatar, rules); | ||
7230 | } | ||
7231 | } | ||
6926 | 7232 | ||
6927 | foreach (SceneObjectPart part in parts) | 7233 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6928 | SetPrimParams(part, rules); | 7234 | { |
7235 | llSetLinkPrimitiveParamsFast(linknumber, rules); | ||
7236 | ScriptSleep(200); | ||
6929 | } | 7237 | } |
6930 | 7238 | ||
6931 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7239 | protected void SetPrimParams(ScenePresence av, LSL_List rules) |
6932 | { | 7240 | { |
6933 | llSetLinkPrimitiveParams(linknumber, rules); | 7241 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7242 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
7243 | |||
7244 | int idx = 0; | ||
7245 | |||
7246 | while (idx < rules.Length) | ||
7247 | { | ||
7248 | int code = rules.GetLSLIntegerItem(idx++); | ||
7249 | |||
7250 | int remain = rules.Length - idx; | ||
7251 | |||
7252 | |||
7253 | |||
7254 | switch (code) | ||
7255 | { | ||
7256 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7257 | if (remain < 1) | ||
7258 | return; | ||
7259 | LSL_Vector v; | ||
7260 | v = rules.GetVector3Item(idx++); | ||
7261 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7262 | av.SendFullUpdateToAllClients(); | ||
7263 | |||
7264 | break; | ||
7265 | |||
7266 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7267 | if (remain < 1) | ||
7268 | return; | ||
7269 | LSL_Rotation r; | ||
7270 | r = rules.GetQuaternionItem(idx++); | ||
7271 | av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7272 | av.SendFullUpdateToAllClients(); | ||
7273 | break; | ||
7274 | } | ||
7275 | } | ||
7276 | |||
6934 | } | 7277 | } |
6935 | 7278 | ||
6936 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7279 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6937 | { | 7280 | { |
7281 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7282 | return; | ||
7283 | |||
6938 | int idx = 0; | 7284 | int idx = 0; |
6939 | 7285 | ||
6940 | while (idx < rules.Length) | 7286 | while (idx < rules.Length) |
@@ -7766,24 +8112,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7766 | break; | 8112 | break; |
7767 | 8113 | ||
7768 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8114 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7769 | // TODO-------------- | ||
7770 | if (remain < 1) | 8115 | if (remain < 1) |
7771 | return res; | 8116 | return res; |
8117 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7772 | 8118 | ||
7773 | face=(int)rules.GetLSLIntegerItem(idx++); | 8119 | tex = part.Shape.Textures; |
7774 | 8120 | int shiny; | |
7775 | res.Add(new LSL_Integer(0)); | 8121 | if (face == ScriptBaseClass.ALL_SIDES) |
7776 | res.Add(new LSL_Integer(0)); | 8122 | { |
8123 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8124 | { | ||
8125 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8126 | if (shinyness == Shininess.High) | ||
8127 | { | ||
8128 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8129 | } | ||
8130 | else if (shinyness == Shininess.Medium) | ||
8131 | { | ||
8132 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8133 | } | ||
8134 | else if (shinyness == Shininess.Low) | ||
8135 | { | ||
8136 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8137 | } | ||
8138 | else | ||
8139 | { | ||
8140 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8141 | } | ||
8142 | res.Add(new LSL_Integer(shiny)); | ||
8143 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8144 | } | ||
8145 | } | ||
8146 | else | ||
8147 | { | ||
8148 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8149 | if (shinyness == Shininess.High) | ||
8150 | { | ||
8151 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8152 | } | ||
8153 | else if (shinyness == Shininess.Medium) | ||
8154 | { | ||
8155 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8156 | } | ||
8157 | else if (shinyness == Shininess.Low) | ||
8158 | { | ||
8159 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8160 | } | ||
8161 | else | ||
8162 | { | ||
8163 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8164 | } | ||
8165 | res.Add(new LSL_Integer(shiny)); | ||
8166 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8167 | } | ||
7777 | break; | 8168 | break; |
7778 | 8169 | ||
7779 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8170 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7780 | // TODO-------------- | ||
7781 | if (remain < 1) | 8171 | if (remain < 1) |
7782 | return res; | 8172 | return res; |
8173 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7783 | 8174 | ||
7784 | face=(int)rules.GetLSLIntegerItem(idx++); | 8175 | tex = part.Shape.Textures; |
7785 | 8176 | int fullbright; | |
7786 | res.Add(new LSL_Integer(0)); | 8177 | if (face == ScriptBaseClass.ALL_SIDES) |
8178 | { | ||
8179 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8180 | { | ||
8181 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8182 | { | ||
8183 | fullbright = ScriptBaseClass.TRUE; | ||
8184 | } | ||
8185 | else | ||
8186 | { | ||
8187 | fullbright = ScriptBaseClass.FALSE; | ||
8188 | } | ||
8189 | res.Add(new LSL_Integer(fullbright)); | ||
8190 | } | ||
8191 | } | ||
8192 | else | ||
8193 | { | ||
8194 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8195 | { | ||
8196 | fullbright = ScriptBaseClass.TRUE; | ||
8197 | } | ||
8198 | else | ||
8199 | { | ||
8200 | fullbright = ScriptBaseClass.FALSE; | ||
8201 | } | ||
8202 | res.Add(new LSL_Integer(fullbright)); | ||
8203 | } | ||
7787 | break; | 8204 | break; |
7788 | 8205 | ||
7789 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8206 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7804,14 +8221,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7804 | break; | 8221 | break; |
7805 | 8222 | ||
7806 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8223 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7807 | // TODO-------------- | ||
7808 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8224 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7809 | if (remain < 1) | 8225 | if (remain < 1) |
7810 | return res; | 8226 | return res; |
8227 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7811 | 8228 | ||
7812 | face=(int)rules.GetLSLIntegerItem(idx++); | 8229 | tex = part.Shape.Textures; |
7813 | 8230 | if (face == ScriptBaseClass.ALL_SIDES) | |
7814 | res.Add(new LSL_Integer(0)); | 8231 | { |
8232 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8233 | { | ||
8234 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8235 | { | ||
8236 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8237 | } | ||
8238 | else | ||
8239 | { | ||
8240 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8241 | } | ||
8242 | } | ||
8243 | } | ||
8244 | else | ||
8245 | { | ||
8246 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8247 | { | ||
8248 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8249 | } | ||
8250 | else | ||
8251 | { | ||
8252 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8253 | } | ||
8254 | } | ||
7815 | break; | 8255 | break; |
7816 | 8256 | ||
7817 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8257 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7830,13 +8270,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7830 | break; | 8270 | break; |
7831 | 8271 | ||
7832 | case (int)ScriptBaseClass.PRIM_GLOW: | 8272 | case (int)ScriptBaseClass.PRIM_GLOW: |
7833 | // TODO-------------- | ||
7834 | if (remain < 1) | 8273 | if (remain < 1) |
7835 | return res; | 8274 | return res; |
8275 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7836 | 8276 | ||
7837 | face=(int)rules.GetLSLIntegerItem(idx++); | 8277 | tex = part.Shape.Textures; |
7838 | 8278 | float primglow; | |
7839 | res.Add(new LSL_Float(0)); | 8279 | if (face == ScriptBaseClass.ALL_SIDES) |
8280 | { | ||
8281 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8282 | { | ||
8283 | primglow = tex.GetFace((uint)face).Glow; | ||
8284 | res.Add(new LSL_Float(primglow)); | ||
8285 | } | ||
8286 | } | ||
8287 | else | ||
8288 | { | ||
8289 | primglow = tex.GetFace((uint)face).Glow; | ||
8290 | res.Add(new LSL_Float(primglow)); | ||
8291 | } | ||
7840 | break; | 8292 | break; |
7841 | case (int)ScriptBaseClass.PRIM_TEXT: | 8293 | case (int)ScriptBaseClass.PRIM_TEXT: |
7842 | Color4 textColor = part.GetTextColor(); | 8294 | Color4 textColor = part.GetTextColor(); |
@@ -8377,8 +8829,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8377 | // The function returns an ordered list | 8829 | // The function returns an ordered list |
8378 | // representing the tokens found in the supplied | 8830 | // representing the tokens found in the supplied |
8379 | // sources string. If two successive tokenizers | 8831 | // sources string. If two successive tokenizers |
8380 | // are encountered, then a NULL entry is added | 8832 | // are encountered, then a null-string entry is |
8381 | // to the list. | 8833 | // added to the list. |
8382 | // | 8834 | // |
8383 | // It is a precondition that the source and | 8835 | // It is a precondition that the source and |
8384 | // toekizer lisst are non-null. If they are null, | 8836 | // toekizer lisst are non-null. If they are null, |
@@ -8386,7 +8838,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8386 | // while their lengths are being determined. | 8838 | // while their lengths are being determined. |
8387 | // | 8839 | // |
8388 | // A small amount of working memoryis required | 8840 | // A small amount of working memoryis required |
8389 | // of approximately 8*#tokenizers. | 8841 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8390 | // | 8842 | // |
8391 | // There are many ways in which this function | 8843 | // There are many ways in which this function |
8392 | // can be implemented, this implementation is | 8844 | // can be implemented, this implementation is |
@@ -8402,136 +8854,111 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8402 | // and eliminates redundant tokenizers as soon | 8854 | // and eliminates redundant tokenizers as soon |
8403 | // as is possible. | 8855 | // as is possible. |
8404 | // | 8856 | // |
8405 | // The implementation tries to avoid any copying | 8857 | // The implementation tries to minimize temporary |
8406 | // of arrays or other objects. | 8858 | // garbage generation. |
8407 | // </remarks> | 8859 | // </remarks> |
8408 | 8860 | ||
8409 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8861 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8410 | { | 8862 | { |
8411 | int beginning = 0; | 8863 | return ParseString2List(src, separators, spacers, true); |
8412 | int srclen = src.Length; | 8864 | } |
8413 | int seplen = separators.Length; | ||
8414 | object[] separray = separators.Data; | ||
8415 | int spclen = spacers.Length; | ||
8416 | object[] spcarray = spacers.Data; | ||
8417 | int mlen = seplen+spclen; | ||
8418 | |||
8419 | int[] offset = new int[mlen+1]; | ||
8420 | bool[] active = new bool[mlen]; | ||
8421 | 8865 | ||
8422 | int best; | 8866 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8423 | int j; | 8867 | { |
8868 | int srclen = src.Length; | ||
8869 | int seplen = separators.Length; | ||
8870 | object[] separray = separators.Data; | ||
8871 | int spclen = spacers.Length; | ||
8872 | object[] spcarray = spacers.Data; | ||
8873 | int dellen = 0; | ||
8874 | string[] delarray = new string[seplen+spclen]; | ||
8424 | 8875 | ||
8425 | // Initial capacity reduces resize cost | 8876 | int outlen = 0; |
8877 | string[] outarray = new string[srclen*2+1]; | ||
8426 | 8878 | ||
8427 | LSL_List tokens = new LSL_List(); | 8879 | int i, j; |
8880 | string d; | ||
8428 | 8881 | ||
8429 | m_host.AddScriptLPS(1); | 8882 | m_host.AddScriptLPS(1); |
8430 | 8883 | ||
8431 | // All entries are initially valid | 8884 | /* |
8432 | 8885 | * Convert separator and spacer lists to C# strings. | |
8433 | for (int i = 0; i < mlen; i++) | 8886 | * Also filter out null strings so we don't hang. |
8434 | active[i] = true; | 8887 | */ |
8435 | 8888 | for (i = 0; i < seplen; i ++) { | |
8436 | offset[mlen] = srclen; | 8889 | d = separray[i].ToString(); |
8437 | 8890 | if (d.Length > 0) { | |
8438 | while (beginning < srclen) | 8891 | delarray[dellen++] = d; |
8439 | { | 8892 | } |
8440 | 8893 | } | |
8441 | best = mlen; // as bad as it gets | 8894 | seplen = dellen; |
8442 | |||
8443 | // Scan for separators | ||
8444 | 8895 | ||
8445 | for (j = 0; j < seplen; j++) | 8896 | for (i = 0; i < spclen; i ++) { |
8446 | { | 8897 | d = spcarray[i].ToString(); |
8447 | if (active[j]) | 8898 | if (d.Length > 0) { |
8448 | { | 8899 | delarray[dellen++] = d; |
8449 | // scan all of the markers | ||
8450 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | ||
8451 | { | ||
8452 | // not present at all | ||
8453 | active[j] = false; | ||
8454 | } | ||
8455 | else | ||
8456 | { | ||
8457 | // present and correct | ||
8458 | if (offset[j] < offset[best]) | ||
8459 | { | ||
8460 | // closest so far | ||
8461 | best = j; | ||
8462 | if (offset[best] == beginning) | ||
8463 | break; | ||
8464 | } | ||
8465 | } | ||
8466 | } | ||
8467 | } | 8900 | } |
8901 | } | ||
8468 | 8902 | ||
8469 | // Scan for spacers | 8903 | /* |
8904 | * Scan through source string from beginning to end. | ||
8905 | */ | ||
8906 | for (i = 0;;) { | ||
8470 | 8907 | ||
8471 | if (offset[best] != beginning) | 8908 | /* |
8472 | { | 8909 | * Find earliest delimeter in src starting at i (if any). |
8473 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 8910 | */ |
8474 | { | 8911 | int earliestDel = -1; |
8475 | if (active[j]) | 8912 | int earliestSrc = srclen; |
8476 | { | 8913 | string earliestStr = null; |
8477 | // scan all of the markers | 8914 | for (j = 0; j < dellen; j ++) { |
8478 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | 8915 | d = delarray[j]; |
8479 | { | 8916 | if (d != null) { |
8480 | // not present at all | 8917 | int index = src.IndexOf(d, i); |
8481 | active[j] = false; | 8918 | if (index < 0) { |
8482 | } | 8919 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8483 | else | 8920 | } else if (index < earliestSrc) { |
8484 | { | 8921 | earliestSrc = index; // where delimeter starts in source string |
8485 | // present and correct | 8922 | earliestDel = j; // where delimeter is in delarray[] |
8486 | if (offset[j] < offset[best]) | 8923 | earliestStr = d; // the delimeter string from delarray[] |
8487 | { | 8924 | if (index == i) break; // can't do any better than found at beg of string |
8488 | // closest so far | ||
8489 | best = j; | ||
8490 | } | ||
8491 | } | ||
8492 | } | 8925 | } |
8493 | } | 8926 | } |
8494 | } | 8927 | } |
8495 | 8928 | ||
8496 | // This is the normal exit from the scanning loop | 8929 | /* |
8497 | 8930 | * Output source string starting at i through start of earliest delimeter. | |
8498 | if (best == mlen) | 8931 | */ |
8499 | { | 8932 | if (keepNulls || (earliestSrc > i)) { |
8500 | // no markers were found on this pass | 8933 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8501 | // so we're pretty much done | ||
8502 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8503 | break; | ||
8504 | } | 8934 | } |
8505 | 8935 | ||
8506 | // Otherwise we just add the newly delimited token | 8936 | /* |
8507 | // and recalculate where the search should continue. | 8937 | * If no delimeter found at or after i, we're done scanning. |
8508 | 8938 | */ | |
8509 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 8939 | if (earliestDel < 0) break; |
8510 | 8940 | ||
8511 | if (best < seplen) | 8941 | /* |
8512 | { | 8942 | * If delimeter was a spacer, output the spacer. |
8513 | beginning = offset[best] + (separray[best].ToString()).Length; | 8943 | */ |
8944 | if (earliestDel >= seplen) { | ||
8945 | outarray[outlen++] = earliestStr; | ||
8514 | } | 8946 | } |
8515 | else | ||
8516 | { | ||
8517 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8518 | tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); | ||
8519 | } | ||
8520 | } | ||
8521 | |||
8522 | // This an awkward an not very intuitive boundary case. If the | ||
8523 | // last substring is a tokenizer, then there is an implied trailing | ||
8524 | // null list entry. Hopefully the single comparison will not be too | ||
8525 | // arduous. Alternatively the 'break' could be replced with a return | ||
8526 | // but that's shabby programming. | ||
8527 | 8947 | ||
8528 | if (beginning == srclen) | 8948 | /* |
8529 | { | 8949 | * Look at rest of src string following delimeter. |
8530 | if (srclen != 0) | 8950 | */ |
8531 | tokens.Add(new LSL_String("")); | 8951 | i = earliestSrc + earliestStr.Length; |
8532 | } | 8952 | } |
8533 | 8953 | ||
8534 | return tokens; | 8954 | /* |
8955 | * Make up an exact-sized output array suitable for an LSL_List object. | ||
8956 | */ | ||
8957 | object[] outlist = new object[outlen]; | ||
8958 | for (i = 0; i < outlen; i ++) { | ||
8959 | outlist[i] = new LSL_String(outarray[i]); | ||
8960 | } | ||
8961 | return new LSL_List(outlist); | ||
8535 | } | 8962 | } |
8536 | 8963 | ||
8537 | public LSL_Integer llGetObjectPermMask(int mask) | 8964 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -8608,28 +9035,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8608 | { | 9035 | { |
8609 | m_host.AddScriptLPS(1); | 9036 | m_host.AddScriptLPS(1); |
8610 | 9037 | ||
8611 | lock (m_host.TaskInventory) | 9038 | m_host.TaskInventory.LockItemsForRead(true); |
9039 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8612 | { | 9040 | { |
8613 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9041 | if (inv.Value.Name == item) |
8614 | { | 9042 | { |
8615 | if (inv.Value.Name == item) | 9043 | m_host.TaskInventory.LockItemsForRead(false); |
9044 | switch (mask) | ||
8616 | { | 9045 | { |
8617 | switch (mask) | 9046 | case 0: |
8618 | { | 9047 | return (int)inv.Value.BasePermissions; |
8619 | case 0: | 9048 | case 1: |
8620 | return (int)inv.Value.BasePermissions; | 9049 | return (int)inv.Value.CurrentPermissions; |
8621 | case 1: | 9050 | case 2: |
8622 | return (int)inv.Value.CurrentPermissions; | 9051 | return (int)inv.Value.GroupPermissions; |
8623 | case 2: | 9052 | case 3: |
8624 | return (int)inv.Value.GroupPermissions; | 9053 | return (int)inv.Value.EveryonePermissions; |
8625 | case 3: | 9054 | case 4: |
8626 | return (int)inv.Value.EveryonePermissions; | 9055 | return (int)inv.Value.NextPermissions; |
8627 | case 4: | ||
8628 | return (int)inv.Value.NextPermissions; | ||
8629 | } | ||
8630 | } | 9056 | } |
8631 | } | 9057 | } |
8632 | } | 9058 | } |
9059 | m_host.TaskInventory.LockItemsForRead(false); | ||
8633 | 9060 | ||
8634 | return -1; | 9061 | return -1; |
8635 | } | 9062 | } |
@@ -8676,16 +9103,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8676 | { | 9103 | { |
8677 | m_host.AddScriptLPS(1); | 9104 | m_host.AddScriptLPS(1); |
8678 | 9105 | ||
8679 | lock (m_host.TaskInventory) | 9106 | m_host.TaskInventory.LockItemsForRead(true); |
9107 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8680 | { | 9108 | { |
8681 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9109 | if (inv.Value.Name == item) |
8682 | { | 9110 | { |
8683 | if (inv.Value.Name == item) | 9111 | m_host.TaskInventory.LockItemsForRead(false); |
8684 | { | 9112 | return inv.Value.CreatorID.ToString(); |
8685 | return inv.Value.CreatorID.ToString(); | ||
8686 | } | ||
8687 | } | 9113 | } |
8688 | } | 9114 | } |
9115 | m_host.TaskInventory.LockItemsForRead(false); | ||
8689 | 9116 | ||
8690 | llSay(0, "No item name '" + item + "'"); | 9117 | llSay(0, "No item name '" + item + "'"); |
8691 | 9118 | ||
@@ -8731,8 +9158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8731 | return UUID.Zero.ToString(); | 9158 | return UUID.Zero.ToString(); |
8732 | } | 9159 | } |
8733 | reply = new LSL_Vector( | 9160 | reply = new LSL_Vector( |
8734 | info.RegionLocX * Constants.RegionSize, | 9161 | info.RegionLocX, |
8735 | info.RegionLocY * Constants.RegionSize, | 9162 | info.RegionLocY, |
8736 | 0).ToString(); | 9163 | 0).ToString(); |
8737 | break; | 9164 | break; |
8738 | case 6: // DATA_SIM_STATUS | 9165 | case 6: // DATA_SIM_STATUS |
@@ -8945,17 +9372,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8945 | int width = 0; | 9372 | int width = 0; |
8946 | int height = 0; | 9373 | int height = 0; |
8947 | 9374 | ||
8948 | ParcelMediaCommandEnum? commandToSend = null; | 9375 | uint commandToSend = 0; |
8949 | float time = 0.0f; // default is from start | 9376 | float time = 0.0f; // default is from start |
8950 | 9377 | ||
8951 | ScenePresence presence = null; | 9378 | ScenePresence presence = null; |
8952 | 9379 | ||
8953 | for (int i = 0; i < commandList.Data.Length; i++) | 9380 | for (int i = 0; i < commandList.Data.Length; i++) |
8954 | { | 9381 | { |
8955 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9382 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8956 | switch (command) | 9383 | switch (command) |
8957 | { | 9384 | { |
8958 | case ParcelMediaCommandEnum.Agent: | 9385 | case (uint)ParcelMediaCommandEnum.Agent: |
8959 | // we send only to one agent | 9386 | // we send only to one agent |
8960 | if ((i + 1) < commandList.Length) | 9387 | if ((i + 1) < commandList.Length) |
8961 | { | 9388 | { |
@@ -8972,25 +9399,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8972 | } | 9399 | } |
8973 | break; | 9400 | break; |
8974 | 9401 | ||
8975 | case ParcelMediaCommandEnum.Loop: | 9402 | case (uint)ParcelMediaCommandEnum.Loop: |
8976 | loop = 1; | 9403 | loop = 1; |
8977 | commandToSend = command; | 9404 | commandToSend = command; |
8978 | update = true; //need to send the media update packet to set looping | 9405 | update = true; //need to send the media update packet to set looping |
8979 | break; | 9406 | break; |
8980 | 9407 | ||
8981 | case ParcelMediaCommandEnum.Play: | 9408 | case (uint)ParcelMediaCommandEnum.Play: |
8982 | loop = 0; | 9409 | loop = 0; |
8983 | commandToSend = command; | 9410 | commandToSend = command; |
8984 | update = true; //need to send the media update packet to make sure it doesn't loop | 9411 | update = true; //need to send the media update packet to make sure it doesn't loop |
8985 | break; | 9412 | break; |
8986 | 9413 | ||
8987 | case ParcelMediaCommandEnum.Pause: | 9414 | case (uint)ParcelMediaCommandEnum.Pause: |
8988 | case ParcelMediaCommandEnum.Stop: | 9415 | case (uint)ParcelMediaCommandEnum.Stop: |
8989 | case ParcelMediaCommandEnum.Unload: | 9416 | case (uint)ParcelMediaCommandEnum.Unload: |
8990 | commandToSend = command; | 9417 | commandToSend = command; |
8991 | break; | 9418 | break; |
8992 | 9419 | ||
8993 | case ParcelMediaCommandEnum.Url: | 9420 | case (uint)ParcelMediaCommandEnum.Url: |
8994 | if ((i + 1) < commandList.Length) | 9421 | if ((i + 1) < commandList.Length) |
8995 | { | 9422 | { |
8996 | if (commandList.Data[i + 1] is LSL_String) | 9423 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9003,7 +9430,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9003 | } | 9430 | } |
9004 | break; | 9431 | break; |
9005 | 9432 | ||
9006 | case ParcelMediaCommandEnum.Texture: | 9433 | case (uint)ParcelMediaCommandEnum.Texture: |
9007 | if ((i + 1) < commandList.Length) | 9434 | if ((i + 1) < commandList.Length) |
9008 | { | 9435 | { |
9009 | if (commandList.Data[i + 1] is LSL_String) | 9436 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9016,7 +9443,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9016 | } | 9443 | } |
9017 | break; | 9444 | break; |
9018 | 9445 | ||
9019 | case ParcelMediaCommandEnum.Time: | 9446 | case (uint)ParcelMediaCommandEnum.Time: |
9020 | if ((i + 1) < commandList.Length) | 9447 | if ((i + 1) < commandList.Length) |
9021 | { | 9448 | { |
9022 | if (commandList.Data[i + 1] is LSL_Float) | 9449 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9028,7 +9455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9028 | } | 9455 | } |
9029 | break; | 9456 | break; |
9030 | 9457 | ||
9031 | case ParcelMediaCommandEnum.AutoAlign: | 9458 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9032 | if ((i + 1) < commandList.Length) | 9459 | if ((i + 1) < commandList.Length) |
9033 | { | 9460 | { |
9034 | if (commandList.Data[i + 1] is LSL_Integer) | 9461 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9042,7 +9469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9042 | } | 9469 | } |
9043 | break; | 9470 | break; |
9044 | 9471 | ||
9045 | case ParcelMediaCommandEnum.Type: | 9472 | case (uint)ParcelMediaCommandEnum.Type: |
9046 | if ((i + 1) < commandList.Length) | 9473 | if ((i + 1) < commandList.Length) |
9047 | { | 9474 | { |
9048 | if (commandList.Data[i + 1] is LSL_String) | 9475 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9055,7 +9482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9055 | } | 9482 | } |
9056 | break; | 9483 | break; |
9057 | 9484 | ||
9058 | case ParcelMediaCommandEnum.Desc: | 9485 | case (uint)ParcelMediaCommandEnum.Desc: |
9059 | if ((i + 1) < commandList.Length) | 9486 | if ((i + 1) < commandList.Length) |
9060 | { | 9487 | { |
9061 | if (commandList.Data[i + 1] is LSL_String) | 9488 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9068,7 +9495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9068 | } | 9495 | } |
9069 | break; | 9496 | break; |
9070 | 9497 | ||
9071 | case ParcelMediaCommandEnum.Size: | 9498 | case (uint)ParcelMediaCommandEnum.Size: |
9072 | if ((i + 2) < commandList.Length) | 9499 | if ((i + 2) < commandList.Length) |
9073 | { | 9500 | { |
9074 | if (commandList.Data[i + 1] is LSL_Integer) | 9501 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9138,7 +9565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9138 | } | 9565 | } |
9139 | } | 9566 | } |
9140 | 9567 | ||
9141 | if (commandToSend != null) | 9568 | if (commandToSend != 0) |
9142 | { | 9569 | { |
9143 | // the commandList contained a start/stop/... command, too | 9570 | // the commandList contained a start/stop/... command, too |
9144 | if (presence == null) | 9571 | if (presence == null) |
@@ -9175,7 +9602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9175 | 9602 | ||
9176 | if (aList.Data[i] != null) | 9603 | if (aList.Data[i] != null) |
9177 | { | 9604 | { |
9178 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 9605 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9179 | { | 9606 | { |
9180 | case ParcelMediaCommandEnum.Url: | 9607 | case ParcelMediaCommandEnum.Url: |
9181 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 9608 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9218,16 +9645,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9218 | { | 9645 | { |
9219 | m_host.AddScriptLPS(1); | 9646 | m_host.AddScriptLPS(1); |
9220 | 9647 | ||
9221 | lock (m_host.TaskInventory) | 9648 | m_host.TaskInventory.LockItemsForRead(true); |
9649 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9222 | { | 9650 | { |
9223 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9651 | if (inv.Value.Name == name) |
9224 | { | 9652 | { |
9225 | if (inv.Value.Name == name) | 9653 | m_host.TaskInventory.LockItemsForRead(false); |
9226 | { | 9654 | return inv.Value.Type; |
9227 | return inv.Value.Type; | ||
9228 | } | ||
9229 | } | 9655 | } |
9230 | } | 9656 | } |
9657 | m_host.TaskInventory.LockItemsForRead(false); | ||
9231 | 9658 | ||
9232 | return -1; | 9659 | return -1; |
9233 | } | 9660 | } |
@@ -9238,15 +9665,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9238 | 9665 | ||
9239 | if (quick_pay_buttons.Data.Length < 4) | 9666 | if (quick_pay_buttons.Data.Length < 4) |
9240 | { | 9667 | { |
9241 | LSLError("List must have at least 4 elements"); | 9668 | int x; |
9242 | return; | 9669 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9670 | { | ||
9671 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9672 | } | ||
9243 | } | 9673 | } |
9244 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9674 | int[] nPrice = new int[5]; |
9245 | 9675 | nPrice[0]=price; | |
9246 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9676 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
9247 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9677 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
9248 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9678 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
9249 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9679 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9680 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9250 | m_host.ParentGroup.HasGroupChanged = true; | 9681 | m_host.ParentGroup.HasGroupChanged = true; |
9251 | } | 9682 | } |
9252 | 9683 | ||
@@ -9258,17 +9689,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9258 | if (invItemID == UUID.Zero) | 9689 | if (invItemID == UUID.Zero) |
9259 | return new LSL_Vector(); | 9690 | return new LSL_Vector(); |
9260 | 9691 | ||
9261 | lock (m_host.TaskInventory) | 9692 | m_host.TaskInventory.LockItemsForRead(true); |
9693 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9262 | { | 9694 | { |
9263 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9695 | m_host.TaskInventory.LockItemsForRead(false); |
9264 | return new LSL_Vector(); | 9696 | return new LSL_Vector(); |
9697 | } | ||
9265 | 9698 | ||
9266 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9699 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9267 | { | 9700 | { |
9268 | ShoutError("No permissions to track the camera"); | 9701 | ShoutError("No permissions to track the camera"); |
9269 | return new LSL_Vector(); | 9702 | m_host.TaskInventory.LockItemsForRead(false); |
9270 | } | 9703 | return new LSL_Vector(); |
9271 | } | 9704 | } |
9705 | m_host.TaskInventory.LockItemsForRead(false); | ||
9272 | 9706 | ||
9273 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9707 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9274 | if (presence != null) | 9708 | if (presence != null) |
@@ -9286,17 +9720,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9286 | if (invItemID == UUID.Zero) | 9720 | if (invItemID == UUID.Zero) |
9287 | return new LSL_Rotation(); | 9721 | return new LSL_Rotation(); |
9288 | 9722 | ||
9289 | lock (m_host.TaskInventory) | 9723 | m_host.TaskInventory.LockItemsForRead(true); |
9724 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
9290 | { | 9725 | { |
9291 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9726 | m_host.TaskInventory.LockItemsForRead(false); |
9292 | return new LSL_Rotation(); | 9727 | return new LSL_Rotation(); |
9293 | 9728 | } | |
9294 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9729 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
9295 | { | 9730 | { |
9296 | ShoutError("No permissions to track the camera"); | 9731 | ShoutError("No permissions to track the camera"); |
9297 | return new LSL_Rotation(); | 9732 | m_host.TaskInventory.LockItemsForRead(false); |
9298 | } | 9733 | return new LSL_Rotation(); |
9299 | } | 9734 | } |
9735 | m_host.TaskInventory.LockItemsForRead(false); | ||
9300 | 9736 | ||
9301 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9737 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
9302 | if (presence != null) | 9738 | if (presence != null) |
@@ -9358,8 +9794,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9358 | { | 9794 | { |
9359 | m_host.AddScriptLPS(1); | 9795 | m_host.AddScriptLPS(1); |
9360 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9796 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9361 | if (detectedParams == null) return; // only works on the first detected avatar | 9797 | if (detectedParams == null) |
9362 | 9798 | { | |
9799 | if (m_host.IsAttachment == true) | ||
9800 | { | ||
9801 | detectedParams = new DetectParams(); | ||
9802 | detectedParams.Key = m_host.OwnerID; | ||
9803 | } | ||
9804 | else | ||
9805 | { | ||
9806 | return; | ||
9807 | } | ||
9808 | } | ||
9809 | |||
9363 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9810 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9364 | if (avatar != null) | 9811 | if (avatar != null) |
9365 | { | 9812 | { |
@@ -9367,6 +9814,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9367 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9814 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9368 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9815 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9369 | } | 9816 | } |
9817 | |||
9370 | ScriptSleep(1000); | 9818 | ScriptSleep(1000); |
9371 | } | 9819 | } |
9372 | 9820 | ||
@@ -9446,14 +9894,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9446 | if (objectID == UUID.Zero) return; | 9894 | if (objectID == UUID.Zero) return; |
9447 | 9895 | ||
9448 | UUID agentID; | 9896 | UUID agentID; |
9449 | lock (m_host.TaskInventory) | 9897 | m_host.TaskInventory.LockItemsForRead(true); |
9450 | { | 9898 | // we need the permission first, to know which avatar we want to set the camera for |
9451 | // we need the permission first, to know which avatar we want to set the camera for | 9899 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9452 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9453 | 9900 | ||
9454 | if (agentID == UUID.Zero) return; | 9901 | if (agentID == UUID.Zero) |
9455 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9902 | { |
9903 | m_host.TaskInventory.LockItemsForRead(false); | ||
9904 | return; | ||
9905 | } | ||
9906 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9907 | { | ||
9908 | m_host.TaskInventory.LockItemsForRead(false); | ||
9909 | return; | ||
9456 | } | 9910 | } |
9911 | m_host.TaskInventory.LockItemsForRead(false); | ||
9457 | 9912 | ||
9458 | ScenePresence presence = World.GetScenePresence(agentID); | 9913 | ScenePresence presence = World.GetScenePresence(agentID); |
9459 | 9914 | ||
@@ -9503,12 +9958,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9503 | 9958 | ||
9504 | // we need the permission first, to know which avatar we want to clear the camera for | 9959 | // we need the permission first, to know which avatar we want to clear the camera for |
9505 | UUID agentID; | 9960 | UUID agentID; |
9506 | lock (m_host.TaskInventory) | 9961 | m_host.TaskInventory.LockItemsForRead(true); |
9962 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9963 | if (agentID == UUID.Zero) | ||
9964 | { | ||
9965 | m_host.TaskInventory.LockItemsForRead(false); | ||
9966 | return; | ||
9967 | } | ||
9968 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9507 | { | 9969 | { |
9508 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9970 | m_host.TaskInventory.LockItemsForRead(false); |
9509 | if (agentID == UUID.Zero) return; | 9971 | return; |
9510 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9511 | } | 9972 | } |
9973 | m_host.TaskInventory.LockItemsForRead(false); | ||
9512 | 9974 | ||
9513 | ScenePresence presence = World.GetScenePresence(agentID); | 9975 | ScenePresence presence = World.GetScenePresence(agentID); |
9514 | 9976 | ||
@@ -9575,19 +10037,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9575 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 10037 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
9576 | { | 10038 | { |
9577 | m_host.AddScriptLPS(1); | 10039 | m_host.AddScriptLPS(1); |
9578 | string ret = String.Empty; | 10040 | |
9579 | string src1 = llBase64ToString(str1); | 10041 | if (str1 == String.Empty) |
9580 | string src2 = llBase64ToString(str2); | 10042 | return String.Empty; |
9581 | int c = 0; | 10043 | if (str2 == String.Empty) |
9582 | for (int i = 0; i < src1.Length; i++) | 10044 | return str1; |
10045 | |||
10046 | byte[] data1 = Convert.FromBase64String(str1); | ||
10047 | byte[] data2 = Convert.FromBase64String(str2); | ||
10048 | |||
10049 | byte[] d2 = new Byte[data1.Length]; | ||
10050 | int pos = 0; | ||
10051 | |||
10052 | if (data1.Length <= data2.Length) | ||
9583 | { | 10053 | { |
9584 | ret += (char) (src1[i] ^ src2[c]); | 10054 | Array.Copy(data2, 0, d2, 0, data1.Length); |
10055 | } | ||
10056 | else | ||
10057 | { | ||
10058 | while (pos < data1.Length) | ||
10059 | { | ||
10060 | int len = data1.Length - pos; | ||
10061 | if (len > data2.Length) | ||
10062 | len = data2.Length; | ||
9585 | 10063 | ||
9586 | c++; | 10064 | Array.Copy(data2, 0, d2, pos, len); |
9587 | if (c >= src2.Length) | 10065 | pos += len; |
9588 | c = 0; | 10066 | } |
9589 | } | 10067 | } |
9590 | return llStringToBase64(ret); | 10068 | |
10069 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
10070 | data1[pos] ^= d2[pos]; | ||
10071 | |||
10072 | return Convert.ToBase64String(data1); | ||
9591 | } | 10073 | } |
9592 | 10074 | ||
9593 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 10075 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -9965,15 +10447,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9965 | 10447 | ||
9966 | internal UUID ScriptByName(string name) | 10448 | internal UUID ScriptByName(string name) |
9967 | { | 10449 | { |
9968 | lock (m_host.TaskInventory) | 10450 | m_host.TaskInventory.LockItemsForRead(true); |
10451 | |||
10452 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9969 | { | 10453 | { |
9970 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10454 | if (item.Type == 10 && item.Name == name) |
9971 | { | 10455 | { |
9972 | if (item.Type == 10 && item.Name == name) | 10456 | m_host.TaskInventory.LockItemsForRead(false); |
9973 | return item.ItemID; | 10457 | return item.ItemID; |
9974 | } | 10458 | } |
9975 | } | 10459 | } |
9976 | 10460 | ||
10461 | m_host.TaskInventory.LockItemsForRead(false); | ||
10462 | |||
9977 | return UUID.Zero; | 10463 | return UUID.Zero; |
9978 | } | 10464 | } |
9979 | 10465 | ||
@@ -10014,6 +10500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10014 | { | 10500 | { |
10015 | m_host.AddScriptLPS(1); | 10501 | m_host.AddScriptLPS(1); |
10016 | 10502 | ||
10503 | //Clone is thread safe | ||
10017 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10504 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10018 | 10505 | ||
10019 | UUID assetID = UUID.Zero; | 10506 | UUID assetID = UUID.Zero; |
@@ -10076,6 +10563,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10076 | { | 10563 | { |
10077 | m_host.AddScriptLPS(1); | 10564 | m_host.AddScriptLPS(1); |
10078 | 10565 | ||
10566 | //Clone is thread safe | ||
10079 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10567 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10080 | 10568 | ||
10081 | UUID assetID = UUID.Zero; | 10569 | 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 5ae6439..f0384f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -1,504 +1,507 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim; | 35 | using OpenSim; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Region.CoreModules.World.LightShare; | 37 | using OpenSim.Region.CoreModules.World.LightShare; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Region.ScriptEngine.Shared; | 40 | using OpenSim.Region.ScriptEngine.Shared; |
41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
43 | using OpenSim.Region.ScriptEngine.Interfaces; | 43 | using OpenSim.Region.ScriptEngine.Interfaces; |
44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | 44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; |
45 | 45 | ||
46 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 46 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
47 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 47 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
48 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 48 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
49 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | 49 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; |
50 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 50 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; |
51 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 51 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
52 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 52 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
53 | 53 | ||
54 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 54 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
55 | { | 55 | { |
56 | [Serializable] | 56 | [Serializable] |
57 | public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi | 57 | public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi |
58 | { | 58 | { |
59 | internal IScriptEngine m_ScriptEngine; | 59 | internal IScriptEngine m_ScriptEngine; |
60 | internal SceneObjectPart m_host; | 60 | internal SceneObjectPart m_host; |
61 | internal uint m_localID; | 61 | internal uint m_localID; |
62 | internal UUID m_itemID; | 62 | internal UUID m_itemID; |
63 | internal bool m_LSFunctionsEnabled = false; | 63 | internal bool m_LSFunctionsEnabled = false; |
64 | internal IScriptModuleComms m_comms = null; | 64 | internal IScriptModuleComms m_comms = null; |
65 | 65 | ||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) |
67 | { | 67 | { |
68 | m_ScriptEngine = ScriptEngine; | 68 | m_ScriptEngine = ScriptEngine; |
69 | m_host = host; | 69 | m_host = host; |
70 | m_localID = localID; | 70 | m_localID = localID; |
71 | m_itemID = itemID; | 71 | m_itemID = itemID; |
72 | 72 | ||
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 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | 76 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) |
77 | if (m_comms == null) | 77 | m_LSFunctionsEnabled = true; |
78 | m_LSFunctionsEnabled = false; | 78 | |
79 | } | 79 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); |
80 | 80 | if (m_comms == null) | |
81 | public override Object InitializeLifetimeService() | 81 | m_LSFunctionsEnabled = false; |
82 | { | 82 | } |
83 | ILease lease = (ILease)base.InitializeLifetimeService(); | 83 | |
84 | 84 | public override Object InitializeLifetimeService() | |
85 | if (lease.CurrentState == LeaseState.Initial) | 85 | { |
86 | { | 86 | ILease lease = (ILease)base.InitializeLifetimeService(); |
87 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | 87 | |
88 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | 88 | if (lease.CurrentState == LeaseState.Initial) |
89 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | 89 | { |
90 | } | 90 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); |
91 | return lease; | 91 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); |
92 | } | 92 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); |
93 | 93 | } | |
94 | public Scene World | 94 | return lease; |
95 | { | 95 | } |
96 | get { return m_ScriptEngine.World; } | 96 | |
97 | } | 97 | public Scene World |
98 | 98 | { | |
99 | // | 99 | get { return m_ScriptEngine.World; } |
100 | //Dumps an error message on the debug console. | 100 | } |
101 | // | 101 | |
102 | 102 | // | |
103 | internal void LSShoutError(string message) | 103 | //Dumps an error message on the debug console. |
104 | { | 104 | // |
105 | if (message.Length > 1023) | 105 | |
106 | message = message.Substring(0, 1023); | 106 | internal void LSShoutError(string message) |
107 | 107 | { | |
108 | World.SimChat(Utils.StringToBytes(message), | 108 | if (message.Length > 1023) |
109 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | 109 | message = message.Substring(0, 1023); |
110 | 110 | ||
111 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 111 | World.SimChat(Utils.StringToBytes(message), |
112 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 112 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); |
113 | } | 113 | |
114 | 114 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | |
115 | /// <summary> | 115 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
116 | /// Get the current Windlight scene | 116 | } |
117 | /// </summary> | 117 | |
118 | /// <returns>List of windlight parameters</returns> | 118 | /// <summary> |
119 | public LSL_List lsGetWindlightScene(LSL_List rules) | 119 | /// Get the current Windlight scene |
120 | { | 120 | /// </summary> |
121 | if (!m_LSFunctionsEnabled) | 121 | /// <returns>List of windlight parameters</returns> |
122 | { | 122 | public LSL_List lsGetWindlightScene(LSL_List rules) |
123 | LSShoutError("LightShare functions are not enabled."); | 123 | { |
124 | return new LSL_List(); | 124 | if (!m_LSFunctionsEnabled) |
125 | } | 125 | { |
126 | m_host.AddScriptLPS(1); | 126 | LSShoutError("LightShare functions are not enabled."); |
127 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | 127 | return new LSL_List(); |
128 | 128 | } | |
129 | LSL_List values = new LSL_List(); | 129 | m_host.AddScriptLPS(1); |
130 | int idx = 0; | 130 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; |
131 | while (idx < rules.Length) | 131 | |
132 | { | 132 | LSL_List values = new LSL_List(); |
133 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | 133 | int idx = 0; |
134 | LSL_List toadd = new LSL_List(); | 134 | while (idx < rules.Length) |
135 | 135 | { | |
136 | switch (rule) | 136 | uint rule = (uint)rules.GetLSLIntegerItem(idx); |
137 | { | 137 | LSL_List toadd = new LSL_List(); |
138 | case (int)ScriptBaseClass.WL_AMBIENT: | 138 | |
139 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | 139 | switch (rule) |
140 | break; | 140 | { |
141 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | 141 | case (int)ScriptBaseClass.WL_AMBIENT: |
142 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | 142 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); |
143 | break; | 143 | break; |
144 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | 144 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: |
145 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | 145 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); |
146 | break; | 146 | break; |
147 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | 147 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: |
148 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | 148 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); |
149 | break; | 149 | break; |
150 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | 150 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: |
151 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | 151 | toadd.Add(new LSL_Float(wl.blurMultiplier)); |
152 | break; | 152 | break; |
153 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | 153 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: |
154 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | 154 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); |
155 | break; | 155 | break; |
156 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | 156 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: |
157 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | 157 | toadd.Add(new LSL_Float(wl.cloudCoverage)); |
158 | break; | 158 | break; |
159 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | 159 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
160 | toadd.Add(new LSL_Float(wl.cloudScale)); | 160 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); |
161 | break; | 161 | break; |
162 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | 162 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
163 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | 163 | toadd.Add(new LSL_Float(wl.cloudScale)); |
164 | break; | 164 | break; |
165 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | 165 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: |
166 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | 166 | toadd.Add(new LSL_Float(wl.cloudScrollX)); |
167 | break; | 167 | break; |
168 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | 168 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: |
169 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | 169 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); |
170 | break; | 170 | break; |
171 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | 171 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: |
172 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | 172 | toadd.Add(new LSL_Float(wl.cloudScrollY)); |
173 | break; | 173 | break; |
174 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | 174 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: |
175 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | 175 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); |
176 | break; | 176 | break; |
177 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | 177 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
178 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | 178 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); |
179 | break; | 179 | break; |
180 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | 180 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
181 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | 181 | toadd.Add(new LSL_Float(wl.densityMultiplier)); |
182 | break; | 182 | break; |
183 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | 183 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: |
184 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | 184 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); |
185 | break; | 185 | break; |
186 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | 186 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: |
187 | toadd.Add(new LSL_Float(wl.eastAngle)); | 187 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); |
188 | break; | 188 | break; |
189 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | 189 | case (int)ScriptBaseClass.WL_EAST_ANGLE: |
190 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | 190 | toadd.Add(new LSL_Float(wl.eastAngle)); |
191 | break; | 191 | break; |
192 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | 192 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: |
193 | toadd.Add(new LSL_Float(wl.fresnelScale)); | 193 | toadd.Add(new LSL_Float(wl.fresnelOffset)); |
194 | break; | 194 | break; |
195 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | 195 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: |
196 | toadd.Add(new LSL_Float(wl.hazeDensity)); | 196 | toadd.Add(new LSL_Float(wl.fresnelScale)); |
197 | break; | 197 | break; |
198 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | 198 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: |
199 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | 199 | toadd.Add(new LSL_Float(wl.hazeDensity)); |
200 | break; | 200 | break; |
201 | case (int)ScriptBaseClass.WL_HORIZON: | 201 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: |
202 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | 202 | toadd.Add(new LSL_Float(wl.hazeHorizon)); |
203 | break; | 203 | break; |
204 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | 204 | case (int)ScriptBaseClass.WL_HORIZON: |
205 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | 205 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); |
206 | break; | 206 | break; |
207 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | 207 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: |
208 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | 208 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); |
209 | break; | 209 | break; |
210 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | 210 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: |
211 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | 211 | toadd.Add(new LSL_Integer(wl.maxAltitude)); |
212 | break; | 212 | break; |
213 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | 213 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: |
214 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | 214 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); |
215 | break; | 215 | break; |
216 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | 216 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
217 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | 217 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); |
218 | break; | 218 | break; |
219 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | 219 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
220 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | 220 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); |
221 | break; | 221 | break; |
222 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | 222 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: |
223 | toadd.Add(new LSL_Float(wl.sceneGamma)); | 223 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); |
224 | break; | 224 | break; |
225 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | 225 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: |
226 | toadd.Add(new LSL_Float(wl.starBrightness)); | 226 | toadd.Add(new LSL_Float(wl.sceneGamma)); |
227 | break; | 227 | break; |
228 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | 228 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: |
229 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | 229 | toadd.Add(new LSL_Float(wl.starBrightness)); |
230 | break; | 230 | break; |
231 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | 231 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: |
232 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | 232 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); |
233 | break; | 233 | break; |
234 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | 234 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: |
235 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | 235 | toadd.Add(new LSL_Float(wl.sunGlowSize)); |
236 | break; | 236 | break; |
237 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | 237 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: |
238 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | 238 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); |
239 | break; | 239 | break; |
240 | case (int)ScriptBaseClass.WL_WATER_COLOR: | 240 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: |
241 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | 241 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); |
242 | break; | 242 | break; |
243 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | 243 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
244 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | 244 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); |
245 | break; | 245 | break; |
246 | } | 246 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
247 | 247 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | |
248 | if (toadd.Length > 0) | 248 | break; |
249 | { | 249 | } |
250 | values.Add(rule); | 250 | |
251 | values.Add(toadd.Data[0]); | 251 | if (toadd.Length > 0) |
252 | } | 252 | { |
253 | idx++; | 253 | values.Add(new LSL_Integer(rule)); |
254 | } | 254 | values.Add(toadd.Data[0]); |
255 | 255 | } | |
256 | 256 | idx++; | |
257 | return values; | 257 | } |
258 | 258 | ||
259 | } | 259 | |
260 | 260 | return values; | |
261 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) | 261 | |
262 | { | 262 | } |
263 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | 263 | |
264 | 264 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) | |
265 | LSL_List values = new LSL_List(); | 265 | { |
266 | int idx = 0; | 266 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); |
267 | while (idx < rules.Length) | 267 | |
268 | { | 268 | LSL_List values = new LSL_List(); |
269 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | 269 | int idx = 0; |
270 | LSL_Types.Quaternion iQ; | 270 | while (idx < rules.Length) |
271 | LSL_Types.Vector3 iV; | 271 | { |
272 | switch (rule) | 272 | uint rule = (uint)rules.GetLSLIntegerItem(idx); |
273 | { | 273 | LSL_Types.Quaternion iQ; |
274 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | 274 | LSL_Types.Vector3 iV; |
275 | idx++; | 275 | switch (rule) |
276 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | 276 | { |
277 | break; | 277 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: |
278 | case (int)ScriptBaseClass.WL_AMBIENT: | 278 | idx++; |
279 | idx++; | 279 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); |
280 | iQ = rules.GetQuaternionItem(idx); | 280 | break; |
281 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | 281 | case (int)ScriptBaseClass.WL_AMBIENT: |
282 | break; | 282 | idx++; |
283 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | 283 | iQ = rules.GetQuaternionItem(idx); |
284 | idx++; | 284 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
285 | iV = rules.GetVector3Item(idx); | 285 | break; |
286 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | 286 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: |
287 | break; | 287 | idx++; |
288 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | 288 | iV = rules.GetVector3Item(idx); |
289 | idx++; | 289 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
290 | iQ = rules.GetQuaternionItem(idx); | 290 | break; |
291 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | 291 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: |
292 | break; | 292 | idx++; |
293 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | 293 | iQ = rules.GetQuaternionItem(idx); |
294 | idx++; | 294 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
295 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | 295 | break; |
296 | break; | 296 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: |
297 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | 297 | idx++; |
298 | idx++; | 298 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); |
299 | iQ = rules.GetQuaternionItem(idx); | 299 | break; |
300 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | 300 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: |
301 | break; | 301 | idx++; |
302 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | 302 | iQ = rules.GetQuaternionItem(idx); |
303 | idx++; | 303 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
304 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | 304 | break; |
305 | break; | 305 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: |
306 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | 306 | idx++; |
307 | idx++; | 307 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); |
308 | iV = rules.GetVector3Item(idx); | 308 | break; |
309 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 309 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
310 | break; | 310 | idx++; |
311 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | 311 | iV = rules.GetVector3Item(idx); |
312 | idx++; | 312 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); |
313 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | 313 | break; |
314 | break; | 314 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
315 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | 315 | idx++; |
316 | idx++; | 316 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); |
317 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | 317 | break; |
318 | break; | 318 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: |
319 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | 319 | idx++; |
320 | idx++; | 320 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); |
321 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | 321 | break; |
322 | break; | 322 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: |
323 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | 323 | idx++; |
324 | idx++; | 324 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
325 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | 325 | break; |
326 | break; | 326 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: |
327 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | 327 | idx++; |
328 | idx++; | 328 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); |
329 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | 329 | break; |
330 | break; | 330 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: |
331 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | 331 | idx++; |
332 | idx++; | 332 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
333 | iV = rules.GetVector3Item(idx); | 333 | break; |
334 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 334 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
335 | break; | 335 | idx++; |
336 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | 336 | iV = rules.GetVector3Item(idx); |
337 | idx++; | 337 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); |
338 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | 338 | break; |
339 | break; | 339 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
340 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | 340 | idx++; |
341 | idx++; | 341 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); |
342 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | 342 | break; |
343 | break; | 343 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: |
344 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | 344 | idx++; |
345 | idx++; | 345 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); |
346 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | 346 | break; |
347 | break; | 347 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: |
348 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | 348 | idx++; |
349 | idx++; | 349 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
350 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | 350 | break; |
351 | break; | 351 | case (int)ScriptBaseClass.WL_EAST_ANGLE: |
352 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | 352 | idx++; |
353 | idx++; | 353 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); |
354 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | 354 | break; |
355 | break; | 355 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: |
356 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | 356 | idx++; |
357 | idx++; | 357 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); |
358 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | 358 | break; |
359 | break; | 359 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: |
360 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | 360 | idx++; |
361 | idx++; | 361 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); |
362 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | 362 | break; |
363 | break; | 363 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: |
364 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | 364 | idx++; |
365 | idx++; | 365 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); |
366 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | 366 | break; |
367 | break; | 367 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: |
368 | case (int)ScriptBaseClass.WL_HORIZON: | 368 | idx++; |
369 | idx++; | 369 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); |
370 | iQ = rules.GetQuaternionItem(idx); | 370 | break; |
371 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | 371 | case (int)ScriptBaseClass.WL_HORIZON: |
372 | break; | 372 | idx++; |
373 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | 373 | iQ = rules.GetQuaternionItem(idx); |
374 | idx++; | 374 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
375 | iV = rules.GetVector3Item(idx); | 375 | break; |
376 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | 376 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: |
377 | break; | 377 | idx++; |
378 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | 378 | iV = rules.GetVector3Item(idx); |
379 | idx++; | 379 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
380 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | 380 | break; |
381 | break; | 381 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: |
382 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | 382 | idx++; |
383 | idx++; | 383 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; |
384 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | 384 | break; |
385 | break; | 385 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: |
386 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | 386 | idx++; |
387 | idx++; | 387 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); |
388 | iV = rules.GetVector3Item(idx); | 388 | break; |
389 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 389 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
390 | break; | 390 | idx++; |
391 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | 391 | iV = rules.GetVector3Item(idx); |
392 | idx++; | 392 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); |
393 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | 393 | break; |
394 | break; | 394 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
395 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | 395 | idx++; |
396 | idx++; | 396 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); |
397 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | 397 | break; |
398 | break; | 398 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: |
399 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | 399 | idx++; |
400 | idx++; | 400 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); |
401 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | 401 | break; |
402 | break; | 402 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: |
403 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | 403 | idx++; |
404 | idx++; | 404 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); |
405 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | 405 | break; |
406 | break; | 406 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: |
407 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | 407 | idx++; |
408 | idx++; | 408 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); |
409 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | 409 | break; |
410 | break; | 410 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: |
411 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | 411 | idx++; |
412 | idx++; | 412 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); |
413 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | 413 | break; |
414 | break; | 414 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: |
415 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | 415 | idx++; |
416 | idx++; | 416 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); |
417 | iQ = rules.GetQuaternionItem(idx); | 417 | break; |
418 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | 418 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: |
419 | break; | 419 | idx++; |
420 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | 420 | iQ = rules.GetQuaternionItem(idx); |
421 | idx++; | 421 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
422 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | 422 | break; |
423 | break; | 423 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: |
424 | case (int)ScriptBaseClass.WL_WATER_COLOR: | 424 | idx++; |
425 | idx++; | 425 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); |
426 | iV = rules.GetVector3Item(idx); | 426 | break; |
427 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 427 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
428 | break; | 428 | idx++; |
429 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | 429 | iV = rules.GetVector3Item(idx); |
430 | idx++; | 430 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); |
431 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | 431 | break; |
432 | break; | 432 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
433 | } | 433 | idx++; |
434 | idx++; | 434 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); |
435 | } | 435 | break; |
436 | return wl; | 436 | } |
437 | } | 437 | idx++; |
438 | /// <summary> | 438 | } |
439 | /// Set the current Windlight scene | 439 | return wl; |
440 | /// </summary> | 440 | } |
441 | /// <param name="rules"></param> | 441 | /// <summary> |
442 | /// <returns>success: true or false</returns> | 442 | /// Set the current Windlight scene |
443 | public int lsSetWindlightScene(LSL_List rules) | 443 | /// </summary> |
444 | { | 444 | /// <param name="rules"></param> |
445 | if (!m_LSFunctionsEnabled) | 445 | /// <returns>success: true or false</returns> |
446 | { | 446 | public int lsSetWindlightScene(LSL_List rules) |
447 | LSShoutError("LightShare functions are not enabled."); | 447 | { |
448 | return 0; | 448 | if (!m_LSFunctionsEnabled) |
449 | } | 449 | { |
450 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 450 | LSShoutError("LightShare functions are not enabled."); |
451 | { | 451 | return 0; |
452 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 452 | } |
453 | return 0; | 453 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
454 | } | 454 | { |
455 | int success = 0; | 455 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
456 | m_host.AddScriptLPS(1); | 456 | return 0; |
457 | if (LightShareModule.EnableWindlight) | 457 | } |
458 | { | 458 | int success = 0; |
459 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | 459 | m_host.AddScriptLPS(1); |
460 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | 460 | if (LightShareModule.EnableWindlight) |
461 | success = 1; | 461 | { |
462 | } | 462 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
463 | else | 463 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); |
464 | { | 464 | success = 1; |
465 | LSShoutError("Windlight module is disabled"); | 465 | } |
466 | return 0; | 466 | else |
467 | } | 467 | { |
468 | return success; | 468 | LSShoutError("Windlight module is disabled"); |
469 | } | 469 | return 0; |
470 | /// <summary> | 470 | } |
471 | /// Set the current Windlight scene to a target avatar | 471 | return success; |
472 | /// </summary> | 472 | } |
473 | /// <param name="rules"></param> | 473 | /// <summary> |
474 | /// <returns>success: true or false</returns> | 474 | /// Set the current Windlight scene to a target avatar |
475 | public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | 475 | /// </summary> |
476 | { | 476 | /// <param name="rules"></param> |
477 | if (!m_LSFunctionsEnabled) | 477 | /// <returns>success: true or false</returns> |
478 | { | 478 | public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) |
479 | LSShoutError("LightShare functions are not enabled."); | 479 | { |
480 | return 0; | 480 | if (!m_LSFunctionsEnabled) |
481 | } | 481 | { |
482 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 482 | LSShoutError("LightShare functions are not enabled."); |
483 | { | 483 | return 0; |
484 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 484 | } |
485 | return 0; | 485 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
486 | } | 486 | { |
487 | int success = 0; | 487 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
488 | m_host.AddScriptLPS(1); | 488 | return 0; |
489 | if (LightShareModule.EnableWindlight) | 489 | } |
490 | { | 490 | int success = 0; |
491 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | 491 | m_host.AddScriptLPS(1); |
492 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | 492 | if (LightShareModule.EnableWindlight) |
493 | success = 1; | 493 | { |
494 | } | 494 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
495 | else | 495 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); |
496 | { | 496 | success = 1; |
497 | LSShoutError("Windlight module is disabled"); | 497 | } |
498 | return 0; | 498 | else |
499 | } | 499 | { |
500 | return success; | 500 | LSShoutError("Windlight module is disabled"); |
501 | } | 501 | return 0; |
502 | 502 | } | |
503 | } | 503 | return success; |
504 | } | 504 | } |
505 | |||
506 | } | ||
507 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a529a94..a08b135 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -129,6 +129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
129 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | 129 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; |
130 | internal float m_ScriptDelayFactor = 1.0f; | 130 | internal float m_ScriptDelayFactor = 1.0f; |
131 | internal float m_ScriptDistanceFactor = 1.0f; | 131 | internal float m_ScriptDistanceFactor = 1.0f; |
132 | internal bool m_debuggerSafe = false; | ||
132 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 133 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
133 | 134 | ||
134 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | 135 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) |
@@ -137,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
137 | m_host = host; | 138 | m_host = host; |
138 | m_localID = localID; | 139 | m_localID = localID; |
139 | m_itemID = itemID; | 140 | m_itemID = itemID; |
141 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
140 | 142 | ||
141 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | 143 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) |
142 | m_OSFunctionsEnabled = true; | 144 | m_OSFunctionsEnabled = true; |
@@ -195,7 +197,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
195 | 197 | ||
196 | internal void OSSLError(string msg) | 198 | internal void OSSLError(string msg) |
197 | { | 199 | { |
198 | throw new Exception("OSSL Runtime Error: " + msg); | 200 | if (m_debuggerSafe) |
201 | { | ||
202 | OSSLShoutError(msg); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | throw new Exception("OSSL Runtime Error: " + msg); | ||
207 | } | ||
199 | } | 208 | } |
200 | 209 | ||
201 | private void InitLSL() | 210 | private void InitLSL() |
@@ -767,18 +776,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
767 | if (target != null) | 776 | if (target != null) |
768 | { | 777 | { |
769 | UUID animID=UUID.Zero; | 778 | UUID animID=UUID.Zero; |
770 | lock (m_host.TaskInventory) | 779 | m_host.TaskInventory.LockItemsForRead(true); |
780 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
771 | { | 781 | { |
772 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 782 | if (inv.Value.Name == animation) |
773 | { | 783 | { |
774 | if (inv.Value.Name == animation) | 784 | if (inv.Value.Type == (int)AssetType.Animation) |
775 | { | 785 | animID = inv.Value.AssetID; |
776 | if (inv.Value.Type == (int)AssetType.Animation) | 786 | continue; |
777 | animID = inv.Value.AssetID; | ||
778 | continue; | ||
779 | } | ||
780 | } | 787 | } |
781 | } | 788 | } |
789 | m_host.TaskInventory.LockItemsForRead(false); | ||
782 | if (animID == UUID.Zero) | 790 | if (animID == UUID.Zero) |
783 | target.Animator.AddAnimation(animation, m_host.UUID); | 791 | target.Animator.AddAnimation(animation, m_host.UUID); |
784 | else | 792 | else |
@@ -800,18 +808,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
800 | if (target != null) | 808 | if (target != null) |
801 | { | 809 | { |
802 | UUID animID=UUID.Zero; | 810 | UUID animID=UUID.Zero; |
803 | lock (m_host.TaskInventory) | 811 | m_host.TaskInventory.LockItemsForRead(true); |
812 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
804 | { | 813 | { |
805 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 814 | if (inv.Value.Name == animation) |
806 | { | 815 | { |
807 | if (inv.Value.Name == animation) | 816 | if (inv.Value.Type == (int)AssetType.Animation) |
808 | { | 817 | animID = inv.Value.AssetID; |
809 | if (inv.Value.Type == (int)AssetType.Animation) | 818 | continue; |
810 | animID = inv.Value.AssetID; | ||
811 | continue; | ||
812 | } | ||
813 | } | 819 | } |
814 | } | 820 | } |
821 | m_host.TaskInventory.LockItemsForRead(false); | ||
815 | 822 | ||
816 | if (animID == UUID.Zero) | 823 | if (animID == UUID.Zero) |
817 | target.Animator.RemoveAnimation(animation); | 824 | target.Animator.RemoveAnimation(animation); |
@@ -1662,6 +1669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1662 | 1669 | ||
1663 | if (!UUID.TryParse(name, out assetID)) | 1670 | if (!UUID.TryParse(name, out assetID)) |
1664 | { | 1671 | { |
1672 | m_host.TaskInventory.LockItemsForRead(true); | ||
1665 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1673 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1666 | { | 1674 | { |
1667 | if (item.Type == 7 && item.Name == name) | 1675 | if (item.Type == 7 && item.Name == name) |
@@ -1669,6 +1677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1669 | assetID = item.AssetID; | 1677 | assetID = item.AssetID; |
1670 | } | 1678 | } |
1671 | } | 1679 | } |
1680 | m_host.TaskInventory.LockItemsForRead(false); | ||
1672 | } | 1681 | } |
1673 | 1682 | ||
1674 | if (assetID == UUID.Zero) | 1683 | if (assetID == UUID.Zero) |
@@ -1715,6 +1724,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1715 | 1724 | ||
1716 | if (!UUID.TryParse(name, out assetID)) | 1725 | if (!UUID.TryParse(name, out assetID)) |
1717 | { | 1726 | { |
1727 | m_host.TaskInventory.LockItemsForRead(true); | ||
1718 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1728 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1719 | { | 1729 | { |
1720 | if (item.Type == 7 && item.Name == name) | 1730 | if (item.Type == 7 && item.Name == name) |
@@ -1722,6 +1732,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1722 | assetID = item.AssetID; | 1732 | assetID = item.AssetID; |
1723 | } | 1733 | } |
1724 | } | 1734 | } |
1735 | m_host.TaskInventory.LockItemsForRead(false); | ||
1725 | } | 1736 | } |
1726 | 1737 | ||
1727 | if (assetID == UUID.Zero) | 1738 | if (assetID == UUID.Zero) |
@@ -1772,6 +1783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1772 | 1783 | ||
1773 | if (!UUID.TryParse(name, out assetID)) | 1784 | if (!UUID.TryParse(name, out assetID)) |
1774 | { | 1785 | { |
1786 | m_host.TaskInventory.LockItemsForRead(true); | ||
1775 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1787 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1776 | { | 1788 | { |
1777 | if (item.Type == 7 && item.Name == name) | 1789 | if (item.Type == 7 && item.Name == name) |
@@ -1779,6 +1791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1779 | assetID = item.AssetID; | 1791 | assetID = item.AssetID; |
1780 | } | 1792 | } |
1781 | } | 1793 | } |
1794 | m_host.TaskInventory.LockItemsForRead(false); | ||
1782 | } | 1795 | } |
1783 | 1796 | ||
1784 | if (assetID == UUID.Zero) | 1797 | if (assetID == UUID.Zero) |
@@ -2216,9 +2229,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2216 | { | 2229 | { |
2217 | if (avatar.IsChildAgent == false) | 2230 | if (avatar.IsChildAgent == false) |
2218 | { | 2231 | { |
2219 | result.Add(avatar.UUID); | 2232 | result.Add(new LSL_Key(avatar.UUID.ToString())); |
2220 | result.Add(avatar.AbsolutePosition); | 2233 | result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z)); |
2221 | result.Add(avatar.Name); | 2234 | result.Add(new LSL_String(avatar.Name)); |
2222 | } | 2235 | } |
2223 | } | 2236 | } |
2224 | }); | 2237 | }); |
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 5da6bb9..6e8435d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -279,6 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 279 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
280 | public const int CHANGED_MEDIA = 2048; | 280 | public const int CHANGED_MEDIA = 2048; |
281 | public const int CHANGED_ANIMATION = 16384; | 281 | public const int CHANGED_ANIMATION = 16384; |
282 | public const int CHANGED_POSITION = 32768; | ||
282 | public const int TYPE_INVALID = 0; | 283 | public const int TYPE_INVALID = 0; |
283 | public const int TYPE_INTEGER = 1; | 284 | public const int TYPE_INTEGER = 1; |
284 | public const int TYPE_FLOAT = 2; | 285 | public const int TYPE_FLOAT = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 451163f..f14967e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
309 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 310 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
310 | } | 311 | } |
311 | 312 | ||
313 | [DebuggerNonUserCode] | ||
312 | public void llDie() | 314 | public void llDie() |
313 | { | 315 | { |
314 | m_LSL_Functions.llDie(); | 316 | m_LSL_Functions.llDie(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs index f8dbe03..8280ca5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs | |||
@@ -72,5 +72,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
72 | { | 72 | { |
73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | 73 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); |
74 | } | 74 | } |
75 | |||
76 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
77 | { | ||
78 | return m_LS_Functions.lsGetWindlightScene(rules); | ||
79 | } | ||
80 | |||
81 | public int cmSetWindlightScene(LSL_List rules) | ||
82 | { | ||
83 | return m_LS_Functions.lsSetWindlightScene(rules); | ||
84 | } | ||
85 | |||
86 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
87 | { | ||
88 | return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); | ||
89 | } | ||
75 | } | 90 | } |
76 | } | 91 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 6663aa5..b4da246 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
238 | 239 | ||
239 | if (part != null) | 240 | if (part != null) |
240 | { | 241 | { |
241 | lock (part.TaskInventory) | 242 | part.TaskInventory.LockItemsForRead(true); |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
242 | { | 244 | { |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
244 | { | ||
245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
246 | } | ||
247 | } | 246 | } |
247 | part.TaskInventory.LockItemsForRead(false); | ||
248 | } | 248 | } |
249 | 249 | ||
250 | ApiManager am = new ApiManager(); | 250 | ApiManager am = new ApiManager(); |
@@ -429,14 +429,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
429 | { | 429 | { |
430 | int permsMask; | 430 | int permsMask; |
431 | UUID permsGranter; | 431 | UUID permsGranter; |
432 | lock (part.TaskInventory) | 432 | part.TaskInventory.LockItemsForRead(true); |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
433 | { | 434 | { |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 435 | part.TaskInventory.LockItemsForRead(false); |
435 | return; | 436 | return; |
436 | |||
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | } | 437 | } |
438 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
439 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
440 | part.TaskInventory.LockItemsForRead(false); | ||
440 | 441 | ||
441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 442 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
442 | { | 443 | { |
@@ -545,6 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
545 | return true; | 546 | return true; |
546 | } | 547 | } |
547 | 548 | ||
549 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
548 | public void SetState(string state) | 550 | public void SetState(string state) |
549 | { | 551 | { |
550 | if (state == State) | 552 | if (state == State) |
@@ -556,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
556 | new DetectParams[0])); | 558 | new DetectParams[0])); |
557 | PostEvent(new EventParams("state_entry", new Object[0], | 559 | PostEvent(new EventParams("state_entry", new Object[0], |
558 | new DetectParams[0])); | 560 | new DetectParams[0])); |
559 | 561 | ||
560 | throw new EventAbortException(); | 562 | throw new EventAbortException(); |
561 | } | 563 | } |
562 | 564 | ||
@@ -639,14 +641,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | /// <returns></returns> | 641 | /// <returns></returns> |
640 | public object EventProcessor() | 642 | public object EventProcessor() |
641 | { | 643 | { |
642 | if (m_Suspended) | 644 | EventParams data = null; |
643 | return 0; | ||
644 | 645 | ||
645 | lock (m_Script) | 646 | lock (m_EventQueue) |
646 | { | 647 | { |
647 | EventParams data = null; | 648 | if (m_Suspended) |
649 | return 0; | ||
648 | 650 | ||
649 | lock (m_EventQueue) | 651 | lock (m_Script) |
650 | { | 652 | { |
651 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | data = (EventParams) m_EventQueue.Dequeue(); |
652 | if (data == null) // Shouldn't happen | 654 | if (data == null) // Shouldn't happen |
@@ -672,6 +674,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
672 | if (data.EventName == "collision") | 674 | if (data.EventName == "collision") |
673 | m_CollisionInQueue = false; | 675 | m_CollisionInQueue = false; |
674 | } | 676 | } |
677 | } | ||
678 | lock(m_Script) | ||
679 | { | ||
675 | 680 | ||
676 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 681 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
677 | 682 | ||
@@ -828,6 +833,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
828 | new Object[0], new DetectParams[0])); | 833 | new Object[0], new DetectParams[0])); |
829 | } | 834 | } |
830 | 835 | ||
836 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
831 | public void ApiResetScript() | 837 | public void ApiResetScript() |
832 | { | 838 | { |
833 | // bool running = Running; | 839 | // bool running = Running; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 91e03ac..a3a2fdf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -83,19 +83,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
83 | 83 | ||
84 | public override string ToString() | 84 | public override string ToString() |
85 | { | 85 | { |
86 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | 86 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); |
87 | return s; | 87 | return s; |
88 | } | 88 | } |
89 | 89 | ||
90 | public static explicit operator LSLString(Vector3 vec) | 90 | public static explicit operator LSLString(Vector3 vec) |
91 | { | 91 | { |
92 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 92 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
93 | return new LSLString(s); | 93 | return new LSLString(s); |
94 | } | 94 | } |
95 | 95 | ||
96 | public static explicit operator string(Vector3 vec) | 96 | public static explicit operator string(Vector3 vec) |
97 | { | 97 | { |
98 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 98 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
99 | return s; | 99 | return s; |
100 | } | 100 | } |
101 | 101 | ||
@@ -342,19 +342,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
342 | 342 | ||
343 | public override string ToString() | 343 | public override string ToString() |
344 | { | 344 | { |
345 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | 345 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); |
346 | return st; | 346 | return st; |
347 | } | 347 | } |
348 | 348 | ||
349 | public static explicit operator string(Quaternion r) | 349 | public static explicit operator string(Quaternion r) |
350 | { | 350 | { |
351 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 351 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
352 | return s; | 352 | return s; |
353 | } | 353 | } |
354 | 354 | ||
355 | public static explicit operator LSLString(Quaternion r) | 355 | public static explicit operator LSLString(Quaternion r) |
356 | { | 356 | { |
357 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 357 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
358 | return new LSLString(s); | 358 | return new LSLString(s); |
359 | } | 359 | } |
360 | 360 | ||
@@ -613,24 +613,16 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
613 | 613 | ||
614 | public static bool operator ==(list a, list b) | 614 | public static bool operator ==(list a, list b) |
615 | { | 615 | { |
616 | int la = -1; | 616 | int la = a.Length; |
617 | int lb = -1; | 617 | int lb = b.Length; |
618 | try { la = a.Length; } | ||
619 | catch (NullReferenceException) { } | ||
620 | try { lb = b.Length; } | ||
621 | catch (NullReferenceException) { } | ||
622 | 618 | ||
623 | return la == lb; | 619 | return la == lb; |
624 | } | 620 | } |
625 | 621 | ||
626 | public static bool operator !=(list a, list b) | 622 | public static bool operator !=(list a, list b) |
627 | { | 623 | { |
628 | int la = -1; | 624 | int la = a.Length; |
629 | int lb = -1; | 625 | int lb = b.Length; |
630 | try { la = a.Length; } | ||
631 | catch (NullReferenceException) { } | ||
632 | try {lb = b.Length;} | ||
633 | catch (NullReferenceException) { } | ||
634 | 626 | ||
635 | return la != lb; | 627 | return la != lb; |
636 | } | 628 | } |