aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs116
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs3167
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs102
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs71
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs56
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
15 files changed, 2891 insertions, 803 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 47a9cdc..94fd940 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -305,6 +305,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
305 return null; 305 return null;
306 } 306 }
307 307
308 public static void StateChange(IScriptEngine engine, uint localID, UUID itemID)
309 {
310 // Remove a specific script
311
312 // Remove dataserver events
313 m_Dataserver[engine].RemoveEvents(localID, itemID);
314
315 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
316 if (comms != null)
317 comms.DeleteListener(itemID);
318
319 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
320 xmlrpc.DeleteChannels(itemID);
321 xmlrpc.CancelSRDRequests(itemID);
322
323 // Remove Sensors
324 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
325
326 }
327
308 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) 328 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID)
309 { 329 {
310 List<Object> data = new List<Object>(); 330 List<Object> data = new List<Object>();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..b5fa6de
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,116 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections;
31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse;
34using Nini.Config;
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.World.LightShare;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
45using OpenSim.Services.Interfaces;
46
47using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
50using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54
55namespace OpenSim.Region.ScriptEngine.Shared.Api
56{
57 [Serializable]
58 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
59 {
60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host;
62 internal TaskInventoryItem m_item;
63 internal bool m_CMFunctionsEnabled = false;
64
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
66 {
67 m_ScriptEngine = ScriptEngine;
68 m_host = host;
69 m_item = item;
70
71 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
72 m_CMFunctionsEnabled = true;
73 }
74
75 public override Object InitializeLifetimeService()
76 {
77 ILease lease = (ILease)base.InitializeLifetimeService();
78
79 if (lease.CurrentState == LeaseState.Initial)
80 {
81 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
82 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
83 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
84 }
85 return lease;
86 }
87
88 public Scene World
89 {
90 get { return m_ScriptEngine.World; }
91 }
92
93 public string cmDetectedCountry(int number)
94 {
95 m_host.AddScriptLPS(1);
96 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
97 if (detectedParams == null)
98 return String.Empty;
99 return detectedParams.Country;
100 }
101
102 public string cmGetAgentCountry(LSL_Key key)
103 {
104 if (!World.Permissions.IsGod(m_host.OwnerID))
105 return String.Empty;
106
107 UUID uuid;
108
109 if (!UUID.TryParse(key, out uuid))
110 return String.Empty;
111
112 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
113 return account.UserCountry;
114 }
115 }
116}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4645e7a..717cc07 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -24,14 +24,16 @@
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
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; //for [DebuggerNonUserCode]
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
34using System.Text.RegularExpressions; 35using System.Text.RegularExpressions;
36using System.Timers;
35using Nini.Config; 37using Nini.Config;
36using log4net; 38using log4net;
37using OpenMetaverse; 39using OpenMetaverse;
@@ -44,6 +46,7 @@ using OpenSim.Region.CoreModules.World.Land;
44using OpenSim.Region.CoreModules.World.Terrain; 46using OpenSim.Region.CoreModules.World.Terrain;
45using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 48using OpenSim.Region.Framework.Scenes;
49using OpenSim.Region.Framework.Scenes.Serialization;
47using OpenSim.Region.Framework.Scenes.Animation; 50using OpenSim.Region.Framework.Scenes.Animation;
48using OpenSim.Region.Physics.Manager; 51using OpenSim.Region.Physics.Manager;
49using OpenSim.Region.ScriptEngine.Shared; 52using OpenSim.Region.ScriptEngine.Shared;
@@ -65,6 +68,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
65using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 68using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
66using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 69using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
67using System.Reflection; 70using System.Reflection;
71using Timer = System.Timers.Timer;
68 72
69namespace OpenSim.Region.ScriptEngine.Shared.Api 73namespace OpenSim.Region.ScriptEngine.Shared.Api
70{ 74{
@@ -103,15 +107,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
103 protected int m_notecardLineReadCharsMax = 255; 107 protected int m_notecardLineReadCharsMax = 255;
104 protected int m_scriptConsoleChannel = 0; 108 protected int m_scriptConsoleChannel = 0;
105 protected bool m_scriptConsoleChannelEnabled = false; 109 protected bool m_scriptConsoleChannelEnabled = false;
110 protected bool m_debuggerSafe = false;
106 protected IUrlModule m_UrlModule = null; 111 protected IUrlModule m_UrlModule = null;
107 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); 112 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
108 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. 113 new Dictionary<UUID, UserInfoCacheEntry>();
114 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
115
116// protected Timer m_ShoutSayTimer;
117 protected int m_SayShoutCount = 0;
118 DateTime m_lastSayShoutCheck;
119
120 private Dictionary<string, string> MovementAnimationsForLSL =
121 new Dictionary<string, string> {
122 {"FLY", "Flying"},
123 {"FLYSLOW", "FlyingSlow"},
124 {"HOVER_UP", "Hovering Up"},
125 {"HOVER_DOWN", "Hovering Down"},
126 {"HOVER", "Hovering"},
127 {"LAND", "Landing"},
128 {"FALLDOWN", "Falling Down"},
129 {"PREJUMP", "PreJumping"},
130 {"JUMP", "Jumping"},
131 {"STANDUP", "Standing Up"},
132 {"SOFT_LAND", "Soft Landing"},
133 {"STAND", "Standing"},
134 {"CROUCHWALK", "CrouchWalking"},
135 {"RUN", "Running"},
136 {"WALK", "Walking"},
137 {"CROUCH", "Crouching"},
138 {"TURNLEFT", "Turning Left"},
139 {"TURNRIGHT", "Turning Right"}
140 };
109 141
110 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 142 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
111 { 143 {
144/*
145 m_ShoutSayTimer = new Timer(1000);
146 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed;
147 m_ShoutSayTimer.AutoReset = true;
148 m_ShoutSayTimer.Start();
149*/
150 m_lastSayShoutCheck = DateTime.UtcNow;
151
112 m_ScriptEngine = ScriptEngine; 152 m_ScriptEngine = ScriptEngine;
113 m_host = host; 153 m_host = host;
114 m_item = item; 154 m_item = item;
155 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
115 156
116 LoadLimits(); // read script limits from config. 157 LoadLimits(); // read script limits from config.
117 158
@@ -171,6 +212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
171 get { return m_ScriptEngine.World; } 212 get { return m_ScriptEngine.World; }
172 } 213 }
173 214
215 [DebuggerNonUserCode]
174 public void state(string newState) 216 public void state(string newState)
175 { 217 {
176 m_ScriptEngine.SetState(m_item.ItemID, newState); 218 m_ScriptEngine.SetState(m_item.ItemID, newState);
@@ -180,6 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
180 /// Reset the named script. The script must be present 222 /// Reset the named script. The script must be present
181 /// in the same prim. 223 /// in the same prim.
182 /// </summary> 224 /// </summary>
225 [DebuggerNonUserCode]
183 public void llResetScript() 226 public void llResetScript()
184 { 227 {
185 m_host.AddScriptLPS(1); 228 m_host.AddScriptLPS(1);
@@ -242,6 +285,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
242 } 285 }
243 } 286 }
244 287
288 public List<ScenePresence> GetLinkAvatars(int linkType)
289 {
290 List<ScenePresence> ret = new List<ScenePresence>();
291 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
292 return ret;
293
294 List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars();
295
296 switch (linkType)
297 {
298 case ScriptBaseClass.LINK_SET:
299 return avs;
300
301 case ScriptBaseClass.LINK_ROOT:
302 return ret;
303
304 case ScriptBaseClass.LINK_ALL_OTHERS:
305 return avs;
306
307 case ScriptBaseClass.LINK_ALL_CHILDREN:
308 return avs;
309
310 case ScriptBaseClass.LINK_THIS:
311 return ret;
312
313 default:
314 if (linkType < 0)
315 return ret;
316
317 int partCount = m_host.ParentGroup.GetPartCount();
318
319 if (linkType <= partCount)
320 {
321 return ret;
322 }
323 else
324 {
325 linkType = linkType - partCount;
326 if (linkType > avs.Count)
327 {
328 return ret;
329 }
330 else
331 {
332 ret.Add(avs[linkType-1]);
333 return ret;
334 }
335 }
336 }
337 }
338
245 public List<SceneObjectPart> GetLinkParts(int linkType) 339 public List<SceneObjectPart> GetLinkParts(int linkType)
246 { 340 {
247 return GetLinkParts(m_host, linkType); 341 return GetLinkParts(m_host, linkType);
@@ -250,6 +344,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
250 private List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) 344 private List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType)
251 { 345 {
252 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 346 List<SceneObjectPart> ret = new List<SceneObjectPart>();
347 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
348 return ret;
253 ret.Add(part); 349 ret.Add(part);
254 350
255 switch (linkType) 351 switch (linkType)
@@ -440,31 +536,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
440 536
441 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 537 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
442 538
443 /// <summary> 539 // Utility function for llRot2Euler
444 /// Convert an LSL rotation to a Euler vector. 540
445 /// </summary> 541 // normalize an angle between -PI and PI (-180 to +180 degrees)
446 /// <remarks> 542 protected double NormalizeAngle(double angle)
447 /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf
448 /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2
449 /// </remarks>
450 /// <param name="r"></param>
451 /// <returns></returns>
452 public LSL_Vector llRot2Euler(LSL_Rotation r)
453 { 543 {
454 m_host.AddScriptLPS(1); 544 if (angle > -Math.PI && angle < Math.PI)
545 return angle;
455 546
456 LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. 547 int numPis = (int)(Math.PI / angle);
457 double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. 548 double remainder = angle - Math.PI * numPis;
458 if (m == 0.0) return new LSL_Vector(); 549 if (numPis % 2 == 1)
459 double x = Math.Atan2(-v.y, v.z); 550 return Math.PI - angle;
460 double sin = v.x / m; 551 return remainder;
461 if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. 552 }
462 double y = Math.Asin(sin);
463 // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation
464 v = new LSL_Vector(1.0, 0.0, 0.0) * ((r * new LSL_Rotation(Math.Sin(-x / 2.0), 0.0, 0.0, Math.Cos(-x / 2.0))) * new LSL_Rotation(0.0, Math.Sin(-y / 2.0), 0.0, Math.Cos(-y / 2.0)));
465 double z = Math.Atan2(v.y, v.x);
466 553
467 return new LSL_Vector(x, y, z); 554 public LSL_Vector llRot2Euler(LSL_Rotation q1)
555 {
556 m_host.AddScriptLPS(1);
557 LSL_Vector eul = new LSL_Vector();
558
559 double sqw = q1.s*q1.s;
560 double sqx = q1.x*q1.x;
561 double sqy = q1.z*q1.z;
562 double sqz = q1.y*q1.y;
563 double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
564 double test = q1.x*q1.z + q1.y*q1.s;
565 if (test > 0.4999*unit) { // singularity at north pole
566 eul.z = 2 * Math.Atan2(q1.x,q1.s);
567 eul.y = Math.PI/2;
568 eul.x = 0;
569 return eul;
570 }
571 if (test < -0.4999*unit) { // singularity at south pole
572 eul.z = -2 * Math.Atan2(q1.x,q1.s);
573 eul.y = -Math.PI/2;
574 eul.x = 0;
575 return eul;
576 }
577 eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw);
578 eul.y = Math.Asin(2*test/unit);
579 eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw);
580 return eul;
468 } 581 }
469 582
470 /* From wiki: 583 /* From wiki:
@@ -517,18 +630,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
517 m_host.AddScriptLPS(1); 630 m_host.AddScriptLPS(1);
518 631
519 double x,y,z,s; 632 double x,y,z,s;
520 633 v.x *= 0.5;
521 double c1 = Math.Cos(v.x * 0.5); 634 v.y *= 0.5;
522 double c2 = Math.Cos(v.y * 0.5); 635 v.z *= 0.5;
523 double c3 = Math.Cos(v.z * 0.5); 636 double c1 = Math.Cos(v.x);
524 double s1 = Math.Sin(v.x * 0.5); 637 double c2 = Math.Cos(v.y);
525 double s2 = Math.Sin(v.y * 0.5); 638 double c1c2 = c1 * c2;
526 double s3 = Math.Sin(v.z * 0.5); 639 double s1 = Math.Sin(v.x);
527 640 double s2 = Math.Sin(v.y);
528 x = s1 * c2 * c3 + c1 * s2 * s3; 641 double s1s2 = s1 * s2;
529 y = c1 * s2 * c3 - s1 * c2 * s3; 642 double c1s2 = c1 * s2;
530 z = s1 * s2 * c3 + c1 * c2 * s3; 643 double s1c2 = s1 * c2;
531 s = c1 * c2 * c3 - s1 * s2 * s3; 644 double c3 = Math.Cos(v.z);
645 double s3 = Math.Sin(v.z);
646
647 x = s1c2 * c3 + c1s2 * s3;
648 y = c1s2 * c3 - s1c2 * s3;
649 z = s1s2 * c3 + c1c2 * s3;
650 s = c1c2 * c3 - s1s2 * s3;
532 651
533 return new LSL_Rotation(x, y, z, s); 652 return new LSL_Rotation(x, y, z, s);
534 } 653 }
@@ -666,77 +785,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
666 { 785 {
667 //A and B should both be normalized 786 //A and B should both be normalized
668 m_host.AddScriptLPS(1); 787 m_host.AddScriptLPS(1);
669 LSL_Rotation rotBetween; 788 /* This method is more accurate than the SL one, and thus causes problems
670 // Check for zero vectors. If either is zero, return zero rotation. Otherwise, 789 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
671 // continue calculation. 790
672 if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) 791 double dotProduct = LSL_Vector.Dot(a, b);
792 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
793 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
794 double angle = Math.Acos(dotProduct / magProduct);
795 LSL_Vector axis = LSL_Vector.Norm(crossProduct);
796 double s = Math.Sin(angle / 2);
797
798 double x = axis.x * s;
799 double y = axis.y * s;
800 double z = axis.z * s;
801 double w = Math.Cos(angle / 2);
802
803 if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w))
804 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
805
806 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
807 */
808
809 // This method mimics the 180 errors found in SL
810 // See www.euclideanspace.com... angleBetween
811 LSL_Vector vec_a = a;
812 LSL_Vector vec_b = b;
813
814 // Eliminate zero length
815 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
816 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
817 if (vec_a_mag < 0.00001 ||
818 vec_b_mag < 0.00001)
673 { 819 {
674 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 820 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
675 } 821 }
676 else 822
823 // Normalize
824 vec_a = llVecNorm(vec_a);
825 vec_b = llVecNorm(vec_b);
826
827 // Calculate axis and rotation angle
828 LSL_Vector axis = vec_a % vec_b;
829 LSL_Float cos_theta = vec_a * vec_b;
830
831 // Check if parallel
832 if (cos_theta > 0.99999)
677 { 833 {
678 a = LSL_Vector.Norm(a); 834 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
679 b = LSL_Vector.Norm(b); 835 }
680 double dotProduct = LSL_Vector.Dot(a, b); 836
681 // There are two degenerate cases possible. These are for vectors 180 or 837 // Check if anti-parallel
682 // 0 degrees apart. These have to be detected and handled individually. 838 else if (cos_theta < -0.99999)
683 // 839 {
684 // Check for vectors 180 degrees apart. 840 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
685 // A dot product of -1 would mean the angle between vectors is 180 degrees. 841 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
686 if (dotProduct < -0.9999999f) 842 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
687 { 843 }
688 // First assume X axis is orthogonal to the vectors. 844 else // other rotation
689 LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); 845 {
690 orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); 846 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
691 // Check for near zero vector. A very small non-zero number here will create 847 axis = llVecNorm(axis);
692 // a rotation in an undesired direction. 848 double x, y, z, s, t;
693 if (LSL_Vector.Mag(orthoVector) > 0.0001) 849 s = Math.Cos(theta);
694 { 850 t = Math.Sin(theta);
695 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); 851 x = axis.x * t;
696 } 852 y = axis.y * t;
697 // If the magnitude of the vector was near zero, then assume the X axis is not 853 z = axis.z * t;
698 // orthogonal and use the Z axis instead. 854 return new LSL_Rotation(x,y,z,s);
699 else
700 {
701 // Set 180 z rotation.
702 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f);
703 }
704 }
705 // Check for parallel vectors.
706 // A dot product of 1 would mean the angle between vectors is 0 degrees.
707 else if (dotProduct > 0.9999999f)
708 {
709 // Set zero rotation.
710 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
711 }
712 else
713 {
714 // All special checks have been performed so get the axis of rotation.
715 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
716 // Quarternion s value is the length of the unit vector + dot product.
717 double qs = 1.0 + dotProduct;
718 rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs);
719 // Normalize the rotation.
720 double mag = LSL_Rotation.Mag(rotBetween);
721 // We shouldn't have to worry about a divide by zero here. The qs value will be
722 // non-zero because we already know if we're here, then the dotProduct is not -1 so
723 // qs will not be zero. Also, we've already handled the input vectors being zero so the
724 // crossProduct vector should also not be zero.
725 rotBetween.x = rotBetween.x / mag;
726 rotBetween.y = rotBetween.y / mag;
727 rotBetween.z = rotBetween.z / mag;
728 rotBetween.s = rotBetween.s / mag;
729 // Check for undefined values and set zero rotation if any found. This code might not actually be required
730 // any longer since zero vectors are checked for at the top.
731 if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s))
732 {
733 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
734 }
735 }
736 } 855 }
737 return rotBetween;
738 } 856 }
739 857
740 public void llWhisper(int channelID, string text) 858 public void llWhisper(int channelID, string text)
741 { 859 {
742 m_host.AddScriptLPS(1); 860 m_host.AddScriptLPS(1);
@@ -752,10 +870,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
752 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); 870 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text);
753 } 871 }
754 872
873 private void CheckSayShoutTime()
874 {
875 DateTime now = DateTime.UtcNow;
876 if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec
877 {
878 m_lastSayShoutCheck = now;
879 m_SayShoutCount = 0;
880 }
881 else
882 m_SayShoutCount++;
883 }
884
755 public void llSay(int channelID, string text) 885 public void llSay(int channelID, string text)
756 { 886 {
757 m_host.AddScriptLPS(1); 887 m_host.AddScriptLPS(1);
758 888
889 if (channelID == 0)
890// m_SayShoutCount++;
891 CheckSayShoutTime();
892
893 if (m_SayShoutCount >= 11)
894 ScriptSleep(2000);
895
759 if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) 896 if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel))
760 { 897 {
761 Console.WriteLine(text); 898 Console.WriteLine(text);
@@ -778,6 +915,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
778 { 915 {
779 m_host.AddScriptLPS(1); 916 m_host.AddScriptLPS(1);
780 917
918 if (channelID == 0)
919// m_SayShoutCount++;
920 CheckSayShoutTime();
921
922 if (m_SayShoutCount >= 11)
923 ScriptSleep(2000);
924
781 if (text.Length > 1023) 925 if (text.Length > 1023)
782 text = text.Substring(0, 1023); 926 text = text.Substring(0, 1023);
783 927
@@ -809,22 +953,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
809 953
810 public void llRegionSayTo(string target, int channel, string msg) 954 public void llRegionSayTo(string target, int channel, string msg)
811 { 955 {
956 string error = String.Empty;
957
812 if (msg.Length > 1023) 958 if (msg.Length > 1023)
813 msg = msg.Substring(0, 1023); 959 msg = msg.Substring(0, 1023);
814 960
815 m_host.AddScriptLPS(1); 961 m_host.AddScriptLPS(1);
816 962
817 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
818 {
819 return;
820 }
821
822 UUID TargetID; 963 UUID TargetID;
823 UUID.TryParse(target, out TargetID); 964 UUID.TryParse(target, out TargetID);
824 965
825 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 966 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
826 if (wComm != null) 967 if (wComm != null)
827 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); 968 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error))
969 LSLError(error);
828 } 970 }
829 971
830 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 972 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -1080,10 +1222,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1080 return detectedParams.TouchUV; 1222 return detectedParams.TouchUV;
1081 } 1223 }
1082 1224
1225 [DebuggerNonUserCode]
1083 public virtual void llDie() 1226 public virtual void llDie()
1084 { 1227 {
1085 m_host.AddScriptLPS(1); 1228 m_host.AddScriptLPS(1);
1086 throw new SelfDeleteException(); 1229 if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException();
1087 } 1230 }
1088 1231
1089 public LSL_Float llGround(LSL_Vector offset) 1232 public LSL_Float llGround(LSL_Vector offset)
@@ -1154,6 +1297,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1154 1297
1155 public void llSetStatus(int status, int value) 1298 public void llSetStatus(int status, int value)
1156 { 1299 {
1300 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1301 return;
1157 m_host.AddScriptLPS(1); 1302 m_host.AddScriptLPS(1);
1158 1303
1159 int statusrotationaxis = 0; 1304 int statusrotationaxis = 0;
@@ -1177,6 +1322,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1177 if (!allow) 1322 if (!allow)
1178 return; 1323 return;
1179 1324
1325 if (m_host.ParentGroup.RootPart.PhysActor != null &&
1326 m_host.ParentGroup.RootPart.PhysActor.IsPhysical)
1327 return;
1328
1180 m_host.ScriptSetPhysicsStatus(true); 1329 m_host.ScriptSetPhysicsStatus(true);
1181 } 1330 }
1182 else 1331 else
@@ -1374,6 +1523,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1374 { 1523 {
1375 m_host.AddScriptLPS(1); 1524 m_host.AddScriptLPS(1);
1376 1525
1526 SetColor(m_host, color, face);
1527 }
1528
1529 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1530 {
1531 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1532 return;
1533
1534 Primitive.TextureEntry tex = part.Shape.Textures;
1535 Color4 texcolor;
1536 if (face >= 0 && face < GetNumberOfSides(part))
1537 {
1538 texcolor = tex.CreateFace((uint)face).RGBA;
1539 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1540 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1541 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1542 tex.FaceTextures[face].RGBA = texcolor;
1543 part.UpdateTextureEntry(tex.GetBytes());
1544 return;
1545 }
1546 else if (face == ScriptBaseClass.ALL_SIDES)
1547 {
1548 for (uint i = 0; i < GetNumberOfSides(part); i++)
1549 {
1550 if (tex.FaceTextures[i] != null)
1551 {
1552 texcolor = tex.FaceTextures[i].RGBA;
1553 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1554 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1555 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1556 tex.FaceTextures[i].RGBA = texcolor;
1557 }
1558 texcolor = tex.DefaultTexture.RGBA;
1559 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1560 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1561 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1562 tex.DefaultTexture.RGBA = texcolor;
1563 }
1564 part.UpdateTextureEntry(tex.GetBytes());
1565 return;
1566 }
1567
1377 if (face == ScriptBaseClass.ALL_SIDES) 1568 if (face == ScriptBaseClass.ALL_SIDES)
1378 face = SceneObjectPart.ALL_SIDES; 1569 face = SceneObjectPart.ALL_SIDES;
1379 1570
@@ -1382,6 +1573,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1382 1573
1383 public void SetTexGen(SceneObjectPart part, int face,int style) 1574 public void SetTexGen(SceneObjectPart part, int face,int style)
1384 { 1575 {
1576 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1577 return;
1578
1385 Primitive.TextureEntry tex = part.Shape.Textures; 1579 Primitive.TextureEntry tex = part.Shape.Textures;
1386 MappingType textype; 1580 MappingType textype;
1387 textype = MappingType.Default; 1581 textype = MappingType.Default;
@@ -1412,6 +1606,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1412 1606
1413 public void SetGlow(SceneObjectPart part, int face, float glow) 1607 public void SetGlow(SceneObjectPart part, int face, float glow)
1414 { 1608 {
1609 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1610 return;
1611
1415 Primitive.TextureEntry tex = part.Shape.Textures; 1612 Primitive.TextureEntry tex = part.Shape.Textures;
1416 if (face >= 0 && face < GetNumberOfSides(part)) 1613 if (face >= 0 && face < GetNumberOfSides(part))
1417 { 1614 {
@@ -1437,6 +1634,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1437 1634
1438 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1635 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1439 { 1636 {
1637 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1638 return;
1440 1639
1441 Shininess sval = new Shininess(); 1640 Shininess sval = new Shininess();
1442 1641
@@ -1487,6 +1686,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1487 1686
1488 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1687 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1489 { 1688 {
1689 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1690 return;
1691
1490 Primitive.TextureEntry tex = part.Shape.Textures; 1692 Primitive.TextureEntry tex = part.Shape.Textures;
1491 if (face >= 0 && face < GetNumberOfSides(part)) 1693 if (face >= 0 && face < GetNumberOfSides(part))
1492 { 1694 {
@@ -1547,13 +1749,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1547 m_host.AddScriptLPS(1); 1749 m_host.AddScriptLPS(1);
1548 1750
1549 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1751 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1550 1752 if (parts.Count > 0)
1551 foreach (SceneObjectPart part in parts) 1753 {
1552 SetAlpha(part, alpha, face); 1754 try
1755 {
1756 foreach (SceneObjectPart part in parts)
1757 SetAlpha(part, alpha, face);
1758 }
1759 finally
1760 {
1761 }
1762 }
1553 } 1763 }
1554 1764
1555 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1765 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1556 { 1766 {
1767 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1768 return;
1769
1557 Primitive.TextureEntry tex = part.Shape.Textures; 1770 Primitive.TextureEntry tex = part.Shape.Textures;
1558 Color4 texcolor; 1771 Color4 texcolor;
1559 if (face >= 0 && face < GetNumberOfSides(part)) 1772 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1606,7 +1819,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1606 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1819 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1607 float wind, float tension, LSL_Vector Force) 1820 float wind, float tension, LSL_Vector Force)
1608 { 1821 {
1609 if (part == null) 1822 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1610 return; 1823 return;
1611 1824
1612 if (flexi) 1825 if (flexi)
@@ -1640,7 +1853,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1640 /// <param name="falloff"></param> 1853 /// <param name="falloff"></param>
1641 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1854 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1642 { 1855 {
1643 if (part == null) 1856 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1644 return; 1857 return;
1645 1858
1646 if (light) 1859 if (light)
@@ -1673,11 +1886,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1673 Primitive.TextureEntry tex = part.Shape.Textures; 1886 Primitive.TextureEntry tex = part.Shape.Textures;
1674 Color4 texcolor; 1887 Color4 texcolor;
1675 LSL_Vector rgb = new LSL_Vector(); 1888 LSL_Vector rgb = new LSL_Vector();
1889 int nsides = GetNumberOfSides(part);
1890
1676 if (face == ScriptBaseClass.ALL_SIDES) 1891 if (face == ScriptBaseClass.ALL_SIDES)
1677 { 1892 {
1678 int i; 1893 int i;
1679 1894 for (i = 0; i < nsides; i++)
1680 for (i = 0 ; i < GetNumberOfSides(part); i++)
1681 { 1895 {
1682 texcolor = tex.GetFace((uint)i).RGBA; 1896 texcolor = tex.GetFace((uint)i).RGBA;
1683 rgb.x += texcolor.R; 1897 rgb.x += texcolor.R;
@@ -1685,14 +1899,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1685 rgb.z += texcolor.B; 1899 rgb.z += texcolor.B;
1686 } 1900 }
1687 1901
1688 rgb.x /= (float)GetNumberOfSides(part); 1902 float invnsides = 1.0f / (float)nsides;
1689 rgb.y /= (float)GetNumberOfSides(part); 1903
1690 rgb.z /= (float)GetNumberOfSides(part); 1904 rgb.x *= invnsides;
1905 rgb.y *= invnsides;
1906 rgb.z *= invnsides;
1691 1907
1692 return rgb; 1908 return rgb;
1693 } 1909 }
1694 1910 if (face >= 0 && face < nsides)
1695 if (face >= 0 && face < GetNumberOfSides(part))
1696 { 1911 {
1697 texcolor = tex.GetFace((uint)face).RGBA; 1912 texcolor = tex.GetFace((uint)face).RGBA;
1698 rgb.x = texcolor.R; 1913 rgb.x = texcolor.R;
@@ -1719,15 +1934,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1719 m_host.AddScriptLPS(1); 1934 m_host.AddScriptLPS(1);
1720 1935
1721 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1936 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1722 1937 if (parts.Count > 0)
1723 foreach (SceneObjectPart part in parts) 1938 {
1724 SetTexture(part, texture, face); 1939 try
1725 1940 {
1941 foreach (SceneObjectPart part in parts)
1942 SetTexture(part, texture, face);
1943 }
1944 finally
1945 {
1946 }
1947 }
1726 ScriptSleep(200); 1948 ScriptSleep(200);
1727 } 1949 }
1728 1950
1729 protected void SetTexture(SceneObjectPart part, string texture, int face) 1951 protected void SetTexture(SceneObjectPart part, string texture, int face)
1730 { 1952 {
1953 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1954 return;
1955
1731 UUID textureID = new UUID(); 1956 UUID textureID = new UUID();
1732 1957
1733 textureID = InventoryKey(texture, (int)AssetType.Texture); 1958 textureID = InventoryKey(texture, (int)AssetType.Texture);
@@ -1772,6 +1997,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1772 1997
1773 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1998 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1774 { 1999 {
2000 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2001 return;
2002
1775 Primitive.TextureEntry tex = part.Shape.Textures; 2003 Primitive.TextureEntry tex = part.Shape.Textures;
1776 if (face >= 0 && face < GetNumberOfSides(part)) 2004 if (face >= 0 && face < GetNumberOfSides(part))
1777 { 2005 {
@@ -1808,6 +2036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1808 2036
1809 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 2037 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1810 { 2038 {
2039 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2040 return;
2041
1811 Primitive.TextureEntry tex = part.Shape.Textures; 2042 Primitive.TextureEntry tex = part.Shape.Textures;
1812 if (face >= 0 && face < GetNumberOfSides(part)) 2043 if (face >= 0 && face < GetNumberOfSides(part))
1813 { 2044 {
@@ -1844,6 +2075,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1844 2075
1845 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2076 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1846 { 2077 {
2078 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2079 return;
2080
1847 Primitive.TextureEntry tex = part.Shape.Textures; 2081 Primitive.TextureEntry tex = part.Shape.Textures;
1848 if (face >= 0 && face < GetNumberOfSides(part)) 2082 if (face >= 0 && face < GetNumberOfSides(part))
1849 { 2083 {
@@ -2014,24 +2248,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2014 /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> 2248 /// <param name="adjust">if TRUE, will cap the distance to 10m.</param>
2015 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) 2249 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust)
2016 { 2250 {
2017 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2251 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2252 return;
2253
2018 LSL_Vector currentPos = GetPartLocalPos(part); 2254 LSL_Vector currentPos = GetPartLocalPos(part);
2255 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos);
2019 2256
2020 float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
2021 bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
2022 2257
2023 if (part.ParentGroup.RootPart == part) 2258 if (part.ParentGroup.RootPart == part)
2024 { 2259 {
2025 if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
2026 targetPos.z = ground;
2027 SceneObjectGroup parent = part.ParentGroup; 2260 SceneObjectGroup parent = part.ParentGroup;
2028 parent.UpdateGroupPosition(!adjust ? targetPos : 2261 if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos))
2029 SetPosAdjust(currentPos, targetPos)); 2262 return;
2263 Util.FireAndForget(delegate(object x) {
2264 parent.UpdateGroupPosition((Vector3)toPos);
2265 });
2030 } 2266 }
2031 else 2267 else
2032 { 2268 {
2033 part.OffsetPosition = !adjust ? targetPos : 2269 part.OffsetPosition = (Vector3)toPos;
2034 SetPosAdjust(currentPos, targetPos);
2035 SceneObjectGroup parent = part.ParentGroup; 2270 SceneObjectGroup parent = part.ParentGroup;
2036 parent.HasGroupChanged = true; 2271 parent.HasGroupChanged = true;
2037 parent.ScheduleGroupForTerseUpdate(); 2272 parent.ScheduleGroupForTerseUpdate();
@@ -2064,13 +2299,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2064 else 2299 else
2065 { 2300 {
2066 if (part.ParentGroup.IsAttachment) 2301 if (part.ParentGroup.IsAttachment)
2067 {
2068 pos = part.AttachedPos; 2302 pos = part.AttachedPos;
2069 }
2070 else 2303 else
2071 {
2072 pos = part.AbsolutePosition; 2304 pos = part.AbsolutePosition;
2073 }
2074 } 2305 }
2075 2306
2076// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); 2307// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
@@ -2083,18 +2314,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2083 m_host.AddScriptLPS(1); 2314 m_host.AddScriptLPS(1);
2084 2315
2085 // try to let this work as in SL... 2316 // try to let this work as in SL...
2086 if (m_host.ParentID == 0) 2317 if (m_host.LinkNum < 2)
2087 { 2318 {
2088 // special case: If we are root, rotate complete SOG to new rotation 2319 // Special case: If we are root, rotate complete SOG to new
2320 // rotation.
2321 // We are root if the link number is 0 (single prim) or 1
2322 // (root prim). ParentID may be nonzero in attachments and
2323 // using it would cause attachments and HUDs to rotate
2324 // to the wrong positions.
2325
2089 SetRot(m_host, rot); 2326 SetRot(m_host, rot);
2090 } 2327 }
2091 else 2328 else
2092 { 2329 {
2093 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 2330 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
2094 SceneObjectPart rootPart = m_host.ParentGroup.RootPart; 2331 SceneObjectPart rootPart;
2095 if (rootPart != null) // better safe than sorry 2332 if (m_host.ParentGroup != null) // better safe than sorry
2096 { 2333 {
2097 SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); 2334 rootPart = m_host.ParentGroup.RootPart;
2335 if (rootPart != null)
2336 SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
2098 } 2337 }
2099 } 2338 }
2100 2339
@@ -2110,25 +2349,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2110 2349
2111 protected void SetRot(SceneObjectPart part, Quaternion rot) 2350 protected void SetRot(SceneObjectPart part, Quaternion rot)
2112 { 2351 {
2113 part.UpdateRotation(rot); 2352 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2114 // Update rotation does not move the object in the physics scene if it's a linkset. 2353 return;
2115 2354
2116//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type 2355 bool isroot = (part == part.ParentGroup.RootPart);
2117// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; 2356 bool isphys;
2118 2357
2119 // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
2120 // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
2121 // It's perfectly okay when the object is not an active physical body though.
2122 // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
2123 // but only if the object is not physial and active. This is important for rotating doors.
2124 // without the absoluteposition = absoluteposition happening, the doors do not move in the physics
2125 // scene
2126 PhysicsActor pa = part.PhysActor; 2358 PhysicsActor pa = part.PhysActor;
2127 2359
2128 if (pa != null && !pa.IsPhysical) 2360 // keep using physactor ideia of isphysical
2361 // it should be SOP ideia of that
2362 // not much of a issue with ubitODE
2363 if (pa != null && pa.IsPhysical)
2364 isphys = true;
2365 else
2366 isphys = false;
2367
2368 // SL doesn't let scripts rotate root of physical linksets
2369 if (isroot && isphys)
2370 return;
2371
2372 part.UpdateRotation(rot);
2373
2374 // Update rotation does not move the object in the physics engine if it's a non physical linkset
2375 // so do a nasty update of parts positions if is a root part rotation
2376 if (isroot && pa != null) // with if above implies non physical root part
2129 { 2377 {
2130 part.ParentGroup.ResetChildPrimPhysicsPositions(); 2378 part.ParentGroup.ResetChildPrimPhysicsPositions();
2131 } 2379 }
2380 else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part
2381 {
2382 List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars();
2383 if (sittingavas.Count > 0)
2384 {
2385 foreach (ScenePresence av in sittingavas)
2386 {
2387 if (isroot || part.LocalId == av.ParentID)
2388 av.SendTerseUpdateToAllClients();
2389 }
2390 }
2391 }
2132 } 2392 }
2133 2393
2134 /// <summary> 2394 /// <summary>
@@ -2176,8 +2436,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2176 2436
2177 public LSL_Rotation llGetLocalRot() 2437 public LSL_Rotation llGetLocalRot()
2178 { 2438 {
2439 return GetPartLocalRot(m_host);
2440 }
2441
2442 private LSL_Rotation GetPartLocalRot(SceneObjectPart part)
2443 {
2179 m_host.AddScriptLPS(1); 2444 m_host.AddScriptLPS(1);
2180 return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); 2445 Quaternion rot = part.RotationOffset;
2446 return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
2181 } 2447 }
2182 2448
2183 public void llSetForce(LSL_Vector force, int local) 2449 public void llSetForce(LSL_Vector force, int local)
@@ -2257,16 +2523,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2257 m_host.ApplyImpulse(v, local != 0); 2523 m_host.ApplyImpulse(v, local != 0);
2258 } 2524 }
2259 2525
2526
2260 public void llApplyRotationalImpulse(LSL_Vector force, int local) 2527 public void llApplyRotationalImpulse(LSL_Vector force, int local)
2261 { 2528 {
2262 m_host.AddScriptLPS(1); 2529 m_host.AddScriptLPS(1);
2263 m_host.ApplyAngularImpulse(force, local != 0); 2530 m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0);
2264 } 2531 }
2265 2532
2266 public void llSetTorque(LSL_Vector torque, int local) 2533 public void llSetTorque(LSL_Vector torque, int local)
2267 { 2534 {
2268 m_host.AddScriptLPS(1); 2535 m_host.AddScriptLPS(1);
2269 m_host.SetAngularImpulse(torque, local != 0); 2536 m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0);
2270 } 2537 }
2271 2538
2272 public LSL_Vector llGetTorque() 2539 public LSL_Vector llGetTorque()
@@ -2283,20 +2550,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2283 llSetTorque(torque, local); 2550 llSetTorque(torque, local);
2284 } 2551 }
2285 2552
2553 public void llSetVelocity(LSL_Vector vel, int local)
2554 {
2555 m_host.AddScriptLPS(1);
2556 m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0);
2557 }
2558
2286 public LSL_Vector llGetVel() 2559 public LSL_Vector llGetVel()
2287 { 2560 {
2288 m_host.AddScriptLPS(1); 2561 m_host.AddScriptLPS(1);
2289 2562
2290 Vector3 vel; 2563 Vector3 vel = Vector3.Zero;
2291 2564
2292 if (m_host.ParentGroup.IsAttachment) 2565 if (m_host.ParentGroup.IsAttachment)
2293 { 2566 {
2294 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); 2567 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar);
2295 vel = avatar.Velocity; 2568 if (avatar != null)
2569 vel = avatar.Velocity;
2296 } 2570 }
2297 else 2571 else
2298 { 2572 {
2299 vel = m_host.Velocity; 2573 vel = m_host.ParentGroup.RootPart.Velocity;
2300 } 2574 }
2301 2575
2302 return new LSL_Vector(vel.X, vel.Y, vel.Z); 2576 return new LSL_Vector(vel.X, vel.Y, vel.Z);
@@ -2308,10 +2582,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2308 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); 2582 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
2309 } 2583 }
2310 2584
2585 public void llSetAngularVelocity(LSL_Vector avel, int local)
2586 {
2587 m_host.AddScriptLPS(1);
2588 m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
2589 }
2590
2311 public LSL_Vector llGetOmega() 2591 public LSL_Vector llGetOmega()
2312 { 2592 {
2313 m_host.AddScriptLPS(1); 2593 m_host.AddScriptLPS(1);
2314 return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); 2594 Vector3 avel = m_host.AngularVelocity;
2595 return new LSL_Vector(avel.X, avel.Y, avel.Z);
2315 } 2596 }
2316 2597
2317 public LSL_Float llGetTimeOfDay() 2598 public LSL_Float llGetTimeOfDay()
@@ -2837,16 +3118,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2837 new_group.RootPart.UUID.ToString()) }, 3118 new_group.RootPart.UUID.ToString()) },
2838 new DetectParams[0])); 3119 new DetectParams[0]));
2839 3120
2840 float groupmass = new_group.GetMass(); 3121 // do recoil
3122 SceneObjectGroup hostgrp = m_host.ParentGroup;
3123 if (hostgrp == null)
3124 return;
3125
3126 if (hostgrp.IsAttachment) // don't recoil avatars
3127 return;
2841 3128
2842 PhysicsActor pa = new_group.RootPart.PhysActor; 3129 PhysicsActor pa = new_group.RootPart.PhysActor;
2843 3130
2844 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) 3131 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
2845 { 3132 {
2846 //Recoil. 3133 float groupmass = new_group.GetMass();
2847 llApplyImpulse(vel * groupmass, 0); 3134 vel *= -groupmass;
3135 llApplyImpulse(vel, 0);
2848 } 3136 }
2849 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3137 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3138 return;
3139
2850 }); 3140 });
2851 3141
2852 //ScriptSleep((int)((groupmass * velmag) / 10)); 3142 //ScriptSleep((int)((groupmass * velmag) / 10));
@@ -2861,35 +3151,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2861 public void llLookAt(LSL_Vector target, double strength, double damping) 3151 public void llLookAt(LSL_Vector target, double strength, double damping)
2862 { 3152 {
2863 m_host.AddScriptLPS(1); 3153 m_host.AddScriptLPS(1);
2864 // Determine where we are looking from
2865 LSL_Vector from = llGetPos();
2866 3154
2867 // Work out the normalised vector from the source to the target 3155 // Get the normalized vector to the target
2868 LSL_Vector delta = llVecNorm(target - from); 3156 LSL_Vector d1 = llVecNorm(target - llGetPos());
2869 LSL_Vector angle = new LSL_Vector(0,0,0);
2870 3157
2871 // Calculate the yaw 3158 // Get the bearing (yaw)
2872 // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system 3159 LSL_Vector a1 = new LSL_Vector(0,0,0);
2873 angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; 3160 a1.z = llAtan2(d1.y, d1.x);
2874 3161
2875 // Calculate pitch 3162 // Get the elevation (pitch)
2876 angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); 3163 LSL_Vector a2 = new LSL_Vector(0,0,0);
3164 a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y)));
2877 3165
2878 // we need to convert from a vector describing 3166 LSL_Rotation r1 = llEuler2Rot(a1);
2879 // the angles of rotation in radians into rotation value 3167 LSL_Rotation r2 = llEuler2Rot(a2);
2880 LSL_Rotation rot = llEuler2Rot(angle); 3168 LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107);
2881
2882 // Per discussion with Melanie, for non-physical objects llLookAt appears to simply
2883 // set the rotation of the object, copy that behavior
2884 PhysicsActor pa = m_host.PhysActor;
2885 3169
2886 if (strength == 0 || pa == null || !pa.IsPhysical) 3170 if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
2887 { 3171 {
2888 llSetRot(rot); 3172 // Do nothing if either value is 0 (this has been checked in SL)
3173 if (strength <= 0.0 || damping <= 0.0)
3174 return;
3175
3176 llSetRot(r3 * r2 * r1);
2889 } 3177 }
2890 else 3178 else
2891 { 3179 {
2892 m_host.StartLookAt(rot, (float)strength, (float)damping); 3180 if (strength == 0)
3181 {
3182 llSetRot(r3 * r2 * r1);
3183 return;
3184 }
3185
3186 m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping);
2893 } 3187 }
2894 } 3188 }
2895 3189
@@ -2935,17 +3229,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2935 } 3229 }
2936 else 3230 else
2937 { 3231 {
2938 if (m_host.IsRoot) 3232 // new SL always returns object mass
2939 { 3233// if (m_host.IsRoot)
3234// {
2940 return m_host.ParentGroup.GetMass(); 3235 return m_host.ParentGroup.GetMass();
2941 } 3236// }
2942 else 3237// else
2943 { 3238// {
2944 return m_host.GetMass(); 3239// return m_host.GetMass();
2945 } 3240// }
2946 } 3241 }
2947 } 3242 }
2948 3243
3244
3245 public LSL_Float llGetMassMKS()
3246 {
3247 return 100f * llGetMass();
3248 }
3249
2949 public void llCollisionFilter(string name, string id, int accept) 3250 public void llCollisionFilter(string name, string id, int accept)
2950 { 3251 {
2951 m_host.AddScriptLPS(1); 3252 m_host.AddScriptLPS(1);
@@ -2993,8 +3294,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2993 { 3294 {
2994 // Unregister controls from Presence 3295 // Unregister controls from Presence
2995 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); 3296 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
2996 // Remove Take Control permission.
2997 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
2998 } 3297 }
2999 } 3298 }
3000 } 3299 }
@@ -3020,7 +3319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3020 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3319 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3021 3320
3022 if (attachmentsModule != null) 3321 if (attachmentsModule != null)
3023 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false); 3322 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false);
3024 else 3323 else
3025 return false; 3324 return false;
3026 } 3325 }
@@ -3050,9 +3349,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3050 { 3349 {
3051 m_host.AddScriptLPS(1); 3350 m_host.AddScriptLPS(1);
3052 3351
3053// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3054// return;
3055
3056 if (m_item.PermsGranter != m_host.OwnerID) 3352 if (m_item.PermsGranter != m_host.OwnerID)
3057 return; 3353 return;
3058 3354
@@ -3095,6 +3391,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3391
3096 public void llInstantMessage(string user, string message) 3392 public void llInstantMessage(string user, string message)
3097 { 3393 {
3394 UUID result;
3395 if (!UUID.TryParse(user, out result))
3396 {
3397 ShoutError("An invalid key was passed to llInstantMessage");
3398 ScriptSleep(2000);
3399 return;
3400 }
3401
3402
3098 m_host.AddScriptLPS(1); 3403 m_host.AddScriptLPS(1);
3099 3404
3100 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3405 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -3109,14 +3414,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3109 UUID friendTransactionID = UUID.Random(); 3414 UUID friendTransactionID = UUID.Random();
3110 3415
3111 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3416 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
3112 3417
3113 GridInstantMessage msg = new GridInstantMessage(); 3418 GridInstantMessage msg = new GridInstantMessage();
3114 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3419 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
3115 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3420 msg.toAgentID = new Guid(user); // toAgentID.Guid;
3116 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3421 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3117// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3422// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3118// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3423// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3119 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3424// DateTime dt = DateTime.UtcNow;
3425//
3426// // Ticks from UtcNow, but make it look like local. Evil, huh?
3427// dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3428//
3429// try
3430// {
3431// // Convert that to the PST timezone
3432// TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3433// dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3434// }
3435// catch
3436// {
3437// // No logging here, as it could be VERY spammy
3438// }
3439//
3440// // And make it look local again to fool the unix time util
3441// dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3442
3443 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
3444
3120 //if (client != null) 3445 //if (client != null)
3121 //{ 3446 //{
3122 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3447 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
@@ -3130,12 +3455,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3130 msg.message = message.Substring(0, 1024); 3455 msg.message = message.Substring(0, 1024);
3131 else 3456 else
3132 msg.message = message; 3457 msg.message = message;
3133 msg.dialog = (byte)19; // messgage from script ??? // dialog; 3458 msg.dialog = (byte)19; // MessageFromObject
3134 msg.fromGroup = false;// fromGroup; 3459 msg.fromGroup = false;// fromGroup;
3135 msg.offline = (byte)0; //offline; 3460 msg.offline = (byte)0; //offline;
3136 msg.ParentEstateID = 0; //ParentEstateID; 3461 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3137 msg.Position = new Vector3(m_host.AbsolutePosition); 3462 msg.Position = new Vector3(m_host.AbsolutePosition);
3138 msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; 3463 msg.RegionID = World.RegionInfo.RegionID.Guid;
3139 msg.binaryBucket 3464 msg.binaryBucket
3140 = Util.StringToBytes256( 3465 = Util.StringToBytes256(
3141 "{0}/{1}/{2}/{3}", 3466 "{0}/{1}/{2}/{3}",
@@ -3163,7 +3488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3163 } 3488 }
3164 3489
3165 emailModule.SendEmail(m_host.UUID, address, subject, message); 3490 emailModule.SendEmail(m_host.UUID, address, subject, message);
3166 llSleep(EMAIL_PAUSE_TIME); 3491 ScriptSleep(EMAIL_PAUSE_TIME * 1000);
3167 } 3492 }
3168 3493
3169 public void llGetNextEmail(string address, string subject) 3494 public void llGetNextEmail(string address, string subject)
@@ -3409,7 +3734,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3409 implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | 3734 implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS |
3410 ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | 3735 ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
3411 ScriptBaseClass.PERMISSION_CONTROL_CAMERA | 3736 ScriptBaseClass.PERMISSION_CONTROL_CAMERA |
3737 ScriptBaseClass.PERMISSION_TRACK_CAMERA |
3412 ScriptBaseClass.PERMISSION_ATTACH; 3738 ScriptBaseClass.PERMISSION_ATTACH;
3739
3413 } 3740 }
3414 else 3741 else
3415 { 3742 {
@@ -3444,11 +3771,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3444 3771
3445 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3772 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3446 { 3773 {
3447 lock (m_host.TaskInventory) 3774 m_host.TaskInventory.LockItemsForWrite(true);
3448 { 3775 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3449 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; 3776 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3450 m_host.TaskInventory[m_item.ItemID].PermsMask = perm; 3777 m_host.TaskInventory.LockItemsForWrite(false);
3451 }
3452 3778
3453 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( 3779 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3454 "run_time_permissions", new Object[] { 3780 "run_time_permissions", new Object[] {
@@ -3491,11 +3817,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3491 3817
3492 if (!m_waitingForScriptAnswer) 3818 if (!m_waitingForScriptAnswer)
3493 { 3819 {
3494 lock (m_host.TaskInventory) 3820 m_host.TaskInventory.LockItemsForWrite(true);
3495 { 3821 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3496 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; 3822 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3497 m_host.TaskInventory[m_item.ItemID].PermsMask = 0; 3823 m_host.TaskInventory.LockItemsForWrite(false);
3498 }
3499 3824
3500 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3825 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3501 m_waitingForScriptAnswer=true; 3826 m_waitingForScriptAnswer=true;
@@ -3524,14 +3849,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3524 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3849 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3525 llReleaseControls(); 3850 llReleaseControls();
3526 3851
3527 lock (m_host.TaskInventory) 3852 m_host.TaskInventory.LockItemsForWrite(true);
3528 { 3853 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
3529 m_host.TaskInventory[m_item.ItemID].PermsMask = answer; 3854 m_host.TaskInventory.LockItemsForWrite(false);
3530 } 3855
3531 3856 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3532 m_ScriptEngine.PostScriptEvent( 3857 "run_time_permissions", new Object[] {
3533 m_item.ItemID, 3858 new LSL_Integer(answer) },
3534 new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); 3859 new DetectParams[0]));
3535 } 3860 }
3536 3861
3537 public LSL_String llGetPermissionsKey() 3862 public LSL_String llGetPermissionsKey()
@@ -3570,14 +3895,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3570 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3895 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3571 { 3896 {
3572 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3897 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3573 3898 if (parts.Count > 0)
3574 foreach (SceneObjectPart part in parts) 3899 {
3575 part.SetFaceColor(color, face); 3900 try
3901 {
3902 foreach (SceneObjectPart part in parts)
3903 part.SetFaceColor(color, face);
3904 }
3905 finally
3906 {
3907 }
3908 }
3576 } 3909 }
3577 3910
3578 public void llCreateLink(string target, int parent) 3911 public void llCreateLink(string target, int parent)
3579 { 3912 {
3580 m_host.AddScriptLPS(1); 3913 m_host.AddScriptLPS(1);
3914
3581 UUID targetID; 3915 UUID targetID;
3582 3916
3583 if (!UUID.TryParse(target, out targetID)) 3917 if (!UUID.TryParse(target, out targetID))
@@ -3683,10 +4017,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3683 // Restructuring Multiple Prims. 4017 // Restructuring Multiple Prims.
3684 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); 4018 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts);
3685 parts.Remove(parentPrim.RootPart); 4019 parts.Remove(parentPrim.RootPart);
3686 foreach (SceneObjectPart part in parts) 4020 if (parts.Count > 0)
3687 { 4021 {
3688 parentPrim.DelinkFromGroup(part.LocalId, true); 4022 try
4023 {
4024 foreach (SceneObjectPart part in parts)
4025 {
4026 parentPrim.DelinkFromGroup(part.LocalId, true);
4027 }
4028 }
4029 finally
4030 {
4031 }
3689 } 4032 }
4033
3690 parentPrim.HasGroupChanged = true; 4034 parentPrim.HasGroupChanged = true;
3691 parentPrim.ScheduleGroupForFullUpdate(); 4035 parentPrim.ScheduleGroupForFullUpdate();
3692 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 4036 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3695,12 +4039,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3695 { 4039 {
3696 SceneObjectPart newRoot = parts[0]; 4040 SceneObjectPart newRoot = parts[0];
3697 parts.Remove(newRoot); 4041 parts.Remove(newRoot);
3698 foreach (SceneObjectPart part in parts) 4042
4043 try
3699 { 4044 {
3700 // Required for linking 4045 foreach (SceneObjectPart part in parts)
3701 part.ClearUpdateSchedule(); 4046 {
3702 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 4047 part.ClearUpdateSchedule();
4048 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
4049 }
3703 } 4050 }
4051 finally
4052 {
4053 }
4054
4055
3704 newRoot.ParentGroup.HasGroupChanged = true; 4056 newRoot.ParentGroup.HasGroupChanged = true;
3705 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 4057 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3706 } 4058 }
@@ -3720,6 +4072,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3720 public void llBreakAllLinks() 4072 public void llBreakAllLinks()
3721 { 4073 {
3722 m_host.AddScriptLPS(1); 4074 m_host.AddScriptLPS(1);
4075
4076 TaskInventoryItem item = m_item;
4077
4078 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4079 && !m_automaticLinkPermission)
4080 {
4081 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4082 return;
4083 }
4084
3723 SceneObjectGroup parentPrim = m_host.ParentGroup; 4085 SceneObjectGroup parentPrim = m_host.ParentGroup;
3724 if (parentPrim.AttachmentPoint != 0) 4086 if (parentPrim.AttachmentPoint != 0)
3725 return; // Fail silently if attached 4087 return; // Fail silently if attached
@@ -3739,25 +4101,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3739 public LSL_String llGetLinkKey(int linknum) 4101 public LSL_String llGetLinkKey(int linknum)
3740 { 4102 {
3741 m_host.AddScriptLPS(1); 4103 m_host.AddScriptLPS(1);
3742 List<UUID> keytable = new List<UUID>();
3743 // parse for sitting avatare-uuids
3744 World.ForEachRootScenePresence(delegate(ScenePresence presence)
3745 {
3746 if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID))
3747 keytable.Add(presence.UUID);
3748 });
3749
3750 int totalprims = m_host.ParentGroup.PrimCount + keytable.Count;
3751 if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims)
3752 {
3753 return keytable[totalprims - linknum].ToString();
3754 }
3755
3756 if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && keytable.Count == 1)
3757 {
3758 return m_host.UUID.ToString();
3759 }
3760
3761 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); 4104 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
3762 if (part != null) 4105 if (part != null)
3763 { 4106 {
@@ -3765,6 +4108,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3765 } 4108 }
3766 else 4109 else
3767 { 4110 {
4111 if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1))
4112 {
4113 linknum -= (m_host.ParentGroup.PrimCount) + 1;
4114
4115 if (linknum < 0)
4116 return UUID.Zero.ToString();
4117
4118 List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET);
4119 if (avatars.Count > linknum)
4120 {
4121 return avatars[linknum].UUID.ToString();
4122 }
4123 }
3768 return UUID.Zero.ToString(); 4124 return UUID.Zero.ToString();
3769 } 4125 }
3770 } 4126 }
@@ -3864,17 +4220,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3864 m_host.AddScriptLPS(1); 4220 m_host.AddScriptLPS(1);
3865 int count = 0; 4221 int count = 0;
3866 4222
3867 lock (m_host.TaskInventory) 4223 m_host.TaskInventory.LockItemsForRead(true);
4224 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3868 { 4225 {
3869 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4226 if (inv.Value.Type == type || type == -1)
3870 { 4227 {
3871 if (inv.Value.Type == type || type == -1) 4228 count = count + 1;
3872 {
3873 count = count + 1;
3874 }
3875 } 4229 }
3876 } 4230 }
3877 4231
4232 m_host.TaskInventory.LockItemsForRead(false);
3878 return count; 4233 return count;
3879 } 4234 }
3880 4235
@@ -3883,16 +4238,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3883 m_host.AddScriptLPS(1); 4238 m_host.AddScriptLPS(1);
3884 ArrayList keys = new ArrayList(); 4239 ArrayList keys = new ArrayList();
3885 4240
3886 lock (m_host.TaskInventory) 4241 m_host.TaskInventory.LockItemsForRead(true);
4242 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3887 { 4243 {
3888 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4244 if (inv.Value.Type == type || type == -1)
3889 { 4245 {
3890 if (inv.Value.Type == type || type == -1) 4246 keys.Add(inv.Value.Name);
3891 {
3892 keys.Add(inv.Value.Name);
3893 }
3894 } 4247 }
3895 } 4248 }
4249 m_host.TaskInventory.LockItemsForRead(false);
3896 4250
3897 if (keys.Count == 0) 4251 if (keys.Count == 0)
3898 { 4252 {
@@ -3930,7 +4284,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3930 if (item == null) 4284 if (item == null)
3931 { 4285 {
3932 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4286 llSay(0, String.Format("Could not find object '{0}'", inventory));
3933 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4287 return;
4288// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3934 } 4289 }
3935 4290
3936 UUID objId = item.ItemID; 4291 UUID objId = item.ItemID;
@@ -3958,33 +4313,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3958 return; 4313 return;
3959 } 4314 }
3960 } 4315 }
4316
3961 // destination is an avatar 4317 // destination is an avatar
3962 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4318 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
3963 4319
3964 if (agentItem == null) 4320 if (agentItem == null)
3965 return; 4321 return;
3966 4322
3967 if (m_TransferModule != null) 4323 byte[] bucket = new byte[1];
3968 { 4324 bucket[0] = (byte)item.Type;
3969 byte[] bucket = new byte[] { (byte)item.Type }; 4325 //byte[] objBytes = agentItem.ID.GetBytes();
4326 //Array.Copy(objBytes, 0, bucket, 1, 16);
4327
4328 GridInstantMessage msg = new GridInstantMessage(World,
4329 m_host.OwnerID, m_host.Name, destId,
4330 (byte)InstantMessageDialog.TaskInventoryOffered,
4331 false, item.Name+". "+m_host.Name+" is located at "+
4332 World.RegionInfo.RegionName+" "+
4333 m_host.AbsolutePosition.ToString(),
4334 agentItem.ID, true, m_host.AbsolutePosition,
4335 bucket);
3970 4336
3971 GridInstantMessage msg = new GridInstantMessage(World, 4337 ScenePresence sp;
3972 m_host.UUID, m_host.Name + ", an object owned by " +
3973 resolveName(m_host.OwnerID) + ",", destId,
3974 (byte)InstantMessageDialog.TaskInventoryOffered,
3975 false, item.Name + "\n" + m_host.Name + " is located at " +
3976 World.RegionInfo.RegionName+" "+
3977 m_host.AbsolutePosition.ToString(),
3978 agentItem.ID, true, m_host.AbsolutePosition,
3979 bucket);
3980 4338
3981 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4339 if (World.TryGetScenePresence(destId, out sp))
4340 {
4341 sp.ControllingClient.SendInstantMessage(msg);
3982 } 4342 }
3983 4343 else
4344 {
4345 if (m_TransferModule != null)
4346 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4347 }
4348
4349 //This delay should only occur when giving inventory to avatars.
3984 ScriptSleep(3000); 4350 ScriptSleep(3000);
3985 } 4351 }
3986 } 4352 }
3987 4353
4354 [DebuggerNonUserCode]
3988 public void llRemoveInventory(string name) 4355 public void llRemoveInventory(string name)
3989 { 4356 {
3990 m_host.AddScriptLPS(1); 4357 m_host.AddScriptLPS(1);
@@ -4028,109 +4395,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4028 { 4395 {
4029 m_host.AddScriptLPS(1); 4396 m_host.AddScriptLPS(1);
4030 4397
4031 UUID uuid = (UUID)id; 4398 UUID uuid;
4032 PresenceInfo pinfo = null; 4399 if (UUID.TryParse(id, out uuid))
4033 UserAccount account;
4034
4035 UserInfoCacheEntry ce;
4036 if (!m_userInfoCache.TryGetValue(uuid, out ce))
4037 { 4400 {
4038 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 4401 PresenceInfo pinfo = null;
4039 if (account == null) 4402 UserAccount account;
4403
4404 UserInfoCacheEntry ce;
4405 if (!m_userInfoCache.TryGetValue(uuid, out ce))
4040 { 4406 {
4041 m_userInfoCache[uuid] = null; // Cache negative 4407 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
4042 return UUID.Zero.ToString(); 4408 if (account == null)
4043 } 4409 {
4410 m_userInfoCache[uuid] = null; // Cache negative
4411 return UUID.Zero.ToString();
4412 }
4044 4413
4045 4414
4046 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 4415 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4047 if (pinfos != null && pinfos.Length > 0) 4416 if (pinfos != null && pinfos.Length > 0)
4048 {
4049 foreach (PresenceInfo p in pinfos)
4050 { 4417 {
4051 if (p.RegionID != UUID.Zero) 4418 foreach (PresenceInfo p in pinfos)
4052 { 4419 {
4053 pinfo = p; 4420 if (p.RegionID != UUID.Zero)
4421 {
4422 pinfo = p;
4423 }
4054 } 4424 }
4055 } 4425 }
4056 }
4057 4426
4058 ce = new UserInfoCacheEntry(); 4427 ce = new UserInfoCacheEntry();
4059 ce.time = Util.EnvironmentTickCount(); 4428 ce.time = Util.EnvironmentTickCount();
4060 ce.account = account; 4429 ce.account = account;
4061 ce.pinfo = pinfo; 4430 ce.pinfo = pinfo;
4062 } 4431 m_userInfoCache[uuid] = ce;
4063 else 4432 }
4064 { 4433 else
4065 if (ce == null) 4434 {
4066 return UUID.Zero.ToString(); 4435 if (ce == null)
4436 return UUID.Zero.ToString();
4067 4437
4068 account = ce.account; 4438 account = ce.account;
4069 pinfo = ce.pinfo; 4439 pinfo = ce.pinfo;
4070 } 4440 }
4071 4441
4072 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) 4442 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
4073 {
4074 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4075 if (pinfos != null && pinfos.Length > 0)
4076 { 4443 {
4077 foreach (PresenceInfo p in pinfos) 4444 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4445 if (pinfos != null && pinfos.Length > 0)
4078 { 4446 {
4079 if (p.RegionID != UUID.Zero) 4447 foreach (PresenceInfo p in pinfos)
4080 { 4448 {
4081 pinfo = p; 4449 if (p.RegionID != UUID.Zero)
4450 {
4451 pinfo = p;
4452 }
4082 } 4453 }
4083 } 4454 }
4084 } 4455 else
4085 else 4456 pinfo = null;
4086 pinfo = null;
4087 4457
4088 ce.time = Util.EnvironmentTickCount(); 4458 ce.time = Util.EnvironmentTickCount();
4089 ce.pinfo = pinfo; 4459 ce.pinfo = pinfo;
4090 } 4460 }
4091 4461
4092 string reply = String.Empty; 4462 string reply = String.Empty;
4093 4463
4094 switch (data) 4464 switch (data)
4095 { 4465 {
4096 case 1: // DATA_ONLINE (0|1) 4466 case 1: // DATA_ONLINE (0|1)
4097 if (pinfo != null && pinfo.RegionID != UUID.Zero) 4467 if (pinfo != null && pinfo.RegionID != UUID.Zero)
4098 reply = "1"; 4468 reply = "1";
4099 else 4469 else
4100 reply = "0"; 4470 reply = "0";
4101 break; 4471 break;
4102 case 2: // DATA_NAME (First Last) 4472 case 2: // DATA_NAME (First Last)
4103 reply = account.FirstName + " " + account.LastName; 4473 reply = account.FirstName + " " + account.LastName;
4104 break; 4474 break;
4105 case 3: // DATA_BORN (YYYY-MM-DD) 4475 case 3: // DATA_BORN (YYYY-MM-DD)
4106 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 4476 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
4107 born = born.AddSeconds(account.Created); 4477 born = born.AddSeconds(account.Created);
4108 reply = born.ToString("yyyy-MM-dd"); 4478 reply = born.ToString("yyyy-MM-dd");
4109 break; 4479 break;
4110 case 4: // DATA_RATING (0,0,0,0,0,0) 4480 case 4: // DATA_RATING (0,0,0,0,0,0)
4111 reply = "0,0,0,0,0,0"; 4481 reply = "0,0,0,0,0,0";
4112 break; 4482 break;
4113 case 7: // DATA_USERLEVEL (integer) 4483 case 8: // DATA_PAYINFO (0|1|2|3)
4114 reply = account.UserLevel.ToString(); 4484 reply = "0";
4115 break; 4485 break;
4116 case 8: // DATA_PAYINFO (0|1|2|3) 4486 default:
4117 reply = "0"; 4487 return UUID.Zero.ToString(); // Raise no event
4118 break; 4488 }
4119 default:
4120 return UUID.Zero.ToString(); // Raise no event
4121 }
4122 4489
4123 UUID rq = UUID.Random(); 4490 UUID rq = UUID.Random();
4124 4491
4125 UUID tid = AsyncCommands. 4492 UUID tid = AsyncCommands.
4126 DataserverPlugin.RegisterRequest(m_host.LocalId, 4493 DataserverPlugin.RegisterRequest(m_host.LocalId,
4127 m_item.ItemID, rq.ToString()); 4494 m_item.ItemID, rq.ToString());
4128 4495
4129 AsyncCommands. 4496 AsyncCommands.
4130 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4497 DataserverPlugin.DataserverReply(rq.ToString(), reply);
4131 4498
4132 ScriptSleep(100); 4499 ScriptSleep(100);
4133 return tid.ToString(); 4500 return tid.ToString();
4501 }
4502 else
4503 {
4504 ShoutError("Invalid UUID passed to llRequestAgentData.");
4505 }
4506 return "";
4134 } 4507 }
4135 4508
4136 public LSL_String llRequestInventoryData(string name) 4509 public LSL_String llRequestInventoryData(string name)
@@ -4187,13 +4560,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4187 if (UUID.TryParse(agent, out agentId)) 4560 if (UUID.TryParse(agent, out agentId))
4188 { 4561 {
4189 ScenePresence presence = World.GetScenePresence(agentId); 4562 ScenePresence presence = World.GetScenePresence(agentId);
4190 if (presence != null) 4563 if (presence != null && presence.PresenceType != PresenceType.Npc)
4191 { 4564 {
4565 // agent must not be a god
4566 if (presence.UserLevel >= 200) return;
4567
4192 // agent must be over the owners land 4568 // agent must be over the owners land
4193 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4569 if (m_host.OwnerID == World.LandChannel.GetLandObject(
4194 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4570 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
4195 { 4571 {
4196 World.TeleportClientHome(agentId, presence.ControllingClient); 4572 if (!World.TeleportClientHome(agentId, presence.ControllingClient))
4573 {
4574 // They can't be teleported home for some reason
4575 GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6"));
4576 if (regionInfo != null)
4577 {
4578 World.RequestTeleportLocation(
4579 presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero,
4580 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
4581 }
4582 }
4197 } 4583 }
4198 } 4584 }
4199 } 4585 }
@@ -4300,7 +4686,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4300 UUID av = new UUID(); 4686 UUID av = new UUID();
4301 if (!UUID.TryParse(agent,out av)) 4687 if (!UUID.TryParse(agent,out av))
4302 { 4688 {
4303 LSLError("First parameter to llDialog needs to be a key"); 4689 //LSLError("First parameter to llDialog needs to be a key");
4304 return; 4690 return;
4305 } 4691 }
4306 4692
@@ -4332,7 +4718,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4332 public void llCollisionSound(string impact_sound, double impact_volume) 4718 public void llCollisionSound(string impact_sound, double impact_volume)
4333 { 4719 {
4334 m_host.AddScriptLPS(1); 4720 m_host.AddScriptLPS(1);
4335 4721
4722 if(impact_sound == "")
4723 {
4724 m_host.CollisionSoundVolume = (float)impact_volume;
4725 m_host.CollisionSound = m_host.invalidCollisionSoundUUID;
4726 m_host.CollisionSoundType = 0;
4727 return;
4728 }
4336 // TODO: Parameter check logic required. 4729 // TODO: Parameter check logic required.
4337 UUID soundId = UUID.Zero; 4730 UUID soundId = UUID.Zero;
4338 if (!UUID.TryParse(impact_sound, out soundId)) 4731 if (!UUID.TryParse(impact_sound, out soundId))
@@ -4345,6 +4738,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4345 4738
4346 m_host.CollisionSound = soundId; 4739 m_host.CollisionSound = soundId;
4347 m_host.CollisionSoundVolume = (float)impact_volume; 4740 m_host.CollisionSoundVolume = (float)impact_volume;
4741 m_host.CollisionSoundType = 1;
4348 } 4742 }
4349 4743
4350 public LSL_String llGetAnimation(string id) 4744 public LSL_String llGetAnimation(string id)
@@ -4358,14 +4752,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4358 4752
4359 if (m_host.RegionHandle == presence.RegionHandle) 4753 if (m_host.RegionHandle == presence.RegionHandle)
4360 { 4754 {
4361 Dictionary<UUID, string> animationstateNames = DefaultAvatarAnimations.AnimStateNames;
4362
4363 if (presence != null) 4755 if (presence != null)
4364 { 4756 {
4365 AnimationSet currentAnims = presence.Animator.Animations; 4757 if (presence.SitGround)
4366 string currentAnimationState = String.Empty; 4758 return "Sitting on Ground";
4367 if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState)) 4759 if (presence.ParentID != 0 || presence.ParentUUID != UUID.Zero)
4368 return currentAnimationState; 4760 return "Sitting";
4761
4762 string movementAnimation = presence.Animator.CurrentMovementAnimation;
4763 string lslMovementAnimation;
4764
4765 if (MovementAnimationsForLSL.TryGetValue(movementAnimation, out lslMovementAnimation))
4766 return lslMovementAnimation;
4369 } 4767 }
4370 } 4768 }
4371 4769
@@ -4512,7 +4910,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4512 { 4910 {
4513 float distance = (PusheePos - m_host.AbsolutePosition).Length(); 4911 float distance = (PusheePos - m_host.AbsolutePosition).Length();
4514 float distance_term = distance * distance * distance; // Script Energy 4912 float distance_term = distance * distance * distance; // Script Energy
4515 float pusher_mass = m_host.GetMass(); 4913 // use total object mass and not part
4914 float pusher_mass = m_host.ParentGroup.GetMass();
4516 4915
4517 float PUSH_ATTENUATION_DISTANCE = 17f; 4916 float PUSH_ATTENUATION_DISTANCE = 17f;
4518 float PUSH_ATTENUATION_SCALE = 5f; 4917 float PUSH_ATTENUATION_SCALE = 5f;
@@ -4762,6 +5161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4762 { 5161 {
4763 return item.AssetID.ToString(); 5162 return item.AssetID.ToString();
4764 } 5163 }
5164 m_host.TaskInventory.LockItemsForRead(false);
4765 5165
4766 return UUID.Zero.ToString(); 5166 return UUID.Zero.ToString();
4767 } 5167 }
@@ -4895,7 +5295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4895 public LSL_Vector llGetCenterOfMass() 5295 public LSL_Vector llGetCenterOfMass()
4896 { 5296 {
4897 m_host.AddScriptLPS(1); 5297 m_host.AddScriptLPS(1);
4898 Vector3 center = m_host.GetGeometricCenter(); 5298 Vector3 center = m_host.GetCenterOfMass();
4899 return new LSL_Vector(center.X,center.Y,center.Z); 5299 return new LSL_Vector(center.X,center.Y,center.Z);
4900 } 5300 }
4901 5301
@@ -4914,14 +5314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4914 { 5314 {
4915 m_host.AddScriptLPS(1); 5315 m_host.AddScriptLPS(1);
4916 5316
4917 if (src == null) 5317 return src.Length;
4918 {
4919 return 0;
4920 }
4921 else
4922 {
4923 return src.Length;
4924 }
4925 } 5318 }
4926 5319
4927 public LSL_Integer llList2Integer(LSL_List src, int index) 5320 public LSL_Integer llList2Integer(LSL_List src, int index)
@@ -4992,7 +5385,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4992 else if (src.Data[index] is LSL_Float) 5385 else if (src.Data[index] is LSL_Float)
4993 return Convert.ToDouble(((LSL_Float)src.Data[index]).value); 5386 return Convert.ToDouble(((LSL_Float)src.Data[index]).value);
4994 else if (src.Data[index] is LSL_String) 5387 else if (src.Data[index] is LSL_String)
4995 return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); 5388 {
5389 string str = ((LSL_String) src.Data[index]).m_string;
5390 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
5391 if (m != Match.Empty)
5392 {
5393 str = m.Value;
5394 double d = 0.0;
5395 if (!Double.TryParse(str, out d))
5396 return 0.0;
5397
5398 return d;
5399 }
5400 return 0.0;
5401 }
4996 return Convert.ToDouble(src.Data[index]); 5402 return Convert.ToDouble(src.Data[index]);
4997 } 5403 }
4998 catch (FormatException) 5404 catch (FormatException)
@@ -5302,7 +5708,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5302 } 5708 }
5303 } 5709 }
5304 } 5710 }
5305 else { 5711 else
5712 {
5306 object[] array = new object[src.Length]; 5713 object[] array = new object[src.Length];
5307 Array.Copy(src.Data, 0, array, 0, src.Length); 5714 Array.Copy(src.Data, 0, array, 0, src.Length);
5308 result = new LSL_List(array); 5715 result = new LSL_List(array);
@@ -5409,7 +5816,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5409 public LSL_Integer llGetRegionAgentCount() 5816 public LSL_Integer llGetRegionAgentCount()
5410 { 5817 {
5411 m_host.AddScriptLPS(1); 5818 m_host.AddScriptLPS(1);
5412 return new LSL_Integer(World.GetRootAgentCount()); 5819
5820 int count = 0;
5821 World.ForEachRootScenePresence(delegate(ScenePresence sp) {
5822 count++;
5823 });
5824
5825 return new LSL_Integer(count);
5413 } 5826 }
5414 5827
5415 public LSL_Vector llGetRegionCorner() 5828 public LSL_Vector llGetRegionCorner()
@@ -5689,6 +6102,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5689 flags |= ScriptBaseClass.AGENT_SITTING; 6102 flags |= ScriptBaseClass.AGENT_SITTING;
5690 } 6103 }
5691 6104
6105 if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0)
6106 {
6107 flags |= ScriptBaseClass.AGENT_MALE;
6108 }
6109
5692 return flags; 6110 return flags;
5693 } 6111 }
5694 6112
@@ -5835,10 +6253,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5835 m_host.AddScriptLPS(1); 6253 m_host.AddScriptLPS(1);
5836 6254
5837 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6255 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5838 6256 if (parts.Count > 0)
5839 foreach (var part in parts)
5840 { 6257 {
5841 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 6258 try
6259 {
6260 foreach (var part in parts)
6261 {
6262 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
6263 }
6264 }
6265 finally
6266 {
6267 }
5842 } 6268 }
5843 } 6269 }
5844 6270
@@ -5890,13 +6316,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5890 6316
5891 if (m_host.OwnerID == land.LandData.OwnerID) 6317 if (m_host.OwnerID == land.LandData.OwnerID)
5892 { 6318 {
5893 World.TeleportClientHome(agentID, presence.ControllingClient); 6319 Vector3 pos = World.GetNearestAllowedPosition(presence, land);
6320 presence.TeleportWithMomentum(pos, null);
6321 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
5894 } 6322 }
5895 } 6323 }
5896 } 6324 }
5897 ScriptSleep(5000); 6325 ScriptSleep(5000);
5898 } 6326 }
5899 6327
6328 public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers)
6329 {
6330 return ParseString2List(str, separators, in_spacers, false);
6331 }
6332
5900 public LSL_Integer llOverMyLand(string id) 6333 public LSL_Integer llOverMyLand(string id)
5901 { 6334 {
5902 m_host.AddScriptLPS(1); 6335 m_host.AddScriptLPS(1);
@@ -5955,20 +6388,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5955 return agentSize; 6388 return agentSize;
5956 } 6389 }
5957 6390
5958 public LSL_Integer llSameGroup(string agent) 6391 public LSL_Integer llSameGroup(string id)
5959 { 6392 {
5960 m_host.AddScriptLPS(1); 6393 m_host.AddScriptLPS(1);
5961 UUID agentId = new UUID(); 6394 UUID uuid = new UUID();
5962 if (!UUID.TryParse(agent, out agentId)) 6395 if (!UUID.TryParse(id, out uuid))
5963 return new LSL_Integer(0);
5964 ScenePresence presence = World.GetScenePresence(agentId);
5965 if (presence == null || presence.IsChildAgent) // Return flase for child agents
5966 return new LSL_Integer(0); 6396 return new LSL_Integer(0);
5967 IClientAPI client = presence.ControllingClient; 6397
5968 if (m_host.GroupID == client.ActiveGroupId) 6398 // Check if it's a group key
6399 if (uuid == m_host.ParentGroup.RootPart.GroupID)
5969 return new LSL_Integer(1); 6400 return new LSL_Integer(1);
5970 else 6401
6402 // We got passed a UUID.Zero
6403 if (uuid == UUID.Zero)
6404 return new LSL_Integer(0);
6405
6406 // Handle the case where id names an avatar
6407 ScenePresence presence = World.GetScenePresence(uuid);
6408 if (presence != null)
6409 {
6410 if (presence.IsChildAgent)
6411 return new LSL_Integer(0);
6412
6413 IClientAPI client = presence.ControllingClient;
6414 if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId)
6415 return new LSL_Integer(1);
6416
6417 return new LSL_Integer(0);
6418 }
6419
6420 // Handle object case
6421 SceneObjectPart part = World.GetSceneObjectPart(uuid);
6422 if (part != null)
6423 {
6424 // This will handle both deed and non-deed and also the no
6425 // group case
6426 if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID)
6427 return new LSL_Integer(1);
6428
5971 return new LSL_Integer(0); 6429 return new LSL_Integer(0);
6430 }
6431
6432 return new LSL_Integer(0);
5972 } 6433 }
5973 6434
5974 public void llUnSit(string id) 6435 public void llUnSit(string id)
@@ -6093,7 +6554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6093 return m_host.ParentGroup.AttachmentPoint; 6554 return m_host.ParentGroup.AttachmentPoint;
6094 } 6555 }
6095 6556
6096 public LSL_Integer llGetFreeMemory() 6557 public virtual LSL_Integer llGetFreeMemory()
6097 { 6558 {
6098 m_host.AddScriptLPS(1); 6559 m_host.AddScriptLPS(1);
6099 // Make scripts designed for LSO happy 6560 // Make scripts designed for LSO happy
@@ -6210,7 +6671,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6210 SetParticleSystem(m_host, rules); 6671 SetParticleSystem(m_host, rules);
6211 } 6672 }
6212 6673
6213 private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { 6674 private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
6675 {
6214 6676
6215 6677
6216 if (rules.Length == 0) 6678 if (rules.Length == 0)
@@ -6524,6 +6986,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6524 6986
6525 protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) 6987 protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot)
6526 { 6988 {
6989 // LSL quaternions can normalize to 0, normal Quaternions can't.
6990 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
6991 rot.s = 1; // ZERO_ROTATION = 0,0,0,1
6992
6527 part.SitTargetPosition = offset; 6993 part.SitTargetPosition = offset;
6528 part.SitTargetOrientation = rot; 6994 part.SitTargetOrientation = rot;
6529 part.ParentGroup.HasGroupChanged = true; 6995 part.ParentGroup.HasGroupChanged = true;
@@ -6679,13 +7145,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6679 UUID av = new UUID(); 7145 UUID av = new UUID();
6680 if (!UUID.TryParse(avatar,out av)) 7146 if (!UUID.TryParse(avatar,out av))
6681 { 7147 {
6682 LSLError("First parameter to llDialog needs to be a key"); 7148 //LSLError("First parameter to llDialog needs to be a key");
6683 return; 7149 return;
6684 } 7150 }
6685 if (buttons.Length < 1) 7151 if (buttons.Length < 1)
6686 { 7152 {
6687 LSLError("No less than 1 button can be shown"); 7153 buttons.Add("OK");
6688 return;
6689 } 7154 }
6690 if (buttons.Length > 12) 7155 if (buttons.Length > 12)
6691 { 7156 {
@@ -6702,7 +7167,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6702 } 7167 }
6703 if (buttons.Data[i].ToString().Length > 24) 7168 if (buttons.Data[i].ToString().Length > 24)
6704 { 7169 {
6705 LSLError("button label cannot be longer than 24 characters"); 7170 llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters");
6706 return; 7171 return;
6707 } 7172 }
6708 buts[i] = buttons.Data[i].ToString(); 7173 buts[i] = buttons.Data[i].ToString();
@@ -6769,9 +7234,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6769 return; 7234 return;
6770 } 7235 }
6771 7236
6772 // the rest of the permission checks are done in RezScript, so check the pin there as well 7237 SceneObjectPart dest = World.GetSceneObjectPart(destId);
6773 World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); 7238 if (dest != null)
7239 {
7240 if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
7241 {
7242 // the rest of the permission checks are done in RezScript, so check the pin there as well
7243 World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param);
6774 7244
7245 if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0)
7246 m_host.Inventory.RemoveInventoryItem(item.ItemID);
7247 }
7248 }
6775 // this will cause the delay even if the script pin or permissions were wrong - seems ok 7249 // this will cause the delay even if the script pin or permissions were wrong - seems ok
6776 ScriptSleep(3000); 7250 ScriptSleep(3000);
6777 } 7251 }
@@ -6834,19 +7308,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6834 public LSL_String llMD5String(string src, int nonce) 7308 public LSL_String llMD5String(string src, int nonce)
6835 { 7309 {
6836 m_host.AddScriptLPS(1); 7310 m_host.AddScriptLPS(1);
6837 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); 7311 return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8);
6838 } 7312 }
6839 7313
6840 public LSL_String llSHA1String(string src) 7314 public LSL_String llSHA1String(string src)
6841 { 7315 {
6842 m_host.AddScriptLPS(1); 7316 m_host.AddScriptLPS(1);
6843 return Util.SHA1Hash(src).ToLower(); 7317 return Util.SHA1Hash(src, Encoding.UTF8).ToLower();
6844 } 7318 }
6845 7319
6846 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) 7320 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve)
6847 { 7321 {
6848 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7322 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
6849 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7323 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
7324 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7325 return shapeBlock;
6850 7326
6851 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 7327 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6852 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 7328 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6951,6 +7427,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6951 // Prim type box, cylinder and prism. 7427 // Prim type box, cylinder and prism.
6952 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) 7428 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve)
6953 { 7429 {
7430 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7431 return;
7432
6954 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7433 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
6955 ObjectShapePacket.ObjectDataBlock shapeBlock; 7434 ObjectShapePacket.ObjectDataBlock shapeBlock;
6956 7435
@@ -7004,6 +7483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7004 // Prim type sphere. 7483 // Prim type sphere.
7005 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) 7484 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve)
7006 { 7485 {
7486 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7487 return;
7488
7007 ObjectShapePacket.ObjectDataBlock shapeBlock; 7489 ObjectShapePacket.ObjectDataBlock shapeBlock;
7008 7490
7009 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); 7491 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve);
@@ -7045,6 +7527,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7045 // Prim type torus, tube and ring. 7527 // Prim type torus, tube and ring.
7046 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 profileshape, byte pathcurve) 7528 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 profileshape, byte pathcurve)
7047 { 7529 {
7530 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7531 return;
7532
7048 float tempFloat; // Use in float expressions below to avoid byte cast precision issues. 7533 float tempFloat; // Use in float expressions below to avoid byte cast precision issues.
7049 ObjectShapePacket.ObjectDataBlock shapeBlock; 7534 ObjectShapePacket.ObjectDataBlock shapeBlock;
7050 7535
@@ -7180,6 +7665,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7180 // Prim type sculpt. 7665 // Prim type sculpt.
7181 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) 7666 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve)
7182 { 7667 {
7668 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7669 return;
7670
7183 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7671 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
7184 UUID sculptId; 7672 UUID sculptId;
7185 7673
@@ -7204,7 +7692,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7204 type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) 7692 type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag))
7205 { 7693 {
7206 // default 7694 // default
7207 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7695 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
7208 } 7696 }
7209 7697
7210 part.Shape.SetSculptProperties((byte)type, sculptId); 7698 part.Shape.SetSculptProperties((byte)type, sculptId);
@@ -7221,46 +7709,309 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7221 ScriptSleep(200); 7709 ScriptSleep(200);
7222 } 7710 }
7223 7711
7224 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7712 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
7225 { 7713 {
7226 m_host.AddScriptLPS(1); 7714 m_host.AddScriptLPS(1);
7227 7715
7228 setLinkPrimParams(linknumber, rules); 7716 setLinkPrimParams(linknumber, rules);
7717 }
7718
7719 private void setLinkPrimParams(int linknumber, LSL_List rules)
7720 {
7721 List<object> parts = new List<object>();
7722 List<SceneObjectPart> prims = GetLinkParts(linknumber);
7723 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7724 foreach (SceneObjectPart p in prims)
7725 parts.Add(p);
7726 foreach (ScenePresence p in avatars)
7727 parts.Add(p);
7229 7728
7729 LSL_List remaining = null;
7730
7731 if (parts.Count > 0)
7732 {
7733 foreach (object part in parts)
7734 {
7735 if (part is SceneObjectPart)
7736 remaining = SetPrimParams((SceneObjectPart)part, rules);
7737 else
7738 remaining = SetPrimParams((ScenePresence)part, rules);
7739 }
7740
7741 while((object)remaining != null && remaining.Length > 2)
7742 {
7743 linknumber = remaining.GetLSLIntegerItem(0);
7744 rules = remaining.GetSublist(1,-1);
7745 parts.Clear();
7746 prims = GetLinkParts(linknumber);
7747 avatars = GetLinkAvatars(linknumber);
7748 foreach (SceneObjectPart p in prims)
7749 parts.Add(p);
7750 foreach (ScenePresence p in avatars)
7751 parts.Add(p);
7752
7753 foreach (object part in parts)
7754 {
7755 if (part is SceneObjectPart)
7756 remaining = SetPrimParams((SceneObjectPart)part, rules);
7757 else
7758 remaining = SetPrimParams((ScenePresence)part, rules);
7759 }
7760 }
7761 }
7762 }
7763
7764 private void SetPhysicsMaterial(SceneObjectPart part, int material_bits,
7765 float material_density, float material_friction,
7766 float material_restitution, float material_gravity_modifier)
7767 {
7768 ExtraPhysicsData physdata = new ExtraPhysicsData();
7769 physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType;
7770 physdata.Density = part.Density;
7771 physdata.Friction = part.Friction;
7772 physdata.Bounce = part.Bounciness;
7773 physdata.GravitationModifier = part.GravityModifier;
7774
7775 if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0)
7776 physdata.Density = material_density;
7777 if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0)
7778 physdata.Friction = material_friction;
7779 if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0)
7780 physdata.Bounce = material_restitution;
7781 if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0)
7782 physdata.GravitationModifier = material_gravity_modifier;
7783
7784 part.UpdateExtraPhysics(physdata);
7785 }
7786
7787 public void llSetPhysicsMaterial(int material_bits,
7788 float material_gravity_modifier, float material_restitution,
7789 float material_friction, float material_density)
7790 {
7791 SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier);
7792 }
7793
7794 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
7795 {
7796 llSetLinkPrimitiveParamsFast(linknumber, rules);
7230 ScriptSleep(200); 7797 ScriptSleep(200);
7231 } 7798 }
7232 7799
7233 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7800 // vector up using libomv (c&p from sop )
7801 // vector up rotated by r
7802 private Vector3 Zrot(Quaternion r)
7234 { 7803 {
7235 m_host.AddScriptLPS(1); 7804 double x, y, z, m;
7236 7805
7237 setLinkPrimParams(linknumber, rules); 7806 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
7807 if (Math.Abs(1.0 - m) > 0.000001)
7808 {
7809 m = 1.0 / Math.Sqrt(m);
7810 r.X *= (float)m;
7811 r.Y *= (float)m;
7812 r.Z *= (float)m;
7813 r.W *= (float)m;
7814 }
7815
7816 x = 2 * (r.X * r.Z + r.Y * r.W);
7817 y = 2 * (-r.X * r.W + r.Y * r.Z);
7818 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
7819
7820 return new Vector3((float)x, (float)y, (float)z);
7238 } 7821 }
7239 7822
7240 protected void setLinkPrimParams(int linknumber, LSL_List rules) 7823 protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules)
7241 { 7824 {
7242 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7825 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7243 7826
7244 LSL_List remaining = null; 7827 int idx = 0;
7245 7828
7246 foreach (SceneObjectPart part in parts) 7829 bool positionChanged = false;
7247 remaining = SetPrimParams(part, rules); 7830 Vector3 finalPos = Vector3.Zero;
7248 7831
7249 while(remaining != null && remaining.Length > 2) 7832 try
7250 { 7833 {
7251 linknumber = remaining.GetLSLIntegerItem(0); 7834 while (idx < rules.Length)
7252 rules = remaining.GetSublist(1,-1); 7835 {
7253 parts = GetLinkParts(linknumber); 7836 int code = rules.GetLSLIntegerItem(idx++);
7837
7838 int remain = rules.Length - idx;
7254 7839
7255 foreach (SceneObjectPart part in parts) 7840 switch (code)
7256 remaining = SetPrimParams(part, rules); 7841 {
7842 case (int)ScriptBaseClass.PRIM_POSITION:
7843 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
7844 {
7845 if (remain < 1)
7846 return null;
7847
7848 LSL_Vector v;
7849 v = rules.GetVector3Item(idx++);
7850
7851 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7852 if (part == null)
7853 break;
7854
7855 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
7856 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
7857 if (part.LinkNum > 1)
7858 {
7859 localRot = GetPartLocalRot(part);
7860 localPos = GetPartLocalPos(part);
7861 }
7862
7863 v -= localPos;
7864 v /= localRot;
7865
7866 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
7867
7868 v = v + 2 * sitOffset;
7869
7870 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7871 av.SendAvatarDataToAllAgents();
7872
7873 }
7874 break;
7875
7876 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
7877 case (int)ScriptBaseClass.PRIM_ROTATION:
7878 {
7879 if (remain < 1)
7880 return null;
7881
7882 LSL_Rotation r;
7883 r = rules.GetQuaternionItem(idx++);
7884
7885 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7886 if (part == null)
7887 break;
7888
7889 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
7890 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
7891
7892 if (part.LinkNum > 1)
7893 localRot = GetPartLocalRot(part);
7894
7895 r = r * llGetRootRotation() / localRot;
7896 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7897 av.SendAvatarDataToAllAgents();
7898 }
7899 break;
7900
7901 // parse rest doing nothing but number of parameters error check
7902 case (int)ScriptBaseClass.PRIM_SIZE:
7903 case (int)ScriptBaseClass.PRIM_MATERIAL:
7904 case (int)ScriptBaseClass.PRIM_PHANTOM:
7905 case (int)ScriptBaseClass.PRIM_PHYSICS:
7906 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
7907 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7908 case (int)ScriptBaseClass.PRIM_NAME:
7909 case (int)ScriptBaseClass.PRIM_DESC:
7910 if (remain < 1)
7911 return null;
7912 idx++;
7913 break;
7914
7915 case (int)ScriptBaseClass.PRIM_GLOW:
7916 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7917 case (int)ScriptBaseClass.PRIM_TEXGEN:
7918 if (remain < 2)
7919 return null;
7920 idx += 2;
7921 break;
7922
7923 case (int)ScriptBaseClass.PRIM_TYPE:
7924 if (remain < 3)
7925 return null;
7926 code = (int)rules.GetLSLIntegerItem(idx++);
7927 remain = rules.Length - idx;
7928 switch (code)
7929 {
7930 case (int)ScriptBaseClass.PRIM_TYPE_BOX:
7931 case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
7932 case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
7933 if (remain < 6)
7934 return null;
7935 idx += 6;
7936 break;
7937
7938 case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
7939 if (remain < 5)
7940 return null;
7941 idx += 5;
7942 break;
7943
7944 case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
7945 case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
7946 case (int)ScriptBaseClass.PRIM_TYPE_RING:
7947 if (remain < 11)
7948 return null;
7949 idx += 11;
7950 break;
7951
7952 case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
7953 if (remain < 2)
7954 return null;
7955 idx += 2;
7956 break;
7957 }
7958 break;
7959
7960 case (int)ScriptBaseClass.PRIM_COLOR:
7961 case (int)ScriptBaseClass.PRIM_TEXT:
7962 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7963 case (int)ScriptBaseClass.PRIM_OMEGA:
7964 if (remain < 3)
7965 return null;
7966 idx += 3;
7967 break;
7968
7969 case (int)ScriptBaseClass.PRIM_TEXTURE:
7970 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
7971 case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
7972 if (remain < 5)
7973 return null;
7974 idx += 5;
7975 break;
7976
7977 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
7978 if (remain < 7)
7979 return null;
7980
7981 idx += 7;
7982 break;
7983
7984 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
7985 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
7986 return null;
7987
7988 return rules.GetSublist(idx, -1);
7989 }
7990 }
7991 }
7992
7993 finally
7994 {
7995 if (positionChanged)
7996 {
7997 av.OffsetPosition = finalPos;
7998// av.SendAvatarDataToAllAgents();
7999 av.SendTerseUpdateToAllClients();
8000 positionChanged = false;
8001 }
7257 } 8002 }
8003 return null;
7258 } 8004 }
7259 8005
7260 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) 8006 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules)
7261 { 8007 {
8008 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
8009 return null;
8010
7262 int idx = 0; 8011 int idx = 0;
7263 8012
8013 SceneObjectGroup parentgrp = part.ParentGroup;
8014
7264 bool positionChanged = false; 8015 bool positionChanged = false;
7265 LSL_Vector currentPosition = GetPartLocalPos(part); 8016 LSL_Vector currentPosition = GetPartLocalPos(part);
7266 8017
@@ -7283,8 +8034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7283 return null; 8034 return null;
7284 8035
7285 v=rules.GetVector3Item(idx++); 8036 v=rules.GetVector3Item(idx++);
7286 positionChanged = true;
7287 currentPosition = GetSetPosTarget(part, v, currentPosition); 8037 currentPosition = GetSetPosTarget(part, v, currentPosition);
8038 positionChanged = true;
7288 8039
7289 break; 8040 break;
7290 case (int)ScriptBaseClass.PRIM_SIZE: 8041 case (int)ScriptBaseClass.PRIM_SIZE:
@@ -7300,8 +8051,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7300 return null; 8051 return null;
7301 8052
7302 LSL_Rotation q = rules.GetQuaternionItem(idx++); 8053 LSL_Rotation q = rules.GetQuaternionItem(idx++);
8054 SceneObjectPart rootPart = parentgrp.RootPart;
7303 // try to let this work as in SL... 8055 // try to let this work as in SL...
7304 if (part.ParentID == 0) 8056 if (rootPart == part)
7305 { 8057 {
7306 // special case: If we are root, rotate complete SOG to new rotation 8058 // special case: If we are root, rotate complete SOG to new rotation
7307 SetRot(part, q); 8059 SetRot(part, q);
@@ -7309,7 +8061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7309 else 8061 else
7310 { 8062 {
7311 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 8063 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
7312 SceneObjectPart rootPart = part.ParentGroup.RootPart; 8064 // sounds like sl bug that we need to replicate
7313 SetRot(part, rootPart.RotationOffset * (Quaternion)q); 8065 SetRot(part, rootPart.RotationOffset * (Quaternion)q);
7314 } 8066 }
7315 8067
@@ -7562,7 +8314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7562 return null; 8314 return null;
7563 8315
7564 string ph = rules.Data[idx++].ToString(); 8316 string ph = rules.Data[idx++].ToString();
7565 m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); 8317 parentgrp.ScriptSetPhantomStatus(ph.Equals("1"));
7566 8318
7567 break; 8319 break;
7568 8320
@@ -7580,12 +8332,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7580 part.ScriptSetPhysicsStatus(physics); 8332 part.ScriptSetPhysicsStatus(physics);
7581 break; 8333 break;
7582 8334
8335 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
8336 if (remain < 1)
8337 return null;
8338
8339 int shape_type = rules.GetLSLIntegerItem(idx++);
8340
8341 ExtraPhysicsData physdata = new ExtraPhysicsData();
8342 physdata.Density = part.Density;
8343 physdata.Bounce = part.Bounciness;
8344 physdata.GravitationModifier = part.GravityModifier;
8345 physdata.PhysShapeType = (PhysShapeType)shape_type;
8346
8347 part.UpdateExtraPhysics(physdata);
8348
8349 break;
8350
8351 case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
8352 if (remain < 5)
8353 return null;
8354
8355 int material_bits = rules.GetLSLIntegerItem(idx++);
8356 float material_density = (float)rules.GetLSLFloatItem(idx++);
8357 float material_friction = (float)rules.GetLSLFloatItem(idx++);
8358 float material_restitution = (float)rules.GetLSLFloatItem(idx++);
8359 float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++);
8360
8361 SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier);
8362
8363 break;
8364
7583 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: 8365 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7584 if (remain < 1) 8366 if (remain < 1)
7585 return null; 8367 return null;
7586 string temp = rules.Data[idx++].ToString(); 8368 string temp = rules.Data[idx++].ToString();
7587 8369
7588 m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); 8370 parentgrp.ScriptSetTemporaryStatus(temp.Equals("1"));
7589 8371
7590 break; 8372 break;
7591 8373
@@ -7657,7 +8439,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7657 if (part.ParentGroup.RootPart == part) 8439 if (part.ParentGroup.RootPart == part)
7658 { 8440 {
7659 SceneObjectGroup parent = part.ParentGroup; 8441 SceneObjectGroup parent = part.ParentGroup;
7660 parent.UpdateGroupPosition(currentPosition); 8442 Util.FireAndForget(delegate(object x) {
8443 parent.UpdateGroupPosition(currentPosition);
8444 });
7661 } 8445 }
7662 else 8446 else
7663 { 8447 {
@@ -7702,10 +8486,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7702 8486
7703 public LSL_String llXorBase64Strings(string str1, string str2) 8487 public LSL_String llXorBase64Strings(string str1, string str2)
7704 { 8488 {
7705 m_host.AddScriptLPS(1); 8489 string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
7706 Deprecated("llXorBase64Strings"); 8490
7707 ScriptSleep(300); 8491 ScriptSleep(300);
7708 return String.Empty; 8492 m_host.AddScriptLPS(1);
8493
8494 if (str1 == String.Empty)
8495 return String.Empty;
8496 if (str2 == String.Empty)
8497 return str1;
8498
8499 int len = str2.Length;
8500 if ((len % 4) != 0) // LL is EVIL!!!!
8501 {
8502 while (str2.EndsWith("="))
8503 str2 = str2.Substring(0, str2.Length - 1);
8504
8505 len = str2.Length;
8506 int mod = len % 4;
8507
8508 if (mod == 1)
8509 str2 = str2.Substring(0, str2.Length - 1);
8510 else if (mod == 2)
8511 str2 += "==";
8512 else if (mod == 3)
8513 str2 += "=";
8514 }
8515
8516 byte[] data1;
8517 byte[] data2;
8518 try
8519 {
8520 data1 = Convert.FromBase64String(str1);
8521 data2 = Convert.FromBase64String(str2);
8522 }
8523 catch (Exception)
8524 {
8525 return new LSL_String(String.Empty);
8526 }
8527
8528 // For cases where the decoded length of s2 is greater
8529 // than the decoded length of s1, simply perform a normal
8530 // decode and XOR
8531 //
8532 if (data2.Length >= data1.Length)
8533 {
8534 for (int pos = 0 ; pos < data1.Length ; pos++ )
8535 data1[pos] ^= data2[pos];
8536
8537 return Convert.ToBase64String(data1);
8538 }
8539
8540 // Remove padding
8541 while (str1.EndsWith("="))
8542 str1 = str1.Substring(0, str1.Length - 1);
8543 while (str2.EndsWith("="))
8544 str2 = str2.Substring(0, str2.Length - 1);
8545
8546 byte[] d1 = new byte[str1.Length];
8547 byte[] d2 = new byte[str2.Length];
8548
8549 for (int i = 0 ; i < str1.Length ; i++)
8550 {
8551 int idx = b64.IndexOf(str1.Substring(i, 1));
8552 if (idx == -1)
8553 idx = 0;
8554 d1[i] = (byte)idx;
8555 }
8556
8557 for (int i = 0 ; i < str2.Length ; i++)
8558 {
8559 int idx = b64.IndexOf(str2.Substring(i, 1));
8560 if (idx == -1)
8561 idx = 0;
8562 d2[i] = (byte)idx;
8563 }
8564
8565 string output = String.Empty;
8566
8567 for (int pos = 0 ; pos < d1.Length ; pos++)
8568 output += b64[d1[pos] ^ d2[pos % d2.Length]];
8569
8570 while (output.Length % 3 > 0)
8571 output += "=";
8572
8573 return output;
7709 } 8574 }
7710 8575
7711 public void llRemoteDataSetRegion() 8576 public void llRemoteDataSetRegion()
@@ -7829,13 +8694,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7829 public LSL_Integer llGetNumberOfPrims() 8694 public LSL_Integer llGetNumberOfPrims()
7830 { 8695 {
7831 m_host.AddScriptLPS(1); 8696 m_host.AddScriptLPS(1);
7832 int avatarCount = 0; 8697 int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count;
7833 World.ForEachRootScenePresence(delegate(ScenePresence presence) 8698
7834 {
7835 if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID))
7836 avatarCount++;
7837 });
7838
7839 return m_host.ParentGroup.PrimCount + avatarCount; 8699 return m_host.ParentGroup.PrimCount + avatarCount;
7840 } 8700 }
7841 8701
@@ -7851,55 +8711,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7851 m_host.AddScriptLPS(1); 8711 m_host.AddScriptLPS(1);
7852 UUID objID = UUID.Zero; 8712 UUID objID = UUID.Zero;
7853 LSL_List result = new LSL_List(); 8713 LSL_List result = new LSL_List();
8714
8715 // If the ID is not valid, return null result
7854 if (!UUID.TryParse(obj, out objID)) 8716 if (!UUID.TryParse(obj, out objID))
7855 { 8717 {
7856 result.Add(new LSL_Vector()); 8718 result.Add(new LSL_Vector());
7857 result.Add(new LSL_Vector()); 8719 result.Add(new LSL_Vector());
7858 return result; 8720 return result;
7859 } 8721 }
8722
8723 // Check if this is an attached prim. If so, replace
8724 // the UUID with the avatar UUID and report it's bounding box
8725 SceneObjectPart part = World.GetSceneObjectPart(objID);
8726 if (part != null && part.ParentGroup.IsAttachment)
8727 objID = part.ParentGroup.AttachedAvatar;
8728
8729 // Find out if this is an avatar ID. If so, return it's box
7860 ScenePresence presence = World.GetScenePresence(objID); 8730 ScenePresence presence = World.GetScenePresence(objID);
7861 if (presence != null) 8731 if (presence != null)
7862 { 8732 {
7863 if (presence.ParentID == 0) // not sat on an object 8733 // As per LSL Wiki, there is no difference between sitting
8734 // and standing avatar since server 1.36
8735 LSL_Vector lower;
8736 LSL_Vector upper;
8737 if (presence.Animator.Animations.DefaultAnimation.AnimID
8738 == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
7864 { 8739 {
7865 LSL_Vector lower; 8740 // This is for ground sitting avatars
7866 LSL_Vector upper; 8741 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7867 if (presence.Animator.Animations.DefaultAnimation.AnimID 8742 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7868 == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) 8743 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7869 {
7870 // This is for ground sitting avatars
7871 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7872 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7873 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7874 }
7875 else
7876 {
7877 // This is for standing/flying avatars
7878 float height = presence.Appearance.AvatarHeight / 2.0f;
7879 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7880 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7881 }
7882 result.Add(lower);
7883 result.Add(upper);
7884 return result;
7885 } 8744 }
7886 else 8745 else
7887 { 8746 {
7888 // sitting on an object so we need the bounding box of that 8747 // This is for standing/flying avatars
7889 // which should include the avatar so set the UUID to the 8748 float height = presence.Appearance.AvatarHeight / 2.0f;
7890 // UUID of the object the avatar is sat on and allow it to fall through 8749 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7891 // to processing an object 8750 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7892 SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID);
7893 objID = p.UUID;
7894 } 8751 }
8752
8753 // Adjust to the documented error offsets (see LSL Wiki)
8754 lower += new LSL_Vector(0.05f, 0.05f, 0.05f);
8755 upper -= new LSL_Vector(0.05f, 0.05f, 0.05f);
8756
8757 if (lower.x > upper.x)
8758 lower.x = upper.x;
8759 if (lower.y > upper.y)
8760 lower.y = upper.y;
8761 if (lower.z > upper.z)
8762 lower.z = upper.z;
8763
8764 result.Add(lower);
8765 result.Add(upper);
8766 return result;
7895 } 8767 }
7896 SceneObjectPart part = World.GetSceneObjectPart(objID); 8768
8769 part = World.GetSceneObjectPart(objID);
7897 // Currently only works for single prims without a sitting avatar 8770 // Currently only works for single prims without a sitting avatar
7898 if (part != null) 8771 if (part != null)
7899 { 8772 {
7900 Vector3 halfSize = part.Scale / 2.0f; 8773 float minX;
7901 LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f; 8774 float maxX;
7902 LSL_Vector upper = new LSL_Vector(halfSize); 8775 float minY;
8776 float maxY;
8777 float minZ;
8778 float maxZ;
8779
8780 // This BBox is in sim coordinates, with the offset being
8781 // a contained point.
8782 Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup },
8783 out minX, out maxX, out minY, out maxY, out minZ, out maxZ);
8784
8785 minX -= offsets[0].X;
8786 maxX -= offsets[0].X;
8787 minY -= offsets[0].Y;
8788 maxY -= offsets[0].Y;
8789 minZ -= offsets[0].Z;
8790 maxZ -= offsets[0].Z;
8791
8792 LSL_Vector lower;
8793 LSL_Vector upper;
8794
8795 // Adjust to the documented error offsets (see LSL Wiki)
8796 lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f);
8797 upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f);
8798
8799 if (lower.x > upper.x)
8800 lower.x = upper.x;
8801 if (lower.y > upper.y)
8802 lower.y = upper.y;
8803 if (lower.z > upper.z)
8804 lower.z = upper.z;
8805
7903 result.Add(lower); 8806 result.Add(lower);
7904 result.Add(upper); 8807 result.Add(upper);
7905 return result; 8808 return result;
@@ -7913,7 +8816,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7913 8816
7914 public LSL_Vector llGetGeometricCenter() 8817 public LSL_Vector llGetGeometricCenter()
7915 { 8818 {
7916 return new LSL_Vector(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); 8819 Vector3 tmp = m_host.GetGeometricCenter();
8820 return new LSL_Vector(tmp.X, tmp.Y, tmp.Z);
7917 } 8821 }
7918 8822
7919 public LSL_List llGetPrimitiveParams(LSL_List rules) 8823 public LSL_List llGetPrimitiveParams(LSL_List rules)
@@ -7926,16 +8830,291 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7926 { 8830 {
7927 m_host.AddScriptLPS(1); 8831 m_host.AddScriptLPS(1);
7928 8832
8833 // acording to SL wiki this must indicate a single link number or link_root or link_this.
8834 // keep other options as before
8835
7929 List<SceneObjectPart> parts = GetLinkParts(linknumber); 8836 List<SceneObjectPart> parts = GetLinkParts(linknumber);
8837 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7930 8838
7931 LSL_List res = new LSL_List(); 8839 LSL_List res = new LSL_List();
7932 8840
7933 foreach (var part in parts) 8841 if (parts.Count > 0)
8842 {
8843 foreach (var part in parts)
8844 {
8845 LSL_List partRes = GetLinkPrimitiveParams(part, rules);
8846 res += partRes;
8847 }
8848 }
8849 if (avatars.Count > 0)
7934 { 8850 {
7935 LSL_List partRes = GetLinkPrimitiveParams(part, rules); 8851 foreach (ScenePresence avatar in avatars)
7936 res += partRes; 8852 {
8853 LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules);
8854 res += avaRes;
8855 }
7937 } 8856 }
8857 return res;
8858 }
8859
8860 public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules)
8861 {
8862 // avatars case
8863 // replies as SL wiki
8864
8865 LSL_List res = new LSL_List();
8866// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
8867 SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
8868
8869 int idx = 0;
8870 while (idx < rules.Length)
8871 {
8872 int code = (int)rules.GetLSLIntegerItem(idx++);
8873 int remain = rules.Length - idx;
8874
8875 switch (code)
8876 {
8877 case (int)ScriptBaseClass.PRIM_MATERIAL:
8878 res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
8879 break;
8880
8881 case (int)ScriptBaseClass.PRIM_PHYSICS:
8882 res.Add(new LSL_Integer(0));
8883 break;
8884
8885 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
8886 res.Add(new LSL_Integer(0));
8887 break;
8888
8889 case (int)ScriptBaseClass.PRIM_PHANTOM:
8890 res.Add(new LSL_Integer(0));
8891 break;
8892
8893 case (int)ScriptBaseClass.PRIM_POSITION:
8894
8895 Vector3 pos = avatar.OffsetPosition;
8896
8897 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
8898 pos -= sitOffset;
8899
8900 if( sitPart != null)
8901 pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
8902
8903 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
8904 break;
8905
8906 case (int)ScriptBaseClass.PRIM_SIZE:
8907 // as in llGetAgentSize above
8908 res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
8909 break;
8910
8911 case (int)ScriptBaseClass.PRIM_ROTATION:
8912 Quaternion rot = avatar.Rotation;
8913 if (sitPart != null)
8914 {
8915 rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
8916 }
8917
8918 res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
8919 break;
8920
8921 case (int)ScriptBaseClass.PRIM_TYPE:
8922 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
8923 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
8924 res.Add(new LSL_Vector(0f,1.0f,0f));
8925 res.Add(new LSL_Float(0.0f));
8926 res.Add(new LSL_Vector(0, 0, 0));
8927 res.Add(new LSL_Vector(1.0f,1.0f,0f));
8928 res.Add(new LSL_Vector(0, 0, 0));
8929 break;
8930
8931 case (int)ScriptBaseClass.PRIM_TEXTURE:
8932 if (remain < 1)
8933 return res;
8934
8935 int face = (int)rules.GetLSLIntegerItem(idx++);
8936 if (face == ScriptBaseClass.ALL_SIDES)
8937 {
8938 for (face = 0; face < 21; face++)
8939 {
8940 res.Add(new LSL_String(""));
8941 res.Add(new LSL_Vector(0,0,0));
8942 res.Add(new LSL_Vector(0,0,0));
8943 res.Add(new LSL_Float(0.0));
8944 }
8945 }
8946 else
8947 {
8948 if (face >= 0 && face < 21)
8949 {
8950 res.Add(new LSL_String(""));
8951 res.Add(new LSL_Vector(0,0,0));
8952 res.Add(new LSL_Vector(0,0,0));
8953 res.Add(new LSL_Float(0.0));
8954 }
8955 }
8956 break;
8957
8958 case (int)ScriptBaseClass.PRIM_COLOR:
8959 if (remain < 1)
8960 return res;
8961
8962 face = (int)rules.GetLSLIntegerItem(idx++);
8963
8964 if (face == ScriptBaseClass.ALL_SIDES)
8965 {
8966 for (face = 0; face < 21; face++)
8967 {
8968 res.Add(new LSL_Vector(0,0,0));
8969 res.Add(new LSL_Float(0));
8970 }
8971 }
8972 else
8973 {
8974 res.Add(new LSL_Vector(0,0,0));
8975 res.Add(new LSL_Float(0));
8976 }
8977 break;
8978
8979 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
8980 if (remain < 1)
8981 return res;
8982 face = (int)rules.GetLSLIntegerItem(idx++);
8983
8984 if (face == ScriptBaseClass.ALL_SIDES)
8985 {
8986 for (face = 0; face < 21; face++)
8987 {
8988 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
8989 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
8990 }
8991 }
8992 else
8993 {
8994 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
8995 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
8996 }
8997 break;
8998
8999 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
9000 if (remain < 1)
9001 return res;
9002 face = (int)rules.GetLSLIntegerItem(idx++);
7938 9003
9004 if (face == ScriptBaseClass.ALL_SIDES)
9005 {
9006 for (face = 0; face < 21; face++)
9007 {
9008 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
9009 }
9010 }
9011 else
9012 {
9013 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
9014 }
9015 break;
9016
9017 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
9018 res.Add(new LSL_Integer(0));
9019 res.Add(new LSL_Integer(0));// softness
9020 res.Add(new LSL_Float(0.0f)); // gravity
9021 res.Add(new LSL_Float(0.0f)); // friction
9022 res.Add(new LSL_Float(0.0f)); // wind
9023 res.Add(new LSL_Float(0.0f)); // tension
9024 res.Add(new LSL_Vector(0f,0f,0f));
9025 break;
9026
9027 case (int)ScriptBaseClass.PRIM_TEXGEN:
9028 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
9029 if (remain < 1)
9030 return res;
9031 face = (int)rules.GetLSLIntegerItem(idx++);
9032
9033 if (face == ScriptBaseClass.ALL_SIDES)
9034 {
9035 for (face = 0; face < 21; face++)
9036 {
9037 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
9038 }
9039 }
9040 else
9041 {
9042 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
9043 }
9044 break;
9045
9046 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
9047 res.Add(new LSL_Integer(0));
9048 res.Add(new LSL_Vector(0f,0f,0f));
9049 res.Add(new LSL_Float(0f)); // intensity
9050 res.Add(new LSL_Float(0f)); // radius
9051 res.Add(new LSL_Float(0f)); // falloff
9052 break;
9053
9054 case (int)ScriptBaseClass.PRIM_GLOW:
9055 if (remain < 1)
9056 return res;
9057 face = (int)rules.GetLSLIntegerItem(idx++);
9058
9059 if (face == ScriptBaseClass.ALL_SIDES)
9060 {
9061 for (face = 0; face < 21; face++)
9062 {
9063 res.Add(new LSL_Float(0f));
9064 }
9065 }
9066 else
9067 {
9068 res.Add(new LSL_Float(0f));
9069 }
9070 break;
9071
9072 case (int)ScriptBaseClass.PRIM_TEXT:
9073 res.Add(new LSL_String(""));
9074 res.Add(new LSL_Vector(0f,0f,0f));
9075 res.Add(new LSL_Float(1.0f));
9076 break;
9077
9078 case (int)ScriptBaseClass.PRIM_NAME:
9079 res.Add(new LSL_String(avatar.Name));
9080 break;
9081
9082 case (int)ScriptBaseClass.PRIM_DESC:
9083 res.Add(new LSL_String(""));
9084 break;
9085
9086 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
9087 Quaternion lrot = avatar.Rotation;
9088
9089 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
9090 {
9091 lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
9092 }
9093 res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
9094 break;
9095
9096 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
9097 Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
9098 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
9099 lpos -= lsitOffset;
9100
9101 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
9102 {
9103 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
9104 }
9105 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
9106 break;
9107
9108 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9109 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9110 return res;
9111 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
9112 LSL_List new_rules = rules.GetSublist(idx, -1);
9113
9114 res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9115 return res;
9116 }
9117 }
7939 return res; 9118 return res;
7940 } 9119 }
7941 9120
@@ -7979,13 +9158,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7979 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, 9158 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X,
7980 part.AbsolutePosition.Y, 9159 part.AbsolutePosition.Y,
7981 part.AbsolutePosition.Z); 9160 part.AbsolutePosition.Z);
7982 // For some reason, the part.AbsolutePosition.* values do not change if the
7983 // linkset is rotated; they always reflect the child prim's world position
7984 // as though the linkset is unrotated. This is incompatible behavior with SL's
7985 // implementation, so will break scripts imported from there (not to mention it
7986 // makes it more difficult to determine a child prim's actual inworld position).
7987 if (part.ParentID != 0)
7988 v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition();
7989 res.Add(v); 9161 res.Add(v);
7990 break; 9162 break;
7991 9163
@@ -8156,56 +9328,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8156 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 9328 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
8157 if (remain < 1) 9329 if (remain < 1)
8158 return res; 9330 return res;
8159 9331 face = (int)rules.GetLSLIntegerItem(idx++);
8160 face=(int)rules.GetLSLIntegerItem(idx++);
8161 9332
8162 tex = part.Shape.Textures; 9333 tex = part.Shape.Textures;
9334 int shiny;
8163 if (face == ScriptBaseClass.ALL_SIDES) 9335 if (face == ScriptBaseClass.ALL_SIDES)
8164 { 9336 {
8165 for (face = 0; face < GetNumberOfSides(part); face++) 9337 for (face = 0; face < GetNumberOfSides(part); face++)
8166 { 9338 {
8167 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 9339 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8168 // Convert Shininess to PRIM_SHINY_* 9340 if (shinyness == Shininess.High)
8169 res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); 9341 {
8170 // PRIM_BUMP_* 9342 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8171 res.Add(new LSL_Integer((int)texface.Bump)); 9343 }
9344 else if (shinyness == Shininess.Medium)
9345 {
9346 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
9347 }
9348 else if (shinyness == Shininess.Low)
9349 {
9350 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
9351 }
9352 else
9353 {
9354 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
9355 }
9356 res.Add(new LSL_Integer(shiny));
9357 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8172 } 9358 }
8173 } 9359 }
8174 else 9360 else
8175 { 9361 {
8176 if (face >= 0 && face < GetNumberOfSides(part)) 9362 Shininess shinyness = tex.GetFace((uint)face).Shiny;
9363 if (shinyness == Shininess.High)
8177 { 9364 {
8178 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 9365 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8179 // Convert Shininess to PRIM_SHINY_* 9366 }
8180 res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); 9367 else if (shinyness == Shininess.Medium)
8181 // PRIM_BUMP_* 9368 {
8182 res.Add(new LSL_Integer((int)texface.Bump)); 9369 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
9370 }
9371 else if (shinyness == Shininess.Low)
9372 {
9373 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
9374 }
9375 else
9376 {
9377 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8183 } 9378 }
9379 res.Add(new LSL_Integer(shiny));
9380 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8184 } 9381 }
8185 break; 9382 break;
8186 9383
8187 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 9384 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
8188 if (remain < 1) 9385 if (remain < 1)
8189 return res; 9386 return res;
8190 9387 face = (int)rules.GetLSLIntegerItem(idx++);
8191 face=(int)rules.GetLSLIntegerItem(idx++);
8192 9388
8193 tex = part.Shape.Textures; 9389 tex = part.Shape.Textures;
9390 int fullbright;
8194 if (face == ScriptBaseClass.ALL_SIDES) 9391 if (face == ScriptBaseClass.ALL_SIDES)
8195 { 9392 {
8196 for (face = 0; face < GetNumberOfSides(part); face++) 9393 for (face = 0; face < GetNumberOfSides(part); face++)
8197 { 9394 {
8198 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 9395 if (tex.GetFace((uint)face).Fullbright == true)
8199 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); 9396 {
9397 fullbright = ScriptBaseClass.TRUE;
9398 }
9399 else
9400 {
9401 fullbright = ScriptBaseClass.FALSE;
9402 }
9403 res.Add(new LSL_Integer(fullbright));
8200 } 9404 }
8201 } 9405 }
8202 else 9406 else
8203 { 9407 {
8204 if (face >= 0 && face < GetNumberOfSides(part)) 9408 if (tex.GetFace((uint)face).Fullbright == true)
8205 { 9409 {
8206 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 9410 fullbright = ScriptBaseClass.TRUE;
8207 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); 9411 }
9412 else
9413 {
9414 fullbright = ScriptBaseClass.FALSE;
8208 } 9415 }
9416 res.Add(new LSL_Integer(fullbright));
8209 } 9417 }
8210 break; 9418 break;
8211 9419
@@ -8227,27 +9435,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8227 break; 9435 break;
8228 9436
8229 case (int)ScriptBaseClass.PRIM_TEXGEN: 9437 case (int)ScriptBaseClass.PRIM_TEXGEN:
9438 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
8230 if (remain < 1) 9439 if (remain < 1)
8231 return res; 9440 return res;
8232 9441 face = (int)rules.GetLSLIntegerItem(idx++);
8233 face=(int)rules.GetLSLIntegerItem(idx++);
8234 9442
8235 tex = part.Shape.Textures; 9443 tex = part.Shape.Textures;
8236 if (face == ScriptBaseClass.ALL_SIDES) 9444 if (face == ScriptBaseClass.ALL_SIDES)
8237 { 9445 {
8238 for (face = 0; face < GetNumberOfSides(part); face++) 9446 for (face = 0; face < GetNumberOfSides(part); face++)
8239 { 9447 {
8240 MappingType texgen = tex.GetFace((uint)face).TexMapType; 9448 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8241 // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. 9449 {
8242 res.Add(new LSL_Integer((uint)texgen >> 1)); 9450 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
9451 }
9452 else
9453 {
9454 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
9455 }
8243 } 9456 }
8244 } 9457 }
8245 else 9458 else
8246 { 9459 {
8247 if (face >= 0 && face < GetNumberOfSides(part)) 9460 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
9461 {
9462 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
9463 }
9464 else
8248 { 9465 {
8249 MappingType texgen = tex.GetFace((uint)face).TexMapType; 9466 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8250 res.Add(new LSL_Integer((uint)texgen >> 1));
8251 } 9467 }
8252 } 9468 }
8253 break; 9469 break;
@@ -8270,25 +9486,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8270 case (int)ScriptBaseClass.PRIM_GLOW: 9486 case (int)ScriptBaseClass.PRIM_GLOW:
8271 if (remain < 1) 9487 if (remain < 1)
8272 return res; 9488 return res;
8273 9489 face = (int)rules.GetLSLIntegerItem(idx++);
8274 face=(int)rules.GetLSLIntegerItem(idx++);
8275 9490
8276 tex = part.Shape.Textures; 9491 tex = part.Shape.Textures;
9492 float primglow;
8277 if (face == ScriptBaseClass.ALL_SIDES) 9493 if (face == ScriptBaseClass.ALL_SIDES)
8278 { 9494 {
8279 for (face = 0; face < GetNumberOfSides(part); face++) 9495 for (face = 0; face < GetNumberOfSides(part); face++)
8280 { 9496 {
8281 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 9497 primglow = tex.GetFace((uint)face).Glow;
8282 res.Add(new LSL_Float(texface.Glow)); 9498 res.Add(new LSL_Float(primglow));
8283 } 9499 }
8284 } 9500 }
8285 else 9501 else
8286 { 9502 {
8287 if (face >= 0 && face < GetNumberOfSides(part)) 9503 primglow = tex.GetFace((uint)face).Glow;
8288 { 9504 res.Add(new LSL_Float(primglow));
8289 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
8290 res.Add(new LSL_Float(texface.Glow));
8291 }
8292 } 9505 }
8293 break; 9506 break;
8294 9507
@@ -8300,18 +9513,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8300 textColor.B)); 9513 textColor.B));
8301 res.Add(new LSL_Float(textColor.A)); 9514 res.Add(new LSL_Float(textColor.A));
8302 break; 9515 break;
9516
8303 case (int)ScriptBaseClass.PRIM_NAME: 9517 case (int)ScriptBaseClass.PRIM_NAME:
8304 res.Add(new LSL_String(part.Name)); 9518 res.Add(new LSL_String(part.Name));
8305 break; 9519 break;
9520
8306 case (int)ScriptBaseClass.PRIM_DESC: 9521 case (int)ScriptBaseClass.PRIM_DESC:
8307 res.Add(new LSL_String(part.Description)); 9522 res.Add(new LSL_String(part.Description));
8308 break; 9523 break;
9524
8309 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 9525 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8310 res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); 9526 res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W));
8311 break; 9527 break;
9528
8312 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 9529 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
8313 res.Add(new LSL_Vector(GetPartLocalPos(part))); 9530 res.Add(new LSL_Vector(GetPartLocalPos(part)));
8314 break; 9531 break;
9532 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9533 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9534 return res;
9535 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
9536 LSL_List new_rules = rules.GetSublist(idx, -1);
9537 LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9538 res += tres;
9539 return res;
8315 case (int)ScriptBaseClass.PRIM_SLICE: 9540 case (int)ScriptBaseClass.PRIM_SLICE:
8316 PrimType prim_type = part.GetPrimType(); 9541 PrimType prim_type = part.GetPrimType();
8317 bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); 9542 bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
@@ -8913,8 +10138,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8913 // The function returns an ordered list 10138 // The function returns an ordered list
8914 // representing the tokens found in the supplied 10139 // representing the tokens found in the supplied
8915 // sources string. If two successive tokenizers 10140 // sources string. If two successive tokenizers
8916 // are encountered, then a NULL entry is added 10141 // are encountered, then a null-string entry is
8917 // to the list. 10142 // added to the list.
8918 // 10143 //
8919 // It is a precondition that the source and 10144 // It is a precondition that the source and
8920 // toekizer lisst are non-null. If they are null, 10145 // toekizer lisst are non-null. If they are null,
@@ -8922,7 +10147,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8922 // while their lengths are being determined. 10147 // while their lengths are being determined.
8923 // 10148 //
8924 // A small amount of working memoryis required 10149 // A small amount of working memoryis required
8925 // of approximately 8*#tokenizers. 10150 // of approximately 8*#tokenizers + 8*srcstrlen.
8926 // 10151 //
8927 // There are many ways in which this function 10152 // There are many ways in which this function
8928 // can be implemented, this implementation is 10153 // can be implemented, this implementation is
@@ -8938,155 +10163,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8938 // and eliminates redundant tokenizers as soon 10163 // and eliminates redundant tokenizers as soon
8939 // as is possible. 10164 // as is possible.
8940 // 10165 //
8941 // The implementation tries to avoid any copying 10166 // The implementation tries to minimize temporary
8942 // of arrays or other objects. 10167 // garbage generation.
8943 // </remarks> 10168 // </remarks>
8944 10169
8945 private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) 10170 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8946 { 10171 {
8947 int beginning = 0; 10172 return ParseString2List(src, separators, spacers, true);
8948 int srclen = src.Length; 10173 }
8949 int seplen = separators.Length;
8950 object[] separray = separators.Data;
8951 int spclen = spacers.Length;
8952 object[] spcarray = spacers.Data;
8953 int mlen = seplen+spclen;
8954
8955 int[] offset = new int[mlen+1];
8956 bool[] active = new bool[mlen];
8957
8958 int best;
8959 int j;
8960
8961 // Initial capacity reduces resize cost
8962 10174
8963 LSL_List tokens = new LSL_List(); 10175 private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls)
10176 {
10177 int srclen = src.Length;
10178 int seplen = separators.Length;
10179 object[] separray = separators.Data;
10180 int spclen = spacers.Length;
10181 object[] spcarray = spacers.Data;
10182 int dellen = 0;
10183 string[] delarray = new string[seplen+spclen];
8964 10184
8965 // All entries are initially valid 10185 int outlen = 0;
10186 string[] outarray = new string[srclen*2+1];
8966 10187
8967 for (int i = 0; i < mlen; i++) 10188 int i, j;
8968 active[i] = true; 10189 string d;
8969 10190
8970 offset[mlen] = srclen; 10191 m_host.AddScriptLPS(1);
8971 10192
8972 while (beginning < srclen) 10193 /*
10194 * Convert separator and spacer lists to C# strings.
10195 * Also filter out null strings so we don't hang.
10196 */
10197 for (i = 0; i < seplen; i ++)
8973 { 10198 {
10199 d = separray[i].ToString();
10200 if (d.Length > 0)
10201 {
10202 delarray[dellen++] = d;
10203 }
10204 }
10205 seplen = dellen;
8974 10206
8975 best = mlen; // as bad as it gets 10207 for (i = 0; i < spclen; i ++)
10208 {
10209 d = spcarray[i].ToString();
10210 if (d.Length > 0)
10211 {
10212 delarray[dellen++] = d;
10213 }
10214 }
8976 10215
8977 // Scan for separators 10216 /*
10217 * Scan through source string from beginning to end.
10218 */
10219 for (i = 0;;)
10220 {
8978 10221
8979 for (j = 0; j < seplen; j++) 10222 /*
10223 * Find earliest delimeter in src starting at i (if any).
10224 */
10225 int earliestDel = -1;
10226 int earliestSrc = srclen;
10227 string earliestStr = null;
10228 for (j = 0; j < dellen; j ++)
8980 { 10229 {
8981 if (separray[j].ToString() == String.Empty) 10230 d = delarray[j];
8982 active[j] = false; 10231 if (d != null)
8983
8984 if (active[j])
8985 { 10232 {
8986 // scan all of the markers 10233 int index = src.IndexOf(d, i);
8987 if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) 10234 if (index < 0)
8988 { 10235 {
8989 // not present at all 10236 delarray[j] = null; // delim nowhere in src, don't check it anymore
8990 active[j] = false;
8991 } 10237 }
8992 else 10238 else if (index < earliestSrc)
8993 { 10239 {
8994 // present and correct 10240 earliestSrc = index; // where delimeter starts in source string
8995 if (offset[j] < offset[best]) 10241 earliestDel = j; // where delimeter is in delarray[]
8996 { 10242 earliestStr = d; // the delimeter string from delarray[]
8997 // closest so far 10243 if (index == i) break; // can't do any better than found at beg of string
8998 best = j;
8999 if (offset[best] == beginning)
9000 break;
9001 }
9002 } 10244 }
9003 } 10245 }
9004 } 10246 }
9005 10247
9006 // Scan for spacers 10248 /*
9007 10249 * Output source string starting at i through start of earliest delimeter.
9008 if (offset[best] != beginning) 10250 */
10251 if (keepNulls || (earliestSrc > i))
9009 { 10252 {
9010 for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) 10253 outarray[outlen++] = src.Substring(i, earliestSrc - i);
9011 {
9012 if (spcarray[j-seplen].ToString() == String.Empty)
9013 active[j] = false;
9014
9015 if (active[j])
9016 {
9017 // scan all of the markers
9018 if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1)
9019 {
9020 // not present at all
9021 active[j] = false;
9022 }
9023 else
9024 {
9025 // present and correct
9026 if (offset[j] < offset[best])
9027 {
9028 // closest so far
9029 best = j;
9030 }
9031 }
9032 }
9033 }
9034 } 10254 }
9035 10255
9036 // This is the normal exit from the scanning loop 10256 /*
10257 * If no delimeter found at or after i, we're done scanning.
10258 */
10259 if (earliestDel < 0) break;
9037 10260
9038 if (best == mlen) 10261 /*
10262 * If delimeter was a spacer, output the spacer.
10263 */
10264 if (earliestDel >= seplen)
9039 { 10265 {
9040 // no markers were found on this pass 10266 outarray[outlen++] = earliestStr;
9041 // so we're pretty much done
9042 if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0))
9043 tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
9044 break;
9045 } 10267 }
9046 10268
9047 // Otherwise we just add the newly delimited token 10269 /*
9048 // and recalculate where the search should continue. 10270 * Look at rest of src string following delimeter.
9049 if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) 10271 */
9050 tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); 10272 i = earliestSrc + earliestStr.Length;
9051
9052 if (best < seplen)
9053 {
9054 beginning = offset[best] + (separray[best].ToString()).Length;
9055 }
9056 else
9057 {
9058 beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
9059 string str = spcarray[best - seplen].ToString();
9060 if ((keepNulls) || ((!keepNulls) && (str.Length > 0)))
9061 tokens.Add(new LSL_String(str));
9062 }
9063 } 10273 }
9064 10274
9065 // This an awkward an not very intuitive boundary case. If the 10275 /*
9066 // last substring is a tokenizer, then there is an implied trailing 10276 * Make up an exact-sized output array suitable for an LSL_List object.
9067 // null list entry. Hopefully the single comparison will not be too 10277 */
9068 // arduous. Alternatively the 'break' could be replced with a return 10278 object[] outlist = new object[outlen];
9069 // but that's shabby programming. 10279 for (i = 0; i < outlen; i ++)
9070
9071 if ((beginning == srclen) && (keepNulls))
9072 { 10280 {
9073 if (srclen != 0) 10281 outlist[i] = new LSL_String(outarray[i]);
9074 tokens.Add(new LSL_String(""));
9075 } 10282 }
9076 10283 return new LSL_List(outlist);
9077 return tokens;
9078 }
9079
9080 public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers)
9081 {
9082 m_host.AddScriptLPS(1);
9083 return this.ParseString(src, separators, spacers, false);
9084 }
9085
9086 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
9087 {
9088 m_host.AddScriptLPS(1);
9089 return this.ParseString(src, separators, spacers, true);
9090 } 10284 }
9091 10285
9092 public LSL_Integer llGetObjectPermMask(int mask) 10286 public LSL_Integer llGetObjectPermMask(int mask)
@@ -9181,6 +10375,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9181 case 4: 10375 case 4:
9182 return (int)item.NextPermissions; 10376 return (int)item.NextPermissions;
9183 } 10377 }
10378 m_host.TaskInventory.LockItemsForRead(false);
9184 10379
9185 return -1; 10380 return -1;
9186 } 10381 }
@@ -9371,9 +10566,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9371 { 10566 {
9372 try 10567 try
9373 { 10568 {
10569 /*
9374 SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); 10570 SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId);
9375 if (obj != null) 10571 if (obj != null)
9376 return (double)obj.GetMass(); 10572 return (double)obj.GetMass();
10573 */
10574 // return total object mass
10575 SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId);
10576 if (obj != null)
10577 return obj.GetMass();
10578
9377 // the object is null so the key is for an avatar 10579 // the object is null so the key is for an avatar
9378 ScenePresence avatar = World.GetScenePresence(key); 10580 ScenePresence avatar = World.GetScenePresence(key);
9379 if (avatar != null) 10581 if (avatar != null)
@@ -9393,7 +10595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9393 } 10595 }
9394 10596
9395 /// <summary> 10597 /// <summary>
9396 /// illListReplaceList removes the sub-list defined by the inclusive indices 10598 /// llListReplaceList removes the sub-list defined by the inclusive indices
9397 /// start and end and inserts the src list in its place. The inclusive 10599 /// start and end and inserts the src list in its place. The inclusive
9398 /// nature of the indices means that at least one element must be deleted 10600 /// nature of the indices means that at least one element must be deleted
9399 /// if the indices are within the bounds of the existing list. I.e. 2,2 10601 /// if the indices are within the bounds of the existing list. I.e. 2,2
@@ -9450,16 +10652,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9450 // based upon end. Note that if end exceeds the upper 10652 // based upon end. Note that if end exceeds the upper
9451 // bound in this case, the entire destination list 10653 // bound in this case, the entire destination list
9452 // is removed. 10654 // is removed.
9453 else 10655 else if (start == 0)
9454 { 10656 {
9455 if (end + 1 < dest.Length) 10657 if (end + 1 < dest.Length)
9456 {
9457 return src + dest.GetSublist(end + 1, -1); 10658 return src + dest.GetSublist(end + 1, -1);
9458 }
9459 else 10659 else
9460 {
9461 return src; 10660 return src;
9462 } 10661 }
10662 else // Start < 0
10663 {
10664 if (end + 1 < dest.Length)
10665 return dest.GetSublist(end + 1, -1);
10666 else
10667 return new LSL_List();
9463 } 10668 }
9464 } 10669 }
9465 // Finally, if start > end, we strip away a prefix and 10670 // Finally, if start > end, we strip away a prefix and
@@ -9510,17 +10715,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9510 int width = 0; 10715 int width = 0;
9511 int height = 0; 10716 int height = 0;
9512 10717
9513 ParcelMediaCommandEnum? commandToSend = null; 10718 uint commandToSend = 0;
9514 float time = 0.0f; // default is from start 10719 float time = 0.0f; // default is from start
9515 10720
9516 ScenePresence presence = null; 10721 ScenePresence presence = null;
9517 10722
9518 for (int i = 0; i < commandList.Data.Length; i++) 10723 for (int i = 0; i < commandList.Data.Length; i++)
9519 { 10724 {
9520 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 10725 uint command = (uint)(commandList.GetLSLIntegerItem(i));
9521 switch (command) 10726 switch (command)
9522 { 10727 {
9523 case ParcelMediaCommandEnum.Agent: 10728 case (uint)ParcelMediaCommandEnum.Agent:
9524 // we send only to one agent 10729 // we send only to one agent
9525 if ((i + 1) < commandList.Length) 10730 if ((i + 1) < commandList.Length)
9526 { 10731 {
@@ -9537,25 +10742,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9537 } 10742 }
9538 break; 10743 break;
9539 10744
9540 case ParcelMediaCommandEnum.Loop: 10745 case (uint)ParcelMediaCommandEnum.Loop:
9541 loop = 1; 10746 loop = 1;
9542 commandToSend = command; 10747 commandToSend = command;
9543 update = true; //need to send the media update packet to set looping 10748 update = true; //need to send the media update packet to set looping
9544 break; 10749 break;
9545 10750
9546 case ParcelMediaCommandEnum.Play: 10751 case (uint)ParcelMediaCommandEnum.Play:
9547 loop = 0; 10752 loop = 0;
9548 commandToSend = command; 10753 commandToSend = command;
9549 update = true; //need to send the media update packet to make sure it doesn't loop 10754 update = true; //need to send the media update packet to make sure it doesn't loop
9550 break; 10755 break;
9551 10756
9552 case ParcelMediaCommandEnum.Pause: 10757 case (uint)ParcelMediaCommandEnum.Pause:
9553 case ParcelMediaCommandEnum.Stop: 10758 case (uint)ParcelMediaCommandEnum.Stop:
9554 case ParcelMediaCommandEnum.Unload: 10759 case (uint)ParcelMediaCommandEnum.Unload:
9555 commandToSend = command; 10760 commandToSend = command;
9556 break; 10761 break;
9557 10762
9558 case ParcelMediaCommandEnum.Url: 10763 case (uint)ParcelMediaCommandEnum.Url:
9559 if ((i + 1) < commandList.Length) 10764 if ((i + 1) < commandList.Length)
9560 { 10765 {
9561 if (commandList.Data[i + 1] is LSL_String) 10766 if (commandList.Data[i + 1] is LSL_String)
@@ -9568,7 +10773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9568 } 10773 }
9569 break; 10774 break;
9570 10775
9571 case ParcelMediaCommandEnum.Texture: 10776 case (uint)ParcelMediaCommandEnum.Texture:
9572 if ((i + 1) < commandList.Length) 10777 if ((i + 1) < commandList.Length)
9573 { 10778 {
9574 if (commandList.Data[i + 1] is LSL_String) 10779 if (commandList.Data[i + 1] is LSL_String)
@@ -9581,7 +10786,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9581 } 10786 }
9582 break; 10787 break;
9583 10788
9584 case ParcelMediaCommandEnum.Time: 10789 case (uint)ParcelMediaCommandEnum.Time:
9585 if ((i + 1) < commandList.Length) 10790 if ((i + 1) < commandList.Length)
9586 { 10791 {
9587 if (commandList.Data[i + 1] is LSL_Float) 10792 if (commandList.Data[i + 1] is LSL_Float)
@@ -9593,7 +10798,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9593 } 10798 }
9594 break; 10799 break;
9595 10800
9596 case ParcelMediaCommandEnum.AutoAlign: 10801 case (uint)ParcelMediaCommandEnum.AutoAlign:
9597 if ((i + 1) < commandList.Length) 10802 if ((i + 1) < commandList.Length)
9598 { 10803 {
9599 if (commandList.Data[i + 1] is LSL_Integer) 10804 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9607,7 +10812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9607 } 10812 }
9608 break; 10813 break;
9609 10814
9610 case ParcelMediaCommandEnum.Type: 10815 case (uint)ParcelMediaCommandEnum.Type:
9611 if ((i + 1) < commandList.Length) 10816 if ((i + 1) < commandList.Length)
9612 { 10817 {
9613 if (commandList.Data[i + 1] is LSL_String) 10818 if (commandList.Data[i + 1] is LSL_String)
@@ -9620,7 +10825,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9620 } 10825 }
9621 break; 10826 break;
9622 10827
9623 case ParcelMediaCommandEnum.Desc: 10828 case (uint)ParcelMediaCommandEnum.Desc:
9624 if ((i + 1) < commandList.Length) 10829 if ((i + 1) < commandList.Length)
9625 { 10830 {
9626 if (commandList.Data[i + 1] is LSL_String) 10831 if (commandList.Data[i + 1] is LSL_String)
@@ -9633,7 +10838,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9633 } 10838 }
9634 break; 10839 break;
9635 10840
9636 case ParcelMediaCommandEnum.Size: 10841 case (uint)ParcelMediaCommandEnum.Size:
9637 if ((i + 2) < commandList.Length) 10842 if ((i + 2) < commandList.Length)
9638 { 10843 {
9639 if (commandList.Data[i + 1] is LSL_Integer) 10844 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9703,7 +10908,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9703 } 10908 }
9704 } 10909 }
9705 10910
9706 if (commandToSend != null) 10911 if (commandToSend != 0)
9707 { 10912 {
9708 // the commandList contained a start/stop/... command, too 10913 // the commandList contained a start/stop/... command, too
9709 if (presence == null) 10914 if (presence == null)
@@ -9740,7 +10945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9740 10945
9741 if (aList.Data[i] != null) 10946 if (aList.Data[i] != null)
9742 { 10947 {
9743 switch ((ParcelMediaCommandEnum) aList.Data[i]) 10948 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
9744 { 10949 {
9745 case ParcelMediaCommandEnum.Url: 10950 case ParcelMediaCommandEnum.Url:
9746 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 10951 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
@@ -9797,15 +11002,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9797 11002
9798 if (quick_pay_buttons.Data.Length < 4) 11003 if (quick_pay_buttons.Data.Length < 4)
9799 { 11004 {
9800 LSLError("List must have at least 4 elements"); 11005 int x;
9801 return; 11006 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
11007 {
11008 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
11009 }
9802 } 11010 }
9803 m_host.ParentGroup.RootPart.PayPrice[0]=price; 11011 int[] nPrice = new int[5];
9804 11012 nPrice[0] = price;
9805 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 11013 nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0);
9806 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 11014 nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1);
9807 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 11015 nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2);
9808 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 11016 nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3);
11017 m_host.ParentGroup.RootPart.PayPrice = nPrice;
9809 m_host.ParentGroup.HasGroupChanged = true; 11018 m_host.ParentGroup.HasGroupChanged = true;
9810 } 11019 }
9811 11020
@@ -9822,7 +11031,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9822 return new LSL_Vector(); 11031 return new LSL_Vector();
9823 } 11032 }
9824 11033
9825 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 11034// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11035 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
9826 if (presence != null) 11036 if (presence != null)
9827 { 11037 {
9828 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); 11038 LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z);
@@ -9844,7 +11054,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9844 return new LSL_Rotation(); 11054 return new LSL_Rotation();
9845 } 11055 }
9846 11056
9847 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 11057// ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
11058 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
9848 if (presence != null) 11059 if (presence != null)
9849 { 11060 {
9850 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); 11061 return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W);
@@ -9904,14 +11115,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9904 { 11115 {
9905 m_host.AddScriptLPS(1); 11116 m_host.AddScriptLPS(1);
9906 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); 11117 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
9907 if (detectedParams == null) return; // only works on the first detected avatar 11118 if (detectedParams == null)
9908 11119 {
11120 if (m_host.ParentGroup.IsAttachment == true)
11121 {
11122 detectedParams = new DetectParams();
11123 detectedParams.Key = m_host.OwnerID;
11124 }
11125 else
11126 {
11127 return;
11128 }
11129 }
11130
9909 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 11131 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9910 if (avatar != null) 11132 if (avatar != null)
9911 { 11133 {
9912 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, 11134 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
9913 simname, pos, lookAt); 11135 simname, pos, lookAt);
9914 } 11136 }
11137
9915 ScriptSleep(1000); 11138 ScriptSleep(1000);
9916 } 11139 }
9917 11140
@@ -10035,12 +11258,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10035 11258
10036 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); 11259 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
10037 object[] data = rules.Data; 11260 object[] data = rules.Data;
10038 for (int i = 0; i < data.Length; ++i) { 11261 for (int i = 0; i < data.Length; ++i)
11262 {
10039 int type = Convert.ToInt32(data[i++].ToString()); 11263 int type = Convert.ToInt32(data[i++].ToString());
10040 if (i >= data.Length) break; // odd number of entries => ignore the last 11264 if (i >= data.Length) break; // odd number of entries => ignore the last
10041 11265
10042 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) 11266 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
10043 switch (type) { 11267 switch (type)
11268 {
10044 case ScriptBaseClass.CAMERA_FOCUS: 11269 case ScriptBaseClass.CAMERA_FOCUS:
10045 case ScriptBaseClass.CAMERA_FOCUS_OFFSET: 11270 case ScriptBaseClass.CAMERA_FOCUS_OFFSET:
10046 case ScriptBaseClass.CAMERA_POSITION: 11271 case ScriptBaseClass.CAMERA_POSITION:
@@ -10146,19 +11371,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10146 public LSL_String llXorBase64StringsCorrect(string str1, string str2) 11371 public LSL_String llXorBase64StringsCorrect(string str1, string str2)
10147 { 11372 {
10148 m_host.AddScriptLPS(1); 11373 m_host.AddScriptLPS(1);
10149 string ret = String.Empty; 11374
10150 string src1 = llBase64ToString(str1); 11375 if (str1 == String.Empty)
10151 string src2 = llBase64ToString(str2); 11376 return String.Empty;
10152 int c = 0; 11377 if (str2 == String.Empty)
10153 for (int i = 0; i < src1.Length; i++) 11378 return str1;
11379
11380 int len = str2.Length;
11381 if ((len % 4) != 0) // LL is EVIL!!!!
10154 { 11382 {
10155 ret += (char) (src1[i] ^ src2[c]); 11383 while (str2.EndsWith("="))
11384 str2 = str2.Substring(0, str2.Length - 1);
11385
11386 len = str2.Length;
11387 int mod = len % 4;
10156 11388
10157 c++; 11389 if (mod == 1)
10158 if (c >= src2.Length) 11390 str2 = str2.Substring(0, str2.Length - 1);
10159 c = 0; 11391 else if (mod == 2)
11392 str2 += "==";
11393 else if (mod == 3)
11394 str2 += "=";
10160 } 11395 }
10161 return llStringToBase64(ret); 11396
11397 byte[] data1;
11398 byte[] data2;
11399 try
11400 {
11401 data1 = Convert.FromBase64String(str1);
11402 data2 = Convert.FromBase64String(str2);
11403 }
11404 catch (Exception)
11405 {
11406 return new LSL_String(String.Empty);
11407 }
11408
11409 byte[] d2 = new Byte[data1.Length];
11410 int pos = 0;
11411
11412 if (data1.Length <= data2.Length)
11413 {
11414 Array.Copy(data2, 0, d2, 0, data1.Length);
11415 }
11416 else
11417 {
11418 while (pos < data1.Length)
11419 {
11420 len = data1.Length - pos;
11421 if (len > data2.Length)
11422 len = data2.Length;
11423
11424 Array.Copy(data2, 0, d2, pos, len);
11425 pos += len;
11426 }
11427 }
11428
11429 for (pos = 0 ; pos < data1.Length ; pos++ )
11430 data1[pos] ^= d2[pos];
11431
11432 return Convert.ToBase64String(data1);
10162 } 11433 }
10163 11434
10164 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) 11435 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body)
@@ -10211,16 +11482,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10211 if (userAgent != null) 11482 if (userAgent != null)
10212 httpHeaders["User-Agent"] = userAgent; 11483 httpHeaders["User-Agent"] = userAgent;
10213 11484
11485 // See if the URL contains any header hacks
11486 string[] urlParts = url.Split(new char[] {'\n'});
11487 if (urlParts.Length > 1)
11488 {
11489 // Iterate the passed headers and parse them
11490 for (int i = 1 ; i < urlParts.Length ; i++ )
11491 {
11492 // The rest of those would be added to the body in SL.
11493 // Let's not do that.
11494 if (urlParts[i] == String.Empty)
11495 break;
11496
11497 // See if this could be a valid header
11498 string[] headerParts = urlParts[i].Split(new char[] {':'}, 2);
11499 if (headerParts.Length != 2)
11500 continue;
11501
11502 string headerName = headerParts[0].Trim();
11503 string headerValue = headerParts[1].Trim();
11504
11505 // Filter out headers that could be used to abuse
11506 // another system or cloak the request
11507 if (headerName.ToLower() == "x-secondlife-shard" ||
11508 headerName.ToLower() == "x-secondlife-object-name" ||
11509 headerName.ToLower() == "x-secondlife-object-key" ||
11510 headerName.ToLower() == "x-secondlife-region" ||
11511 headerName.ToLower() == "x-secondlife-local-position" ||
11512 headerName.ToLower() == "x-secondlife-local-velocity" ||
11513 headerName.ToLower() == "x-secondlife-local-rotation" ||
11514 headerName.ToLower() == "x-secondlife-owner-name" ||
11515 headerName.ToLower() == "x-secondlife-owner-key" ||
11516 headerName.ToLower() == "connection" ||
11517 headerName.ToLower() == "content-length" ||
11518 headerName.ToLower() == "from" ||
11519 headerName.ToLower() == "host" ||
11520 headerName.ToLower() == "proxy-authorization" ||
11521 headerName.ToLower() == "referer" ||
11522 headerName.ToLower() == "trailer" ||
11523 headerName.ToLower() == "transfer-encoding" ||
11524 headerName.ToLower() == "via" ||
11525 headerName.ToLower() == "authorization")
11526 continue;
11527
11528 httpHeaders[headerName] = headerValue;
11529 }
11530
11531 // Finally, strip any protocol specifier from the URL
11532 url = urlParts[0].Trim();
11533 int idx = url.IndexOf(" HTTP/");
11534 if (idx != -1)
11535 url = url.Substring(0, idx);
11536 }
11537
10214 string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; 11538 string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$";
10215 Regex r = new Regex(authregex); 11539 Regex r = new Regex(authregex);
10216 int[] gnums = r.GetGroupNumbers(); 11540 int[] gnums = r.GetGroupNumbers();
10217 Match m = r.Match(url); 11541 Match m = r.Match(url);
10218 if (m.Success) { 11542 if (m.Success)
10219 for (int i = 1; i < gnums.Length; i++) { 11543 {
11544 for (int i = 1; i < gnums.Length; i++)
11545 {
10220 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; 11546 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]];
10221 //CaptureCollection cc = g.Captures; 11547 //CaptureCollection cc = g.Captures;
10222 } 11548 }
10223 if (m.Groups.Count == 5) { 11549 if (m.Groups.Count == 5)
11550 {
10224 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); 11551 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString())));
10225 url = m.Groups[1].ToString() + m.Groups[4].ToString(); 11552 url = m.Groups[1].ToString() + m.Groups[4].ToString();
10226 } 11553 }
@@ -10423,6 +11750,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10423 11750
10424 LSL_List ret = new LSL_List(); 11751 LSL_List ret = new LSL_List();
10425 UUID key = new UUID(); 11752 UUID key = new UUID();
11753
11754
10426 if (UUID.TryParse(id, out key)) 11755 if (UUID.TryParse(id, out key))
10427 { 11756 {
10428 ScenePresence av = World.GetScenePresence(key); 11757 ScenePresence av = World.GetScenePresence(key);
@@ -10440,13 +11769,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10440 ret.Add(new LSL_String("")); 11769 ret.Add(new LSL_String(""));
10441 break; 11770 break;
10442 case ScriptBaseClass.OBJECT_POS: 11771 case ScriptBaseClass.OBJECT_POS:
10443 ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); 11772 Vector3 avpos;
11773
11774 if (av.ParentID != 0 && av.ParentPart != null)
11775 {
11776 avpos = av.OffsetPosition;
11777
11778 Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f);
11779 avpos -= sitOffset;
11780
11781 avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation();
11782 }
11783 else
11784 avpos = av.AbsolutePosition;
11785
11786 ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z));
10444 break; 11787 break;
10445 case ScriptBaseClass.OBJECT_ROT: 11788 case ScriptBaseClass.OBJECT_ROT:
10446 ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); 11789 Quaternion avrot = av.Rotation;
11790 if (av.ParentID != 0 && av.ParentPart != null)
11791 {
11792 avrot = av.ParentPart.GetWorldRotation() * avrot;
11793 }
11794 ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W));
10447 break; 11795 break;
10448 case ScriptBaseClass.OBJECT_VELOCITY: 11796 case ScriptBaseClass.OBJECT_VELOCITY:
10449 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); 11797 Vector3 avvel = av.Velocity;
11798 ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z));
10450 break; 11799 break;
10451 case ScriptBaseClass.OBJECT_OWNER: 11800 case ScriptBaseClass.OBJECT_OWNER:
10452 ret.Add(new LSL_String(id)); 11801 ret.Add(new LSL_String(id));
@@ -10502,11 +11851,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10502 case ScriptBaseClass.OBJECT_NAME: 11851 case ScriptBaseClass.OBJECT_NAME:
10503 ret.Add(new LSL_String(obj.Name)); 11852 ret.Add(new LSL_String(obj.Name));
10504 break; 11853 break;
10505 case ScriptBaseClass.OBJECT_DESC: 11854 case ScriptBaseClass.OBJECT_DESC:
10506 ret.Add(new LSL_String(obj.Description)); 11855 ret.Add(new LSL_String(obj.Description));
10507 break; 11856 break;
10508 case ScriptBaseClass.OBJECT_POS: 11857 case ScriptBaseClass.OBJECT_POS:
10509 ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); 11858 Vector3 opos = obj.AbsolutePosition;
11859 ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z));
10510 break; 11860 break;
10511 case ScriptBaseClass.OBJECT_ROT: 11861 case ScriptBaseClass.OBJECT_ROT:
10512 { 11862 {
@@ -10556,9 +11906,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10556 // The value returned in SL for normal prims is prim count 11906 // The value returned in SL for normal prims is prim count
10557 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); 11907 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
10558 break; 11908 break;
10559 // The following 3 costs I have intentionaly coded to return zero. They are part of 11909
10560 // "Land Impact" calculations. These calculations are probably not applicable 11910 // costs below may need to be diferent for root parts, need to check
10561 // to OpenSim and are not yet complete in SL
10562 case ScriptBaseClass.OBJECT_SERVER_COST: 11911 case ScriptBaseClass.OBJECT_SERVER_COST:
10563 // The linden calculation is here 11912 // The linden calculation is here
10564 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight 11913 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
@@ -10566,16 +11915,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10566 ret.Add(new LSL_Float(0)); 11915 ret.Add(new LSL_Float(0));
10567 break; 11916 break;
10568 case ScriptBaseClass.OBJECT_STREAMING_COST: 11917 case ScriptBaseClass.OBJECT_STREAMING_COST:
10569 // The linden calculation is here 11918 // The value returned in SL for normal prims is prim count * 0.06
10570 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost 11919 ret.Add(new LSL_Float(obj.StreamingCost));
10571 // The value returned in SL for normal prims looks like the prim count * 0.06
10572 ret.Add(new LSL_Float(0));
10573 break; 11920 break;
10574 case ScriptBaseClass.OBJECT_PHYSICS_COST: 11921 case ScriptBaseClass.OBJECT_PHYSICS_COST:
10575 // The linden calculation is here 11922 // The value returned in SL for normal prims is prim count
10576 // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics 11923 ret.Add(new LSL_Float(obj.PhysicsCost));
10577 // The value returned in SL for normal prims looks like the prim count
10578 ret.Add(new LSL_Float(0));
10579 break; 11924 break;
10580 default: 11925 default:
10581 // Invalid or unhandled constant. 11926 // Invalid or unhandled constant.
@@ -10773,15 +12118,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10773 return GetLinkPrimitiveParams(obj, rules); 12118 return GetLinkPrimitiveParams(obj, rules);
10774 } 12119 }
10775 12120
10776 public void print(string str) 12121 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
10777 { 12122 {
10778 // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print 12123 List<SceneObjectPart> parts = GetLinkParts(link);
10779 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); 12124 if (parts.Count < 1)
10780 if (ossl != null) 12125 return 0;
10781 { 12126
10782 ossl.CheckThreatLevel(ThreatLevel.High, "print"); 12127 return GetNumberOfSides(parts[0]);
10783 m_log.Info("LSL print():" + str);
10784 }
10785 } 12128 }
10786 12129
10787 private string Name2Username(string name) 12130 private string Name2Username(string name)
@@ -10826,7 +12169,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10826 12169
10827 return rq.ToString(); 12170 return rq.ToString();
10828 } 12171 }
10829 12172/*
12173 private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args)
12174 {
12175 m_SayShoutCount = 0;
12176 }
12177*/
10830 private struct Tri 12178 private struct Tri
10831 { 12179 {
10832 public Vector3 p1; 12180 public Vector3 p1;
@@ -10966,9 +12314,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10966 12314
10967 ContactResult result = new ContactResult (); 12315 ContactResult result = new ContactResult ();
10968 result.ConsumerID = group.LocalId; 12316 result.ConsumerID = group.LocalId;
10969 result.Depth = intersection.distance; 12317// result.Depth = intersection.distance;
10970 result.Normal = intersection.normal; 12318 result.Normal = intersection.normal;
10971 result.Pos = intersection.ipoint; 12319 result.Pos = intersection.ipoint;
12320 result.Depth = Vector3.Mag(rayStart - result.Pos);
10972 12321
10973 contacts.Add(result); 12322 contacts.Add(result);
10974 }); 12323 });
@@ -11101,6 +12450,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11101 12450
11102 return contacts[0]; 12451 return contacts[0];
11103 } 12452 }
12453/*
12454 // not done:
12455 private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght)
12456 {
12457 ContactResult[] contacts = null;
12458 World.ForEachSOG(delegate(SceneObjectGroup group)
12459 {
12460 if (m_host.ParentGroup == group)
12461 return;
12462
12463 if (group.IsAttachment)
12464 return;
12465
12466 if(group.RootPart.PhysActor != null)
12467 return;
12468
12469 contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght);
12470 });
12471 return contacts;
12472 }
12473*/
11104 12474
11105 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) 12475 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
11106 { 12476 {
@@ -11142,32 +12512,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11142 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); 12512 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
11143 12513
11144 12514
11145 if (checkTerrain) 12515 if (World.SuportsRayCastFiltered())
11146 { 12516 {
11147 ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); 12517 if (dist == 0)
11148 if (groundContact != null) 12518 return list;
11149 results.Add((ContactResult)groundContact);
11150 }
11151 12519
11152 if (checkAgents) 12520 RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull;
11153 { 12521 if (checkTerrain)
11154 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); 12522 rayfilter |= RayFilterFlags.land;
11155 foreach (ContactResult r in agentHits) 12523// if (checkAgents)
11156 results.Add(r); 12524// rayfilter |= RayFilterFlags.agent;
11157 } 12525 if (checkPhysical)
12526 rayfilter |= RayFilterFlags.physical;
12527 if (checkNonPhysical)
12528 rayfilter |= RayFilterFlags.nonphysical;
12529 if (detectPhantom)
12530 rayfilter |= RayFilterFlags.LSLPhanton;
12531
12532 Vector3 direction = dir * ( 1/dist);
11158 12533
11159 if (checkPhysical || checkNonPhysical || detectPhantom) 12534 if(rayfilter == 0)
12535 {
12536 list.Add(new LSL_Integer(0));
12537 return list;
12538 }
12539
12540 // get some more contacts to sort ???
12541 int physcount = 4 * count;
12542 if (physcount > 20)
12543 physcount = 20;
12544
12545 object physresults;
12546 physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter);
12547
12548 if (physresults == null)
12549 {
12550 list.Add(new LSL_Integer(-3)); // timeout error
12551 return list;
12552 }
12553
12554 results = (List<ContactResult>)physresults;
12555
12556 // for now physics doesn't detect sitted avatars so do it outside physics
12557 if (checkAgents)
12558 {
12559 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
12560 foreach (ContactResult r in agentHits)
12561 results.Add(r);
12562 }
12563
12564 // TODO: Replace this with a better solution. ObjectIntersection can only
12565 // detect nonphysical phantoms. They are detected by virtue of being
12566 // nonphysical (e.g. no PhysActor) so will not conflict with detecting
12567 // physicsl phantoms as done by the physics scene
12568 // We don't want anything else but phantoms here.
12569 if (detectPhantom)
12570 {
12571 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, false, false, true);
12572 foreach (ContactResult r in objectHits)
12573 results.Add(r);
12574 }
12575 }
12576 else
11160 { 12577 {
11161 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); 12578 if (checkTerrain)
11162 foreach (ContactResult r in objectHits) 12579 {
11163 results.Add(r); 12580 ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
12581 if (groundContact != null)
12582 results.Add((ContactResult)groundContact);
12583 }
12584
12585 if (checkAgents)
12586 {
12587 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
12588 foreach (ContactResult r in agentHits)
12589 results.Add(r);
12590 }
12591
12592 if (checkPhysical || checkNonPhysical || detectPhantom)
12593 {
12594 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
12595 foreach (ContactResult r in objectHits)
12596 results.Add(r);
12597 }
11164 } 12598 }
11165 12599
11166 results.Sort(delegate(ContactResult a, ContactResult b) 12600 results.Sort(delegate(ContactResult a, ContactResult b)
11167 { 12601 {
11168 return a.Depth.CompareTo(b.Depth); 12602 return a.Depth.CompareTo(b.Depth);
11169 }); 12603 });
11170 12604
11171 int values = 0; 12605 int values = 0;
11172 SceneObjectGroup thisgrp = m_host.ParentGroup; 12606 SceneObjectGroup thisgrp = m_host.ParentGroup;
11173 12607
@@ -11260,7 +12694,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11260 case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: 12694 case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD:
11261 if (!isAccount) return 0; 12695 if (!isAccount) return 0;
11262 if (estate.HasAccess(id)) return 1; 12696 if (estate.HasAccess(id)) return 1;
11263 if (estate.IsBanned(id)) 12697 if (estate.IsBanned(id, World.GetUserFlags(id)))
11264 estate.RemoveBan(id); 12698 estate.RemoveBan(id);
11265 estate.AddEstateUser(id); 12699 estate.AddEstateUser(id);
11266 break; 12700 break;
@@ -11279,14 +12713,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11279 break; 12713 break;
11280 case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: 12714 case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD:
11281 if (!isAccount) return 0; 12715 if (!isAccount) return 0;
11282 if (estate.IsBanned(id)) return 1; 12716 if (estate.IsBanned(id, World.GetUserFlags(id))) return 1;
11283 EstateBan ban = new EstateBan(); 12717 EstateBan ban = new EstateBan();
11284 ban.EstateID = estate.EstateID; 12718 ban.EstateID = estate.EstateID;
11285 ban.BannedUserID = id; 12719 ban.BannedUserID = id;
11286 estate.AddBan(ban); 12720 estate.AddBan(ban);
11287 break; 12721 break;
11288 case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: 12722 case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE:
11289 if (!isAccount || !estate.IsBanned(id)) return 0; 12723 if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0;
11290 estate.RemoveBan(id); 12724 estate.RemoveBan(id);
11291 break; 12725 break;
11292 default: return 0; 12726 default: return 0;
@@ -11315,7 +12749,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11315 return 16384; 12749 return 16384;
11316 } 12750 }
11317 12751
11318 public LSL_Integer llGetUsedMemory() 12752 public virtual LSL_Integer llGetUsedMemory()
11319 { 12753 {
11320 m_host.AddScriptLPS(1); 12754 m_host.AddScriptLPS(1);
11321 // The value returned for LSO scripts in SL 12755 // The value returned for LSO scripts in SL
@@ -11343,7 +12777,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11343 public void llSetSoundQueueing(int queue) 12777 public void llSetSoundQueueing(int queue)
11344 { 12778 {
11345 m_host.AddScriptLPS(1); 12779 m_host.AddScriptLPS(1);
11346 NotImplemented("llSetSoundQueueing");
11347 } 12780 }
11348 12781
11349 public void llCollisionSprite(string impact_sprite) 12782 public void llCollisionSprite(string impact_sprite)
@@ -11355,10 +12788,270 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11355 public void llGodLikeRezObject(string inventory, LSL_Vector pos) 12788 public void llGodLikeRezObject(string inventory, LSL_Vector pos)
11356 { 12789 {
11357 m_host.AddScriptLPS(1); 12790 m_host.AddScriptLPS(1);
11358 NotImplemented("llGodLikeRezObject"); 12791
12792 if (!World.Permissions.IsGod(m_host.OwnerID))
12793 NotImplemented("llGodLikeRezObject");
12794
12795 AssetBase rezAsset = World.AssetService.Get(inventory);
12796 if (rezAsset == null)
12797 {
12798 llSay(0, "Asset not found");
12799 return;
12800 }
12801
12802 SceneObjectGroup group = null;
12803
12804 try
12805 {
12806 string xmlData = Utils.BytesToString(rezAsset.Data);
12807 group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
12808 }
12809 catch
12810 {
12811 llSay(0, "Asset not found");
12812 return;
12813 }
12814
12815 if (group == null)
12816 {
12817 llSay(0, "Asset not found");
12818 return;
12819 }
12820
12821 group.RootPart.AttachPoint = group.RootPart.Shape.State;
12822 group.RootPart.AttachOffset = group.AbsolutePosition;
12823
12824 group.ResetIDs();
12825
12826 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
12827 World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero);
12828 group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3);
12829 group.ScheduleGroupForFullUpdate();
12830
12831 // objects rezzed with this method are die_at_edge by default.
12832 group.RootPart.SetDieAtEdge(true);
12833
12834 group.ResumeScripts();
12835
12836 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
12837 "object_rez", new Object[] {
12838 new LSL_String(
12839 group.RootPart.UUID.ToString()) },
12840 new DetectParams[0]));
12841 }
12842
12843 public LSL_String llTransferLindenDollars(string destination, int amount)
12844 {
12845 UUID txn = UUID.Random();
12846
12847 Util.FireAndForget(delegate(object x)
12848 {
12849 int replycode = 0;
12850 string replydata = destination + "," + amount.ToString();
12851
12852 try
12853 {
12854 TaskInventoryItem item = m_item;
12855 if (item == null)
12856 {
12857 replydata = "SERVICE_ERROR";
12858 return;
12859 }
12860
12861 m_host.AddScriptLPS(1);
12862
12863 if (item.PermsGranter == UUID.Zero)
12864 {
12865 replydata = "MISSING_PERMISSION_DEBIT";
12866 return;
12867 }
12868
12869 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
12870 {
12871 replydata = "MISSING_PERMISSION_DEBIT";
12872 return;
12873 }
12874
12875 UUID toID = new UUID();
12876
12877 if (!UUID.TryParse(destination, out toID))
12878 {
12879 replydata = "INVALID_AGENT";
12880 return;
12881 }
12882
12883 IMoneyModule money = World.RequestModuleInterface<IMoneyModule>();
12884
12885 if (money == null)
12886 {
12887 replydata = "TRANSFERS_DISABLED";
12888 return;
12889 }
12890
12891 bool result = money.ObjectGiveMoney(
12892 m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount);
12893
12894 if (result)
12895 {
12896 replycode = 1;
12897 return;
12898 }
12899
12900 replydata = "LINDENDOLLAR_INSUFFICIENTFUNDS";
12901 }
12902 finally
12903 {
12904 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
12905 "transaction_result", new Object[] {
12906 new LSL_String(txn.ToString()),
12907 new LSL_Integer(replycode),
12908 new LSL_String(replydata) },
12909 new DetectParams[0]));
12910 }
12911 });
12912
12913 return txn.ToString();
11359 } 12914 }
11360 12915
11361 #endregion 12916 #endregion
12917
12918 public void llSetKeyframedMotion(LSL_List frames, LSL_List options)
12919 {
12920 SceneObjectGroup group = m_host.ParentGroup;
12921
12922 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical)
12923 return;
12924 if (group.IsAttachment)
12925 return;
12926
12927 if (frames.Data.Length > 0) // We are getting a new motion
12928 {
12929 if (group.RootPart.KeyframeMotion != null)
12930 group.RootPart.KeyframeMotion.Stop();
12931 group.RootPart.KeyframeMotion = null;
12932
12933 int idx = 0;
12934
12935 KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward;
12936 KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation;
12937
12938 while (idx < options.Data.Length)
12939 {
12940 int option = (int)options.GetLSLIntegerItem(idx++);
12941 int remain = options.Data.Length - idx;
12942
12943 switch (option)
12944 {
12945 case ScriptBaseClass.KFM_MODE:
12946 if (remain < 1)
12947 break;
12948 int modeval = (int)options.GetLSLIntegerItem(idx++);
12949 switch(modeval)
12950 {
12951 case ScriptBaseClass.KFM_FORWARD:
12952 mode = KeyframeMotion.PlayMode.Forward;
12953 break;
12954 case ScriptBaseClass.KFM_REVERSE:
12955 mode = KeyframeMotion.PlayMode.Reverse;
12956 break;
12957 case ScriptBaseClass.KFM_LOOP:
12958 mode = KeyframeMotion.PlayMode.Loop;
12959 break;
12960 case ScriptBaseClass.KFM_PING_PONG:
12961 mode = KeyframeMotion.PlayMode.PingPong;
12962 break;
12963 }
12964 break;
12965 case ScriptBaseClass.KFM_DATA:
12966 if (remain < 1)
12967 break;
12968 int dataval = (int)options.GetLSLIntegerItem(idx++);
12969 data = (KeyframeMotion.DataFormat)dataval;
12970 break;
12971 }
12972 }
12973
12974 group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data);
12975
12976 idx = 0;
12977
12978 int elemLength = 2;
12979 if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation))
12980 elemLength = 3;
12981
12982 List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>();
12983 while (idx < frames.Data.Length)
12984 {
12985 int remain = frames.Data.Length - idx;
12986
12987 if (remain < elemLength)
12988 break;
12989
12990 KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe();
12991 frame.Position = null;
12992 frame.Rotation = null;
12993
12994 if ((data & KeyframeMotion.DataFormat.Translation) != 0)
12995 {
12996 LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++);
12997 frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z);
12998 }
12999 if ((data & KeyframeMotion.DataFormat.Rotation) != 0)
13000 {
13001 LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++);
13002 frame.Rotation = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s);
13003 }
13004
13005 float tempf = (float)frames.GetLSLFloatItem(idx++);
13006 frame.TimeMS = (int)(tempf * 1000.0f);
13007
13008 keyframes.Add(frame);
13009 }
13010
13011 group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray());
13012 group.RootPart.KeyframeMotion.Start();
13013 }
13014 else
13015 {
13016 if (group.RootPart.KeyframeMotion == null)
13017 return;
13018
13019 if (options.Data.Length == 0)
13020 {
13021 group.RootPart.KeyframeMotion.Stop();
13022 return;
13023 }
13024
13025 int code = (int)options.GetLSLIntegerItem(0);
13026
13027 int idx = 0;
13028
13029 while (idx < options.Data.Length)
13030 {
13031 int option = (int)options.GetLSLIntegerItem(idx++);
13032 int remain = options.Data.Length - idx;
13033
13034 switch (option)
13035 {
13036 case ScriptBaseClass.KFM_COMMAND:
13037 int cmd = (int)options.GetLSLIntegerItem(idx++);
13038 switch (cmd)
13039 {
13040 case ScriptBaseClass.KFM_CMD_PLAY:
13041 group.RootPart.KeyframeMotion.Start();
13042 break;
13043 case ScriptBaseClass.KFM_CMD_STOP:
13044 group.RootPart.KeyframeMotion.Stop();
13045 break;
13046 case ScriptBaseClass.KFM_CMD_PAUSE:
13047 group.RootPart.KeyframeMotion.Pause();
13048 break;
13049 }
13050 break;
13051 }
13052 }
13053 }
13054 }
11362 } 13055 }
11363 13056
11364 public class NotecardCache 13057 public class NotecardCache
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8936cb2..37766fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -138,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
139 internal float m_ScriptDelayFactor = 1.0f; 139 internal float m_ScriptDelayFactor = 1.0f;
140 internal float m_ScriptDistanceFactor = 1.0f; 140 internal float m_ScriptDistanceFactor = 1.0f;
141 internal bool m_debuggerSafe = false;
141 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
142 143
143 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
@@ -145,6 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
145 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
146 m_host = host; 147 m_host = host;
147 m_item = item; 148 m_item = item;
149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
148 150
149 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
150 m_OSFunctionsEnabled = true; 152 m_OSFunctionsEnabled = true;
@@ -206,7 +208,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
206 208
207 internal void OSSLError(string msg) 209 internal void OSSLError(string msg)
208 { 210 {
209 throw new Exception("OSSL Runtime Error: " + msg); 211 if (m_debuggerSafe)
212 {
213 OSSLShoutError(msg);
214 }
215 else
216 {
217 throw new Exception("OSSL Runtime Error: " + msg);
218 }
210 } 219 }
211 220
212 /// <summary> 221 /// <summary>
@@ -914,18 +923,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
914 if (target != null) 923 if (target != null)
915 { 924 {
916 UUID animID=UUID.Zero; 925 UUID animID=UUID.Zero;
917 lock (m_host.TaskInventory) 926 m_host.TaskInventory.LockItemsForRead(true);
927 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
918 { 928 {
919 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 929 if (inv.Value.Name == animation)
920 { 930 {
921 if (inv.Value.Name == animation) 931 if (inv.Value.Type == (int)AssetType.Animation)
922 { 932 animID = inv.Value.AssetID;
923 if (inv.Value.Type == (int)AssetType.Animation) 933 continue;
924 animID = inv.Value.AssetID;
925 continue;
926 }
927 } 934 }
928 } 935 }
936 m_host.TaskInventory.LockItemsForRead(false);
929 if (animID == UUID.Zero) 937 if (animID == UUID.Zero)
930 target.Animator.AddAnimation(animation, m_host.UUID); 938 target.Animator.AddAnimation(animation, m_host.UUID);
931 else 939 else
@@ -966,6 +974,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
966 else 974 else
967 animID = UUID.Zero; 975 animID = UUID.Zero;
968 } 976 }
977 m_host.TaskInventory.LockItemsForRead(false);
969 978
970 if (animID == UUID.Zero) 979 if (animID == UUID.Zero)
971 target.Animator.RemoveAnimation(animation); 980 target.Animator.RemoveAnimation(animation);
@@ -1799,6 +1808,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1799 1808
1800 if (!UUID.TryParse(notecardNameOrUuid, out assetID)) 1809 if (!UUID.TryParse(notecardNameOrUuid, out assetID))
1801 { 1810 {
1811 m_host.TaskInventory.LockItemsForRead(true);
1802 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1812 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1803 { 1813 {
1804 if (item.Type == 7 && item.Name == notecardNameOrUuid) 1814 if (item.Type == 7 && item.Name == notecardNameOrUuid)
@@ -1806,6 +1816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1806 assetID = item.AssetID; 1816 assetID = item.AssetID;
1807 } 1817 }
1808 } 1818 }
1819 m_host.TaskInventory.LockItemsForRead(false);
1809 } 1820 }
1810 1821
1811 if (assetID == UUID.Zero) 1822 if (assetID == UUID.Zero)
@@ -2277,7 +2288,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2277 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 2288 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
2278 m_host.AddScriptLPS(1); 2289 m_host.AddScriptLPS(1);
2279 2290
2280 return NpcCreate(firstname, lastname, position, notecard, false, false); 2291 return NpcCreate(firstname, lastname, position, notecard, true, false);
2281 } 2292 }
2282 2293
2283 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) 2294 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
@@ -2288,24 +2299,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2288 return NpcCreate( 2299 return NpcCreate(
2289 firstname, lastname, position, notecard, 2300 firstname, lastname, position, notecard,
2290 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, 2301 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
2291 (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); 2302 false);
2303// (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0);
2292 } 2304 }
2293 2305
2294 private LSL_Key NpcCreate( 2306 private LSL_Key NpcCreate(
2295 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) 2307 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
2296 { 2308 {
2309 if (!owned)
2310 OSSLError("Unowned NPCs are unsupported");
2311
2312 string groupTitle = String.Empty;
2313
2314 if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
2315 return new LSL_Key(UUID.Zero.ToString());
2316
2317 if (firstname != String.Empty || lastname != String.Empty)
2318 {
2319 if (firstname != "Shown outfit:")
2320 groupTitle = "- NPC -";
2321 }
2322
2297 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2323 INPCModule module = World.RequestModuleInterface<INPCModule>();
2298 if (module != null) 2324 if (module != null)
2299 { 2325 {
2300 AvatarAppearance appearance = null; 2326 AvatarAppearance appearance = null;
2301 2327
2302 UUID id; 2328// UUID id;
2303 if (UUID.TryParse(notecard, out id)) 2329// if (UUID.TryParse(notecard, out id))
2304 { 2330// {
2305 ScenePresence clonePresence = World.GetScenePresence(id); 2331// ScenePresence clonePresence = World.GetScenePresence(id);
2306 if (clonePresence != null) 2332// if (clonePresence != null)
2307 appearance = clonePresence.Appearance; 2333// appearance = clonePresence.Appearance;
2308 } 2334// }
2309 2335
2310 if (appearance == null) 2336 if (appearance == null)
2311 { 2337 {
@@ -2333,6 +2359,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2333 World, 2359 World,
2334 appearance); 2360 appearance);
2335 2361
2362 ScenePresence sp;
2363 if (World.TryGetScenePresence(x, out sp))
2364 {
2365 sp.Grouptitle = groupTitle;
2366 sp.SendAvatarDataToAllAgents();
2367 }
2336 return new LSL_Key(x.ToString()); 2368 return new LSL_Key(x.ToString());
2337 } 2369 }
2338 2370
@@ -2632,16 +2664,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2632 CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); 2664 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
2633 m_host.AddScriptLPS(1); 2665 m_host.AddScriptLPS(1);
2634 2666
2635 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2667 ManualResetEvent ev = new ManualResetEvent(false);
2636 if (module != null)
2637 {
2638 UUID npcId = new UUID(npc.m_string);
2639 2668
2640 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2669 Util.FireAndForget(delegate(object x) {
2641 return; 2670 try
2671 {
2672 INPCModule module = World.RequestModuleInterface<INPCModule>();
2673 if (module != null)
2674 {
2675 UUID npcId = new UUID(npc.m_string);
2642 2676
2643 module.DeleteNPC(npcId, World); 2677 ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y);
2644 } 2678 if (l == null || m_host.OwnerID != l.LandData.OwnerID)
2679 {
2680 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2681 return;
2682 }
2683
2684 module.DeleteNPC(npcId, World);
2685 }
2686 }
2687 finally
2688 {
2689 ev.Set();
2690 }
2691 });
2692 ev.WaitOne();
2645 } 2693 }
2646 2694
2647 public void osNpcPlayAnimation(LSL_Key npc, string animation) 2695 public void osNpcPlayAnimation(LSL_Key npc, string animation)
@@ -3334,4 +3382,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3334 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); 3382 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
3335 } 3383 }
3336 } 3384 }
3337} \ No newline at end of file 3385}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 24cceea..4dd795d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -70,7 +70,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
70 private const int AGENT = 1; 70 private const int AGENT = 1;
71 private const int AGENT_BY_USERNAME = 0x10; 71 private const int AGENT_BY_USERNAME = 0x10;
72 private const int NPC = 0x20; 72 private const int NPC = 0x20;
73 private const int OS_NPC = 0x01000000;
74 private const int ACTIVE = 2; 73 private const int ACTIVE = 2;
75 private const int PASSIVE = 4; 74 private const int PASSIVE = 4;
76 private const int SCRIPTED = 8; 75 private const int SCRIPTED = 8;
@@ -235,7 +234,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
235 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 234 List<SensedEntity> sensedEntities = new List<SensedEntity>();
236 235
237 // Is the sensor type is AGENT and not SCRIPTED then include agents 236 // Is the sensor type is AGENT and not SCRIPTED then include agents
238 if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) 237 if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0)
239 { 238 {
240 sensedEntities.AddRange(doAgentSensor(ts)); 239 sensedEntities.AddRange(doAgentSensor(ts));
241 } 240 }
@@ -334,7 +333,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
334 float dy; 333 float dy;
335 float dz; 334 float dz;
336 335
337 Quaternion q = SensePoint.GetWorldRotation(); 336// Quaternion q = SensePoint.RotationOffset;
337 Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation!
338 if (SensePoint.ParentGroup.IsAttachment) 338 if (SensePoint.ParentGroup.IsAttachment)
339 { 339 {
340 // In attachments, rotate the sensor cone with the 340 // In attachments, rotate the sensor cone with the
@@ -348,7 +348,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
348 // Position of a sensor in a child prim attached to an avatar 348 // Position of a sensor in a child prim attached to an avatar
349 // will be still wrong. 349 // will be still wrong.
350 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 350 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
351 q = avatar.Rotation * q; 351 fromRegionPos = avatar.AbsolutePosition;
352 q = avatar.Rotation;
352 } 353 }
353 354
354 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); 355 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
@@ -475,7 +476,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
475 // Position of a sensor in a child prim attached to an avatar 476 // Position of a sensor in a child prim attached to an avatar
476 // will be still wrong. 477 // will be still wrong.
477 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 478 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
478 q = avatar.Rotation * q; 479 if (avatar == null)
480 return sensedEntities;
481 fromRegionPos = avatar.AbsolutePosition;
482 q = avatar.Rotation;
479 } 483 }
480 484
481 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); 485 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
@@ -491,7 +495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
491// "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", 495// "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}",
492// presence.Name, presence.PresenceType, ts.name, ts.type); 496// presence.Name, presence.PresenceType, ts.name, ts.type);
493 497
494 if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) 498 if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc)
495 { 499 {
496 INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); 500 INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene);
497 if (npcData == null || !npcData.SenseAsAgent) 501 if (npcData == null || !npcData.SenseAsAgent)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index bc63030..9ee6946 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -118,25 +118,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
118 if (Timers.Count == 0) 118 if (Timers.Count == 0)
119 return; 119 return;
120 120
121 Dictionary<string, TimerClass>.ValueCollection tvals;
121 lock (TimerListLock) 122 lock (TimerListLock)
122 { 123 {
123 // Go through all timers 124 // Go through all timers
124 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 125 tvals = Timers.Values;
125 foreach (TimerClass ts in tvals) 126 }
127
128 foreach (TimerClass ts in tvals)
129 {
130 // Time has passed?
131 if (ts.next < DateTime.Now.Ticks)
126 { 132 {
127 // Time has passed? 133 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
128 if (ts.next < DateTime.Now.Ticks) 134 // Add it to queue
129 { 135 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
130 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 136 new EventParams("timer", new Object[0],
131 // Add it to queue 137 new DetectParams[0]));
132 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 138 // set next interval
133 new EventParams("timer", new Object[0], 139
134 new DetectParams[0])); 140 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
135 // set next interval 141 ts.next = DateTime.Now.Ticks + ts.interval;
136
137 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
138 ts.next = DateTime.Now.Ticks + ts.interval;
139 }
140 } 142 }
141 } 143 }
142 } 144 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..ab215f3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections;
29using OpenSim.Region.ScriptEngine.Interfaces;
30
31using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
32using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
33using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
34using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
35using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
36using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
37using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
38
39namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
40{
41 public interface ICM_Api
42 {
43 string cmDetectedCountry(int num);
44 string cmGetAgentCountry(key key);
45 }
46}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 3fb463b..af35258 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -126,6 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
126 LSL_Float llGetEnergy(); 126 LSL_Float llGetEnergy();
127 LSL_Vector llGetForce(); 127 LSL_Vector llGetForce();
128 LSL_Integer llGetFreeMemory(); 128 LSL_Integer llGetFreeMemory();
129 LSL_Integer llGetUsedMemory();
129 LSL_Integer llGetFreeURLs(); 130 LSL_Integer llGetFreeURLs();
130 LSL_Vector llGetGeometricCenter(); 131 LSL_Vector llGetGeometricCenter();
131 LSL_Float llGetGMTclock(); 132 LSL_Float llGetGMTclock();
@@ -149,6 +150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
149 LSL_Vector llGetLocalPos(); 150 LSL_Vector llGetLocalPos();
150 LSL_Rotation llGetLocalRot(); 151 LSL_Rotation llGetLocalRot();
151 LSL_Float llGetMass(); 152 LSL_Float llGetMass();
153 LSL_Float llGetMassMKS();
152 LSL_Integer llGetMemoryLimit(); 154 LSL_Integer llGetMemoryLimit();
153 void llGetNextEmail(string address, string subject); 155 void llGetNextEmail(string address, string subject);
154 LSL_String llGetNotecardLine(string name, int line); 156 LSL_String llGetNotecardLine(string name, int line);
@@ -202,12 +204,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
202 LSL_String llGetTimestamp(); 204 LSL_String llGetTimestamp();
203 LSL_Vector llGetTorque(); 205 LSL_Vector llGetTorque();
204 LSL_Integer llGetUnixTime(); 206 LSL_Integer llGetUnixTime();
205 LSL_Integer llGetUsedMemory();
206 LSL_Vector llGetVel(); 207 LSL_Vector llGetVel();
207 LSL_Float llGetWallclock(); 208 LSL_Float llGetWallclock();
208 void llGiveInventory(string destination, string inventory); 209 void llGiveInventory(string destination, string inventory);
209 void llGiveInventoryList(string destination, string category, LSL_List inventory); 210 void llGiveInventoryList(string destination, string category, LSL_List inventory);
210 LSL_Integer llGiveMoney(string destination, int amount); 211 LSL_Integer llGiveMoney(string destination, int amount);
212 LSL_String llTransferLindenDollars(string destination, int amount);
211 void llGodLikeRezObject(string inventory, LSL_Vector pos); 213 void llGodLikeRezObject(string inventory, LSL_Vector pos);
212 LSL_Float llGround(LSL_Vector offset); 214 LSL_Float llGround(LSL_Vector offset);
213 LSL_Vector llGroundContour(LSL_Vector offset); 215 LSL_Vector llGroundContour(LSL_Vector offset);
@@ -330,6 +332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
330 void llSensorRemove(); 332 void llSensorRemove();
331 void llSensorRepeat(string name, string id, int type, double range, double arc, double rate); 333 void llSensorRepeat(string name, string id, int type, double range, double arc, double rate);
332 void llSetAlpha(double alpha, int face); 334 void llSetAlpha(double alpha, int face);
335 void llSetAngularVelocity(LSL_Vector angvelocity, int local);
333 void llSetBuoyancy(double buoyancy); 336 void llSetBuoyancy(double buoyancy);
334 void llSetCameraAtOffset(LSL_Vector offset); 337 void llSetCameraAtOffset(LSL_Vector offset);
335 void llSetCameraEyeOffset(LSL_Vector offset); 338 void llSetCameraEyeOffset(LSL_Vector offset);
@@ -355,11 +358,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
355 void llSetParcelMusicURL(string url); 358 void llSetParcelMusicURL(string url);
356 void llSetPayPrice(int price, LSL_List quick_pay_buttons); 359 void llSetPayPrice(int price, LSL_List quick_pay_buttons);
357 void llSetPos(LSL_Vector pos); 360 void llSetPos(LSL_Vector pos);
361 LSL_Integer llSetRegionPos(LSL_Vector pos);
358 LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); 362 LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules);
359 void llSetPrimitiveParams(LSL_List rules); 363 void llSetPrimitiveParams(LSL_List rules);
360 void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); 364 void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules);
361 void llSetPrimURL(string url); 365 void llSetPrimURL(string url);
362 LSL_Integer llSetRegionPos(LSL_Vector pos);
363 void llSetRemoteScriptAccessPin(int pin); 366 void llSetRemoteScriptAccessPin(int pin);
364 void llSetRot(LSL_Rotation rot); 367 void llSetRot(LSL_Rotation rot);
365 void llSetScale(LSL_Vector scale); 368 void llSetScale(LSL_Vector scale);
@@ -379,6 +382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
379 void llSetVehicleRotationParam(int param, LSL_Rotation rot); 382 void llSetVehicleRotationParam(int param, LSL_Rotation rot);
380 void llSetVehicleType(int type); 383 void llSetVehicleType(int type);
381 void llSetVehicleVectorParam(int param, LSL_Vector vec); 384 void llSetVehicleVectorParam(int param, LSL_Vector vec);
385 void llSetVelocity(LSL_Vector velocity, int local);
382 void llShout(int channelID, string text); 386 void llShout(int channelID, string text);
383 LSL_Float llSin(double f); 387 LSL_Float llSin(double f);
384 void llSitTarget(LSL_Vector offset, LSL_Rotation rot); 388 void llSitTarget(LSL_Vector offset, LSL_Rotation rot);
@@ -422,9 +426,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
422 LSL_Vector llWind(LSL_Vector offset); 426 LSL_Vector llWind(LSL_Vector offset);
423 LSL_String llXorBase64Strings(string str1, string str2); 427 LSL_String llXorBase64Strings(string str1, string str2);
424 LSL_String llXorBase64StringsCorrect(string str1, string str2); 428 LSL_String llXorBase64StringsCorrect(string str1, string str2);
425 void print(string str); 429 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link);
430 void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density);
426 431
427 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 432 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
428 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 433 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
434 void llSetKeyframedMotion(LSL_List frames, LSL_List options);
429 } 435 }
430} 436}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 1f000a3..8c34ed3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
85 // Avatar Info Commands 85 // Avatar Info Commands
86 string osGetAgentIP(string agent); 86 string osGetAgentIP(string agent);
87 LSL_List osGetAgents(); 87 LSL_List osGetAgents();
88 88
89 // Teleport commands 89 // Teleport commands
90 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 90 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
91 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 91 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/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..4132dfa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
46
47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
48{
49 public partial class ScriptBaseClass : MarshalByRefObject
50 {
51 public ICM_Api m_CM_Functions;
52
53 public void ApiTypeCM(IScriptApi api)
54 {
55 if (!(api is ICM_Api))
56 return;
57
58 m_CM_Functions = (ICM_Api)api;
59 }
60
61 public string cmDetectedCountry(int num)
62 {
63 return m_CM_Functions.cmDetectedCountry(num);
64 }
65
66 public string cmGetAgentCountry(key key)
67 {
68 return m_CM_Functions.cmGetAgentCountry(key);
69 }
70 }
71}
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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Reflection; 31using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using OpenSim.Region.ScriptEngine.Shared; 33using 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 cad8518..05ba222 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -56,7 +56,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
56 public const int ACTIVE = 2; 56 public const int ACTIVE = 2;
57 public const int PASSIVE = 4; 57 public const int PASSIVE = 4;
58 public const int SCRIPTED = 8; 58 public const int SCRIPTED = 8;
59 public const int OS_NPC = 0x01000000;
60 59
61 public const int CONTROL_FWD = 1; 60 public const int CONTROL_FWD = 1;
62 public const int CONTROL_BACK = 2; 61 public const int CONTROL_BACK = 2;
@@ -95,6 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
95 public const int AGENT_CROUCHING = 1024; 94 public const int AGENT_CROUCHING = 1024;
96 public const int AGENT_BUSY = 2048; 95 public const int AGENT_BUSY = 2048;
97 public const int AGENT_ALWAYS_RUN = 4096; 96 public const int AGENT_ALWAYS_RUN = 4096;
97 public const int AGENT_MALE = 8192;
98 98
99 //Particle Systems 99 //Particle Systems
100 public const int PSYS_PART_INTERP_COLOR_MASK = 1; 100 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
@@ -285,6 +285,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
285 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART 285 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
286 public const int CHANGED_MEDIA = 2048; 286 public const int CHANGED_MEDIA = 2048;
287 public const int CHANGED_ANIMATION = 16384; 287 public const int CHANGED_ANIMATION = 16384;
288 public const int CHANGED_POSITION = 32768;
288 public const int TYPE_INVALID = 0; 289 public const int TYPE_INVALID = 0;
289 public const int TYPE_INTEGER = 1; 290 public const int TYPE_INTEGER = 1;
290 public const int TYPE_FLOAT = 2; 291 public const int TYPE_FLOAT = 2;
@@ -590,6 +591,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
590 public const int PRIM_MEDIA_PERM_OWNER = 1; 591 public const int PRIM_MEDIA_PERM_OWNER = 1;
591 public const int PRIM_MEDIA_PERM_GROUP = 2; 592 public const int PRIM_MEDIA_PERM_GROUP = 2;
592 public const int PRIM_MEDIA_PERM_ANYONE = 4; 593 public const int PRIM_MEDIA_PERM_ANYONE = 4;
594
595 public const int PRIM_PHYSICS_SHAPE_TYPE = 30;
596 public const int PRIM_PHYSICS_SHAPE_PRIM = 0;
597 public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
598 public const int PRIM_PHYSICS_SHAPE_NONE = 1;
599
600 public const int PRIM_PHYSICS_MATERIAL = 31;
601 public const int DENSITY = 1;
602 public const int FRICTION = 2;
603 public const int RESTITUTION = 4;
604 public const int GRAVITY_MULTIPLIER = 8;
593 605
594 // extra constants for llSetPrimMediaParams 606 // extra constants for llSetPrimMediaParams
595 public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); 607 public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0);
@@ -662,6 +674,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
662 674
663 public static readonly LSLInteger RCERR_UNKNOWN = -1; 675 public static readonly LSLInteger RCERR_UNKNOWN = -1;
664 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; 676 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2;
665 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; 677 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = -3;
678
679 public const int KFM_MODE = 1;
680 public const int KFM_LOOP = 1;
681 public const int KFM_REVERSE = 3;
682 public const int KFM_FORWARD = 0;
683 public const int KFM_PING_PONG = 2;
684 public const int KFM_DATA = 2;
685 public const int KFM_TRANSLATION = 2;
686 public const int KFM_ROTATION = 1;
687 public const int KFM_COMMAND = 0;
688 public const int KFM_CMD_PLAY = 0;
689 public const int KFM_CMD_STOP = 1;
690 public const int KFM_CMD_PAUSE = 2;
666 } 691 }
667} 692}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index c457880..89b6eff 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
28using System; 28using System;
29using System.Diagnostics; //for [DebuggerNonUserCode]
29using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
30using System.Threading; 31using System.Threading;
31using System.Reflection; 32using System.Reflection;
@@ -314,6 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
314 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); 315 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
315 } 316 }
316 317
318 [DebuggerNonUserCode]
317 public void llDie() 319 public void llDie()
318 { 320 {
319 m_LSL_Functions.llDie(); 321 m_LSL_Functions.llDie();
@@ -474,6 +476,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
474 return m_LSL_Functions.llGetFreeMemory(); 476 return m_LSL_Functions.llGetFreeMemory();
475 } 477 }
476 478
479 public LSL_Integer llGetUsedMemory()
480 {
481 return m_LSL_Functions.llGetUsedMemory();
482 }
483
477 public LSL_Integer llGetFreeURLs() 484 public LSL_Integer llGetFreeURLs()
478 { 485 {
479 return m_LSL_Functions.llGetFreeURLs(); 486 return m_LSL_Functions.llGetFreeURLs();
@@ -579,6 +586,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
579 return m_LSL_Functions.llGetMass(); 586 return m_LSL_Functions.llGetMass();
580 } 587 }
581 588
589 public LSL_Float llGetMassMKS()
590 {
591 return m_LSL_Functions.llGetMassMKS();
592 }
593
582 public LSL_Integer llGetMemoryLimit() 594 public LSL_Integer llGetMemoryLimit()
583 { 595 {
584 return m_LSL_Functions.llGetMemoryLimit(); 596 return m_LSL_Functions.llGetMemoryLimit();
@@ -844,11 +856,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
844 return m_LSL_Functions.llGetUnixTime(); 856 return m_LSL_Functions.llGetUnixTime();
845 } 857 }
846 858
847 public LSL_Integer llGetUsedMemory()
848 {
849 return m_LSL_Functions.llGetUsedMemory();
850 }
851
852 public LSL_Vector llGetVel() 859 public LSL_Vector llGetVel()
853 { 860 {
854 return m_LSL_Functions.llGetVel(); 861 return m_LSL_Functions.llGetVel();
@@ -874,6 +881,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
874 return m_LSL_Functions.llGiveMoney(destination, amount); 881 return m_LSL_Functions.llGiveMoney(destination, amount);
875 } 882 }
876 883
884 public LSL_String llTransferLindenDollars(string destination, int amount)
885 {
886 return m_LSL_Functions.llTransferLindenDollars(destination, amount);
887 }
888
877 public void llGodLikeRezObject(string inventory, LSL_Vector pos) 889 public void llGodLikeRezObject(string inventory, LSL_Vector pos)
878 { 890 {
879 m_LSL_Functions.llGodLikeRezObject(inventory, pos); 891 m_LSL_Functions.llGodLikeRezObject(inventory, pos);
@@ -1483,6 +1495,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1483 m_LSL_Functions.llSetAlpha(alpha, face); 1495 m_LSL_Functions.llSetAlpha(alpha, face);
1484 } 1496 }
1485 1497
1498 public void llSetAngularVelocity(LSL_Vector angvelocity, int local)
1499 {
1500 m_LSL_Functions.llSetAngularVelocity(angvelocity, local);
1501 }
1502
1486 public void llSetBuoyancy(double buoyancy) 1503 public void llSetBuoyancy(double buoyancy)
1487 { 1504 {
1488 m_LSL_Functions.llSetBuoyancy(buoyancy); 1505 m_LSL_Functions.llSetBuoyancy(buoyancy);
@@ -1603,6 +1620,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1603 m_LSL_Functions.llSetPos(pos); 1620 m_LSL_Functions.llSetPos(pos);
1604 } 1621 }
1605 1622
1623 public LSL_Integer llSetRegionPos(LSL_Vector pos)
1624 {
1625 return m_LSL_Functions.llSetRegionPos(pos);
1626 }
1627
1606 public void llSetPrimitiveParams(LSL_List rules) 1628 public void llSetPrimitiveParams(LSL_List rules)
1607 { 1629 {
1608 m_LSL_Functions.llSetPrimitiveParams(rules); 1630 m_LSL_Functions.llSetPrimitiveParams(rules);
@@ -1618,11 +1640,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1618 m_LSL_Functions.llSetPrimURL(url); 1640 m_LSL_Functions.llSetPrimURL(url);
1619 } 1641 }
1620 1642
1621 public LSL_Integer llSetRegionPos(LSL_Vector pos)
1622 {
1623 return m_LSL_Functions.llSetRegionPos(pos);
1624 }
1625
1626 public void llSetRemoteScriptAccessPin(int pin) 1643 public void llSetRemoteScriptAccessPin(int pin)
1627 { 1644 {
1628 m_LSL_Functions.llSetRemoteScriptAccessPin(pin); 1645 m_LSL_Functions.llSetRemoteScriptAccessPin(pin);
@@ -1718,6 +1735,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1718 m_LSL_Functions.llSetVehicleVectorParam(param, vec); 1735 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1719 } 1736 }
1720 1737
1738 public void llSetVelocity(LSL_Vector velocity, int local)
1739 {
1740 m_LSL_Functions.llSetVelocity(velocity, local);
1741 }
1742
1721 public void llShout(int channelID, string text) 1743 public void llShout(int channelID, string text)
1722 { 1744 {
1723 m_LSL_Functions.llShout(channelID, text); 1745 m_LSL_Functions.llShout(channelID, text);
@@ -1968,9 +1990,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1968 return m_LSL_Functions.llClearLinkMedia(link, face); 1990 return m_LSL_Functions.llClearLinkMedia(link, face);
1969 } 1991 }
1970 1992
1971 public void print(string str) 1993 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
1994 {
1995 return m_LSL_Functions.llGetLinkNumberOfSides(link);
1996 }
1997
1998 public void llSetKeyframedMotion(LSL_List frames, LSL_List options)
1999 {
2000 m_LSL_Functions.llSetKeyframedMotion(frames, options);
2001 }
2002
2003 public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density)
1972 { 2004 {
1973 m_LSL_Functions.print(str); 2005 m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density);
1974 } 2006 }
1975 } 2007 }
1976} 2008}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
index 143b497..2e27f16 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
@@ -72,9 +72,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
72 { 72 {
73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); 73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
74 } 74 }
75
75 public void lsClearWindlightScene() 76 public void lsClearWindlightScene()
76 { 77 {
77 m_LS_Functions.lsClearWindlightScene(); 78 m_LS_Functions.lsClearWindlightScene();
78 } 79 }
80
81 public LSL_List cmGetWindlightScene(LSL_List rules)
82 {
83 return m_LS_Functions.lsGetWindlightScene(rules);
84 }
85
86 public int cmSetWindlightScene(LSL_List rules)
87 {
88 return m_LS_Functions.lsSetWindlightScene(rules);
89 }
90
91 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
92 {
93 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
94 }
95
96 public void cmClearWindlightScene()
97 {
98 m_LS_Functions.lsClearWindlightScene();
99 }
79 } 100 }
80} 101}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index edbbc2a..b138da3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using System.Collections; 34using System.Collections;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Diagnostics; //for [DebuggerNonUserCode]
36using OpenSim.Region.ScriptEngine.Interfaces; 37using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 38using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; 39using 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);