diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
18 files changed, 2982 insertions, 884 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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Runtime.Remoting.Lifetime; | ||
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.World.LightShare; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.ScriptEngine.Shared; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
43 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | |||
47 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
48 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
49 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
51 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
52 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
53 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
54 | |||
55 | namespace 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 bca9a75..c305f86 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
34 | using System.Text.RegularExpressions; | 35 | using System.Text.RegularExpressions; |
36 | using System.Timers; | ||
35 | using Nini.Config; | 37 | using Nini.Config; |
36 | using log4net; | 38 | using log4net; |
37 | using OpenMetaverse; | 39 | using OpenMetaverse; |
@@ -44,6 +46,7 @@ using OpenSim.Region.CoreModules.World.Land; | |||
44 | using OpenSim.Region.CoreModules.World.Terrain; | 46 | using OpenSim.Region.CoreModules.World.Terrain; |
45 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
47 | using OpenSim.Region.Framework.Scenes.Animation; | 50 | using OpenSim.Region.Framework.Scenes.Animation; |
48 | using OpenSim.Region.Physics.Manager; | 51 | using OpenSim.Region.Physics.Manager; |
49 | using OpenSim.Region.ScriptEngine.Shared; | 52 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -65,6 +68,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | |||
65 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 68 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
66 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 69 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
67 | using System.Reflection; | 70 | using System.Reflection; |
71 | using Timer = System.Timers.Timer; | ||
68 | 72 | ||
69 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 73 | namespace 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) |
@@ -448,31 +544,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
448 | 544 | ||
449 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 545 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
450 | 546 | ||
451 | /// <summary> | 547 | // Utility function for llRot2Euler |
452 | /// Convert an LSL rotation to a Euler vector. | 548 | |
453 | /// </summary> | 549 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
454 | /// <remarks> | 550 | protected double NormalizeAngle(double angle) |
455 | /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf | ||
456 | /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 | ||
457 | /// </remarks> | ||
458 | /// <param name="r"></param> | ||
459 | /// <returns></returns> | ||
460 | public LSL_Vector llRot2Euler(LSL_Rotation r) | ||
461 | { | 551 | { |
462 | m_host.AddScriptLPS(1); | 552 | if (angle > -Math.PI && angle < Math.PI) |
553 | return angle; | ||
463 | 554 | ||
464 | LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. | 555 | int numPis = (int)(Math.PI / angle); |
465 | double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. | 556 | double remainder = angle - Math.PI * numPis; |
466 | if (m == 0.0) return new LSL_Vector(); | 557 | if (numPis % 2 == 1) |
467 | double x = Math.Atan2(-v.y, v.z); | 558 | return Math.PI - angle; |
468 | double sin = v.x / m; | 559 | return remainder; |
469 | if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. | 560 | } |
470 | double y = Math.Asin(sin); | ||
471 | // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation | ||
472 | 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))); | ||
473 | double z = Math.Atan2(v.y, v.x); | ||
474 | 561 | ||
475 | return new LSL_Vector(x, y, z); | 562 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
563 | { | ||
564 | m_host.AddScriptLPS(1); | ||
565 | LSL_Vector eul = new LSL_Vector(); | ||
566 | |||
567 | double sqw = q1.s*q1.s; | ||
568 | double sqx = q1.x*q1.x; | ||
569 | double sqy = q1.z*q1.z; | ||
570 | double sqz = q1.y*q1.y; | ||
571 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor | ||
572 | double test = q1.x*q1.z + q1.y*q1.s; | ||
573 | if (test > 0.4999*unit) { // singularity at north pole | ||
574 | eul.z = 2 * Math.Atan2(q1.x,q1.s); | ||
575 | eul.y = Math.PI/2; | ||
576 | eul.x = 0; | ||
577 | return eul; | ||
578 | } | ||
579 | if (test < -0.4999*unit) { // singularity at south pole | ||
580 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
581 | eul.y = -Math.PI/2; | ||
582 | eul.x = 0; | ||
583 | return eul; | ||
584 | } | ||
585 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
586 | eul.y = Math.Asin(2*test/unit); | ||
587 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
588 | return eul; | ||
476 | } | 589 | } |
477 | 590 | ||
478 | /* From wiki: | 591 | /* From wiki: |
@@ -525,18 +638,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
525 | m_host.AddScriptLPS(1); | 638 | m_host.AddScriptLPS(1); |
526 | 639 | ||
527 | double x,y,z,s; | 640 | double x,y,z,s; |
528 | 641 | v.x *= 0.5; | |
529 | double c1 = Math.Cos(v.x * 0.5); | 642 | v.y *= 0.5; |
530 | double c2 = Math.Cos(v.y * 0.5); | 643 | v.z *= 0.5; |
531 | double c3 = Math.Cos(v.z * 0.5); | 644 | double c1 = Math.Cos(v.x); |
532 | double s1 = Math.Sin(v.x * 0.5); | 645 | double c2 = Math.Cos(v.y); |
533 | double s2 = Math.Sin(v.y * 0.5); | 646 | double c1c2 = c1 * c2; |
534 | double s3 = Math.Sin(v.z * 0.5); | 647 | double s1 = Math.Sin(v.x); |
535 | 648 | double s2 = Math.Sin(v.y); | |
536 | x = s1 * c2 * c3 + c1 * s2 * s3; | 649 | double s1s2 = s1 * s2; |
537 | y = c1 * s2 * c3 - s1 * c2 * s3; | 650 | double c1s2 = c1 * s2; |
538 | z = s1 * s2 * c3 + c1 * c2 * s3; | 651 | double s1c2 = s1 * c2; |
539 | s = c1 * c2 * c3 - s1 * s2 * s3; | 652 | double c3 = Math.Cos(v.z); |
653 | double s3 = Math.Sin(v.z); | ||
654 | |||
655 | x = s1c2 * c3 + c1s2 * s3; | ||
656 | y = c1s2 * c3 - s1c2 * s3; | ||
657 | z = s1s2 * c3 + c1c2 * s3; | ||
658 | s = c1c2 * c3 - s1s2 * s3; | ||
540 | 659 | ||
541 | return new LSL_Rotation(x, y, z, s); | 660 | return new LSL_Rotation(x, y, z, s); |
542 | } | 661 | } |
@@ -674,77 +793,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
674 | { | 793 | { |
675 | //A and B should both be normalized | 794 | //A and B should both be normalized |
676 | m_host.AddScriptLPS(1); | 795 | m_host.AddScriptLPS(1); |
677 | LSL_Rotation rotBetween; | 796 | /* This method is more accurate than the SL one, and thus causes problems |
678 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 797 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
679 | // continue calculation. | 798 | |
680 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 799 | double dotProduct = LSL_Vector.Dot(a, b); |
800 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
801 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
802 | double angle = Math.Acos(dotProduct / magProduct); | ||
803 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
804 | double s = Math.Sin(angle / 2); | ||
805 | |||
806 | double x = axis.x * s; | ||
807 | double y = axis.y * s; | ||
808 | double z = axis.z * s; | ||
809 | double w = Math.Cos(angle / 2); | ||
810 | |||
811 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
812 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
813 | |||
814 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
815 | */ | ||
816 | |||
817 | // This method mimics the 180 errors found in SL | ||
818 | // See www.euclideanspace.com... angleBetween | ||
819 | LSL_Vector vec_a = a; | ||
820 | LSL_Vector vec_b = b; | ||
821 | |||
822 | // Eliminate zero length | ||
823 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
824 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
825 | if (vec_a_mag < 0.00001 || | ||
826 | vec_b_mag < 0.00001) | ||
681 | { | 827 | { |
682 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 828 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
683 | } | 829 | } |
684 | else | 830 | |
831 | // Normalize | ||
832 | vec_a = llVecNorm(vec_a); | ||
833 | vec_b = llVecNorm(vec_b); | ||
834 | |||
835 | // Calculate axis and rotation angle | ||
836 | LSL_Vector axis = vec_a % vec_b; | ||
837 | LSL_Float cos_theta = vec_a * vec_b; | ||
838 | |||
839 | // Check if parallel | ||
840 | if (cos_theta > 0.99999) | ||
685 | { | 841 | { |
686 | a = LSL_Vector.Norm(a); | 842 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
687 | b = LSL_Vector.Norm(b); | 843 | } |
688 | double dotProduct = LSL_Vector.Dot(a, b); | 844 | |
689 | // There are two degenerate cases possible. These are for vectors 180 or | 845 | // Check if anti-parallel |
690 | // 0 degrees apart. These have to be detected and handled individually. | 846 | else if (cos_theta < -0.99999) |
691 | // | 847 | { |
692 | // Check for vectors 180 degrees apart. | 848 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
693 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 849 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
694 | if (dotProduct < -0.9999999f) | 850 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
695 | { | 851 | } |
696 | // First assume X axis is orthogonal to the vectors. | 852 | else // other rotation |
697 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 853 | { |
698 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 854 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
699 | // Check for near zero vector. A very small non-zero number here will create | 855 | axis = llVecNorm(axis); |
700 | // a rotation in an undesired direction. | 856 | double x, y, z, s, t; |
701 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 857 | s = Math.Cos(theta); |
702 | { | 858 | t = Math.Sin(theta); |
703 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 859 | x = axis.x * t; |
704 | } | 860 | y = axis.y * t; |
705 | // If the magnitude of the vector was near zero, then assume the X axis is not | 861 | z = axis.z * t; |
706 | // orthogonal and use the Z axis instead. | 862 | return new LSL_Rotation(x,y,z,s); |
707 | else | ||
708 | { | ||
709 | // Set 180 z rotation. | ||
710 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
711 | } | ||
712 | } | ||
713 | // Check for parallel vectors. | ||
714 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
715 | else if (dotProduct > 0.9999999f) | ||
716 | { | ||
717 | // Set zero rotation. | ||
718 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
719 | } | ||
720 | else | ||
721 | { | ||
722 | // All special checks have been performed so get the axis of rotation. | ||
723 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
724 | // Quarternion s value is the length of the unit vector + dot product. | ||
725 | double qs = 1.0 + dotProduct; | ||
726 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
727 | // Normalize the rotation. | ||
728 | double mag = LSL_Rotation.Mag(rotBetween); | ||
729 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
730 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
731 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
732 | // crossProduct vector should also not be zero. | ||
733 | rotBetween.x = rotBetween.x / mag; | ||
734 | rotBetween.y = rotBetween.y / mag; | ||
735 | rotBetween.z = rotBetween.z / mag; | ||
736 | rotBetween.s = rotBetween.s / mag; | ||
737 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
738 | // any longer since zero vectors are checked for at the top. | ||
739 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
740 | { | ||
741 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
742 | } | ||
743 | } | ||
744 | } | 863 | } |
745 | return rotBetween; | ||
746 | } | 864 | } |
747 | 865 | ||
748 | public void llWhisper(int channelID, string text) | 866 | public void llWhisper(int channelID, string text) |
749 | { | 867 | { |
750 | m_host.AddScriptLPS(1); | 868 | m_host.AddScriptLPS(1); |
@@ -760,10 +878,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
760 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | 878 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); |
761 | } | 879 | } |
762 | 880 | ||
881 | private void CheckSayShoutTime() | ||
882 | { | ||
883 | DateTime now = DateTime.UtcNow; | ||
884 | if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec | ||
885 | { | ||
886 | m_lastSayShoutCheck = now; | ||
887 | m_SayShoutCount = 0; | ||
888 | } | ||
889 | else | ||
890 | m_SayShoutCount++; | ||
891 | } | ||
892 | |||
763 | public void llSay(int channelID, string text) | 893 | public void llSay(int channelID, string text) |
764 | { | 894 | { |
765 | m_host.AddScriptLPS(1); | 895 | m_host.AddScriptLPS(1); |
766 | 896 | ||
897 | if (channelID == 0) | ||
898 | // m_SayShoutCount++; | ||
899 | CheckSayShoutTime(); | ||
900 | |||
901 | if (m_SayShoutCount >= 11) | ||
902 | ScriptSleep(2000); | ||
903 | |||
767 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) | 904 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) |
768 | { | 905 | { |
769 | Console.WriteLine(text); | 906 | Console.WriteLine(text); |
@@ -786,6 +923,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
786 | { | 923 | { |
787 | m_host.AddScriptLPS(1); | 924 | m_host.AddScriptLPS(1); |
788 | 925 | ||
926 | if (channelID == 0) | ||
927 | // m_SayShoutCount++; | ||
928 | CheckSayShoutTime(); | ||
929 | |||
930 | if (m_SayShoutCount >= 11) | ||
931 | ScriptSleep(2000); | ||
932 | |||
789 | if (text.Length > 1023) | 933 | if (text.Length > 1023) |
790 | text = text.Substring(0, 1023); | 934 | text = text.Substring(0, 1023); |
791 | 935 | ||
@@ -817,22 +961,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
817 | 961 | ||
818 | public void llRegionSayTo(string target, int channel, string msg) | 962 | public void llRegionSayTo(string target, int channel, string msg) |
819 | { | 963 | { |
964 | string error = String.Empty; | ||
965 | |||
820 | if (msg.Length > 1023) | 966 | if (msg.Length > 1023) |
821 | msg = msg.Substring(0, 1023); | 967 | msg = msg.Substring(0, 1023); |
822 | 968 | ||
823 | m_host.AddScriptLPS(1); | 969 | m_host.AddScriptLPS(1); |
824 | 970 | ||
825 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
826 | { | ||
827 | return; | ||
828 | } | ||
829 | |||
830 | UUID TargetID; | 971 | UUID TargetID; |
831 | UUID.TryParse(target, out TargetID); | 972 | UUID.TryParse(target, out TargetID); |
832 | 973 | ||
833 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 974 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
834 | if (wComm != null) | 975 | if (wComm != null) |
835 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); | 976 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) |
977 | LSLError(error); | ||
836 | } | 978 | } |
837 | 979 | ||
838 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 980 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -1088,10 +1230,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1088 | return detectedParams.TouchUV; | 1230 | return detectedParams.TouchUV; |
1089 | } | 1231 | } |
1090 | 1232 | ||
1233 | [DebuggerNonUserCode] | ||
1091 | public virtual void llDie() | 1234 | public virtual void llDie() |
1092 | { | 1235 | { |
1093 | m_host.AddScriptLPS(1); | 1236 | m_host.AddScriptLPS(1); |
1094 | throw new SelfDeleteException(); | 1237 | if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); |
1095 | } | 1238 | } |
1096 | 1239 | ||
1097 | public LSL_Float llGround(LSL_Vector offset) | 1240 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1162,6 +1305,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1162 | 1305 | ||
1163 | public void llSetStatus(int status, int value) | 1306 | public void llSetStatus(int status, int value) |
1164 | { | 1307 | { |
1308 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1309 | return; | ||
1165 | m_host.AddScriptLPS(1); | 1310 | m_host.AddScriptLPS(1); |
1166 | 1311 | ||
1167 | int statusrotationaxis = 0; | 1312 | int statusrotationaxis = 0; |
@@ -1185,6 +1330,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1185 | if (!allow) | 1330 | if (!allow) |
1186 | return; | 1331 | return; |
1187 | 1332 | ||
1333 | if (m_host.ParentGroup.RootPart.PhysActor != null && | ||
1334 | m_host.ParentGroup.RootPart.PhysActor.IsPhysical) | ||
1335 | return; | ||
1336 | |||
1188 | m_host.ScriptSetPhysicsStatus(true); | 1337 | m_host.ScriptSetPhysicsStatus(true); |
1189 | } | 1338 | } |
1190 | else | 1339 | else |
@@ -1382,6 +1531,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1382 | { | 1531 | { |
1383 | m_host.AddScriptLPS(1); | 1532 | m_host.AddScriptLPS(1); |
1384 | 1533 | ||
1534 | SetColor(m_host, color, face); | ||
1535 | } | ||
1536 | |||
1537 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1538 | { | ||
1539 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1540 | return; | ||
1541 | |||
1542 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1543 | Color4 texcolor; | ||
1544 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1545 | { | ||
1546 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1547 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1548 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1549 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1550 | tex.FaceTextures[face].RGBA = texcolor; | ||
1551 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1552 | return; | ||
1553 | } | ||
1554 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1555 | { | ||
1556 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1557 | { | ||
1558 | if (tex.FaceTextures[i] != null) | ||
1559 | { | ||
1560 | texcolor = tex.FaceTextures[i].RGBA; | ||
1561 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1562 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1563 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1564 | tex.FaceTextures[i].RGBA = texcolor; | ||
1565 | } | ||
1566 | texcolor = tex.DefaultTexture.RGBA; | ||
1567 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1568 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1569 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1570 | tex.DefaultTexture.RGBA = texcolor; | ||
1571 | } | ||
1572 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1573 | return; | ||
1574 | } | ||
1575 | |||
1385 | if (face == ScriptBaseClass.ALL_SIDES) | 1576 | if (face == ScriptBaseClass.ALL_SIDES) |
1386 | face = SceneObjectPart.ALL_SIDES; | 1577 | face = SceneObjectPart.ALL_SIDES; |
1387 | 1578 | ||
@@ -1390,6 +1581,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1390 | 1581 | ||
1391 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1582 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1392 | { | 1583 | { |
1584 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1585 | return; | ||
1586 | |||
1393 | Primitive.TextureEntry tex = part.Shape.Textures; | 1587 | Primitive.TextureEntry tex = part.Shape.Textures; |
1394 | MappingType textype; | 1588 | MappingType textype; |
1395 | textype = MappingType.Default; | 1589 | textype = MappingType.Default; |
@@ -1420,6 +1614,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1420 | 1614 | ||
1421 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1615 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1422 | { | 1616 | { |
1617 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1618 | return; | ||
1619 | |||
1423 | Primitive.TextureEntry tex = part.Shape.Textures; | 1620 | Primitive.TextureEntry tex = part.Shape.Textures; |
1424 | if (face >= 0 && face < GetNumberOfSides(part)) | 1621 | if (face >= 0 && face < GetNumberOfSides(part)) |
1425 | { | 1622 | { |
@@ -1445,6 +1642,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1445 | 1642 | ||
1446 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1643 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1447 | { | 1644 | { |
1645 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1646 | return; | ||
1448 | 1647 | ||
1449 | Shininess sval = new Shininess(); | 1648 | Shininess sval = new Shininess(); |
1450 | 1649 | ||
@@ -1495,6 +1694,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1495 | 1694 | ||
1496 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1695 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1497 | { | 1696 | { |
1697 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1698 | return; | ||
1699 | |||
1498 | Primitive.TextureEntry tex = part.Shape.Textures; | 1700 | Primitive.TextureEntry tex = part.Shape.Textures; |
1499 | if (face >= 0 && face < GetNumberOfSides(part)) | 1701 | if (face >= 0 && face < GetNumberOfSides(part)) |
1500 | { | 1702 | { |
@@ -1555,13 +1757,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1555 | m_host.AddScriptLPS(1); | 1757 | m_host.AddScriptLPS(1); |
1556 | 1758 | ||
1557 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1759 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1558 | 1760 | if (parts.Count > 0) | |
1559 | foreach (SceneObjectPart part in parts) | 1761 | { |
1560 | SetAlpha(part, alpha, face); | 1762 | try |
1763 | { | ||
1764 | foreach (SceneObjectPart part in parts) | ||
1765 | SetAlpha(part, alpha, face); | ||
1766 | } | ||
1767 | finally | ||
1768 | { | ||
1769 | } | ||
1770 | } | ||
1561 | } | 1771 | } |
1562 | 1772 | ||
1563 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1773 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1564 | { | 1774 | { |
1775 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1776 | return; | ||
1777 | |||
1565 | Primitive.TextureEntry tex = part.Shape.Textures; | 1778 | Primitive.TextureEntry tex = part.Shape.Textures; |
1566 | Color4 texcolor; | 1779 | Color4 texcolor; |
1567 | if (face >= 0 && face < GetNumberOfSides(part)) | 1780 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1614,7 +1827,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1614 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1827 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1615 | float wind, float tension, LSL_Vector Force) | 1828 | float wind, float tension, LSL_Vector Force) |
1616 | { | 1829 | { |
1617 | if (part == null) | 1830 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1618 | return; | 1831 | return; |
1619 | 1832 | ||
1620 | if (flexi) | 1833 | if (flexi) |
@@ -1648,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1648 | /// <param name="falloff"></param> | 1861 | /// <param name="falloff"></param> |
1649 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1862 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1650 | { | 1863 | { |
1651 | if (part == null) | 1864 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1652 | return; | 1865 | return; |
1653 | 1866 | ||
1654 | if (light) | 1867 | if (light) |
@@ -1681,11 +1894,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1681 | Primitive.TextureEntry tex = part.Shape.Textures; | 1894 | Primitive.TextureEntry tex = part.Shape.Textures; |
1682 | Color4 texcolor; | 1895 | Color4 texcolor; |
1683 | LSL_Vector rgb = new LSL_Vector(); | 1896 | LSL_Vector rgb = new LSL_Vector(); |
1897 | int nsides = GetNumberOfSides(part); | ||
1898 | |||
1684 | if (face == ScriptBaseClass.ALL_SIDES) | 1899 | if (face == ScriptBaseClass.ALL_SIDES) |
1685 | { | 1900 | { |
1686 | int i; | 1901 | int i; |
1687 | 1902 | for (i = 0; i < nsides; i++) | |
1688 | for (i = 0 ; i < GetNumberOfSides(part); i++) | ||
1689 | { | 1903 | { |
1690 | texcolor = tex.GetFace((uint)i).RGBA; | 1904 | texcolor = tex.GetFace((uint)i).RGBA; |
1691 | rgb.x += texcolor.R; | 1905 | rgb.x += texcolor.R; |
@@ -1693,14 +1907,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1693 | rgb.z += texcolor.B; | 1907 | rgb.z += texcolor.B; |
1694 | } | 1908 | } |
1695 | 1909 | ||
1696 | rgb.x /= (float)GetNumberOfSides(part); | 1910 | float invnsides = 1.0f / (float)nsides; |
1697 | rgb.y /= (float)GetNumberOfSides(part); | 1911 | |
1698 | rgb.z /= (float)GetNumberOfSides(part); | 1912 | rgb.x *= invnsides; |
1913 | rgb.y *= invnsides; | ||
1914 | rgb.z *= invnsides; | ||
1699 | 1915 | ||
1700 | return rgb; | 1916 | return rgb; |
1701 | } | 1917 | } |
1702 | 1918 | if (face >= 0 && face < nsides) | |
1703 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1704 | { | 1919 | { |
1705 | texcolor = tex.GetFace((uint)face).RGBA; | 1920 | texcolor = tex.GetFace((uint)face).RGBA; |
1706 | rgb.x = texcolor.R; | 1921 | rgb.x = texcolor.R; |
@@ -1727,15 +1942,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1727 | m_host.AddScriptLPS(1); | 1942 | m_host.AddScriptLPS(1); |
1728 | 1943 | ||
1729 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1944 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1730 | 1945 | if (parts.Count > 0) | |
1731 | foreach (SceneObjectPart part in parts) | 1946 | { |
1732 | SetTexture(part, texture, face); | 1947 | try |
1733 | 1948 | { | |
1949 | foreach (SceneObjectPart part in parts) | ||
1950 | SetTexture(part, texture, face); | ||
1951 | } | ||
1952 | finally | ||
1953 | { | ||
1954 | } | ||
1955 | } | ||
1734 | ScriptSleep(200); | 1956 | ScriptSleep(200); |
1735 | } | 1957 | } |
1736 | 1958 | ||
1737 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1959 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1738 | { | 1960 | { |
1961 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1962 | return; | ||
1963 | |||
1739 | UUID textureID = new UUID(); | 1964 | UUID textureID = new UUID(); |
1740 | 1965 | ||
1741 | textureID = InventoryKey(texture, (int)AssetType.Texture); | 1966 | textureID = InventoryKey(texture, (int)AssetType.Texture); |
@@ -1780,6 +2005,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1780 | 2005 | ||
1781 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 2006 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1782 | { | 2007 | { |
2008 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2009 | return; | ||
2010 | |||
1783 | Primitive.TextureEntry tex = part.Shape.Textures; | 2011 | Primitive.TextureEntry tex = part.Shape.Textures; |
1784 | if (face >= 0 && face < GetNumberOfSides(part)) | 2012 | if (face >= 0 && face < GetNumberOfSides(part)) |
1785 | { | 2013 | { |
@@ -1816,6 +2044,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1816 | 2044 | ||
1817 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2045 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1818 | { | 2046 | { |
2047 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2048 | return; | ||
2049 | |||
1819 | Primitive.TextureEntry tex = part.Shape.Textures; | 2050 | Primitive.TextureEntry tex = part.Shape.Textures; |
1820 | if (face >= 0 && face < GetNumberOfSides(part)) | 2051 | if (face >= 0 && face < GetNumberOfSides(part)) |
1821 | { | 2052 | { |
@@ -1852,6 +2083,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1852 | 2083 | ||
1853 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2084 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1854 | { | 2085 | { |
2086 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2087 | return; | ||
2088 | |||
1855 | Primitive.TextureEntry tex = part.Shape.Textures; | 2089 | Primitive.TextureEntry tex = part.Shape.Textures; |
1856 | if (face >= 0 && face < GetNumberOfSides(part)) | 2090 | if (face >= 0 && face < GetNumberOfSides(part)) |
1857 | { | 2091 | { |
@@ -2022,24 +2256,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2022 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> | 2256 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> |
2023 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) | 2257 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) |
2024 | { | 2258 | { |
2025 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2259 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2260 | return; | ||
2261 | |||
2026 | LSL_Vector currentPos = GetPartLocalPos(part); | 2262 | LSL_Vector currentPos = GetPartLocalPos(part); |
2263 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); | ||
2027 | 2264 | ||
2028 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); | ||
2029 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); | ||
2030 | 2265 | ||
2031 | if (part.ParentGroup.RootPart == part) | 2266 | if (part.ParentGroup.RootPart == part) |
2032 | { | 2267 | { |
2033 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | ||
2034 | targetPos.z = ground; | ||
2035 | SceneObjectGroup parent = part.ParentGroup; | 2268 | SceneObjectGroup parent = part.ParentGroup; |
2036 | parent.UpdateGroupPosition(!adjust ? targetPos : | 2269 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) |
2037 | SetPosAdjust(currentPos, targetPos)); | 2270 | return; |
2271 | Util.FireAndForget(delegate(object x) { | ||
2272 | parent.UpdateGroupPosition((Vector3)toPos); | ||
2273 | }); | ||
2038 | } | 2274 | } |
2039 | else | 2275 | else |
2040 | { | 2276 | { |
2041 | part.OffsetPosition = !adjust ? targetPos : SetPosAdjust( | 2277 | part.OffsetPosition = (Vector3)toPos; |
2042 | currentPos, targetPos); | ||
2043 | SceneObjectGroup parent = part.ParentGroup; | 2278 | SceneObjectGroup parent = part.ParentGroup; |
2044 | parent.HasGroupChanged = true; | 2279 | parent.HasGroupChanged = true; |
2045 | parent.ScheduleGroupForTerseUpdate(); | 2280 | parent.ScheduleGroupForTerseUpdate(); |
@@ -2072,13 +2307,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2072 | else | 2307 | else |
2073 | { | 2308 | { |
2074 | if (part.ParentGroup.IsAttachment) | 2309 | if (part.ParentGroup.IsAttachment) |
2075 | { | ||
2076 | pos = part.AttachedPos; | 2310 | pos = part.AttachedPos; |
2077 | } | ||
2078 | else | 2311 | else |
2079 | { | ||
2080 | pos = part.AbsolutePosition; | 2312 | pos = part.AbsolutePosition; |
2081 | } | ||
2082 | } | 2313 | } |
2083 | 2314 | ||
2084 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); | 2315 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); |
@@ -2091,18 +2322,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2091 | m_host.AddScriptLPS(1); | 2322 | m_host.AddScriptLPS(1); |
2092 | 2323 | ||
2093 | // try to let this work as in SL... | 2324 | // try to let this work as in SL... |
2094 | if (m_host.ParentID == 0) | 2325 | if (m_host.LinkNum < 2) |
2095 | { | 2326 | { |
2096 | // special case: If we are root, rotate complete SOG to new rotation | 2327 | // Special case: If we are root, rotate complete SOG to new |
2328 | // rotation. | ||
2329 | // We are root if the link number is 0 (single prim) or 1 | ||
2330 | // (root prim). ParentID may be nonzero in attachments and | ||
2331 | // using it would cause attachments and HUDs to rotate | ||
2332 | // to the wrong positions. | ||
2333 | |||
2097 | SetRot(m_host, Rot2Quaternion(rot)); | 2334 | SetRot(m_host, Rot2Quaternion(rot)); |
2098 | } | 2335 | } |
2099 | else | 2336 | else |
2100 | { | 2337 | { |
2101 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 2338 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
2102 | SceneObjectPart rootPart = m_host.ParentGroup.RootPart; | 2339 | SceneObjectPart rootPart; |
2103 | if (rootPart != null) // better safe than sorry | 2340 | if (m_host.ParentGroup != null) // better safe than sorry |
2104 | { | 2341 | { |
2105 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | 2342 | rootPart = m_host.ParentGroup.RootPart; |
2343 | if (rootPart != null) | ||
2344 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | ||
2106 | } | 2345 | } |
2107 | } | 2346 | } |
2108 | 2347 | ||
@@ -2112,31 +2351,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2112 | public void llSetLocalRot(LSL_Rotation rot) | 2351 | public void llSetLocalRot(LSL_Rotation rot) |
2113 | { | 2352 | { |
2114 | m_host.AddScriptLPS(1); | 2353 | m_host.AddScriptLPS(1); |
2354 | |||
2115 | SetRot(m_host, Rot2Quaternion(rot)); | 2355 | SetRot(m_host, Rot2Quaternion(rot)); |
2116 | ScriptSleep(200); | 2356 | ScriptSleep(200); |
2117 | } | 2357 | } |
2118 | 2358 | ||
2119 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2359 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2120 | { | 2360 | { |
2121 | part.UpdateRotation(rot); | 2361 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2122 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2362 | return; |
2123 | 2363 | ||
2124 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | 2364 | bool isroot = (part == part.ParentGroup.RootPart); |
2125 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 2365 | bool isphys; |
2126 | 2366 | ||
2127 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2128 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2129 | // It's perfectly okay when the object is not an active physical body though. | ||
2130 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2131 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2132 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2133 | // scene | ||
2134 | PhysicsActor pa = part.PhysActor; | 2367 | PhysicsActor pa = part.PhysActor; |
2135 | 2368 | ||
2136 | if (pa != null && !pa.IsPhysical) | 2369 | // keep using physactor ideia of isphysical |
2370 | // it should be SOP ideia of that | ||
2371 | // not much of a issue with ubitODE | ||
2372 | if (pa != null && pa.IsPhysical) | ||
2373 | isphys = true; | ||
2374 | else | ||
2375 | isphys = false; | ||
2376 | |||
2377 | // SL doesn't let scripts rotate root of physical linksets | ||
2378 | if (isroot && isphys) | ||
2379 | return; | ||
2380 | |||
2381 | part.UpdateRotation(rot); | ||
2382 | |||
2383 | // Update rotation does not move the object in the physics engine if it's a non physical linkset | ||
2384 | // so do a nasty update of parts positions if is a root part rotation | ||
2385 | if (isroot && pa != null) // with if above implies non physical root part | ||
2137 | { | 2386 | { |
2138 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | 2387 | part.ParentGroup.ResetChildPrimPhysicsPositions(); |
2139 | } | 2388 | } |
2389 | else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part | ||
2390 | { | ||
2391 | List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars(); | ||
2392 | if (sittingavas.Count > 0) | ||
2393 | { | ||
2394 | foreach (ScenePresence av in sittingavas) | ||
2395 | { | ||
2396 | if (isroot || part.LocalId == av.ParentID) | ||
2397 | av.SendTerseUpdateToAllClients(); | ||
2398 | } | ||
2399 | } | ||
2400 | } | ||
2140 | } | 2401 | } |
2141 | 2402 | ||
2142 | /// <summary> | 2403 | /// <summary> |
@@ -2184,8 +2445,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2184 | 2445 | ||
2185 | public LSL_Rotation llGetLocalRot() | 2446 | public LSL_Rotation llGetLocalRot() |
2186 | { | 2447 | { |
2448 | return GetPartLocalRot(m_host); | ||
2449 | } | ||
2450 | |||
2451 | private LSL_Rotation GetPartLocalRot(SceneObjectPart part) | ||
2452 | { | ||
2187 | m_host.AddScriptLPS(1); | 2453 | m_host.AddScriptLPS(1); |
2188 | return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); | 2454 | Quaternion rot = part.RotationOffset; |
2455 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2189 | } | 2456 | } |
2190 | 2457 | ||
2191 | public void llSetForce(LSL_Vector force, int local) | 2458 | public void llSetForce(LSL_Vector force, int local) |
@@ -2266,16 +2533,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2266 | m_host.ApplyImpulse(v, local != 0); | 2533 | m_host.ApplyImpulse(v, local != 0); |
2267 | } | 2534 | } |
2268 | 2535 | ||
2536 | |||
2269 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 2537 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2270 | { | 2538 | { |
2271 | m_host.AddScriptLPS(1); | 2539 | m_host.AddScriptLPS(1); |
2272 | m_host.ApplyAngularImpulse(force, local != 0); | 2540 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); |
2273 | } | 2541 | } |
2274 | 2542 | ||
2275 | public void llSetTorque(LSL_Vector torque, int local) | 2543 | public void llSetTorque(LSL_Vector torque, int local) |
2276 | { | 2544 | { |
2277 | m_host.AddScriptLPS(1); | 2545 | m_host.AddScriptLPS(1); |
2278 | m_host.SetAngularImpulse(torque, local != 0); | 2546 | m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); |
2279 | } | 2547 | } |
2280 | 2548 | ||
2281 | public LSL_Vector llGetTorque() | 2549 | public LSL_Vector llGetTorque() |
@@ -2292,20 +2560,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2292 | llSetTorque(torque, local); | 2560 | llSetTorque(torque, local); |
2293 | } | 2561 | } |
2294 | 2562 | ||
2563 | public void llSetVelocity(LSL_Vector vel, int local) | ||
2564 | { | ||
2565 | m_host.AddScriptLPS(1); | ||
2566 | m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); | ||
2567 | } | ||
2568 | |||
2295 | public LSL_Vector llGetVel() | 2569 | public LSL_Vector llGetVel() |
2296 | { | 2570 | { |
2297 | m_host.AddScriptLPS(1); | 2571 | m_host.AddScriptLPS(1); |
2298 | 2572 | ||
2299 | Vector3 vel; | 2573 | Vector3 vel = Vector3.Zero; |
2300 | 2574 | ||
2301 | if (m_host.ParentGroup.IsAttachment) | 2575 | if (m_host.ParentGroup.IsAttachment) |
2302 | { | 2576 | { |
2303 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | 2577 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
2304 | vel = avatar.Velocity; | 2578 | if (avatar != null) |
2579 | vel = avatar.Velocity; | ||
2305 | } | 2580 | } |
2306 | else | 2581 | else |
2307 | { | 2582 | { |
2308 | vel = m_host.Velocity; | 2583 | vel = m_host.ParentGroup.RootPart.Velocity; |
2309 | } | 2584 | } |
2310 | 2585 | ||
2311 | return new LSL_Vector(vel.X, vel.Y, vel.Z); | 2586 | return new LSL_Vector(vel.X, vel.Y, vel.Z); |
@@ -2317,10 +2592,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2317 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); | 2592 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); |
2318 | } | 2593 | } |
2319 | 2594 | ||
2595 | public void llSetAngularVelocity(LSL_Vector avel, int local) | ||
2596 | { | ||
2597 | m_host.AddScriptLPS(1); | ||
2598 | m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); | ||
2599 | } | ||
2600 | |||
2320 | public LSL_Vector llGetOmega() | 2601 | public LSL_Vector llGetOmega() |
2321 | { | 2602 | { |
2322 | m_host.AddScriptLPS(1); | 2603 | m_host.AddScriptLPS(1); |
2323 | return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); | 2604 | Vector3 avel = m_host.AngularVelocity; |
2605 | return new LSL_Vector(avel.X, avel.Y, avel.Z); | ||
2324 | } | 2606 | } |
2325 | 2607 | ||
2326 | public LSL_Float llGetTimeOfDay() | 2608 | public LSL_Float llGetTimeOfDay() |
@@ -2846,16 +3128,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2846 | new_group.RootPart.UUID.ToString()) }, | 3128 | new_group.RootPart.UUID.ToString()) }, |
2847 | new DetectParams[0])); | 3129 | new DetectParams[0])); |
2848 | 3130 | ||
2849 | float groupmass = new_group.GetMass(); | 3131 | // do recoil |
3132 | SceneObjectGroup hostgrp = m_host.ParentGroup; | ||
3133 | if (hostgrp == null) | ||
3134 | return; | ||
3135 | |||
3136 | if (hostgrp.IsAttachment) // don't recoil avatars | ||
3137 | return; | ||
2850 | 3138 | ||
2851 | PhysicsActor pa = new_group.RootPart.PhysActor; | 3139 | PhysicsActor pa = new_group.RootPart.PhysActor; |
2852 | 3140 | ||
2853 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) | 3141 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) |
2854 | { | 3142 | { |
2855 | //Recoil. | 3143 | float groupmass = new_group.GetMass(); |
2856 | llApplyImpulse(vel * groupmass, 0); | 3144 | vel *= -groupmass; |
3145 | llApplyImpulse(vel, 0); | ||
2857 | } | 3146 | } |
2858 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | 3147 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) |
3148 | return; | ||
3149 | |||
2859 | }); | 3150 | }); |
2860 | 3151 | ||
2861 | //ScriptSleep((int)((groupmass * velmag) / 10)); | 3152 | //ScriptSleep((int)((groupmass * velmag) / 10)); |
@@ -2870,35 +3161,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2870 | public void llLookAt(LSL_Vector target, double strength, double damping) | 3161 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2871 | { | 3162 | { |
2872 | m_host.AddScriptLPS(1); | 3163 | m_host.AddScriptLPS(1); |
2873 | // Determine where we are looking from | ||
2874 | LSL_Vector from = llGetPos(); | ||
2875 | 3164 | ||
2876 | // Work out the normalised vector from the source to the target | 3165 | // Get the normalized vector to the target |
2877 | LSL_Vector delta = llVecNorm(target - from); | 3166 | LSL_Vector d1 = llVecNorm(target - llGetPos()); |
2878 | LSL_Vector angle = new LSL_Vector(0,0,0); | ||
2879 | 3167 | ||
2880 | // Calculate the yaw | 3168 | // Get the bearing (yaw) |
2881 | // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system | 3169 | LSL_Vector a1 = new LSL_Vector(0,0,0); |
2882 | angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; | 3170 | a1.z = llAtan2(d1.y, d1.x); |
2883 | 3171 | ||
2884 | // Calculate pitch | 3172 | // Get the elevation (pitch) |
2885 | angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); | 3173 | LSL_Vector a2 = new LSL_Vector(0,0,0); |
3174 | a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y))); | ||
2886 | 3175 | ||
2887 | // we need to convert from a vector describing | 3176 | LSL_Rotation r1 = llEuler2Rot(a1); |
2888 | // the angles of rotation in radians into rotation value | 3177 | LSL_Rotation r2 = llEuler2Rot(a2); |
2889 | LSL_Rotation rot = llEuler2Rot(angle); | 3178 | LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107); |
2890 | |||
2891 | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply | ||
2892 | // set the rotation of the object, copy that behavior | ||
2893 | PhysicsActor pa = m_host.PhysActor; | ||
2894 | 3179 | ||
2895 | if (strength == 0 || pa == null || !pa.IsPhysical) | 3180 | if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) |
2896 | { | 3181 | { |
2897 | llSetRot(rot); | 3182 | // Do nothing if either value is 0 (this has been checked in SL) |
3183 | if (strength <= 0.0 || damping <= 0.0) | ||
3184 | return; | ||
3185 | |||
3186 | llSetRot(r3 * r2 * r1); | ||
2898 | } | 3187 | } |
2899 | else | 3188 | else |
2900 | { | 3189 | { |
2901 | m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); | 3190 | if (strength == 0) |
3191 | { | ||
3192 | llSetRot(r3 * r2 * r1); | ||
3193 | return; | ||
3194 | } | ||
3195 | |||
3196 | m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); | ||
2902 | } | 3197 | } |
2903 | } | 3198 | } |
2904 | 3199 | ||
@@ -2944,17 +3239,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2944 | } | 3239 | } |
2945 | else | 3240 | else |
2946 | { | 3241 | { |
2947 | if (m_host.IsRoot) | 3242 | // new SL always returns object mass |
2948 | { | 3243 | // if (m_host.IsRoot) |
3244 | // { | ||
2949 | return m_host.ParentGroup.GetMass(); | 3245 | return m_host.ParentGroup.GetMass(); |
2950 | } | 3246 | // } |
2951 | else | 3247 | // else |
2952 | { | 3248 | // { |
2953 | return m_host.GetMass(); | 3249 | // return m_host.GetMass(); |
2954 | } | 3250 | // } |
2955 | } | 3251 | } |
2956 | } | 3252 | } |
2957 | 3253 | ||
3254 | |||
3255 | public LSL_Float llGetMassMKS() | ||
3256 | { | ||
3257 | return 100f * llGetMass(); | ||
3258 | } | ||
3259 | |||
2958 | public void llCollisionFilter(string name, string id, int accept) | 3260 | public void llCollisionFilter(string name, string id, int accept) |
2959 | { | 3261 | { |
2960 | m_host.AddScriptLPS(1); | 3262 | m_host.AddScriptLPS(1); |
@@ -3002,8 +3304,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3002 | { | 3304 | { |
3003 | // Unregister controls from Presence | 3305 | // Unregister controls from Presence |
3004 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); | 3306 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); |
3005 | // Remove Take Control permission. | ||
3006 | m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | ||
3007 | } | 3307 | } |
3008 | } | 3308 | } |
3009 | } | 3309 | } |
@@ -3029,7 +3329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3029 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3329 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3030 | 3330 | ||
3031 | if (attachmentsModule != null) | 3331 | if (attachmentsModule != null) |
3032 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false); | 3332 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false); |
3033 | else | 3333 | else |
3034 | return false; | 3334 | return false; |
3035 | } | 3335 | } |
@@ -3059,9 +3359,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3059 | { | 3359 | { |
3060 | m_host.AddScriptLPS(1); | 3360 | m_host.AddScriptLPS(1); |
3061 | 3361 | ||
3062 | // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
3063 | // return; | ||
3064 | |||
3065 | if (m_item.PermsGranter != m_host.OwnerID) | 3362 | if (m_item.PermsGranter != m_host.OwnerID) |
3066 | return; | 3363 | return; |
3067 | 3364 | ||
@@ -3104,6 +3401,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3104 | 3401 | ||
3105 | public void llInstantMessage(string user, string message) | 3402 | public void llInstantMessage(string user, string message) |
3106 | { | 3403 | { |
3404 | UUID result; | ||
3405 | if (!UUID.TryParse(user, out result)) | ||
3406 | { | ||
3407 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3408 | ScriptSleep(2000); | ||
3409 | return; | ||
3410 | } | ||
3411 | |||
3412 | |||
3107 | m_host.AddScriptLPS(1); | 3413 | m_host.AddScriptLPS(1); |
3108 | 3414 | ||
3109 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3415 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3118,14 +3424,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3118 | UUID friendTransactionID = UUID.Random(); | 3424 | UUID friendTransactionID = UUID.Random(); |
3119 | 3425 | ||
3120 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3426 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3121 | 3427 | ||
3122 | GridInstantMessage msg = new GridInstantMessage(); | 3428 | GridInstantMessage msg = new GridInstantMessage(); |
3123 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3429 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3124 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3430 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3125 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3431 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3126 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3432 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3127 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3433 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3128 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3434 | // DateTime dt = DateTime.UtcNow; |
3435 | // | ||
3436 | // // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3437 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3438 | // | ||
3439 | // try | ||
3440 | // { | ||
3441 | // // Convert that to the PST timezone | ||
3442 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3443 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3444 | // } | ||
3445 | // catch | ||
3446 | // { | ||
3447 | // // No logging here, as it could be VERY spammy | ||
3448 | // } | ||
3449 | // | ||
3450 | // // And make it look local again to fool the unix time util | ||
3451 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3452 | |||
3453 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
3454 | |||
3129 | //if (client != null) | 3455 | //if (client != null) |
3130 | //{ | 3456 | //{ |
3131 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3457 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3139,12 +3465,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3139 | msg.message = message.Substring(0, 1024); | 3465 | msg.message = message.Substring(0, 1024); |
3140 | else | 3466 | else |
3141 | msg.message = message; | 3467 | msg.message = message; |
3142 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3468 | msg.dialog = (byte)19; // MessageFromObject |
3143 | msg.fromGroup = false;// fromGroup; | 3469 | msg.fromGroup = false;// fromGroup; |
3144 | msg.offline = (byte)0; //offline; | 3470 | msg.offline = (byte)0; //offline; |
3145 | msg.ParentEstateID = 0; //ParentEstateID; | 3471 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3146 | msg.Position = new Vector3(m_host.AbsolutePosition); | 3472 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3147 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3473 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3148 | msg.binaryBucket | 3474 | msg.binaryBucket |
3149 | = Util.StringToBytes256( | 3475 | = Util.StringToBytes256( |
3150 | "{0}/{1}/{2}/{3}", | 3476 | "{0}/{1}/{2}/{3}", |
@@ -3172,7 +3498,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3172 | } | 3498 | } |
3173 | 3499 | ||
3174 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3500 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3175 | llSleep(EMAIL_PAUSE_TIME); | 3501 | ScriptSleep(EMAIL_PAUSE_TIME * 1000); |
3176 | } | 3502 | } |
3177 | 3503 | ||
3178 | public void llGetNextEmail(string address, string subject) | 3504 | public void llGetNextEmail(string address, string subject) |
@@ -3418,7 +3744,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3418 | implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | 3744 | implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | |
3419 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 3745 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | |
3420 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | 3746 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | |
3747 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | ||
3421 | ScriptBaseClass.PERMISSION_ATTACH; | 3748 | ScriptBaseClass.PERMISSION_ATTACH; |
3749 | |||
3422 | } | 3750 | } |
3423 | else | 3751 | else |
3424 | { | 3752 | { |
@@ -3453,11 +3781,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3453 | 3781 | ||
3454 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3782 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3455 | { | 3783 | { |
3456 | lock (m_host.TaskInventory) | 3784 | m_host.TaskInventory.LockItemsForWrite(true); |
3457 | { | 3785 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3458 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3786 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3459 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | 3787 | m_host.TaskInventory.LockItemsForWrite(false); |
3460 | } | ||
3461 | 3788 | ||
3462 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3789 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3463 | "run_time_permissions", new Object[] { | 3790 | "run_time_permissions", new Object[] { |
@@ -3500,11 +3827,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3500 | 3827 | ||
3501 | if (!m_waitingForScriptAnswer) | 3828 | if (!m_waitingForScriptAnswer) |
3502 | { | 3829 | { |
3503 | lock (m_host.TaskInventory) | 3830 | m_host.TaskInventory.LockItemsForWrite(true); |
3504 | { | 3831 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3505 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3832 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3506 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; | 3833 | m_host.TaskInventory.LockItemsForWrite(false); |
3507 | } | ||
3508 | 3834 | ||
3509 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3835 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3510 | m_waitingForScriptAnswer=true; | 3836 | m_waitingForScriptAnswer=true; |
@@ -3533,14 +3859,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3533 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3859 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3534 | llReleaseControls(); | 3860 | llReleaseControls(); |
3535 | 3861 | ||
3536 | lock (m_host.TaskInventory) | 3862 | m_host.TaskInventory.LockItemsForWrite(true); |
3537 | { | 3863 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3538 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; | 3864 | m_host.TaskInventory.LockItemsForWrite(false); |
3539 | } | 3865 | |
3540 | 3866 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | |
3541 | m_ScriptEngine.PostScriptEvent( | 3867 | "run_time_permissions", new Object[] { |
3542 | m_item.ItemID, | 3868 | new LSL_Integer(answer) }, |
3543 | new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); | 3869 | new DetectParams[0])); |
3544 | } | 3870 | } |
3545 | 3871 | ||
3546 | public LSL_String llGetPermissionsKey() | 3872 | public LSL_String llGetPermissionsKey() |
@@ -3579,14 +3905,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3579 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3905 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3580 | { | 3906 | { |
3581 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3907 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3582 | 3908 | if (parts.Count > 0) | |
3583 | foreach (SceneObjectPart part in parts) | 3909 | { |
3584 | part.SetFaceColor(color, face); | 3910 | try |
3911 | { | ||
3912 | foreach (SceneObjectPart part in parts) | ||
3913 | part.SetFaceColor(color, face); | ||
3914 | } | ||
3915 | finally | ||
3916 | { | ||
3917 | } | ||
3918 | } | ||
3585 | } | 3919 | } |
3586 | 3920 | ||
3587 | public void llCreateLink(string target, int parent) | 3921 | public void llCreateLink(string target, int parent) |
3588 | { | 3922 | { |
3589 | m_host.AddScriptLPS(1); | 3923 | m_host.AddScriptLPS(1); |
3924 | |||
3590 | UUID targetID; | 3925 | UUID targetID; |
3591 | 3926 | ||
3592 | if (!UUID.TryParse(target, out targetID)) | 3927 | if (!UUID.TryParse(target, out targetID)) |
@@ -3692,10 +4027,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3692 | // Restructuring Multiple Prims. | 4027 | // Restructuring Multiple Prims. |
3693 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 4028 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3694 | parts.Remove(parentPrim.RootPart); | 4029 | parts.Remove(parentPrim.RootPart); |
3695 | foreach (SceneObjectPart part in parts) | 4030 | if (parts.Count > 0) |
3696 | { | 4031 | { |
3697 | parentPrim.DelinkFromGroup(part.LocalId, true); | 4032 | try |
4033 | { | ||
4034 | foreach (SceneObjectPart part in parts) | ||
4035 | { | ||
4036 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
4037 | } | ||
4038 | } | ||
4039 | finally | ||
4040 | { | ||
4041 | } | ||
3698 | } | 4042 | } |
4043 | |||
3699 | parentPrim.HasGroupChanged = true; | 4044 | parentPrim.HasGroupChanged = true; |
3700 | parentPrim.ScheduleGroupForFullUpdate(); | 4045 | parentPrim.ScheduleGroupForFullUpdate(); |
3701 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 4046 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3704,12 +4049,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3704 | { | 4049 | { |
3705 | SceneObjectPart newRoot = parts[0]; | 4050 | SceneObjectPart newRoot = parts[0]; |
3706 | parts.Remove(newRoot); | 4051 | parts.Remove(newRoot); |
3707 | foreach (SceneObjectPart part in parts) | 4052 | |
4053 | try | ||
3708 | { | 4054 | { |
3709 | // Required for linking | 4055 | foreach (SceneObjectPart part in parts) |
3710 | part.ClearUpdateSchedule(); | 4056 | { |
3711 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 4057 | part.ClearUpdateSchedule(); |
4058 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
4059 | } | ||
3712 | } | 4060 | } |
4061 | finally | ||
4062 | { | ||
4063 | } | ||
4064 | |||
4065 | |||
3713 | newRoot.ParentGroup.HasGroupChanged = true; | 4066 | newRoot.ParentGroup.HasGroupChanged = true; |
3714 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 4067 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3715 | } | 4068 | } |
@@ -3729,6 +4082,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3729 | public void llBreakAllLinks() | 4082 | public void llBreakAllLinks() |
3730 | { | 4083 | { |
3731 | m_host.AddScriptLPS(1); | 4084 | m_host.AddScriptLPS(1); |
4085 | |||
4086 | TaskInventoryItem item = m_item; | ||
4087 | |||
4088 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
4089 | && !m_automaticLinkPermission) | ||
4090 | { | ||
4091 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | ||
4092 | return; | ||
4093 | } | ||
4094 | |||
3732 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 4095 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
3733 | if (parentPrim.AttachmentPoint != 0) | 4096 | if (parentPrim.AttachmentPoint != 0) |
3734 | return; // Fail silently if attached | 4097 | return; // Fail silently if attached |
@@ -3748,25 +4111,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3748 | public LSL_String llGetLinkKey(int linknum) | 4111 | public LSL_String llGetLinkKey(int linknum) |
3749 | { | 4112 | { |
3750 | m_host.AddScriptLPS(1); | 4113 | m_host.AddScriptLPS(1); |
3751 | List<UUID> keytable = new List<UUID>(); | ||
3752 | // parse for sitting avatare-uuids | ||
3753 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | ||
3754 | { | ||
3755 | if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID)) | ||
3756 | keytable.Add(presence.UUID); | ||
3757 | }); | ||
3758 | |||
3759 | int totalprims = m_host.ParentGroup.PrimCount + keytable.Count; | ||
3760 | if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) | ||
3761 | { | ||
3762 | return keytable[totalprims - linknum].ToString(); | ||
3763 | } | ||
3764 | |||
3765 | if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && keytable.Count == 1) | ||
3766 | { | ||
3767 | return m_host.UUID.ToString(); | ||
3768 | } | ||
3769 | |||
3770 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | 4114 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); |
3771 | if (part != null) | 4115 | if (part != null) |
3772 | { | 4116 | { |
@@ -3774,6 +4118,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3774 | } | 4118 | } |
3775 | else | 4119 | else |
3776 | { | 4120 | { |
4121 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
4122 | { | ||
4123 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4124 | |||
4125 | if (linknum < 0) | ||
4126 | return UUID.Zero.ToString(); | ||
4127 | |||
4128 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
4129 | if (avatars.Count > linknum) | ||
4130 | { | ||
4131 | return avatars[linknum].UUID.ToString(); | ||
4132 | } | ||
4133 | } | ||
3777 | return UUID.Zero.ToString(); | 4134 | return UUID.Zero.ToString(); |
3778 | } | 4135 | } |
3779 | } | 4136 | } |
@@ -3873,17 +4230,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3873 | m_host.AddScriptLPS(1); | 4230 | m_host.AddScriptLPS(1); |
3874 | int count = 0; | 4231 | int count = 0; |
3875 | 4232 | ||
3876 | lock (m_host.TaskInventory) | 4233 | m_host.TaskInventory.LockItemsForRead(true); |
4234 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3877 | { | 4235 | { |
3878 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4236 | if (inv.Value.Type == type || type == -1) |
3879 | { | 4237 | { |
3880 | if (inv.Value.Type == type || type == -1) | 4238 | count = count + 1; |
3881 | { | ||
3882 | count = count + 1; | ||
3883 | } | ||
3884 | } | 4239 | } |
3885 | } | 4240 | } |
3886 | 4241 | ||
4242 | m_host.TaskInventory.LockItemsForRead(false); | ||
3887 | return count; | 4243 | return count; |
3888 | } | 4244 | } |
3889 | 4245 | ||
@@ -3892,16 +4248,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3892 | m_host.AddScriptLPS(1); | 4248 | m_host.AddScriptLPS(1); |
3893 | ArrayList keys = new ArrayList(); | 4249 | ArrayList keys = new ArrayList(); |
3894 | 4250 | ||
3895 | lock (m_host.TaskInventory) | 4251 | m_host.TaskInventory.LockItemsForRead(true); |
4252 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3896 | { | 4253 | { |
3897 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4254 | if (inv.Value.Type == type || type == -1) |
3898 | { | 4255 | { |
3899 | if (inv.Value.Type == type || type == -1) | 4256 | keys.Add(inv.Value.Name); |
3900 | { | ||
3901 | keys.Add(inv.Value.Name); | ||
3902 | } | ||
3903 | } | 4257 | } |
3904 | } | 4258 | } |
4259 | m_host.TaskInventory.LockItemsForRead(false); | ||
3905 | 4260 | ||
3906 | if (keys.Count == 0) | 4261 | if (keys.Count == 0) |
3907 | { | 4262 | { |
@@ -3939,7 +4294,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3939 | if (item == null) | 4294 | if (item == null) |
3940 | { | 4295 | { |
3941 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | 4296 | llSay(0, String.Format("Could not find object '{0}'", inventory)); |
3942 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4297 | return; |
4298 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | ||
3943 | } | 4299 | } |
3944 | 4300 | ||
3945 | UUID objId = item.ItemID; | 4301 | UUID objId = item.ItemID; |
@@ -3967,33 +4323,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3967 | return; | 4323 | return; |
3968 | } | 4324 | } |
3969 | } | 4325 | } |
4326 | |||
3970 | // destination is an avatar | 4327 | // destination is an avatar |
3971 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4328 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3972 | 4329 | ||
3973 | if (agentItem == null) | 4330 | if (agentItem == null) |
3974 | return; | 4331 | return; |
3975 | 4332 | ||
3976 | if (m_TransferModule != null) | 4333 | byte[] bucket = new byte[1]; |
3977 | { | 4334 | bucket[0] = (byte)item.Type; |
3978 | byte[] bucket = new byte[] { (byte)item.Type }; | 4335 | //byte[] objBytes = agentItem.ID.GetBytes(); |
4336 | //Array.Copy(objBytes, 0, bucket, 1, 16); | ||
4337 | |||
4338 | GridInstantMessage msg = new GridInstantMessage(World, | ||
4339 | m_host.OwnerID, m_host.Name, destId, | ||
4340 | (byte)InstantMessageDialog.TaskInventoryOffered, | ||
4341 | false, item.Name+". "+m_host.Name+" is located at "+ | ||
4342 | World.RegionInfo.RegionName+" "+ | ||
4343 | m_host.AbsolutePosition.ToString(), | ||
4344 | agentItem.ID, true, m_host.AbsolutePosition, | ||
4345 | bucket); | ||
3979 | 4346 | ||
3980 | GridInstantMessage msg = new GridInstantMessage(World, | 4347 | ScenePresence sp; |
3981 | m_host.UUID, m_host.Name + ", an object owned by " + | ||
3982 | resolveName(m_host.OwnerID) + ",", destId, | ||
3983 | (byte)InstantMessageDialog.TaskInventoryOffered, | ||
3984 | false, item.Name + "\n" + m_host.Name + " is located at " + | ||
3985 | World.RegionInfo.RegionName+" "+ | ||
3986 | m_host.AbsolutePosition.ToString(), | ||
3987 | agentItem.ID, true, m_host.AbsolutePosition, | ||
3988 | bucket); | ||
3989 | 4348 | ||
3990 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4349 | if (World.TryGetScenePresence(destId, out sp)) |
4350 | { | ||
4351 | sp.ControllingClient.SendInstantMessage(msg); | ||
3991 | } | 4352 | } |
3992 | 4353 | else | |
4354 | { | ||
4355 | if (m_TransferModule != null) | ||
4356 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | ||
4357 | } | ||
4358 | |||
4359 | //This delay should only occur when giving inventory to avatars. | ||
3993 | ScriptSleep(3000); | 4360 | ScriptSleep(3000); |
3994 | } | 4361 | } |
3995 | } | 4362 | } |
3996 | 4363 | ||
4364 | [DebuggerNonUserCode] | ||
3997 | public void llRemoveInventory(string name) | 4365 | public void llRemoveInventory(string name) |
3998 | { | 4366 | { |
3999 | m_host.AddScriptLPS(1); | 4367 | m_host.AddScriptLPS(1); |
@@ -4037,109 +4405,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4037 | { | 4405 | { |
4038 | m_host.AddScriptLPS(1); | 4406 | m_host.AddScriptLPS(1); |
4039 | 4407 | ||
4040 | UUID uuid = (UUID)id; | 4408 | UUID uuid; |
4041 | PresenceInfo pinfo = null; | 4409 | if (UUID.TryParse(id, out uuid)) |
4042 | UserAccount account; | ||
4043 | |||
4044 | UserInfoCacheEntry ce; | ||
4045 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4046 | { | 4410 | { |
4047 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4411 | PresenceInfo pinfo = null; |
4048 | if (account == null) | 4412 | UserAccount account; |
4413 | |||
4414 | UserInfoCacheEntry ce; | ||
4415 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4049 | { | 4416 | { |
4050 | m_userInfoCache[uuid] = null; // Cache negative | 4417 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
4051 | return UUID.Zero.ToString(); | 4418 | if (account == null) |
4052 | } | 4419 | { |
4420 | m_userInfoCache[uuid] = null; // Cache negative | ||
4421 | return UUID.Zero.ToString(); | ||
4422 | } | ||
4053 | 4423 | ||
4054 | 4424 | ||
4055 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4425 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4056 | if (pinfos != null && pinfos.Length > 0) | 4426 | if (pinfos != null && pinfos.Length > 0) |
4057 | { | ||
4058 | foreach (PresenceInfo p in pinfos) | ||
4059 | { | 4427 | { |
4060 | if (p.RegionID != UUID.Zero) | 4428 | foreach (PresenceInfo p in pinfos) |
4061 | { | 4429 | { |
4062 | pinfo = p; | 4430 | if (p.RegionID != UUID.Zero) |
4431 | { | ||
4432 | pinfo = p; | ||
4433 | } | ||
4063 | } | 4434 | } |
4064 | } | 4435 | } |
4065 | } | ||
4066 | 4436 | ||
4067 | ce = new UserInfoCacheEntry(); | 4437 | ce = new UserInfoCacheEntry(); |
4068 | ce.time = Util.EnvironmentTickCount(); | 4438 | ce.time = Util.EnvironmentTickCount(); |
4069 | ce.account = account; | 4439 | ce.account = account; |
4070 | ce.pinfo = pinfo; | 4440 | ce.pinfo = pinfo; |
4071 | } | 4441 | m_userInfoCache[uuid] = ce; |
4072 | else | 4442 | } |
4073 | { | 4443 | else |
4074 | if (ce == null) | 4444 | { |
4075 | return UUID.Zero.ToString(); | 4445 | if (ce == null) |
4446 | return UUID.Zero.ToString(); | ||
4076 | 4447 | ||
4077 | account = ce.account; | 4448 | account = ce.account; |
4078 | pinfo = ce.pinfo; | 4449 | pinfo = ce.pinfo; |
4079 | } | 4450 | } |
4080 | 4451 | ||
4081 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 4452 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
4082 | { | ||
4083 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
4084 | if (pinfos != null && pinfos.Length > 0) | ||
4085 | { | 4453 | { |
4086 | foreach (PresenceInfo p in pinfos) | 4454 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4455 | if (pinfos != null && pinfos.Length > 0) | ||
4087 | { | 4456 | { |
4088 | if (p.RegionID != UUID.Zero) | 4457 | foreach (PresenceInfo p in pinfos) |
4089 | { | 4458 | { |
4090 | pinfo = p; | 4459 | if (p.RegionID != UUID.Zero) |
4460 | { | ||
4461 | pinfo = p; | ||
4462 | } | ||
4091 | } | 4463 | } |
4092 | } | 4464 | } |
4093 | } | 4465 | else |
4094 | else | 4466 | pinfo = null; |
4095 | pinfo = null; | ||
4096 | 4467 | ||
4097 | ce.time = Util.EnvironmentTickCount(); | 4468 | ce.time = Util.EnvironmentTickCount(); |
4098 | ce.pinfo = pinfo; | 4469 | ce.pinfo = pinfo; |
4099 | } | 4470 | } |
4100 | 4471 | ||
4101 | string reply = String.Empty; | 4472 | string reply = String.Empty; |
4102 | 4473 | ||
4103 | switch (data) | 4474 | switch (data) |
4104 | { | 4475 | { |
4105 | case 1: // DATA_ONLINE (0|1) | 4476 | case 1: // DATA_ONLINE (0|1) |
4106 | if (pinfo != null && pinfo.RegionID != UUID.Zero) | 4477 | if (pinfo != null && pinfo.RegionID != UUID.Zero) |
4107 | reply = "1"; | 4478 | reply = "1"; |
4108 | else | 4479 | else |
4109 | reply = "0"; | 4480 | reply = "0"; |
4110 | break; | 4481 | break; |
4111 | case 2: // DATA_NAME (First Last) | 4482 | case 2: // DATA_NAME (First Last) |
4112 | reply = account.FirstName + " " + account.LastName; | 4483 | reply = account.FirstName + " " + account.LastName; |
4113 | break; | 4484 | break; |
4114 | case 3: // DATA_BORN (YYYY-MM-DD) | 4485 | case 3: // DATA_BORN (YYYY-MM-DD) |
4115 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | 4486 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); |
4116 | born = born.AddSeconds(account.Created); | 4487 | born = born.AddSeconds(account.Created); |
4117 | reply = born.ToString("yyyy-MM-dd"); | 4488 | reply = born.ToString("yyyy-MM-dd"); |
4118 | break; | 4489 | break; |
4119 | case 4: // DATA_RATING (0,0,0,0,0,0) | 4490 | case 4: // DATA_RATING (0,0,0,0,0,0) |
4120 | reply = "0,0,0,0,0,0"; | 4491 | reply = "0,0,0,0,0,0"; |
4121 | break; | 4492 | break; |
4122 | case 7: // DATA_USERLEVEL (integer) | 4493 | case 8: // DATA_PAYINFO (0|1|2|3) |
4123 | reply = account.UserLevel.ToString(); | 4494 | reply = "0"; |
4124 | break; | 4495 | break; |
4125 | case 8: // DATA_PAYINFO (0|1|2|3) | 4496 | default: |
4126 | reply = "0"; | 4497 | return UUID.Zero.ToString(); // Raise no event |
4127 | break; | 4498 | } |
4128 | default: | ||
4129 | return UUID.Zero.ToString(); // Raise no event | ||
4130 | } | ||
4131 | 4499 | ||
4132 | UUID rq = UUID.Random(); | 4500 | UUID rq = UUID.Random(); |
4133 | 4501 | ||
4134 | UUID tid = AsyncCommands. | 4502 | UUID tid = AsyncCommands. |
4135 | DataserverPlugin.RegisterRequest(m_host.LocalId, | 4503 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4136 | m_item.ItemID, rq.ToString()); | 4504 | m_item.ItemID, rq.ToString()); |
4137 | 4505 | ||
4138 | AsyncCommands. | 4506 | AsyncCommands. |
4139 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4507 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
4140 | 4508 | ||
4141 | ScriptSleep(100); | 4509 | ScriptSleep(100); |
4142 | return tid.ToString(); | 4510 | return tid.ToString(); |
4511 | } | ||
4512 | else | ||
4513 | { | ||
4514 | ShoutError("Invalid UUID passed to llRequestAgentData."); | ||
4515 | } | ||
4516 | return ""; | ||
4143 | } | 4517 | } |
4144 | 4518 | ||
4145 | public LSL_String llRequestInventoryData(string name) | 4519 | public LSL_String llRequestInventoryData(string name) |
@@ -4196,13 +4570,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4196 | if (UUID.TryParse(agent, out agentId)) | 4570 | if (UUID.TryParse(agent, out agentId)) |
4197 | { | 4571 | { |
4198 | ScenePresence presence = World.GetScenePresence(agentId); | 4572 | ScenePresence presence = World.GetScenePresence(agentId); |
4199 | if (presence != null) | 4573 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4200 | { | 4574 | { |
4575 | // agent must not be a god | ||
4576 | if (presence.UserLevel >= 200) return; | ||
4577 | |||
4201 | // agent must be over the owners land | 4578 | // agent must be over the owners land |
4202 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4579 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4203 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4580 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
4204 | { | 4581 | { |
4205 | World.TeleportClientHome(agentId, presence.ControllingClient); | 4582 | if (!World.TeleportClientHome(agentId, presence.ControllingClient)) |
4583 | { | ||
4584 | // They can't be teleported home for some reason | ||
4585 | GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6")); | ||
4586 | if (regionInfo != null) | ||
4587 | { | ||
4588 | World.RequestTeleportLocation( | ||
4589 | presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, | ||
4590 | (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); | ||
4591 | } | ||
4592 | } | ||
4206 | } | 4593 | } |
4207 | } | 4594 | } |
4208 | } | 4595 | } |
@@ -4309,7 +4696,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4309 | UUID av = new UUID(); | 4696 | UUID av = new UUID(); |
4310 | if (!UUID.TryParse(agent,out av)) | 4697 | if (!UUID.TryParse(agent,out av)) |
4311 | { | 4698 | { |
4312 | LSLError("First parameter to llDialog needs to be a key"); | 4699 | //LSLError("First parameter to llDialog needs to be a key"); |
4313 | return; | 4700 | return; |
4314 | } | 4701 | } |
4315 | 4702 | ||
@@ -4341,7 +4728,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4341 | public void llCollisionSound(string impact_sound, double impact_volume) | 4728 | public void llCollisionSound(string impact_sound, double impact_volume) |
4342 | { | 4729 | { |
4343 | m_host.AddScriptLPS(1); | 4730 | m_host.AddScriptLPS(1); |
4344 | 4731 | ||
4732 | if(impact_sound == "") | ||
4733 | { | ||
4734 | m_host.CollisionSoundVolume = (float)impact_volume; | ||
4735 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; | ||
4736 | m_host.CollisionSoundType = 0; | ||
4737 | return; | ||
4738 | } | ||
4345 | // TODO: Parameter check logic required. | 4739 | // TODO: Parameter check logic required. |
4346 | UUID soundId = UUID.Zero; | 4740 | UUID soundId = UUID.Zero; |
4347 | if (!UUID.TryParse(impact_sound, out soundId)) | 4741 | if (!UUID.TryParse(impact_sound, out soundId)) |
@@ -4354,6 +4748,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4354 | 4748 | ||
4355 | m_host.CollisionSound = soundId; | 4749 | m_host.CollisionSound = soundId; |
4356 | m_host.CollisionSoundVolume = (float)impact_volume; | 4750 | m_host.CollisionSoundVolume = (float)impact_volume; |
4751 | m_host.CollisionSoundType = 1; | ||
4357 | } | 4752 | } |
4358 | 4753 | ||
4359 | public LSL_String llGetAnimation(string id) | 4754 | public LSL_String llGetAnimation(string id) |
@@ -4367,14 +4762,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4367 | 4762 | ||
4368 | if (m_host.RegionHandle == presence.RegionHandle) | 4763 | if (m_host.RegionHandle == presence.RegionHandle) |
4369 | { | 4764 | { |
4370 | Dictionary<UUID, string> animationstateNames = DefaultAvatarAnimations.AnimStateNames; | ||
4371 | |||
4372 | if (presence != null) | 4765 | if (presence != null) |
4373 | { | 4766 | { |
4374 | AnimationSet currentAnims = presence.Animator.Animations; | 4767 | if (presence.SitGround) |
4375 | string currentAnimationState = String.Empty; | 4768 | return "Sitting on Ground"; |
4376 | if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState)) | 4769 | if (presence.ParentID != 0 || presence.ParentUUID != UUID.Zero) |
4377 | return currentAnimationState; | 4770 | return "Sitting"; |
4771 | |||
4772 | string movementAnimation = presence.Animator.CurrentMovementAnimation; | ||
4773 | string lslMovementAnimation; | ||
4774 | |||
4775 | if (MovementAnimationsForLSL.TryGetValue(movementAnimation, out lslMovementAnimation)) | ||
4776 | return lslMovementAnimation; | ||
4378 | } | 4777 | } |
4379 | } | 4778 | } |
4380 | 4779 | ||
@@ -4521,7 +4920,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4521 | { | 4920 | { |
4522 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); | 4921 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); |
4523 | float distance_term = distance * distance * distance; // Script Energy | 4922 | float distance_term = distance * distance * distance; // Script Energy |
4524 | float pusher_mass = m_host.GetMass(); | 4923 | // use total object mass and not part |
4924 | float pusher_mass = m_host.ParentGroup.GetMass(); | ||
4525 | 4925 | ||
4526 | float PUSH_ATTENUATION_DISTANCE = 17f; | 4926 | float PUSH_ATTENUATION_DISTANCE = 17f; |
4527 | float PUSH_ATTENUATION_SCALE = 5f; | 4927 | float PUSH_ATTENUATION_SCALE = 5f; |
@@ -4771,6 +5171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4771 | { | 5171 | { |
4772 | return item.AssetID.ToString(); | 5172 | return item.AssetID.ToString(); |
4773 | } | 5173 | } |
5174 | m_host.TaskInventory.LockItemsForRead(false); | ||
4774 | 5175 | ||
4775 | return UUID.Zero.ToString(); | 5176 | return UUID.Zero.ToString(); |
4776 | } | 5177 | } |
@@ -4904,7 +5305,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4904 | public LSL_Vector llGetCenterOfMass() | 5305 | public LSL_Vector llGetCenterOfMass() |
4905 | { | 5306 | { |
4906 | m_host.AddScriptLPS(1); | 5307 | m_host.AddScriptLPS(1); |
4907 | Vector3 center = m_host.GetGeometricCenter(); | 5308 | Vector3 center = m_host.GetCenterOfMass(); |
4908 | return new LSL_Vector(center.X,center.Y,center.Z); | 5309 | return new LSL_Vector(center.X,center.Y,center.Z); |
4909 | } | 5310 | } |
4910 | 5311 | ||
@@ -4923,14 +5324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4923 | { | 5324 | { |
4924 | m_host.AddScriptLPS(1); | 5325 | m_host.AddScriptLPS(1); |
4925 | 5326 | ||
4926 | if (src == null) | 5327 | return src.Length; |
4927 | { | ||
4928 | return 0; | ||
4929 | } | ||
4930 | else | ||
4931 | { | ||
4932 | return src.Length; | ||
4933 | } | ||
4934 | } | 5328 | } |
4935 | 5329 | ||
4936 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5330 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -5001,7 +5395,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5001 | else if (src.Data[index] is LSL_Float) | 5395 | else if (src.Data[index] is LSL_Float) |
5002 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); | 5396 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); |
5003 | else if (src.Data[index] is LSL_String) | 5397 | else if (src.Data[index] is LSL_String) |
5004 | return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); | 5398 | { |
5399 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5400 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5401 | if (m != Match.Empty) | ||
5402 | { | ||
5403 | str = m.Value; | ||
5404 | double d = 0.0; | ||
5405 | if (!Double.TryParse(str, out d)) | ||
5406 | return 0.0; | ||
5407 | |||
5408 | return d; | ||
5409 | } | ||
5410 | return 0.0; | ||
5411 | } | ||
5005 | return Convert.ToDouble(src.Data[index]); | 5412 | return Convert.ToDouble(src.Data[index]); |
5006 | } | 5413 | } |
5007 | catch (FormatException) | 5414 | catch (FormatException) |
@@ -5311,7 +5718,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5311 | } | 5718 | } |
5312 | } | 5719 | } |
5313 | } | 5720 | } |
5314 | else { | 5721 | else |
5722 | { | ||
5315 | object[] array = new object[src.Length]; | 5723 | object[] array = new object[src.Length]; |
5316 | Array.Copy(src.Data, 0, array, 0, src.Length); | 5724 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5317 | result = new LSL_List(array); | 5725 | result = new LSL_List(array); |
@@ -5418,7 +5826,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5418 | public LSL_Integer llGetRegionAgentCount() | 5826 | public LSL_Integer llGetRegionAgentCount() |
5419 | { | 5827 | { |
5420 | m_host.AddScriptLPS(1); | 5828 | m_host.AddScriptLPS(1); |
5421 | return new LSL_Integer(World.GetRootAgentCount()); | 5829 | |
5830 | int count = 0; | ||
5831 | World.ForEachRootScenePresence(delegate(ScenePresence sp) { | ||
5832 | count++; | ||
5833 | }); | ||
5834 | |||
5835 | return new LSL_Integer(count); | ||
5422 | } | 5836 | } |
5423 | 5837 | ||
5424 | public LSL_Vector llGetRegionCorner() | 5838 | public LSL_Vector llGetRegionCorner() |
@@ -5698,6 +6112,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5698 | flags |= ScriptBaseClass.AGENT_SITTING; | 6112 | flags |= ScriptBaseClass.AGENT_SITTING; |
5699 | } | 6113 | } |
5700 | 6114 | ||
6115 | if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0) | ||
6116 | { | ||
6117 | flags |= ScriptBaseClass.AGENT_MALE; | ||
6118 | } | ||
6119 | |||
5701 | return flags; | 6120 | return flags; |
5702 | } | 6121 | } |
5703 | 6122 | ||
@@ -5844,10 +6263,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5844 | m_host.AddScriptLPS(1); | 6263 | m_host.AddScriptLPS(1); |
5845 | 6264 | ||
5846 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6265 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5847 | 6266 | if (parts.Count > 0) | |
5848 | foreach (var part in parts) | ||
5849 | { | 6267 | { |
5850 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 6268 | try |
6269 | { | ||
6270 | foreach (var part in parts) | ||
6271 | { | ||
6272 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6273 | } | ||
6274 | } | ||
6275 | finally | ||
6276 | { | ||
6277 | } | ||
5851 | } | 6278 | } |
5852 | } | 6279 | } |
5853 | 6280 | ||
@@ -5899,13 +6326,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5899 | 6326 | ||
5900 | if (m_host.OwnerID == land.LandData.OwnerID) | 6327 | if (m_host.OwnerID == land.LandData.OwnerID) |
5901 | { | 6328 | { |
5902 | World.TeleportClientHome(agentID, presence.ControllingClient); | 6329 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6330 | presence.TeleportWithMomentum(pos, null); | ||
6331 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
5903 | } | 6332 | } |
5904 | } | 6333 | } |
5905 | } | 6334 | } |
5906 | ScriptSleep(5000); | 6335 | ScriptSleep(5000); |
5907 | } | 6336 | } |
5908 | 6337 | ||
6338 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
6339 | { | ||
6340 | return ParseString2List(str, separators, in_spacers, false); | ||
6341 | } | ||
6342 | |||
5909 | public LSL_Integer llOverMyLand(string id) | 6343 | public LSL_Integer llOverMyLand(string id) |
5910 | { | 6344 | { |
5911 | m_host.AddScriptLPS(1); | 6345 | m_host.AddScriptLPS(1); |
@@ -5964,20 +6398,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5964 | return agentSize; | 6398 | return agentSize; |
5965 | } | 6399 | } |
5966 | 6400 | ||
5967 | public LSL_Integer llSameGroup(string agent) | 6401 | public LSL_Integer llSameGroup(string id) |
5968 | { | 6402 | { |
5969 | m_host.AddScriptLPS(1); | 6403 | m_host.AddScriptLPS(1); |
5970 | UUID agentId = new UUID(); | 6404 | UUID uuid = new UUID(); |
5971 | if (!UUID.TryParse(agent, out agentId)) | 6405 | if (!UUID.TryParse(id, out uuid)) |
5972 | return new LSL_Integer(0); | 6406 | return new LSL_Integer(0); |
5973 | ScenePresence presence = World.GetScenePresence(agentId); | 6407 | |
5974 | if (presence == null || presence.IsChildAgent) // Return flase for child agents | 6408 | // Check if it's a group key |
5975 | return new LSL_Integer(0); | 6409 | if (uuid == m_host.ParentGroup.RootPart.GroupID) |
5976 | IClientAPI client = presence.ControllingClient; | ||
5977 | if (m_host.GroupID == client.ActiveGroupId) | ||
5978 | return new LSL_Integer(1); | 6410 | return new LSL_Integer(1); |
5979 | else | 6411 | |
6412 | // We got passed a UUID.Zero | ||
6413 | if (uuid == UUID.Zero) | ||
6414 | return new LSL_Integer(0); | ||
6415 | |||
6416 | // Handle the case where id names an avatar | ||
6417 | ScenePresence presence = World.GetScenePresence(uuid); | ||
6418 | if (presence != null) | ||
6419 | { | ||
6420 | if (presence.IsChildAgent) | ||
6421 | return new LSL_Integer(0); | ||
6422 | |||
6423 | IClientAPI client = presence.ControllingClient; | ||
6424 | if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId) | ||
6425 | return new LSL_Integer(1); | ||
6426 | |||
6427 | return new LSL_Integer(0); | ||
6428 | } | ||
6429 | |||
6430 | // Handle object case | ||
6431 | SceneObjectPart part = World.GetSceneObjectPart(uuid); | ||
6432 | if (part != null) | ||
6433 | { | ||
6434 | // This will handle both deed and non-deed and also the no | ||
6435 | // group case | ||
6436 | if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID) | ||
6437 | return new LSL_Integer(1); | ||
6438 | |||
5980 | return new LSL_Integer(0); | 6439 | return new LSL_Integer(0); |
6440 | } | ||
6441 | |||
6442 | return new LSL_Integer(0); | ||
5981 | } | 6443 | } |
5982 | 6444 | ||
5983 | public void llUnSit(string id) | 6445 | public void llUnSit(string id) |
@@ -6102,7 +6564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6102 | return m_host.ParentGroup.AttachmentPoint; | 6564 | return m_host.ParentGroup.AttachmentPoint; |
6103 | } | 6565 | } |
6104 | 6566 | ||
6105 | public LSL_Integer llGetFreeMemory() | 6567 | public virtual LSL_Integer llGetFreeMemory() |
6106 | { | 6568 | { |
6107 | m_host.AddScriptLPS(1); | 6569 | m_host.AddScriptLPS(1); |
6108 | // Make scripts designed for LSO happy | 6570 | // Make scripts designed for LSO happy |
@@ -6219,7 +6681,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6219 | SetParticleSystem(m_host, rules); | 6681 | SetParticleSystem(m_host, rules); |
6220 | } | 6682 | } |
6221 | 6683 | ||
6222 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { | 6684 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) |
6685 | { | ||
6223 | 6686 | ||
6224 | 6687 | ||
6225 | if (rules.Length == 0) | 6688 | if (rules.Length == 0) |
@@ -6535,7 +6998,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6535 | { | 6998 | { |
6536 | // LSL quaternions can normalize to 0, normal Quaternions can't. | 6999 | // LSL quaternions can normalize to 0, normal Quaternions can't. |
6537 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | 7000 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) |
6538 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | 7001 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 |
6539 | 7002 | ||
6540 | part.SitTargetPosition = offset; | 7003 | part.SitTargetPosition = offset; |
6541 | part.SitTargetOrientation = Rot2Quaternion(rot); | 7004 | part.SitTargetOrientation = Rot2Quaternion(rot); |
@@ -6692,13 +7155,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6692 | UUID av = new UUID(); | 7155 | UUID av = new UUID(); |
6693 | if (!UUID.TryParse(avatar,out av)) | 7156 | if (!UUID.TryParse(avatar,out av)) |
6694 | { | 7157 | { |
6695 | LSLError("First parameter to llDialog needs to be a key"); | 7158 | //LSLError("First parameter to llDialog needs to be a key"); |
6696 | return; | 7159 | return; |
6697 | } | 7160 | } |
6698 | if (buttons.Length < 1) | 7161 | if (buttons.Length < 1) |
6699 | { | 7162 | { |
6700 | LSLError("No less than 1 button can be shown"); | 7163 | buttons.Add("OK"); |
6701 | return; | ||
6702 | } | 7164 | } |
6703 | if (buttons.Length > 12) | 7165 | if (buttons.Length > 12) |
6704 | { | 7166 | { |
@@ -6715,7 +7177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6715 | } | 7177 | } |
6716 | if (buttons.Data[i].ToString().Length > 24) | 7178 | if (buttons.Data[i].ToString().Length > 24) |
6717 | { | 7179 | { |
6718 | LSLError("button label cannot be longer than 24 characters"); | 7180 | llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); |
6719 | return; | 7181 | return; |
6720 | } | 7182 | } |
6721 | buts[i] = buttons.Data[i].ToString(); | 7183 | buts[i] = buttons.Data[i].ToString(); |
@@ -6782,9 +7244,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6782 | return; | 7244 | return; |
6783 | } | 7245 | } |
6784 | 7246 | ||
6785 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 7247 | SceneObjectPart dest = World.GetSceneObjectPart(destId); |
6786 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | 7248 | if (dest != null) |
7249 | { | ||
7250 | if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) | ||
7251 | { | ||
7252 | // the rest of the permission checks are done in RezScript, so check the pin there as well | ||
7253 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | ||
6787 | 7254 | ||
7255 | if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0) | ||
7256 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
7257 | } | ||
7258 | } | ||
6788 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 7259 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
6789 | ScriptSleep(3000); | 7260 | ScriptSleep(3000); |
6790 | } | 7261 | } |
@@ -6847,19 +7318,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6847 | public LSL_String llMD5String(string src, int nonce) | 7318 | public LSL_String llMD5String(string src, int nonce) |
6848 | { | 7319 | { |
6849 | m_host.AddScriptLPS(1); | 7320 | m_host.AddScriptLPS(1); |
6850 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 7321 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
6851 | } | 7322 | } |
6852 | 7323 | ||
6853 | public LSL_String llSHA1String(string src) | 7324 | public LSL_String llSHA1String(string src) |
6854 | { | 7325 | { |
6855 | m_host.AddScriptLPS(1); | 7326 | m_host.AddScriptLPS(1); |
6856 | return Util.SHA1Hash(src).ToLower(); | 7327 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
6857 | } | 7328 | } |
6858 | 7329 | ||
6859 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) | 7330 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) |
6860 | { | 7331 | { |
6861 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7332 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6862 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7333 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7334 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7335 | return shapeBlock; | ||
6863 | 7336 | ||
6864 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 7337 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6865 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 7338 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6964,6 +7437,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6964 | // Prim type box, cylinder and prism. | 7437 | // Prim type box, cylinder and prism. |
6965 | 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) | 7438 | 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) |
6966 | { | 7439 | { |
7440 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7441 | return; | ||
7442 | |||
6967 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7443 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6968 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7444 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6969 | 7445 | ||
@@ -7017,6 +7493,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7017 | // Prim type sphere. | 7493 | // Prim type sphere. |
7018 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) | 7494 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) |
7019 | { | 7495 | { |
7496 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7497 | return; | ||
7498 | |||
7020 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7499 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7021 | 7500 | ||
7022 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); | 7501 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
@@ -7058,6 +7537,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7058 | // Prim type torus, tube and ring. | 7537 | // Prim type torus, tube and ring. |
7059 | 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) | 7538 | 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) |
7060 | { | 7539 | { |
7540 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7541 | return; | ||
7542 | |||
7061 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7543 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7062 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7544 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7063 | 7545 | ||
@@ -7193,6 +7675,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7193 | // Prim type sculpt. | 7675 | // Prim type sculpt. |
7194 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) | 7676 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) |
7195 | { | 7677 | { |
7678 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7679 | return; | ||
7680 | |||
7196 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7681 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7197 | UUID sculptId; | 7682 | UUID sculptId; |
7198 | 7683 | ||
@@ -7217,7 +7702,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7217 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) | 7702 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) |
7218 | { | 7703 | { |
7219 | // default | 7704 | // default |
7220 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7705 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
7221 | } | 7706 | } |
7222 | 7707 | ||
7223 | part.Shape.SetSculptProperties((byte)type, sculptId); | 7708 | part.Shape.SetSculptProperties((byte)type, sculptId); |
@@ -7234,46 +7719,309 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7234 | ScriptSleep(200); | 7719 | ScriptSleep(200); |
7235 | } | 7720 | } |
7236 | 7721 | ||
7237 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7722 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
7238 | { | 7723 | { |
7239 | m_host.AddScriptLPS(1); | 7724 | m_host.AddScriptLPS(1); |
7240 | 7725 | ||
7241 | setLinkPrimParams(linknumber, rules); | 7726 | setLinkPrimParams(linknumber, rules); |
7727 | } | ||
7728 | |||
7729 | private void setLinkPrimParams(int linknumber, LSL_List rules) | ||
7730 | { | ||
7731 | List<object> parts = new List<object>(); | ||
7732 | List<SceneObjectPart> prims = GetLinkParts(linknumber); | ||
7733 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7734 | foreach (SceneObjectPart p in prims) | ||
7735 | parts.Add(p); | ||
7736 | foreach (ScenePresence p in avatars) | ||
7737 | parts.Add(p); | ||
7242 | 7738 | ||
7739 | LSL_List remaining = null; | ||
7740 | |||
7741 | if (parts.Count > 0) | ||
7742 | { | ||
7743 | foreach (object part in parts) | ||
7744 | { | ||
7745 | if (part is SceneObjectPart) | ||
7746 | remaining = SetPrimParams((SceneObjectPart)part, rules); | ||
7747 | else | ||
7748 | remaining = SetPrimParams((ScenePresence)part, rules); | ||
7749 | } | ||
7750 | |||
7751 | while((object)remaining != null && remaining.Length > 2) | ||
7752 | { | ||
7753 | linknumber = remaining.GetLSLIntegerItem(0); | ||
7754 | rules = remaining.GetSublist(1,-1); | ||
7755 | parts.Clear(); | ||
7756 | prims = GetLinkParts(linknumber); | ||
7757 | avatars = GetLinkAvatars(linknumber); | ||
7758 | foreach (SceneObjectPart p in prims) | ||
7759 | parts.Add(p); | ||
7760 | foreach (ScenePresence p in avatars) | ||
7761 | parts.Add(p); | ||
7762 | |||
7763 | foreach (object part in parts) | ||
7764 | { | ||
7765 | if (part is SceneObjectPart) | ||
7766 | remaining = SetPrimParams((SceneObjectPart)part, rules); | ||
7767 | else | ||
7768 | remaining = SetPrimParams((ScenePresence)part, rules); | ||
7769 | } | ||
7770 | } | ||
7771 | } | ||
7772 | } | ||
7773 | |||
7774 | private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, | ||
7775 | float material_density, float material_friction, | ||
7776 | float material_restitution, float material_gravity_modifier) | ||
7777 | { | ||
7778 | ExtraPhysicsData physdata = new ExtraPhysicsData(); | ||
7779 | physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; | ||
7780 | physdata.Density = part.Density; | ||
7781 | physdata.Friction = part.Friction; | ||
7782 | physdata.Bounce = part.Bounciness; | ||
7783 | physdata.GravitationModifier = part.GravityModifier; | ||
7784 | |||
7785 | if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) | ||
7786 | physdata.Density = material_density; | ||
7787 | if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) | ||
7788 | physdata.Friction = material_friction; | ||
7789 | if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) | ||
7790 | physdata.Bounce = material_restitution; | ||
7791 | if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) | ||
7792 | physdata.GravitationModifier = material_gravity_modifier; | ||
7793 | |||
7794 | part.UpdateExtraPhysics(physdata); | ||
7795 | } | ||
7796 | |||
7797 | public void llSetPhysicsMaterial(int material_bits, | ||
7798 | float material_gravity_modifier, float material_restitution, | ||
7799 | float material_friction, float material_density) | ||
7800 | { | ||
7801 | SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | ||
7802 | } | ||
7803 | |||
7804 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | ||
7805 | { | ||
7806 | llSetLinkPrimitiveParamsFast(linknumber, rules); | ||
7243 | ScriptSleep(200); | 7807 | ScriptSleep(200); |
7244 | } | 7808 | } |
7245 | 7809 | ||
7246 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7810 | // vector up using libomv (c&p from sop ) |
7811 | // vector up rotated by r | ||
7812 | private Vector3 Zrot(Quaternion r) | ||
7247 | { | 7813 | { |
7248 | m_host.AddScriptLPS(1); | 7814 | double x, y, z, m; |
7249 | 7815 | ||
7250 | setLinkPrimParams(linknumber, rules); | 7816 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; |
7817 | if (Math.Abs(1.0 - m) > 0.000001) | ||
7818 | { | ||
7819 | m = 1.0 / Math.Sqrt(m); | ||
7820 | r.X *= (float)m; | ||
7821 | r.Y *= (float)m; | ||
7822 | r.Z *= (float)m; | ||
7823 | r.W *= (float)m; | ||
7824 | } | ||
7825 | |||
7826 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
7827 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
7828 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
7829 | |||
7830 | return new Vector3((float)x, (float)y, (float)z); | ||
7251 | } | 7831 | } |
7252 | 7832 | ||
7253 | protected void setLinkPrimParams(int linknumber, LSL_List rules) | 7833 | protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules) |
7254 | { | 7834 | { |
7255 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7835 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7256 | 7836 | ||
7257 | LSL_List remaining = null; | 7837 | int idx = 0; |
7258 | 7838 | ||
7259 | foreach (SceneObjectPart part in parts) | 7839 | bool positionChanged = false; |
7260 | remaining = SetPrimParams(part, rules); | 7840 | Vector3 finalPos = Vector3.Zero; |
7261 | 7841 | ||
7262 | while(remaining != null && remaining.Length > 2) | 7842 | try |
7263 | { | 7843 | { |
7264 | linknumber = remaining.GetLSLIntegerItem(0); | 7844 | while (idx < rules.Length) |
7265 | rules = remaining.GetSublist(1,-1); | 7845 | { |
7266 | parts = GetLinkParts(linknumber); | 7846 | int code = rules.GetLSLIntegerItem(idx++); |
7847 | |||
7848 | int remain = rules.Length - idx; | ||
7267 | 7849 | ||
7268 | foreach (SceneObjectPart part in parts) | 7850 | switch (code) |
7269 | remaining = SetPrimParams(part, rules); | 7851 | { |
7852 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7853 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
7854 | { | ||
7855 | if (remain < 1) | ||
7856 | return null; | ||
7857 | |||
7858 | LSL_Vector v; | ||
7859 | v = rules.GetVector3Item(idx++); | ||
7860 | |||
7861 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7862 | if (part == null) | ||
7863 | break; | ||
7864 | |||
7865 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7866 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7867 | if (part.LinkNum > 1) | ||
7868 | { | ||
7869 | localRot = GetPartLocalRot(part); | ||
7870 | localPos = GetPartLocalPos(part); | ||
7871 | } | ||
7872 | |||
7873 | v -= localPos; | ||
7874 | v /= localRot; | ||
7875 | |||
7876 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
7877 | |||
7878 | v = v + 2 * sitOffset; | ||
7879 | |||
7880 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7881 | av.SendAvatarDataToAllAgents(); | ||
7882 | |||
7883 | } | ||
7884 | break; | ||
7885 | |||
7886 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
7887 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7888 | { | ||
7889 | if (remain < 1) | ||
7890 | return null; | ||
7891 | |||
7892 | LSL_Rotation r; | ||
7893 | r = rules.GetQuaternionItem(idx++); | ||
7894 | |||
7895 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7896 | if (part == null) | ||
7897 | break; | ||
7898 | |||
7899 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7900 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7901 | |||
7902 | if (part.LinkNum > 1) | ||
7903 | localRot = GetPartLocalRot(part); | ||
7904 | |||
7905 | r = r * llGetRootRotation() / localRot; | ||
7906 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7907 | av.SendAvatarDataToAllAgents(); | ||
7908 | } | ||
7909 | break; | ||
7910 | |||
7911 | // parse rest doing nothing but number of parameters error check | ||
7912 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
7913 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
7914 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
7915 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
7916 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
7917 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
7918 | case (int)ScriptBaseClass.PRIM_NAME: | ||
7919 | case (int)ScriptBaseClass.PRIM_DESC: | ||
7920 | if (remain < 1) | ||
7921 | return null; | ||
7922 | idx++; | ||
7923 | break; | ||
7924 | |||
7925 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
7926 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
7927 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
7928 | if (remain < 2) | ||
7929 | return null; | ||
7930 | idx += 2; | ||
7931 | break; | ||
7932 | |||
7933 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
7934 | if (remain < 3) | ||
7935 | return null; | ||
7936 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
7937 | remain = rules.Length - idx; | ||
7938 | switch (code) | ||
7939 | { | ||
7940 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
7941 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
7942 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
7943 | if (remain < 6) | ||
7944 | return null; | ||
7945 | idx += 6; | ||
7946 | break; | ||
7947 | |||
7948 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
7949 | if (remain < 5) | ||
7950 | return null; | ||
7951 | idx += 5; | ||
7952 | break; | ||
7953 | |||
7954 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
7955 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
7956 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
7957 | if (remain < 11) | ||
7958 | return null; | ||
7959 | idx += 11; | ||
7960 | break; | ||
7961 | |||
7962 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
7963 | if (remain < 2) | ||
7964 | return null; | ||
7965 | idx += 2; | ||
7966 | break; | ||
7967 | } | ||
7968 | break; | ||
7969 | |||
7970 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
7971 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
7972 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
7973 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
7974 | if (remain < 3) | ||
7975 | return null; | ||
7976 | idx += 3; | ||
7977 | break; | ||
7978 | |||
7979 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
7980 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
7981 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
7982 | if (remain < 5) | ||
7983 | return null; | ||
7984 | idx += 5; | ||
7985 | break; | ||
7986 | |||
7987 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
7988 | if (remain < 7) | ||
7989 | return null; | ||
7990 | |||
7991 | idx += 7; | ||
7992 | break; | ||
7993 | |||
7994 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
7995 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
7996 | return null; | ||
7997 | |||
7998 | return rules.GetSublist(idx, -1); | ||
7999 | } | ||
8000 | } | ||
8001 | } | ||
8002 | |||
8003 | finally | ||
8004 | { | ||
8005 | if (positionChanged) | ||
8006 | { | ||
8007 | av.OffsetPosition = finalPos; | ||
8008 | // av.SendAvatarDataToAllAgents(); | ||
8009 | av.SendTerseUpdateToAllClients(); | ||
8010 | positionChanged = false; | ||
8011 | } | ||
7270 | } | 8012 | } |
8013 | return null; | ||
7271 | } | 8014 | } |
7272 | 8015 | ||
7273 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) | 8016 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) |
7274 | { | 8017 | { |
8018 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8019 | return null; | ||
8020 | |||
7275 | int idx = 0; | 8021 | int idx = 0; |
7276 | 8022 | ||
8023 | SceneObjectGroup parentgrp = part.ParentGroup; | ||
8024 | |||
7277 | bool positionChanged = false; | 8025 | bool positionChanged = false; |
7278 | LSL_Vector currentPosition = GetPartLocalPos(part); | 8026 | LSL_Vector currentPosition = GetPartLocalPos(part); |
7279 | 8027 | ||
@@ -7296,8 +8044,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7296 | return null; | 8044 | return null; |
7297 | 8045 | ||
7298 | v=rules.GetVector3Item(idx++); | 8046 | v=rules.GetVector3Item(idx++); |
7299 | positionChanged = true; | ||
7300 | currentPosition = GetSetPosTarget(part, v, currentPosition); | 8047 | currentPosition = GetSetPosTarget(part, v, currentPosition); |
8048 | positionChanged = true; | ||
7301 | 8049 | ||
7302 | break; | 8050 | break; |
7303 | case (int)ScriptBaseClass.PRIM_SIZE: | 8051 | case (int)ScriptBaseClass.PRIM_SIZE: |
@@ -7313,8 +8061,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7313 | return null; | 8061 | return null; |
7314 | 8062 | ||
7315 | LSL_Rotation q = rules.GetQuaternionItem(idx++); | 8063 | LSL_Rotation q = rules.GetQuaternionItem(idx++); |
8064 | SceneObjectPart rootPart = parentgrp.RootPart; | ||
7316 | // try to let this work as in SL... | 8065 | // try to let this work as in SL... |
7317 | if (part.ParentID == 0) | 8066 | if (rootPart == part) |
7318 | { | 8067 | { |
7319 | // special case: If we are root, rotate complete SOG to new rotation | 8068 | // special case: If we are root, rotate complete SOG to new rotation |
7320 | SetRot(part, Rot2Quaternion(q)); | 8069 | SetRot(part, Rot2Quaternion(q)); |
@@ -7322,7 +8071,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7322 | else | 8071 | else |
7323 | { | 8072 | { |
7324 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 8073 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
7325 | SceneObjectPart rootPart = part.ParentGroup.RootPart; | 8074 | // sounds like sl bug that we need to replicate |
7326 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); | 8075 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); |
7327 | } | 8076 | } |
7328 | 8077 | ||
@@ -7575,7 +8324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7575 | return null; | 8324 | return null; |
7576 | 8325 | ||
7577 | string ph = rules.Data[idx++].ToString(); | 8326 | string ph = rules.Data[idx++].ToString(); |
7578 | m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); | 8327 | parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); |
7579 | 8328 | ||
7580 | break; | 8329 | break; |
7581 | 8330 | ||
@@ -7593,12 +8342,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7593 | part.ScriptSetPhysicsStatus(physics); | 8342 | part.ScriptSetPhysicsStatus(physics); |
7594 | break; | 8343 | break; |
7595 | 8344 | ||
8345 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
8346 | if (remain < 1) | ||
8347 | return null; | ||
8348 | |||
8349 | int shape_type = rules.GetLSLIntegerItem(idx++); | ||
8350 | |||
8351 | ExtraPhysicsData physdata = new ExtraPhysicsData(); | ||
8352 | physdata.Density = part.Density; | ||
8353 | physdata.Bounce = part.Bounciness; | ||
8354 | physdata.GravitationModifier = part.GravityModifier; | ||
8355 | physdata.PhysShapeType = (PhysShapeType)shape_type; | ||
8356 | |||
8357 | part.UpdateExtraPhysics(physdata); | ||
8358 | |||
8359 | break; | ||
8360 | |||
8361 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
8362 | if (remain < 5) | ||
8363 | return null; | ||
8364 | |||
8365 | int material_bits = rules.GetLSLIntegerItem(idx++); | ||
8366 | float material_density = (float)rules.GetLSLFloatItem(idx++); | ||
8367 | float material_friction = (float)rules.GetLSLFloatItem(idx++); | ||
8368 | float material_restitution = (float)rules.GetLSLFloatItem(idx++); | ||
8369 | float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); | ||
8370 | |||
8371 | SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | ||
8372 | |||
8373 | break; | ||
8374 | |||
7596 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 8375 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: |
7597 | if (remain < 1) | 8376 | if (remain < 1) |
7598 | return null; | 8377 | return null; |
7599 | string temp = rules.Data[idx++].ToString(); | 8378 | string temp = rules.Data[idx++].ToString(); |
7600 | 8379 | ||
7601 | m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); | 8380 | parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); |
7602 | 8381 | ||
7603 | break; | 8382 | break; |
7604 | 8383 | ||
@@ -7671,7 +8450,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7671 | if (part.ParentGroup.RootPart == part) | 8450 | if (part.ParentGroup.RootPart == part) |
7672 | { | 8451 | { |
7673 | SceneObjectGroup parent = part.ParentGroup; | 8452 | SceneObjectGroup parent = part.ParentGroup; |
7674 | parent.UpdateGroupPosition(currentPosition); | 8453 | Util.FireAndForget(delegate(object x) { |
8454 | parent.UpdateGroupPosition(currentPosition); | ||
8455 | }); | ||
7675 | } | 8456 | } |
7676 | else | 8457 | else |
7677 | { | 8458 | { |
@@ -7716,10 +8497,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7716 | 8497 | ||
7717 | public LSL_String llXorBase64Strings(string str1, string str2) | 8498 | public LSL_String llXorBase64Strings(string str1, string str2) |
7718 | { | 8499 | { |
7719 | m_host.AddScriptLPS(1); | 8500 | string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
7720 | Deprecated("llXorBase64Strings"); | 8501 | |
7721 | ScriptSleep(300); | 8502 | ScriptSleep(300); |
7722 | return String.Empty; | 8503 | m_host.AddScriptLPS(1); |
8504 | |||
8505 | if (str1 == String.Empty) | ||
8506 | return String.Empty; | ||
8507 | if (str2 == String.Empty) | ||
8508 | return str1; | ||
8509 | |||
8510 | int len = str2.Length; | ||
8511 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
8512 | { | ||
8513 | while (str2.EndsWith("=")) | ||
8514 | str2 = str2.Substring(0, str2.Length - 1); | ||
8515 | |||
8516 | len = str2.Length; | ||
8517 | int mod = len % 4; | ||
8518 | |||
8519 | if (mod == 1) | ||
8520 | str2 = str2.Substring(0, str2.Length - 1); | ||
8521 | else if (mod == 2) | ||
8522 | str2 += "=="; | ||
8523 | else if (mod == 3) | ||
8524 | str2 += "="; | ||
8525 | } | ||
8526 | |||
8527 | byte[] data1; | ||
8528 | byte[] data2; | ||
8529 | try | ||
8530 | { | ||
8531 | data1 = Convert.FromBase64String(str1); | ||
8532 | data2 = Convert.FromBase64String(str2); | ||
8533 | } | ||
8534 | catch (Exception) | ||
8535 | { | ||
8536 | return new LSL_String(String.Empty); | ||
8537 | } | ||
8538 | |||
8539 | // For cases where the decoded length of s2 is greater | ||
8540 | // than the decoded length of s1, simply perform a normal | ||
8541 | // decode and XOR | ||
8542 | // | ||
8543 | if (data2.Length >= data1.Length) | ||
8544 | { | ||
8545 | for (int pos = 0 ; pos < data1.Length ; pos++ ) | ||
8546 | data1[pos] ^= data2[pos]; | ||
8547 | |||
8548 | return Convert.ToBase64String(data1); | ||
8549 | } | ||
8550 | |||
8551 | // Remove padding | ||
8552 | while (str1.EndsWith("=")) | ||
8553 | str1 = str1.Substring(0, str1.Length - 1); | ||
8554 | while (str2.EndsWith("=")) | ||
8555 | str2 = str2.Substring(0, str2.Length - 1); | ||
8556 | |||
8557 | byte[] d1 = new byte[str1.Length]; | ||
8558 | byte[] d2 = new byte[str2.Length]; | ||
8559 | |||
8560 | for (int i = 0 ; i < str1.Length ; i++) | ||
8561 | { | ||
8562 | int idx = b64.IndexOf(str1.Substring(i, 1)); | ||
8563 | if (idx == -1) | ||
8564 | idx = 0; | ||
8565 | d1[i] = (byte)idx; | ||
8566 | } | ||
8567 | |||
8568 | for (int i = 0 ; i < str2.Length ; i++) | ||
8569 | { | ||
8570 | int idx = b64.IndexOf(str2.Substring(i, 1)); | ||
8571 | if (idx == -1) | ||
8572 | idx = 0; | ||
8573 | d2[i] = (byte)idx; | ||
8574 | } | ||
8575 | |||
8576 | string output = String.Empty; | ||
8577 | |||
8578 | for (int pos = 0 ; pos < d1.Length ; pos++) | ||
8579 | output += b64[d1[pos] ^ d2[pos % d2.Length]]; | ||
8580 | |||
8581 | while (output.Length % 3 > 0) | ||
8582 | output += "="; | ||
8583 | |||
8584 | return output; | ||
7723 | } | 8585 | } |
7724 | 8586 | ||
7725 | public void llRemoteDataSetRegion() | 8587 | public void llRemoteDataSetRegion() |
@@ -7843,13 +8705,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7843 | public LSL_Integer llGetNumberOfPrims() | 8705 | public LSL_Integer llGetNumberOfPrims() |
7844 | { | 8706 | { |
7845 | m_host.AddScriptLPS(1); | 8707 | m_host.AddScriptLPS(1); |
7846 | int avatarCount = 0; | 8708 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; |
7847 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | 8709 | |
7848 | { | ||
7849 | if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID)) | ||
7850 | avatarCount++; | ||
7851 | }); | ||
7852 | |||
7853 | return m_host.ParentGroup.PrimCount + avatarCount; | 8710 | return m_host.ParentGroup.PrimCount + avatarCount; |
7854 | } | 8711 | } |
7855 | 8712 | ||
@@ -7865,55 +8722,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7865 | m_host.AddScriptLPS(1); | 8722 | m_host.AddScriptLPS(1); |
7866 | UUID objID = UUID.Zero; | 8723 | UUID objID = UUID.Zero; |
7867 | LSL_List result = new LSL_List(); | 8724 | LSL_List result = new LSL_List(); |
8725 | |||
8726 | // If the ID is not valid, return null result | ||
7868 | if (!UUID.TryParse(obj, out objID)) | 8727 | if (!UUID.TryParse(obj, out objID)) |
7869 | { | 8728 | { |
7870 | result.Add(new LSL_Vector()); | 8729 | result.Add(new LSL_Vector()); |
7871 | result.Add(new LSL_Vector()); | 8730 | result.Add(new LSL_Vector()); |
7872 | return result; | 8731 | return result; |
7873 | } | 8732 | } |
8733 | |||
8734 | // Check if this is an attached prim. If so, replace | ||
8735 | // the UUID with the avatar UUID and report it's bounding box | ||
8736 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
8737 | if (part != null && part.ParentGroup.IsAttachment) | ||
8738 | objID = part.ParentGroup.AttachedAvatar; | ||
8739 | |||
8740 | // Find out if this is an avatar ID. If so, return it's box | ||
7874 | ScenePresence presence = World.GetScenePresence(objID); | 8741 | ScenePresence presence = World.GetScenePresence(objID); |
7875 | if (presence != null) | 8742 | if (presence != null) |
7876 | { | 8743 | { |
7877 | if (presence.ParentID == 0) // not sat on an object | 8744 | // As per LSL Wiki, there is no difference between sitting |
8745 | // and standing avatar since server 1.36 | ||
8746 | LSL_Vector lower; | ||
8747 | LSL_Vector upper; | ||
8748 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
8749 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7878 | { | 8750 | { |
7879 | LSL_Vector lower; | 8751 | // This is for ground sitting avatars |
7880 | LSL_Vector upper; | 8752 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7881 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 8753 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7882 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 8754 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7883 | { | ||
7884 | // This is for ground sitting avatars | ||
7885 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7886 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7887 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7888 | } | ||
7889 | else | ||
7890 | { | ||
7891 | // This is for standing/flying avatars | ||
7892 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7893 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7894 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7895 | } | ||
7896 | result.Add(lower); | ||
7897 | result.Add(upper); | ||
7898 | return result; | ||
7899 | } | 8755 | } |
7900 | else | 8756 | else |
7901 | { | 8757 | { |
7902 | // sitting on an object so we need the bounding box of that | 8758 | // This is for standing/flying avatars |
7903 | // which should include the avatar so set the UUID to the | 8759 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7904 | // UUID of the object the avatar is sat on and allow it to fall through | 8760 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7905 | // to processing an object | 8761 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7906 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7907 | objID = p.UUID; | ||
7908 | } | 8762 | } |
8763 | |||
8764 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8765 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
8766 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
8767 | |||
8768 | if (lower.x > upper.x) | ||
8769 | lower.x = upper.x; | ||
8770 | if (lower.y > upper.y) | ||
8771 | lower.y = upper.y; | ||
8772 | if (lower.z > upper.z) | ||
8773 | lower.z = upper.z; | ||
8774 | |||
8775 | result.Add(lower); | ||
8776 | result.Add(upper); | ||
8777 | return result; | ||
7909 | } | 8778 | } |
7910 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 8779 | |
8780 | part = World.GetSceneObjectPart(objID); | ||
7911 | // Currently only works for single prims without a sitting avatar | 8781 | // Currently only works for single prims without a sitting avatar |
7912 | if (part != null) | 8782 | if (part != null) |
7913 | { | 8783 | { |
7914 | Vector3 halfSize = part.Scale / 2.0f; | 8784 | float minX; |
7915 | LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f; | 8785 | float maxX; |
7916 | LSL_Vector upper = new LSL_Vector(halfSize); | 8786 | float minY; |
8787 | float maxY; | ||
8788 | float minZ; | ||
8789 | float maxZ; | ||
8790 | |||
8791 | // This BBox is in sim coordinates, with the offset being | ||
8792 | // a contained point. | ||
8793 | Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
8794 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
8795 | |||
8796 | minX -= offsets[0].X; | ||
8797 | maxX -= offsets[0].X; | ||
8798 | minY -= offsets[0].Y; | ||
8799 | maxY -= offsets[0].Y; | ||
8800 | minZ -= offsets[0].Z; | ||
8801 | maxZ -= offsets[0].Z; | ||
8802 | |||
8803 | LSL_Vector lower; | ||
8804 | LSL_Vector upper; | ||
8805 | |||
8806 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8807 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
8808 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
8809 | |||
8810 | if (lower.x > upper.x) | ||
8811 | lower.x = upper.x; | ||
8812 | if (lower.y > upper.y) | ||
8813 | lower.y = upper.y; | ||
8814 | if (lower.z > upper.z) | ||
8815 | lower.z = upper.z; | ||
8816 | |||
7917 | result.Add(lower); | 8817 | result.Add(lower); |
7918 | result.Add(upper); | 8818 | result.Add(upper); |
7919 | return result; | 8819 | return result; |
@@ -7927,7 +8827,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7927 | 8827 | ||
7928 | public LSL_Vector llGetGeometricCenter() | 8828 | public LSL_Vector llGetGeometricCenter() |
7929 | { | 8829 | { |
7930 | return new LSL_Vector(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); | 8830 | Vector3 tmp = m_host.GetGeometricCenter(); |
8831 | return new LSL_Vector(tmp.X, tmp.Y, tmp.Z); | ||
7931 | } | 8832 | } |
7932 | 8833 | ||
7933 | public LSL_List llGetPrimitiveParams(LSL_List rules) | 8834 | public LSL_List llGetPrimitiveParams(LSL_List rules) |
@@ -7940,16 +8841,291 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7940 | { | 8841 | { |
7941 | m_host.AddScriptLPS(1); | 8842 | m_host.AddScriptLPS(1); |
7942 | 8843 | ||
8844 | // acording to SL wiki this must indicate a single link number or link_root or link_this. | ||
8845 | // keep other options as before | ||
8846 | |||
7943 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 8847 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
8848 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7944 | 8849 | ||
7945 | LSL_List res = new LSL_List(); | 8850 | LSL_List res = new LSL_List(); |
7946 | 8851 | ||
7947 | foreach (var part in parts) | 8852 | if (parts.Count > 0) |
8853 | { | ||
8854 | foreach (var part in parts) | ||
8855 | { | ||
8856 | LSL_List partRes = GetLinkPrimitiveParams(part, rules); | ||
8857 | res += partRes; | ||
8858 | } | ||
8859 | } | ||
8860 | if (avatars.Count > 0) | ||
7948 | { | 8861 | { |
7949 | LSL_List partRes = GetLinkPrimitiveParams(part, rules); | 8862 | foreach (ScenePresence avatar in avatars) |
7950 | res += partRes; | 8863 | { |
8864 | LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules); | ||
8865 | res += avaRes; | ||
8866 | } | ||
7951 | } | 8867 | } |
8868 | return res; | ||
8869 | } | ||
8870 | |||
8871 | public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules) | ||
8872 | { | ||
8873 | // avatars case | ||
8874 | // replies as SL wiki | ||
8875 | |||
8876 | LSL_List res = new LSL_List(); | ||
8877 | // SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed | ||
8878 | SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? | ||
8879 | |||
8880 | int idx = 0; | ||
8881 | while (idx < rules.Length) | ||
8882 | { | ||
8883 | int code = (int)rules.GetLSLIntegerItem(idx++); | ||
8884 | int remain = rules.Length - idx; | ||
8885 | |||
8886 | switch (code) | ||
8887 | { | ||
8888 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
8889 | res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); | ||
8890 | break; | ||
8891 | |||
8892 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
8893 | res.Add(new LSL_Integer(0)); | ||
8894 | break; | ||
8895 | |||
8896 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
8897 | res.Add(new LSL_Integer(0)); | ||
8898 | break; | ||
8899 | |||
8900 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
8901 | res.Add(new LSL_Integer(0)); | ||
8902 | break; | ||
8903 | |||
8904 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
8905 | |||
8906 | Vector3 pos = avatar.OffsetPosition; | ||
8907 | |||
8908 | Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
8909 | pos -= sitOffset; | ||
8910 | |||
8911 | if( sitPart != null) | ||
8912 | pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); | ||
8913 | |||
8914 | res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); | ||
8915 | break; | ||
8916 | |||
8917 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
8918 | // as in llGetAgentSize above | ||
8919 | res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); | ||
8920 | break; | ||
8921 | |||
8922 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
8923 | Quaternion rot = avatar.Rotation; | ||
8924 | if (sitPart != null) | ||
8925 | { | ||
8926 | rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation | ||
8927 | } | ||
8928 | |||
8929 | res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); | ||
8930 | break; | ||
8931 | |||
8932 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
8933 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); | ||
8934 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); | ||
8935 | res.Add(new LSL_Vector(0f,1.0f,0f)); | ||
8936 | res.Add(new LSL_Float(0.0f)); | ||
8937 | res.Add(new LSL_Vector(0, 0, 0)); | ||
8938 | res.Add(new LSL_Vector(1.0f,1.0f,0f)); | ||
8939 | res.Add(new LSL_Vector(0, 0, 0)); | ||
8940 | break; | ||
8941 | |||
8942 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
8943 | if (remain < 1) | ||
8944 | return res; | ||
8945 | |||
8946 | int face = (int)rules.GetLSLIntegerItem(idx++); | ||
8947 | if (face == ScriptBaseClass.ALL_SIDES) | ||
8948 | { | ||
8949 | for (face = 0; face < 21; face++) | ||
8950 | { | ||
8951 | res.Add(new LSL_String("")); | ||
8952 | res.Add(new LSL_Vector(0,0,0)); | ||
8953 | res.Add(new LSL_Vector(0,0,0)); | ||
8954 | res.Add(new LSL_Float(0.0)); | ||
8955 | } | ||
8956 | } | ||
8957 | else | ||
8958 | { | ||
8959 | if (face >= 0 && face < 21) | ||
8960 | { | ||
8961 | res.Add(new LSL_String("")); | ||
8962 | res.Add(new LSL_Vector(0,0,0)); | ||
8963 | res.Add(new LSL_Vector(0,0,0)); | ||
8964 | res.Add(new LSL_Float(0.0)); | ||
8965 | } | ||
8966 | } | ||
8967 | break; | ||
8968 | |||
8969 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
8970 | if (remain < 1) | ||
8971 | return res; | ||
8972 | |||
8973 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
8974 | |||
8975 | if (face == ScriptBaseClass.ALL_SIDES) | ||
8976 | { | ||
8977 | for (face = 0; face < 21; face++) | ||
8978 | { | ||
8979 | res.Add(new LSL_Vector(0,0,0)); | ||
8980 | res.Add(new LSL_Float(0)); | ||
8981 | } | ||
8982 | } | ||
8983 | else | ||
8984 | { | ||
8985 | res.Add(new LSL_Vector(0,0,0)); | ||
8986 | res.Add(new LSL_Float(0)); | ||
8987 | } | ||
8988 | break; | ||
8989 | |||
8990 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
8991 | if (remain < 1) | ||
8992 | return res; | ||
8993 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
8994 | |||
8995 | if (face == ScriptBaseClass.ALL_SIDES) | ||
8996 | { | ||
8997 | for (face = 0; face < 21; face++) | ||
8998 | { | ||
8999 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
9000 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
9001 | } | ||
9002 | } | ||
9003 | else | ||
9004 | { | ||
9005 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
9006 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
9007 | } | ||
9008 | break; | ||
9009 | |||
9010 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
9011 | if (remain < 1) | ||
9012 | return res; | ||
9013 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7952 | 9014 | ||
9015 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9016 | { | ||
9017 | for (face = 0; face < 21; face++) | ||
9018 | { | ||
9019 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
9020 | } | ||
9021 | } | ||
9022 | else | ||
9023 | { | ||
9024 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
9025 | } | ||
9026 | break; | ||
9027 | |||
9028 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
9029 | res.Add(new LSL_Integer(0)); | ||
9030 | res.Add(new LSL_Integer(0));// softness | ||
9031 | res.Add(new LSL_Float(0.0f)); // gravity | ||
9032 | res.Add(new LSL_Float(0.0f)); // friction | ||
9033 | res.Add(new LSL_Float(0.0f)); // wind | ||
9034 | res.Add(new LSL_Float(0.0f)); // tension | ||
9035 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9036 | break; | ||
9037 | |||
9038 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
9039 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
9040 | if (remain < 1) | ||
9041 | return res; | ||
9042 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9043 | |||
9044 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9045 | { | ||
9046 | for (face = 0; face < 21; face++) | ||
9047 | { | ||
9048 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9049 | } | ||
9050 | } | ||
9051 | else | ||
9052 | { | ||
9053 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9054 | } | ||
9055 | break; | ||
9056 | |||
9057 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
9058 | res.Add(new LSL_Integer(0)); | ||
9059 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9060 | res.Add(new LSL_Float(0f)); // intensity | ||
9061 | res.Add(new LSL_Float(0f)); // radius | ||
9062 | res.Add(new LSL_Float(0f)); // falloff | ||
9063 | break; | ||
9064 | |||
9065 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
9066 | if (remain < 1) | ||
9067 | return res; | ||
9068 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9069 | |||
9070 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9071 | { | ||
9072 | for (face = 0; face < 21; face++) | ||
9073 | { | ||
9074 | res.Add(new LSL_Float(0f)); | ||
9075 | } | ||
9076 | } | ||
9077 | else | ||
9078 | { | ||
9079 | res.Add(new LSL_Float(0f)); | ||
9080 | } | ||
9081 | break; | ||
9082 | |||
9083 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
9084 | res.Add(new LSL_String("")); | ||
9085 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9086 | res.Add(new LSL_Float(1.0f)); | ||
9087 | break; | ||
9088 | |||
9089 | case (int)ScriptBaseClass.PRIM_NAME: | ||
9090 | res.Add(new LSL_String(avatar.Name)); | ||
9091 | break; | ||
9092 | |||
9093 | case (int)ScriptBaseClass.PRIM_DESC: | ||
9094 | res.Add(new LSL_String("")); | ||
9095 | break; | ||
9096 | |||
9097 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
9098 | Quaternion lrot = avatar.Rotation; | ||
9099 | |||
9100 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
9101 | { | ||
9102 | lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset | ||
9103 | } | ||
9104 | res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); | ||
9105 | break; | ||
9106 | |||
9107 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
9108 | Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part | ||
9109 | Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
9110 | lpos -= lsitOffset; | ||
9111 | |||
9112 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
9113 | { | ||
9114 | lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim | ||
9115 | } | ||
9116 | res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); | ||
9117 | break; | ||
9118 | |||
9119 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
9120 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
9121 | return res; | ||
9122 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | ||
9123 | LSL_List new_rules = rules.GetSublist(idx, -1); | ||
9124 | |||
9125 | res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules); | ||
9126 | return res; | ||
9127 | } | ||
9128 | } | ||
7953 | return res; | 9129 | return res; |
7954 | } | 9130 | } |
7955 | 9131 | ||
@@ -7993,13 +9169,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7993 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, | 9169 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
7994 | part.AbsolutePosition.Y, | 9170 | part.AbsolutePosition.Y, |
7995 | part.AbsolutePosition.Z); | 9171 | part.AbsolutePosition.Z); |
7996 | // For some reason, the part.AbsolutePosition.* values do not change if the | ||
7997 | // linkset is rotated; they always reflect the child prim's world position | ||
7998 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
7999 | // implementation, so will break scripts imported from there (not to mention it | ||
8000 | // makes it more difficult to determine a child prim's actual inworld position). | ||
8001 | if (part.ParentID != 0) | ||
8002 | v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); | ||
8003 | res.Add(v); | 9172 | res.Add(v); |
8004 | break; | 9173 | break; |
8005 | 9174 | ||
@@ -8170,56 +9339,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8170 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 9339 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
8171 | if (remain < 1) | 9340 | if (remain < 1) |
8172 | return res; | 9341 | return res; |
8173 | 9342 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8174 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8175 | 9343 | ||
8176 | tex = part.Shape.Textures; | 9344 | tex = part.Shape.Textures; |
9345 | int shiny; | ||
8177 | if (face == ScriptBaseClass.ALL_SIDES) | 9346 | if (face == ScriptBaseClass.ALL_SIDES) |
8178 | { | 9347 | { |
8179 | for (face = 0; face < GetNumberOfSides(part); face++) | 9348 | for (face = 0; face < GetNumberOfSides(part); face++) |
8180 | { | 9349 | { |
8181 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9350 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
8182 | // Convert Shininess to PRIM_SHINY_* | 9351 | if (shinyness == Shininess.High) |
8183 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 9352 | { |
8184 | // PRIM_BUMP_* | 9353 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8185 | res.Add(new LSL_Integer((int)texface.Bump)); | 9354 | } |
9355 | else if (shinyness == Shininess.Medium) | ||
9356 | { | ||
9357 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
9358 | } | ||
9359 | else if (shinyness == Shininess.Low) | ||
9360 | { | ||
9361 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
9362 | } | ||
9363 | else | ||
9364 | { | ||
9365 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
9366 | } | ||
9367 | res.Add(new LSL_Integer(shiny)); | ||
9368 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8186 | } | 9369 | } |
8187 | } | 9370 | } |
8188 | else | 9371 | else |
8189 | { | 9372 | { |
8190 | if (face >= 0 && face < GetNumberOfSides(part)) | 9373 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
9374 | if (shinyness == Shininess.High) | ||
8191 | { | 9375 | { |
8192 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9376 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8193 | // Convert Shininess to PRIM_SHINY_* | 9377 | } |
8194 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 9378 | else if (shinyness == Shininess.Medium) |
8195 | // PRIM_BUMP_* | 9379 | { |
8196 | res.Add(new LSL_Integer((int)texface.Bump)); | 9380 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; |
9381 | } | ||
9382 | else if (shinyness == Shininess.Low) | ||
9383 | { | ||
9384 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
9385 | } | ||
9386 | else | ||
9387 | { | ||
9388 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8197 | } | 9389 | } |
9390 | res.Add(new LSL_Integer(shiny)); | ||
9391 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8198 | } | 9392 | } |
8199 | break; | 9393 | break; |
8200 | 9394 | ||
8201 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 9395 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
8202 | if (remain < 1) | 9396 | if (remain < 1) |
8203 | return res; | 9397 | return res; |
8204 | 9398 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8205 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8206 | 9399 | ||
8207 | tex = part.Shape.Textures; | 9400 | tex = part.Shape.Textures; |
9401 | int fullbright; | ||
8208 | if (face == ScriptBaseClass.ALL_SIDES) | 9402 | if (face == ScriptBaseClass.ALL_SIDES) |
8209 | { | 9403 | { |
8210 | for (face = 0; face < GetNumberOfSides(part); face++) | 9404 | for (face = 0; face < GetNumberOfSides(part); face++) |
8211 | { | 9405 | { |
8212 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9406 | if (tex.GetFace((uint)face).Fullbright == true) |
8213 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 9407 | { |
9408 | fullbright = ScriptBaseClass.TRUE; | ||
9409 | } | ||
9410 | else | ||
9411 | { | ||
9412 | fullbright = ScriptBaseClass.FALSE; | ||
9413 | } | ||
9414 | res.Add(new LSL_Integer(fullbright)); | ||
8214 | } | 9415 | } |
8215 | } | 9416 | } |
8216 | else | 9417 | else |
8217 | { | 9418 | { |
8218 | if (face >= 0 && face < GetNumberOfSides(part)) | 9419 | if (tex.GetFace((uint)face).Fullbright == true) |
8219 | { | 9420 | { |
8220 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9421 | fullbright = ScriptBaseClass.TRUE; |
8221 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 9422 | } |
9423 | else | ||
9424 | { | ||
9425 | fullbright = ScriptBaseClass.FALSE; | ||
8222 | } | 9426 | } |
9427 | res.Add(new LSL_Integer(fullbright)); | ||
8223 | } | 9428 | } |
8224 | break; | 9429 | break; |
8225 | 9430 | ||
@@ -8241,27 +9446,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8241 | break; | 9446 | break; |
8242 | 9447 | ||
8243 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 9448 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
9449 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
8244 | if (remain < 1) | 9450 | if (remain < 1) |
8245 | return res; | 9451 | return res; |
8246 | 9452 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8247 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8248 | 9453 | ||
8249 | tex = part.Shape.Textures; | 9454 | tex = part.Shape.Textures; |
8250 | if (face == ScriptBaseClass.ALL_SIDES) | 9455 | if (face == ScriptBaseClass.ALL_SIDES) |
8251 | { | 9456 | { |
8252 | for (face = 0; face < GetNumberOfSides(part); face++) | 9457 | for (face = 0; face < GetNumberOfSides(part); face++) |
8253 | { | 9458 | { |
8254 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 9459 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8255 | // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. | 9460 | { |
8256 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 9461 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
9462 | } | ||
9463 | else | ||
9464 | { | ||
9465 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9466 | } | ||
8257 | } | 9467 | } |
8258 | } | 9468 | } |
8259 | else | 9469 | else |
8260 | { | 9470 | { |
8261 | if (face >= 0 && face < GetNumberOfSides(part)) | 9471 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
9472 | { | ||
9473 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
9474 | } | ||
9475 | else | ||
8262 | { | 9476 | { |
8263 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 9477 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); |
8264 | res.Add(new LSL_Integer((uint)texgen >> 1)); | ||
8265 | } | 9478 | } |
8266 | } | 9479 | } |
8267 | break; | 9480 | break; |
@@ -8284,25 +9497,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8284 | case (int)ScriptBaseClass.PRIM_GLOW: | 9497 | case (int)ScriptBaseClass.PRIM_GLOW: |
8285 | if (remain < 1) | 9498 | if (remain < 1) |
8286 | return res; | 9499 | return res; |
8287 | 9500 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8288 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8289 | 9501 | ||
8290 | tex = part.Shape.Textures; | 9502 | tex = part.Shape.Textures; |
9503 | float primglow; | ||
8291 | if (face == ScriptBaseClass.ALL_SIDES) | 9504 | if (face == ScriptBaseClass.ALL_SIDES) |
8292 | { | 9505 | { |
8293 | for (face = 0; face < GetNumberOfSides(part); face++) | 9506 | for (face = 0; face < GetNumberOfSides(part); face++) |
8294 | { | 9507 | { |
8295 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9508 | primglow = tex.GetFace((uint)face).Glow; |
8296 | res.Add(new LSL_Float(texface.Glow)); | 9509 | res.Add(new LSL_Float(primglow)); |
8297 | } | 9510 | } |
8298 | } | 9511 | } |
8299 | else | 9512 | else |
8300 | { | 9513 | { |
8301 | if (face >= 0 && face < GetNumberOfSides(part)) | 9514 | primglow = tex.GetFace((uint)face).Glow; |
8302 | { | 9515 | res.Add(new LSL_Float(primglow)); |
8303 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
8304 | res.Add(new LSL_Float(texface.Glow)); | ||
8305 | } | ||
8306 | } | 9516 | } |
8307 | break; | 9517 | break; |
8308 | 9518 | ||
@@ -8314,18 +9524,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8314 | textColor.B)); | 9524 | textColor.B)); |
8315 | res.Add(new LSL_Float(textColor.A)); | 9525 | res.Add(new LSL_Float(textColor.A)); |
8316 | break; | 9526 | break; |
9527 | |||
8317 | case (int)ScriptBaseClass.PRIM_NAME: | 9528 | case (int)ScriptBaseClass.PRIM_NAME: |
8318 | res.Add(new LSL_String(part.Name)); | 9529 | res.Add(new LSL_String(part.Name)); |
8319 | break; | 9530 | break; |
9531 | |||
8320 | case (int)ScriptBaseClass.PRIM_DESC: | 9532 | case (int)ScriptBaseClass.PRIM_DESC: |
8321 | res.Add(new LSL_String(part.Description)); | 9533 | res.Add(new LSL_String(part.Description)); |
8322 | break; | 9534 | break; |
9535 | |||
8323 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 9536 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8324 | res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); | 9537 | res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); |
8325 | break; | 9538 | break; |
9539 | |||
8326 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 9540 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
8327 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 9541 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
8328 | break; | 9542 | break; |
9543 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
9544 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
9545 | return res; | ||
9546 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | ||
9547 | LSL_List new_rules = rules.GetSublist(idx, -1); | ||
9548 | LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); | ||
9549 | res += tres; | ||
9550 | return res; | ||
8329 | case (int)ScriptBaseClass.PRIM_SLICE: | 9551 | case (int)ScriptBaseClass.PRIM_SLICE: |
8330 | PrimType prim_type = part.GetPrimType(); | 9552 | PrimType prim_type = part.GetPrimType(); |
8331 | bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); | 9553 | bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); |
@@ -8927,8 +10149,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8927 | // The function returns an ordered list | 10149 | // The function returns an ordered list |
8928 | // representing the tokens found in the supplied | 10150 | // representing the tokens found in the supplied |
8929 | // sources string. If two successive tokenizers | 10151 | // sources string. If two successive tokenizers |
8930 | // are encountered, then a NULL entry is added | 10152 | // are encountered, then a null-string entry is |
8931 | // to the list. | 10153 | // added to the list. |
8932 | // | 10154 | // |
8933 | // It is a precondition that the source and | 10155 | // It is a precondition that the source and |
8934 | // toekizer lisst are non-null. If they are null, | 10156 | // toekizer lisst are non-null. If they are null, |
@@ -8936,7 +10158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8936 | // while their lengths are being determined. | 10158 | // while their lengths are being determined. |
8937 | // | 10159 | // |
8938 | // A small amount of working memoryis required | 10160 | // A small amount of working memoryis required |
8939 | // of approximately 8*#tokenizers. | 10161 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8940 | // | 10162 | // |
8941 | // There are many ways in which this function | 10163 | // There are many ways in which this function |
8942 | // can be implemented, this implementation is | 10164 | // can be implemented, this implementation is |
@@ -8952,155 +10174,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8952 | // and eliminates redundant tokenizers as soon | 10174 | // and eliminates redundant tokenizers as soon |
8953 | // as is possible. | 10175 | // as is possible. |
8954 | // | 10176 | // |
8955 | // The implementation tries to avoid any copying | 10177 | // The implementation tries to minimize temporary |
8956 | // of arrays or other objects. | 10178 | // garbage generation. |
8957 | // </remarks> | 10179 | // </remarks> |
8958 | 10180 | ||
8959 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 10181 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8960 | { | 10182 | { |
8961 | int beginning = 0; | 10183 | return ParseString2List(src, separators, spacers, true); |
8962 | int srclen = src.Length; | 10184 | } |
8963 | int seplen = separators.Length; | ||
8964 | object[] separray = separators.Data; | ||
8965 | int spclen = spacers.Length; | ||
8966 | object[] spcarray = spacers.Data; | ||
8967 | int mlen = seplen+spclen; | ||
8968 | |||
8969 | int[] offset = new int[mlen+1]; | ||
8970 | bool[] active = new bool[mlen]; | ||
8971 | |||
8972 | int best; | ||
8973 | int j; | ||
8974 | |||
8975 | // Initial capacity reduces resize cost | ||
8976 | 10185 | ||
8977 | LSL_List tokens = new LSL_List(); | 10186 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
10187 | { | ||
10188 | int srclen = src.Length; | ||
10189 | int seplen = separators.Length; | ||
10190 | object[] separray = separators.Data; | ||
10191 | int spclen = spacers.Length; | ||
10192 | object[] spcarray = spacers.Data; | ||
10193 | int dellen = 0; | ||
10194 | string[] delarray = new string[seplen+spclen]; | ||
8978 | 10195 | ||
8979 | // All entries are initially valid | 10196 | int outlen = 0; |
10197 | string[] outarray = new string[srclen*2+1]; | ||
8980 | 10198 | ||
8981 | for (int i = 0; i < mlen; i++) | 10199 | int i, j; |
8982 | active[i] = true; | 10200 | string d; |
8983 | 10201 | ||
8984 | offset[mlen] = srclen; | 10202 | m_host.AddScriptLPS(1); |
8985 | 10203 | ||
8986 | while (beginning < srclen) | 10204 | /* |
10205 | * Convert separator and spacer lists to C# strings. | ||
10206 | * Also filter out null strings so we don't hang. | ||
10207 | */ | ||
10208 | for (i = 0; i < seplen; i ++) | ||
8987 | { | 10209 | { |
10210 | d = separray[i].ToString(); | ||
10211 | if (d.Length > 0) | ||
10212 | { | ||
10213 | delarray[dellen++] = d; | ||
10214 | } | ||
10215 | } | ||
10216 | seplen = dellen; | ||
8988 | 10217 | ||
8989 | best = mlen; // as bad as it gets | 10218 | for (i = 0; i < spclen; i ++) |
10219 | { | ||
10220 | d = spcarray[i].ToString(); | ||
10221 | if (d.Length > 0) | ||
10222 | { | ||
10223 | delarray[dellen++] = d; | ||
10224 | } | ||
10225 | } | ||
8990 | 10226 | ||
8991 | // Scan for separators | 10227 | /* |
10228 | * Scan through source string from beginning to end. | ||
10229 | */ | ||
10230 | for (i = 0;;) | ||
10231 | { | ||
8992 | 10232 | ||
8993 | for (j = 0; j < seplen; j++) | 10233 | /* |
10234 | * Find earliest delimeter in src starting at i (if any). | ||
10235 | */ | ||
10236 | int earliestDel = -1; | ||
10237 | int earliestSrc = srclen; | ||
10238 | string earliestStr = null; | ||
10239 | for (j = 0; j < dellen; j ++) | ||
8994 | { | 10240 | { |
8995 | if (separray[j].ToString() == String.Empty) | 10241 | d = delarray[j]; |
8996 | active[j] = false; | 10242 | if (d != null) |
8997 | |||
8998 | if (active[j]) | ||
8999 | { | 10243 | { |
9000 | // scan all of the markers | 10244 | int index = src.IndexOf(d, i); |
9001 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 10245 | if (index < 0) |
9002 | { | 10246 | { |
9003 | // not present at all | 10247 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
9004 | active[j] = false; | ||
9005 | } | 10248 | } |
9006 | else | 10249 | else if (index < earliestSrc) |
9007 | { | 10250 | { |
9008 | // present and correct | 10251 | earliestSrc = index; // where delimeter starts in source string |
9009 | if (offset[j] < offset[best]) | 10252 | earliestDel = j; // where delimeter is in delarray[] |
9010 | { | 10253 | earliestStr = d; // the delimeter string from delarray[] |
9011 | // closest so far | 10254 | if (index == i) break; // can't do any better than found at beg of string |
9012 | best = j; | ||
9013 | if (offset[best] == beginning) | ||
9014 | break; | ||
9015 | } | ||
9016 | } | 10255 | } |
9017 | } | 10256 | } |
9018 | } | 10257 | } |
9019 | 10258 | ||
9020 | // Scan for spacers | 10259 | /* |
9021 | 10260 | * Output source string starting at i through start of earliest delimeter. | |
9022 | if (offset[best] != beginning) | 10261 | */ |
10262 | if (keepNulls || (earliestSrc > i)) | ||
9023 | { | 10263 | { |
9024 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 10264 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
9025 | { | ||
9026 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
9027 | active[j] = false; | ||
9028 | |||
9029 | if (active[j]) | ||
9030 | { | ||
9031 | // scan all of the markers | ||
9032 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
9033 | { | ||
9034 | // not present at all | ||
9035 | active[j] = false; | ||
9036 | } | ||
9037 | else | ||
9038 | { | ||
9039 | // present and correct | ||
9040 | if (offset[j] < offset[best]) | ||
9041 | { | ||
9042 | // closest so far | ||
9043 | best = j; | ||
9044 | } | ||
9045 | } | ||
9046 | } | ||
9047 | } | ||
9048 | } | 10265 | } |
9049 | 10266 | ||
9050 | // This is the normal exit from the scanning loop | 10267 | /* |
10268 | * If no delimeter found at or after i, we're done scanning. | ||
10269 | */ | ||
10270 | if (earliestDel < 0) break; | ||
9051 | 10271 | ||
9052 | if (best == mlen) | 10272 | /* |
10273 | * If delimeter was a spacer, output the spacer. | ||
10274 | */ | ||
10275 | if (earliestDel >= seplen) | ||
9053 | { | 10276 | { |
9054 | // no markers were found on this pass | 10277 | outarray[outlen++] = earliestStr; |
9055 | // so we're pretty much done | ||
9056 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
9057 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
9058 | break; | ||
9059 | } | 10278 | } |
9060 | 10279 | ||
9061 | // Otherwise we just add the newly delimited token | 10280 | /* |
9062 | // and recalculate where the search should continue. | 10281 | * Look at rest of src string following delimeter. |
9063 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 10282 | */ |
9064 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 10283 | i = earliestSrc + earliestStr.Length; |
9065 | |||
9066 | if (best < seplen) | ||
9067 | { | ||
9068 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
9069 | } | ||
9070 | else | ||
9071 | { | ||
9072 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
9073 | string str = spcarray[best - seplen].ToString(); | ||
9074 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
9075 | tokens.Add(new LSL_String(str)); | ||
9076 | } | ||
9077 | } | 10284 | } |
9078 | 10285 | ||
9079 | // This an awkward an not very intuitive boundary case. If the | 10286 | /* |
9080 | // last substring is a tokenizer, then there is an implied trailing | 10287 | * Make up an exact-sized output array suitable for an LSL_List object. |
9081 | // null list entry. Hopefully the single comparison will not be too | 10288 | */ |
9082 | // arduous. Alternatively the 'break' could be replced with a return | 10289 | object[] outlist = new object[outlen]; |
9083 | // but that's shabby programming. | 10290 | for (i = 0; i < outlen; i ++) |
9084 | |||
9085 | if ((beginning == srclen) && (keepNulls)) | ||
9086 | { | 10291 | { |
9087 | if (srclen != 0) | 10292 | outlist[i] = new LSL_String(outarray[i]); |
9088 | tokens.Add(new LSL_String("")); | ||
9089 | } | 10293 | } |
9090 | 10294 | return new LSL_List(outlist); | |
9091 | return tokens; | ||
9092 | } | ||
9093 | |||
9094 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
9095 | { | ||
9096 | m_host.AddScriptLPS(1); | ||
9097 | return this.ParseString(src, separators, spacers, false); | ||
9098 | } | ||
9099 | |||
9100 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
9101 | { | ||
9102 | m_host.AddScriptLPS(1); | ||
9103 | return this.ParseString(src, separators, spacers, true); | ||
9104 | } | 10295 | } |
9105 | 10296 | ||
9106 | public LSL_Integer llGetObjectPermMask(int mask) | 10297 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -9195,6 +10386,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9195 | case 4: | 10386 | case 4: |
9196 | return (int)item.NextPermissions; | 10387 | return (int)item.NextPermissions; |
9197 | } | 10388 | } |
10389 | m_host.TaskInventory.LockItemsForRead(false); | ||
9198 | 10390 | ||
9199 | return -1; | 10391 | return -1; |
9200 | } | 10392 | } |
@@ -9385,9 +10577,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9385 | { | 10577 | { |
9386 | try | 10578 | try |
9387 | { | 10579 | { |
10580 | /* | ||
9388 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | 10581 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); |
9389 | if (obj != null) | 10582 | if (obj != null) |
9390 | return (double)obj.GetMass(); | 10583 | return (double)obj.GetMass(); |
10584 | */ | ||
10585 | // return total object mass | ||
10586 | SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId); | ||
10587 | if (obj != null) | ||
10588 | return obj.GetMass(); | ||
10589 | |||
9391 | // the object is null so the key is for an avatar | 10590 | // the object is null so the key is for an avatar |
9392 | ScenePresence avatar = World.GetScenePresence(key); | 10591 | ScenePresence avatar = World.GetScenePresence(key); |
9393 | if (avatar != null) | 10592 | if (avatar != null) |
@@ -9407,7 +10606,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9407 | } | 10606 | } |
9408 | 10607 | ||
9409 | /// <summary> | 10608 | /// <summary> |
9410 | /// illListReplaceList removes the sub-list defined by the inclusive indices | 10609 | /// llListReplaceList removes the sub-list defined by the inclusive indices |
9411 | /// start and end and inserts the src list in its place. The inclusive | 10610 | /// start and end and inserts the src list in its place. The inclusive |
9412 | /// nature of the indices means that at least one element must be deleted | 10611 | /// nature of the indices means that at least one element must be deleted |
9413 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | 10612 | /// if the indices are within the bounds of the existing list. I.e. 2,2 |
@@ -9464,16 +10663,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9464 | // based upon end. Note that if end exceeds the upper | 10663 | // based upon end. Note that if end exceeds the upper |
9465 | // bound in this case, the entire destination list | 10664 | // bound in this case, the entire destination list |
9466 | // is removed. | 10665 | // is removed. |
9467 | else | 10666 | else if (start == 0) |
9468 | { | 10667 | { |
9469 | if (end + 1 < dest.Length) | 10668 | if (end + 1 < dest.Length) |
9470 | { | ||
9471 | return src + dest.GetSublist(end + 1, -1); | 10669 | return src + dest.GetSublist(end + 1, -1); |
9472 | } | ||
9473 | else | 10670 | else |
9474 | { | ||
9475 | return src; | 10671 | return src; |
9476 | } | 10672 | } |
10673 | else // Start < 0 | ||
10674 | { | ||
10675 | if (end + 1 < dest.Length) | ||
10676 | return dest.GetSublist(end + 1, -1); | ||
10677 | else | ||
10678 | return new LSL_List(); | ||
9477 | } | 10679 | } |
9478 | } | 10680 | } |
9479 | // Finally, if start > end, we strip away a prefix and | 10681 | // Finally, if start > end, we strip away a prefix and |
@@ -9524,17 +10726,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9524 | int width = 0; | 10726 | int width = 0; |
9525 | int height = 0; | 10727 | int height = 0; |
9526 | 10728 | ||
9527 | ParcelMediaCommandEnum? commandToSend = null; | 10729 | uint commandToSend = 0; |
9528 | float time = 0.0f; // default is from start | 10730 | float time = 0.0f; // default is from start |
9529 | 10731 | ||
9530 | ScenePresence presence = null; | 10732 | ScenePresence presence = null; |
9531 | 10733 | ||
9532 | for (int i = 0; i < commandList.Data.Length; i++) | 10734 | for (int i = 0; i < commandList.Data.Length; i++) |
9533 | { | 10735 | { |
9534 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 10736 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
9535 | switch (command) | 10737 | switch (command) |
9536 | { | 10738 | { |
9537 | case ParcelMediaCommandEnum.Agent: | 10739 | case (uint)ParcelMediaCommandEnum.Agent: |
9538 | // we send only to one agent | 10740 | // we send only to one agent |
9539 | if ((i + 1) < commandList.Length) | 10741 | if ((i + 1) < commandList.Length) |
9540 | { | 10742 | { |
@@ -9551,25 +10753,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9551 | } | 10753 | } |
9552 | break; | 10754 | break; |
9553 | 10755 | ||
9554 | case ParcelMediaCommandEnum.Loop: | 10756 | case (uint)ParcelMediaCommandEnum.Loop: |
9555 | loop = 1; | 10757 | loop = 1; |
9556 | commandToSend = command; | 10758 | commandToSend = command; |
9557 | update = true; //need to send the media update packet to set looping | 10759 | update = true; //need to send the media update packet to set looping |
9558 | break; | 10760 | break; |
9559 | 10761 | ||
9560 | case ParcelMediaCommandEnum.Play: | 10762 | case (uint)ParcelMediaCommandEnum.Play: |
9561 | loop = 0; | 10763 | loop = 0; |
9562 | commandToSend = command; | 10764 | commandToSend = command; |
9563 | update = true; //need to send the media update packet to make sure it doesn't loop | 10765 | update = true; //need to send the media update packet to make sure it doesn't loop |
9564 | break; | 10766 | break; |
9565 | 10767 | ||
9566 | case ParcelMediaCommandEnum.Pause: | 10768 | case (uint)ParcelMediaCommandEnum.Pause: |
9567 | case ParcelMediaCommandEnum.Stop: | 10769 | case (uint)ParcelMediaCommandEnum.Stop: |
9568 | case ParcelMediaCommandEnum.Unload: | 10770 | case (uint)ParcelMediaCommandEnum.Unload: |
9569 | commandToSend = command; | 10771 | commandToSend = command; |
9570 | break; | 10772 | break; |
9571 | 10773 | ||
9572 | case ParcelMediaCommandEnum.Url: | 10774 | case (uint)ParcelMediaCommandEnum.Url: |
9573 | if ((i + 1) < commandList.Length) | 10775 | if ((i + 1) < commandList.Length) |
9574 | { | 10776 | { |
9575 | if (commandList.Data[i + 1] is LSL_String) | 10777 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9582,7 +10784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9582 | } | 10784 | } |
9583 | break; | 10785 | break; |
9584 | 10786 | ||
9585 | case ParcelMediaCommandEnum.Texture: | 10787 | case (uint)ParcelMediaCommandEnum.Texture: |
9586 | if ((i + 1) < commandList.Length) | 10788 | if ((i + 1) < commandList.Length) |
9587 | { | 10789 | { |
9588 | if (commandList.Data[i + 1] is LSL_String) | 10790 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9595,7 +10797,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9595 | } | 10797 | } |
9596 | break; | 10798 | break; |
9597 | 10799 | ||
9598 | case ParcelMediaCommandEnum.Time: | 10800 | case (uint)ParcelMediaCommandEnum.Time: |
9599 | if ((i + 1) < commandList.Length) | 10801 | if ((i + 1) < commandList.Length) |
9600 | { | 10802 | { |
9601 | if (commandList.Data[i + 1] is LSL_Float) | 10803 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9607,7 +10809,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9607 | } | 10809 | } |
9608 | break; | 10810 | break; |
9609 | 10811 | ||
9610 | case ParcelMediaCommandEnum.AutoAlign: | 10812 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9611 | if ((i + 1) < commandList.Length) | 10813 | if ((i + 1) < commandList.Length) |
9612 | { | 10814 | { |
9613 | if (commandList.Data[i + 1] is LSL_Integer) | 10815 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9621,7 +10823,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9621 | } | 10823 | } |
9622 | break; | 10824 | break; |
9623 | 10825 | ||
9624 | case ParcelMediaCommandEnum.Type: | 10826 | case (uint)ParcelMediaCommandEnum.Type: |
9625 | if ((i + 1) < commandList.Length) | 10827 | if ((i + 1) < commandList.Length) |
9626 | { | 10828 | { |
9627 | if (commandList.Data[i + 1] is LSL_String) | 10829 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9634,7 +10836,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9634 | } | 10836 | } |
9635 | break; | 10837 | break; |
9636 | 10838 | ||
9637 | case ParcelMediaCommandEnum.Desc: | 10839 | case (uint)ParcelMediaCommandEnum.Desc: |
9638 | if ((i + 1) < commandList.Length) | 10840 | if ((i + 1) < commandList.Length) |
9639 | { | 10841 | { |
9640 | if (commandList.Data[i + 1] is LSL_String) | 10842 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9647,7 +10849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9647 | } | 10849 | } |
9648 | break; | 10850 | break; |
9649 | 10851 | ||
9650 | case ParcelMediaCommandEnum.Size: | 10852 | case (uint)ParcelMediaCommandEnum.Size: |
9651 | if ((i + 2) < commandList.Length) | 10853 | if ((i + 2) < commandList.Length) |
9652 | { | 10854 | { |
9653 | if (commandList.Data[i + 1] is LSL_Integer) | 10855 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9717,7 +10919,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9717 | } | 10919 | } |
9718 | } | 10920 | } |
9719 | 10921 | ||
9720 | if (commandToSend != null) | 10922 | if (commandToSend != 0) |
9721 | { | 10923 | { |
9722 | // the commandList contained a start/stop/... command, too | 10924 | // the commandList contained a start/stop/... command, too |
9723 | if (presence == null) | 10925 | if (presence == null) |
@@ -9754,7 +10956,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9754 | 10956 | ||
9755 | if (aList.Data[i] != null) | 10957 | if (aList.Data[i] != null) |
9756 | { | 10958 | { |
9757 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 10959 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9758 | { | 10960 | { |
9759 | case ParcelMediaCommandEnum.Url: | 10961 | case ParcelMediaCommandEnum.Url: |
9760 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 10962 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9811,15 +11013,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9811 | 11013 | ||
9812 | if (quick_pay_buttons.Data.Length < 4) | 11014 | if (quick_pay_buttons.Data.Length < 4) |
9813 | { | 11015 | { |
9814 | LSLError("List must have at least 4 elements"); | 11016 | int x; |
9815 | return; | 11017 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
11018 | { | ||
11019 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
11020 | } | ||
9816 | } | 11021 | } |
9817 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 11022 | int[] nPrice = new int[5]; |
9818 | 11023 | nPrice[0] = price; | |
9819 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 11024 | nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); |
9820 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 11025 | nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); |
9821 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 11026 | nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); |
9822 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 11027 | nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); |
11028 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9823 | m_host.ParentGroup.HasGroupChanged = true; | 11029 | m_host.ParentGroup.HasGroupChanged = true; |
9824 | } | 11030 | } |
9825 | 11031 | ||
@@ -9836,7 +11042,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9836 | return new LSL_Vector(); | 11042 | return new LSL_Vector(); |
9837 | } | 11043 | } |
9838 | 11044 | ||
9839 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 11045 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
11046 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9840 | if (presence != null) | 11047 | if (presence != null) |
9841 | { | 11048 | { |
9842 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); | 11049 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); |
@@ -9858,7 +11065,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9858 | return new LSL_Rotation(); | 11065 | return new LSL_Rotation(); |
9859 | } | 11066 | } |
9860 | 11067 | ||
9861 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 11068 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
11069 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9862 | if (presence != null) | 11070 | if (presence != null) |
9863 | { | 11071 | { |
9864 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); | 11072 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); |
@@ -9918,14 +11126,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9918 | { | 11126 | { |
9919 | m_host.AddScriptLPS(1); | 11127 | m_host.AddScriptLPS(1); |
9920 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); | 11128 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
9921 | if (detectedParams == null) return; // only works on the first detected avatar | 11129 | if (detectedParams == null) |
9922 | 11130 | { | |
11131 | if (m_host.ParentGroup.IsAttachment == true) | ||
11132 | { | ||
11133 | detectedParams = new DetectParams(); | ||
11134 | detectedParams.Key = m_host.OwnerID; | ||
11135 | } | ||
11136 | else | ||
11137 | { | ||
11138 | return; | ||
11139 | } | ||
11140 | } | ||
11141 | |||
9923 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 11142 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9924 | if (avatar != null) | 11143 | if (avatar != null) |
9925 | { | 11144 | { |
9926 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, | 11145 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, |
9927 | simname, pos, lookAt); | 11146 | simname, pos, lookAt); |
9928 | } | 11147 | } |
11148 | |||
9929 | ScriptSleep(1000); | 11149 | ScriptSleep(1000); |
9930 | } | 11150 | } |
9931 | 11151 | ||
@@ -10049,12 +11269,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10049 | 11269 | ||
10050 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | 11270 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); |
10051 | object[] data = rules.Data; | 11271 | object[] data = rules.Data; |
10052 | for (int i = 0; i < data.Length; ++i) { | 11272 | for (int i = 0; i < data.Length; ++i) |
11273 | { | ||
10053 | int type = Convert.ToInt32(data[i++].ToString()); | 11274 | int type = Convert.ToInt32(data[i++].ToString()); |
10054 | if (i >= data.Length) break; // odd number of entries => ignore the last | 11275 | if (i >= data.Length) break; // odd number of entries => ignore the last |
10055 | 11276 | ||
10056 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 11277 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
10057 | switch (type) { | 11278 | switch (type) |
11279 | { | ||
10058 | case ScriptBaseClass.CAMERA_FOCUS: | 11280 | case ScriptBaseClass.CAMERA_FOCUS: |
10059 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | 11281 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: |
10060 | case ScriptBaseClass.CAMERA_POSITION: | 11282 | case ScriptBaseClass.CAMERA_POSITION: |
@@ -10160,19 +11382,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10160 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 11382 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
10161 | { | 11383 | { |
10162 | m_host.AddScriptLPS(1); | 11384 | m_host.AddScriptLPS(1); |
10163 | string ret = String.Empty; | 11385 | |
10164 | string src1 = llBase64ToString(str1); | 11386 | if (str1 == String.Empty) |
10165 | string src2 = llBase64ToString(str2); | 11387 | return String.Empty; |
10166 | int c = 0; | 11388 | if (str2 == String.Empty) |
10167 | for (int i = 0; i < src1.Length; i++) | 11389 | return str1; |
11390 | |||
11391 | int len = str2.Length; | ||
11392 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
10168 | { | 11393 | { |
10169 | ret += (char) (src1[i] ^ src2[c]); | 11394 | while (str2.EndsWith("=")) |
11395 | str2 = str2.Substring(0, str2.Length - 1); | ||
11396 | |||
11397 | len = str2.Length; | ||
11398 | int mod = len % 4; | ||
10170 | 11399 | ||
10171 | c++; | 11400 | if (mod == 1) |
10172 | if (c >= src2.Length) | 11401 | str2 = str2.Substring(0, str2.Length - 1); |
10173 | c = 0; | 11402 | else if (mod == 2) |
11403 | str2 += "=="; | ||
11404 | else if (mod == 3) | ||
11405 | str2 += "="; | ||
10174 | } | 11406 | } |
10175 | return llStringToBase64(ret); | 11407 | |
11408 | byte[] data1; | ||
11409 | byte[] data2; | ||
11410 | try | ||
11411 | { | ||
11412 | data1 = Convert.FromBase64String(str1); | ||
11413 | data2 = Convert.FromBase64String(str2); | ||
11414 | } | ||
11415 | catch (Exception) | ||
11416 | { | ||
11417 | return new LSL_String(String.Empty); | ||
11418 | } | ||
11419 | |||
11420 | byte[] d2 = new Byte[data1.Length]; | ||
11421 | int pos = 0; | ||
11422 | |||
11423 | if (data1.Length <= data2.Length) | ||
11424 | { | ||
11425 | Array.Copy(data2, 0, d2, 0, data1.Length); | ||
11426 | } | ||
11427 | else | ||
11428 | { | ||
11429 | while (pos < data1.Length) | ||
11430 | { | ||
11431 | len = data1.Length - pos; | ||
11432 | if (len > data2.Length) | ||
11433 | len = data2.Length; | ||
11434 | |||
11435 | Array.Copy(data2, 0, d2, pos, len); | ||
11436 | pos += len; | ||
11437 | } | ||
11438 | } | ||
11439 | |||
11440 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
11441 | data1[pos] ^= d2[pos]; | ||
11442 | |||
11443 | return Convert.ToBase64String(data1); | ||
10176 | } | 11444 | } |
10177 | 11445 | ||
10178 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 11446 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -10225,16 +11493,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10225 | if (userAgent != null) | 11493 | if (userAgent != null) |
10226 | httpHeaders["User-Agent"] = userAgent; | 11494 | httpHeaders["User-Agent"] = userAgent; |
10227 | 11495 | ||
11496 | // See if the URL contains any header hacks | ||
11497 | string[] urlParts = url.Split(new char[] {'\n'}); | ||
11498 | if (urlParts.Length > 1) | ||
11499 | { | ||
11500 | // Iterate the passed headers and parse them | ||
11501 | for (int i = 1 ; i < urlParts.Length ; i++ ) | ||
11502 | { | ||
11503 | // The rest of those would be added to the body in SL. | ||
11504 | // Let's not do that. | ||
11505 | if (urlParts[i] == String.Empty) | ||
11506 | break; | ||
11507 | |||
11508 | // See if this could be a valid header | ||
11509 | string[] headerParts = urlParts[i].Split(new char[] {':'}, 2); | ||
11510 | if (headerParts.Length != 2) | ||
11511 | continue; | ||
11512 | |||
11513 | string headerName = headerParts[0].Trim(); | ||
11514 | string headerValue = headerParts[1].Trim(); | ||
11515 | |||
11516 | // Filter out headers that could be used to abuse | ||
11517 | // another system or cloak the request | ||
11518 | if (headerName.ToLower() == "x-secondlife-shard" || | ||
11519 | headerName.ToLower() == "x-secondlife-object-name" || | ||
11520 | headerName.ToLower() == "x-secondlife-object-key" || | ||
11521 | headerName.ToLower() == "x-secondlife-region" || | ||
11522 | headerName.ToLower() == "x-secondlife-local-position" || | ||
11523 | headerName.ToLower() == "x-secondlife-local-velocity" || | ||
11524 | headerName.ToLower() == "x-secondlife-local-rotation" || | ||
11525 | headerName.ToLower() == "x-secondlife-owner-name" || | ||
11526 | headerName.ToLower() == "x-secondlife-owner-key" || | ||
11527 | headerName.ToLower() == "connection" || | ||
11528 | headerName.ToLower() == "content-length" || | ||
11529 | headerName.ToLower() == "from" || | ||
11530 | headerName.ToLower() == "host" || | ||
11531 | headerName.ToLower() == "proxy-authorization" || | ||
11532 | headerName.ToLower() == "referer" || | ||
11533 | headerName.ToLower() == "trailer" || | ||
11534 | headerName.ToLower() == "transfer-encoding" || | ||
11535 | headerName.ToLower() == "via" || | ||
11536 | headerName.ToLower() == "authorization") | ||
11537 | continue; | ||
11538 | |||
11539 | httpHeaders[headerName] = headerValue; | ||
11540 | } | ||
11541 | |||
11542 | // Finally, strip any protocol specifier from the URL | ||
11543 | url = urlParts[0].Trim(); | ||
11544 | int idx = url.IndexOf(" HTTP/"); | ||
11545 | if (idx != -1) | ||
11546 | url = url.Substring(0, idx); | ||
11547 | } | ||
11548 | |||
10228 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; | 11549 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; |
10229 | Regex r = new Regex(authregex); | 11550 | Regex r = new Regex(authregex); |
10230 | int[] gnums = r.GetGroupNumbers(); | 11551 | int[] gnums = r.GetGroupNumbers(); |
10231 | Match m = r.Match(url); | 11552 | Match m = r.Match(url); |
10232 | if (m.Success) { | 11553 | if (m.Success) |
10233 | for (int i = 1; i < gnums.Length; i++) { | 11554 | { |
11555 | for (int i = 1; i < gnums.Length; i++) | ||
11556 | { | ||
10234 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 11557 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
10235 | //CaptureCollection cc = g.Captures; | 11558 | //CaptureCollection cc = g.Captures; |
10236 | } | 11559 | } |
10237 | if (m.Groups.Count == 5) { | 11560 | if (m.Groups.Count == 5) |
11561 | { | ||
10238 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 11562 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
10239 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 11563 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
10240 | } | 11564 | } |
@@ -10437,6 +11761,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10437 | 11761 | ||
10438 | LSL_List ret = new LSL_List(); | 11762 | LSL_List ret = new LSL_List(); |
10439 | UUID key = new UUID(); | 11763 | UUID key = new UUID(); |
11764 | |||
11765 | |||
10440 | if (UUID.TryParse(id, out key)) | 11766 | if (UUID.TryParse(id, out key)) |
10441 | { | 11767 | { |
10442 | ScenePresence av = World.GetScenePresence(key); | 11768 | ScenePresence av = World.GetScenePresence(key); |
@@ -10454,13 +11780,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10454 | ret.Add(new LSL_String("")); | 11780 | ret.Add(new LSL_String("")); |
10455 | break; | 11781 | break; |
10456 | case ScriptBaseClass.OBJECT_POS: | 11782 | case ScriptBaseClass.OBJECT_POS: |
10457 | ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); | 11783 | Vector3 avpos; |
11784 | |||
11785 | if (av.ParentID != 0 && av.ParentPart != null) | ||
11786 | { | ||
11787 | avpos = av.OffsetPosition; | ||
11788 | |||
11789 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
11790 | avpos -= sitOffset; | ||
11791 | |||
11792 | avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); | ||
11793 | } | ||
11794 | else | ||
11795 | avpos = av.AbsolutePosition; | ||
11796 | |||
11797 | ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); | ||
10458 | break; | 11798 | break; |
10459 | case ScriptBaseClass.OBJECT_ROT: | 11799 | case ScriptBaseClass.OBJECT_ROT: |
10460 | ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); | 11800 | Quaternion avrot = av.Rotation; |
11801 | if (av.ParentID != 0 && av.ParentPart != null) | ||
11802 | { | ||
11803 | avrot = av.ParentPart.GetWorldRotation() * avrot; | ||
11804 | } | ||
11805 | ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W)); | ||
10461 | break; | 11806 | break; |
10462 | case ScriptBaseClass.OBJECT_VELOCITY: | 11807 | case ScriptBaseClass.OBJECT_VELOCITY: |
10463 | ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); | 11808 | Vector3 avvel = av.Velocity; |
11809 | ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z)); | ||
10464 | break; | 11810 | break; |
10465 | case ScriptBaseClass.OBJECT_OWNER: | 11811 | case ScriptBaseClass.OBJECT_OWNER: |
10466 | ret.Add(new LSL_String(id)); | 11812 | ret.Add(new LSL_String(id)); |
@@ -10516,11 +11862,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10516 | case ScriptBaseClass.OBJECT_NAME: | 11862 | case ScriptBaseClass.OBJECT_NAME: |
10517 | ret.Add(new LSL_String(obj.Name)); | 11863 | ret.Add(new LSL_String(obj.Name)); |
10518 | break; | 11864 | break; |
10519 | case ScriptBaseClass.OBJECT_DESC: | 11865 | case ScriptBaseClass.OBJECT_DESC: |
10520 | ret.Add(new LSL_String(obj.Description)); | 11866 | ret.Add(new LSL_String(obj.Description)); |
10521 | break; | 11867 | break; |
10522 | case ScriptBaseClass.OBJECT_POS: | 11868 | case ScriptBaseClass.OBJECT_POS: |
10523 | ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); | 11869 | Vector3 opos = obj.AbsolutePosition; |
11870 | ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); | ||
10524 | break; | 11871 | break; |
10525 | case ScriptBaseClass.OBJECT_ROT: | 11872 | case ScriptBaseClass.OBJECT_ROT: |
10526 | { | 11873 | { |
@@ -10536,7 +11883,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10536 | } | 11883 | } |
10537 | break; | 11884 | break; |
10538 | case ScriptBaseClass.OBJECT_VELOCITY: | 11885 | case ScriptBaseClass.OBJECT_VELOCITY: |
10539 | ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); | 11886 | Vector3 ovel = obj.Velocity; |
11887 | ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z)); | ||
10540 | break; | 11888 | break; |
10541 | case ScriptBaseClass.OBJECT_OWNER: | 11889 | case ScriptBaseClass.OBJECT_OWNER: |
10542 | ret.Add(new LSL_String(obj.OwnerID.ToString())); | 11890 | ret.Add(new LSL_String(obj.OwnerID.ToString())); |
@@ -10570,9 +11918,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10570 | // The value returned in SL for normal prims is prim count | 11918 | // The value returned in SL for normal prims is prim count |
10571 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); | 11919 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
10572 | break; | 11920 | break; |
10573 | // The following 3 costs I have intentionaly coded to return zero. They are part of | 11921 | |
10574 | // "Land Impact" calculations. These calculations are probably not applicable | 11922 | // costs below may need to be diferent for root parts, need to check |
10575 | // to OpenSim and are not yet complete in SL | ||
10576 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11923 | case ScriptBaseClass.OBJECT_SERVER_COST: |
10577 | // The linden calculation is here | 11924 | // The linden calculation is here |
10578 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | 11925 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight |
@@ -10580,16 +11927,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10580 | ret.Add(new LSL_Float(0)); | 11927 | ret.Add(new LSL_Float(0)); |
10581 | break; | 11928 | break; |
10582 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11929 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
10583 | // The linden calculation is here | 11930 | // The value returned in SL for normal prims is prim count * 0.06 |
10584 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | 11931 | ret.Add(new LSL_Float(obj.StreamingCost)); |
10585 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
10586 | ret.Add(new LSL_Float(0)); | ||
10587 | break; | 11932 | break; |
10588 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11933 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
10589 | // The linden calculation is here | 11934 | // The value returned in SL for normal prims is prim count |
10590 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | 11935 | ret.Add(new LSL_Float(obj.PhysicsCost)); |
10591 | // The value returned in SL for normal prims looks like the prim count | ||
10592 | ret.Add(new LSL_Float(0)); | ||
10593 | break; | 11936 | break; |
10594 | default: | 11937 | default: |
10595 | // Invalid or unhandled constant. | 11938 | // Invalid or unhandled constant. |
@@ -10787,15 +12130,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10787 | return GetLinkPrimitiveParams(obj, rules); | 12130 | return GetLinkPrimitiveParams(obj, rules); |
10788 | } | 12131 | } |
10789 | 12132 | ||
10790 | public void print(string str) | 12133 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
10791 | { | 12134 | { |
10792 | // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print | 12135 | List<SceneObjectPart> parts = GetLinkParts(link); |
10793 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); | 12136 | if (parts.Count < 1) |
10794 | if (ossl != null) | 12137 | return 0; |
10795 | { | 12138 | |
10796 | ossl.CheckThreatLevel(ThreatLevel.High, "print"); | 12139 | return GetNumberOfSides(parts[0]); |
10797 | m_log.Info("LSL print():" + str); | ||
10798 | } | ||
10799 | } | 12140 | } |
10800 | 12141 | ||
10801 | private string Name2Username(string name) | 12142 | private string Name2Username(string name) |
@@ -10840,7 +12181,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10840 | 12181 | ||
10841 | return rq.ToString(); | 12182 | return rq.ToString(); |
10842 | } | 12183 | } |
10843 | 12184 | /* | |
12185 | private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) | ||
12186 | { | ||
12187 | m_SayShoutCount = 0; | ||
12188 | } | ||
12189 | */ | ||
10844 | private struct Tri | 12190 | private struct Tri |
10845 | { | 12191 | { |
10846 | public Vector3 p1; | 12192 | public Vector3 p1; |
@@ -10980,9 +12326,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10980 | 12326 | ||
10981 | ContactResult result = new ContactResult (); | 12327 | ContactResult result = new ContactResult (); |
10982 | result.ConsumerID = group.LocalId; | 12328 | result.ConsumerID = group.LocalId; |
10983 | result.Depth = intersection.distance; | 12329 | // result.Depth = intersection.distance; |
10984 | result.Normal = intersection.normal; | 12330 | result.Normal = intersection.normal; |
10985 | result.Pos = intersection.ipoint; | 12331 | result.Pos = intersection.ipoint; |
12332 | result.Depth = Vector3.Mag(rayStart - result.Pos); | ||
10986 | 12333 | ||
10987 | contacts.Add(result); | 12334 | contacts.Add(result); |
10988 | }); | 12335 | }); |
@@ -11115,6 +12462,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11115 | 12462 | ||
11116 | return contacts[0]; | 12463 | return contacts[0]; |
11117 | } | 12464 | } |
12465 | /* | ||
12466 | // not done: | ||
12467 | private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght) | ||
12468 | { | ||
12469 | ContactResult[] contacts = null; | ||
12470 | World.ForEachSOG(delegate(SceneObjectGroup group) | ||
12471 | { | ||
12472 | if (m_host.ParentGroup == group) | ||
12473 | return; | ||
12474 | |||
12475 | if (group.IsAttachment) | ||
12476 | return; | ||
12477 | |||
12478 | if(group.RootPart.PhysActor != null) | ||
12479 | return; | ||
12480 | |||
12481 | contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght); | ||
12482 | }); | ||
12483 | return contacts; | ||
12484 | } | ||
12485 | */ | ||
11118 | 12486 | ||
11119 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | 12487 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) |
11120 | { | 12488 | { |
@@ -11156,32 +12524,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11156 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 12524 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
11157 | 12525 | ||
11158 | 12526 | ||
11159 | if (checkTerrain) | 12527 | if (World.SuportsRayCastFiltered()) |
11160 | { | 12528 | { |
11161 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | 12529 | if (dist == 0) |
11162 | if (groundContact != null) | 12530 | return list; |
11163 | results.Add((ContactResult)groundContact); | ||
11164 | } | ||
11165 | 12531 | ||
11166 | if (checkAgents) | 12532 | RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull; |
11167 | { | 12533 | if (checkTerrain) |
11168 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 12534 | rayfilter |= RayFilterFlags.land; |
11169 | foreach (ContactResult r in agentHits) | 12535 | // if (checkAgents) |
11170 | results.Add(r); | 12536 | // rayfilter |= RayFilterFlags.agent; |
11171 | } | 12537 | if (checkPhysical) |
12538 | rayfilter |= RayFilterFlags.physical; | ||
12539 | if (checkNonPhysical) | ||
12540 | rayfilter |= RayFilterFlags.nonphysical; | ||
12541 | if (detectPhantom) | ||
12542 | rayfilter |= RayFilterFlags.LSLPhanton; | ||
12543 | |||
12544 | Vector3 direction = dir * ( 1/dist); | ||
11172 | 12545 | ||
11173 | if (checkPhysical || checkNonPhysical || detectPhantom) | 12546 | if(rayfilter == 0) |
12547 | { | ||
12548 | list.Add(new LSL_Integer(0)); | ||
12549 | return list; | ||
12550 | } | ||
12551 | |||
12552 | // get some more contacts to sort ??? | ||
12553 | int physcount = 4 * count; | ||
12554 | if (physcount > 20) | ||
12555 | physcount = 20; | ||
12556 | |||
12557 | object physresults; | ||
12558 | physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); | ||
12559 | |||
12560 | if (physresults == null) | ||
12561 | { | ||
12562 | list.Add(new LSL_Integer(-3)); // timeout error | ||
12563 | return list; | ||
12564 | } | ||
12565 | |||
12566 | results = (List<ContactResult>)physresults; | ||
12567 | |||
12568 | // for now physics doesn't detect sitted avatars so do it outside physics | ||
12569 | if (checkAgents) | ||
12570 | { | ||
12571 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | ||
12572 | foreach (ContactResult r in agentHits) | ||
12573 | results.Add(r); | ||
12574 | } | ||
12575 | |||
12576 | // TODO: Replace this with a better solution. ObjectIntersection can only | ||
12577 | // detect nonphysical phantoms. They are detected by virtue of being | ||
12578 | // nonphysical (e.g. no PhysActor) so will not conflict with detecting | ||
12579 | // physicsl phantoms as done by the physics scene | ||
12580 | // We don't want anything else but phantoms here. | ||
12581 | if (detectPhantom) | ||
12582 | { | ||
12583 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, false, false, true); | ||
12584 | foreach (ContactResult r in objectHits) | ||
12585 | results.Add(r); | ||
12586 | } | ||
12587 | } | ||
12588 | else | ||
11174 | { | 12589 | { |
11175 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); | 12590 | if (checkTerrain) |
11176 | foreach (ContactResult r in objectHits) | 12591 | { |
11177 | results.Add(r); | 12592 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); |
12593 | if (groundContact != null) | ||
12594 | results.Add((ContactResult)groundContact); | ||
12595 | } | ||
12596 | |||
12597 | if (checkAgents) | ||
12598 | { | ||
12599 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | ||
12600 | foreach (ContactResult r in agentHits) | ||
12601 | results.Add(r); | ||
12602 | } | ||
12603 | |||
12604 | if (checkPhysical || checkNonPhysical || detectPhantom) | ||
12605 | { | ||
12606 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); | ||
12607 | foreach (ContactResult r in objectHits) | ||
12608 | results.Add(r); | ||
12609 | } | ||
11178 | } | 12610 | } |
11179 | 12611 | ||
11180 | results.Sort(delegate(ContactResult a, ContactResult b) | 12612 | results.Sort(delegate(ContactResult a, ContactResult b) |
11181 | { | 12613 | { |
11182 | return a.Depth.CompareTo(b.Depth); | 12614 | return a.Depth.CompareTo(b.Depth); |
11183 | }); | 12615 | }); |
11184 | 12616 | ||
11185 | int values = 0; | 12617 | int values = 0; |
11186 | SceneObjectGroup thisgrp = m_host.ParentGroup; | 12618 | SceneObjectGroup thisgrp = m_host.ParentGroup; |
11187 | 12619 | ||
@@ -11274,7 +12706,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11274 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: | 12706 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: |
11275 | if (!isAccount) return 0; | 12707 | if (!isAccount) return 0; |
11276 | if (estate.HasAccess(id)) return 1; | 12708 | if (estate.HasAccess(id)) return 1; |
11277 | if (estate.IsBanned(id)) | 12709 | if (estate.IsBanned(id, World.GetUserFlags(id))) |
11278 | estate.RemoveBan(id); | 12710 | estate.RemoveBan(id); |
11279 | estate.AddEstateUser(id); | 12711 | estate.AddEstateUser(id); |
11280 | break; | 12712 | break; |
@@ -11293,14 +12725,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11293 | break; | 12725 | break; |
11294 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: | 12726 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: |
11295 | if (!isAccount) return 0; | 12727 | if (!isAccount) return 0; |
11296 | if (estate.IsBanned(id)) return 1; | 12728 | if (estate.IsBanned(id, World.GetUserFlags(id))) return 1; |
11297 | EstateBan ban = new EstateBan(); | 12729 | EstateBan ban = new EstateBan(); |
11298 | ban.EstateID = estate.EstateID; | 12730 | ban.EstateID = estate.EstateID; |
11299 | ban.BannedUserID = id; | 12731 | ban.BannedUserID = id; |
11300 | estate.AddBan(ban); | 12732 | estate.AddBan(ban); |
11301 | break; | 12733 | break; |
11302 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: | 12734 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: |
11303 | if (!isAccount || !estate.IsBanned(id)) return 0; | 12735 | if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0; |
11304 | estate.RemoveBan(id); | 12736 | estate.RemoveBan(id); |
11305 | break; | 12737 | break; |
11306 | default: return 0; | 12738 | default: return 0; |
@@ -11329,7 +12761,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11329 | return 16384; | 12761 | return 16384; |
11330 | } | 12762 | } |
11331 | 12763 | ||
11332 | public LSL_Integer llGetUsedMemory() | 12764 | public virtual LSL_Integer llGetUsedMemory() |
11333 | { | 12765 | { |
11334 | m_host.AddScriptLPS(1); | 12766 | m_host.AddScriptLPS(1); |
11335 | // The value returned for LSO scripts in SL | 12767 | // The value returned for LSO scripts in SL |
@@ -11357,7 +12789,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11357 | public void llSetSoundQueueing(int queue) | 12789 | public void llSetSoundQueueing(int queue) |
11358 | { | 12790 | { |
11359 | m_host.AddScriptLPS(1); | 12791 | m_host.AddScriptLPS(1); |
11360 | NotImplemented("llSetSoundQueueing"); | ||
11361 | } | 12792 | } |
11362 | 12793 | ||
11363 | public void llCollisionSprite(string impact_sprite) | 12794 | public void llCollisionSprite(string impact_sprite) |
@@ -11369,10 +12800,270 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11369 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) | 12800 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) |
11370 | { | 12801 | { |
11371 | m_host.AddScriptLPS(1); | 12802 | m_host.AddScriptLPS(1); |
11372 | NotImplemented("llGodLikeRezObject"); | 12803 | |
12804 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
12805 | NotImplemented("llGodLikeRezObject"); | ||
12806 | |||
12807 | AssetBase rezAsset = World.AssetService.Get(inventory); | ||
12808 | if (rezAsset == null) | ||
12809 | { | ||
12810 | llSay(0, "Asset not found"); | ||
12811 | return; | ||
12812 | } | ||
12813 | |||
12814 | SceneObjectGroup group = null; | ||
12815 | |||
12816 | try | ||
12817 | { | ||
12818 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
12819 | group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
12820 | } | ||
12821 | catch | ||
12822 | { | ||
12823 | llSay(0, "Asset not found"); | ||
12824 | return; | ||
12825 | } | ||
12826 | |||
12827 | if (group == null) | ||
12828 | { | ||
12829 | llSay(0, "Asset not found"); | ||
12830 | return; | ||
12831 | } | ||
12832 | |||
12833 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
12834 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
12835 | |||
12836 | group.ResetIDs(); | ||
12837 | |||
12838 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
12839 | World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); | ||
12840 | group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); | ||
12841 | group.ScheduleGroupForFullUpdate(); | ||
12842 | |||
12843 | // objects rezzed with this method are die_at_edge by default. | ||
12844 | group.RootPart.SetDieAtEdge(true); | ||
12845 | |||
12846 | group.ResumeScripts(); | ||
12847 | |||
12848 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | ||
12849 | "object_rez", new Object[] { | ||
12850 | new LSL_String( | ||
12851 | group.RootPart.UUID.ToString()) }, | ||
12852 | new DetectParams[0])); | ||
12853 | } | ||
12854 | |||
12855 | public LSL_String llTransferLindenDollars(string destination, int amount) | ||
12856 | { | ||
12857 | UUID txn = UUID.Random(); | ||
12858 | |||
12859 | Util.FireAndForget(delegate(object x) | ||
12860 | { | ||
12861 | int replycode = 0; | ||
12862 | string replydata = destination + "," + amount.ToString(); | ||
12863 | |||
12864 | try | ||
12865 | { | ||
12866 | TaskInventoryItem item = m_item; | ||
12867 | if (item == null) | ||
12868 | { | ||
12869 | replydata = "SERVICE_ERROR"; | ||
12870 | return; | ||
12871 | } | ||
12872 | |||
12873 | m_host.AddScriptLPS(1); | ||
12874 | |||
12875 | if (item.PermsGranter == UUID.Zero) | ||
12876 | { | ||
12877 | replydata = "MISSING_PERMISSION_DEBIT"; | ||
12878 | return; | ||
12879 | } | ||
12880 | |||
12881 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) | ||
12882 | { | ||
12883 | replydata = "MISSING_PERMISSION_DEBIT"; | ||
12884 | return; | ||
12885 | } | ||
12886 | |||
12887 | UUID toID = new UUID(); | ||
12888 | |||
12889 | if (!UUID.TryParse(destination, out toID)) | ||
12890 | { | ||
12891 | replydata = "INVALID_AGENT"; | ||
12892 | return; | ||
12893 | } | ||
12894 | |||
12895 | IMoneyModule money = World.RequestModuleInterface<IMoneyModule>(); | ||
12896 | |||
12897 | if (money == null) | ||
12898 | { | ||
12899 | replydata = "TRANSFERS_DISABLED"; | ||
12900 | return; | ||
12901 | } | ||
12902 | |||
12903 | bool result = money.ObjectGiveMoney( | ||
12904 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | ||
12905 | |||
12906 | if (result) | ||
12907 | { | ||
12908 | replycode = 1; | ||
12909 | return; | ||
12910 | } | ||
12911 | |||
12912 | replydata = "LINDENDOLLAR_INSUFFICIENTFUNDS"; | ||
12913 | } | ||
12914 | finally | ||
12915 | { | ||
12916 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | ||
12917 | "transaction_result", new Object[] { | ||
12918 | new LSL_String(txn.ToString()), | ||
12919 | new LSL_Integer(replycode), | ||
12920 | new LSL_String(replydata) }, | ||
12921 | new DetectParams[0])); | ||
12922 | } | ||
12923 | }); | ||
12924 | |||
12925 | return txn.ToString(); | ||
11373 | } | 12926 | } |
11374 | 12927 | ||
11375 | #endregion | 12928 | #endregion |
12929 | |||
12930 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
12931 | { | ||
12932 | SceneObjectGroup group = m_host.ParentGroup; | ||
12933 | |||
12934 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) | ||
12935 | return; | ||
12936 | if (group.IsAttachment) | ||
12937 | return; | ||
12938 | |||
12939 | if (frames.Data.Length > 0) // We are getting a new motion | ||
12940 | { | ||
12941 | if (group.RootPart.KeyframeMotion != null) | ||
12942 | group.RootPart.KeyframeMotion.Stop(); | ||
12943 | group.RootPart.KeyframeMotion = null; | ||
12944 | |||
12945 | int idx = 0; | ||
12946 | |||
12947 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
12948 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
12949 | |||
12950 | while (idx < options.Data.Length) | ||
12951 | { | ||
12952 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12953 | int remain = options.Data.Length - idx; | ||
12954 | |||
12955 | switch (option) | ||
12956 | { | ||
12957 | case ScriptBaseClass.KFM_MODE: | ||
12958 | if (remain < 1) | ||
12959 | break; | ||
12960 | int modeval = (int)options.GetLSLIntegerItem(idx++); | ||
12961 | switch(modeval) | ||
12962 | { | ||
12963 | case ScriptBaseClass.KFM_FORWARD: | ||
12964 | mode = KeyframeMotion.PlayMode.Forward; | ||
12965 | break; | ||
12966 | case ScriptBaseClass.KFM_REVERSE: | ||
12967 | mode = KeyframeMotion.PlayMode.Reverse; | ||
12968 | break; | ||
12969 | case ScriptBaseClass.KFM_LOOP: | ||
12970 | mode = KeyframeMotion.PlayMode.Loop; | ||
12971 | break; | ||
12972 | case ScriptBaseClass.KFM_PING_PONG: | ||
12973 | mode = KeyframeMotion.PlayMode.PingPong; | ||
12974 | break; | ||
12975 | } | ||
12976 | break; | ||
12977 | case ScriptBaseClass.KFM_DATA: | ||
12978 | if (remain < 1) | ||
12979 | break; | ||
12980 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
12981 | data = (KeyframeMotion.DataFormat)dataval; | ||
12982 | break; | ||
12983 | } | ||
12984 | } | ||
12985 | |||
12986 | group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); | ||
12987 | |||
12988 | idx = 0; | ||
12989 | |||
12990 | int elemLength = 2; | ||
12991 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | ||
12992 | elemLength = 3; | ||
12993 | |||
12994 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | ||
12995 | while (idx < frames.Data.Length) | ||
12996 | { | ||
12997 | int remain = frames.Data.Length - idx; | ||
12998 | |||
12999 | if (remain < elemLength) | ||
13000 | break; | ||
13001 | |||
13002 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | ||
13003 | frame.Position = null; | ||
13004 | frame.Rotation = null; | ||
13005 | |||
13006 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | ||
13007 | { | ||
13008 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | ||
13009 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | ||
13010 | } | ||
13011 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | ||
13012 | { | ||
13013 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
13014 | frame.Rotation = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
13015 | } | ||
13016 | |||
13017 | float tempf = (float)frames.GetLSLFloatItem(idx++); | ||
13018 | frame.TimeMS = (int)(tempf * 1000.0f); | ||
13019 | |||
13020 | keyframes.Add(frame); | ||
13021 | } | ||
13022 | |||
13023 | group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | ||
13024 | group.RootPart.KeyframeMotion.Start(); | ||
13025 | } | ||
13026 | else | ||
13027 | { | ||
13028 | if (group.RootPart.KeyframeMotion == null) | ||
13029 | return; | ||
13030 | |||
13031 | if (options.Data.Length == 0) | ||
13032 | { | ||
13033 | group.RootPart.KeyframeMotion.Stop(); | ||
13034 | return; | ||
13035 | } | ||
13036 | |||
13037 | int code = (int)options.GetLSLIntegerItem(0); | ||
13038 | |||
13039 | int idx = 0; | ||
13040 | |||
13041 | while (idx < options.Data.Length) | ||
13042 | { | ||
13043 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
13044 | int remain = options.Data.Length - idx; | ||
13045 | |||
13046 | switch (option) | ||
13047 | { | ||
13048 | case ScriptBaseClass.KFM_COMMAND: | ||
13049 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
13050 | switch (cmd) | ||
13051 | { | ||
13052 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
13053 | group.RootPart.KeyframeMotion.Start(); | ||
13054 | break; | ||
13055 | case ScriptBaseClass.KFM_CMD_STOP: | ||
13056 | group.RootPart.KeyframeMotion.Stop(); | ||
13057 | break; | ||
13058 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
13059 | group.RootPart.KeyframeMotion.Pause(); | ||
13060 | break; | ||
13061 | } | ||
13062 | break; | ||
13063 | } | ||
13064 | } | ||
13065 | } | ||
13066 | } | ||
11376 | } | 13067 | } |
11377 | 13068 | ||
11378 | public class NotecardCache | 13069 | 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 eff1598..321d1d8 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 7162226..8b3be4a 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.X, q.Y, q.Z, q.W); | 355 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -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.X, q.Y, q.Z, q.W); | 485 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -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 | |||
28 | using System.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace 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 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -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; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 5a58f73..22804f5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -35,6 +35,7 @@ using OpenMetaverse; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.CoreModules; | 36 | using OpenSim.Region.CoreModules; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | 40 | ||
40 | namespace OpenSim.Region.ScriptEngine.Shared | 41 | namespace OpenSim.Region.ScriptEngine.Shared |
@@ -102,6 +103,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
102 | Type = 0; | 103 | Type = 0; |
103 | Velocity = new LSL_Types.Vector3(); | 104 | Velocity = new LSL_Types.Vector3(); |
104 | initializeSurfaceTouch(); | 105 | initializeSurfaceTouch(); |
106 | Country = String.Empty; | ||
105 | } | 107 | } |
106 | 108 | ||
107 | public UUID Key; | 109 | public UUID Key; |
@@ -133,6 +135,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
133 | private int touchFace; | 135 | private int touchFace; |
134 | public int TouchFace { get { return touchFace; } } | 136 | public int TouchFace { get { return touchFace; } } |
135 | 137 | ||
138 | public string Country; | ||
139 | |||
136 | // This can be done in two places including the constructor | 140 | // This can be done in two places including the constructor |
137 | // so be carefull what gets added here | 141 | // so be carefull what gets added here |
138 | private void initializeSurfaceTouch() | 142 | private void initializeSurfaceTouch() |
@@ -180,6 +184,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
180 | return; | 184 | return; |
181 | 185 | ||
182 | Name = presence.Firstname + " " + presence.Lastname; | 186 | Name = presence.Firstname + " " + presence.Lastname; |
187 | UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, Key); | ||
188 | if (account != null) | ||
189 | Country = account.UserCountry; | ||
190 | |||
183 | Owner = Key; | 191 | Owner = Key; |
184 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); | 192 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); |
185 | Rotation = new LSL_Types.Quaternion( | 193 | Rotation = new LSL_Types.Quaternion( |
@@ -189,22 +197,27 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
189 | presence.Rotation.W); | 197 | presence.Rotation.W); |
190 | Velocity = new LSL_Types.Vector3(presence.Velocity); | 198 | Velocity = new LSL_Types.Vector3(presence.Velocity); |
191 | 199 | ||
192 | if (presence.PresenceType != PresenceType.Npc) | 200 | Type = 0x01; // Avatar |
193 | { | 201 | if (presence.PresenceType == PresenceType.Npc) |
194 | Type = AGENT; | 202 | Type = 0x20; |
195 | } | 203 | |
196 | else | 204 | // Cope Impl. We don't use OS_NPC. |
197 | { | 205 | //if (presence.PresenceType != PresenceType.Npc) |
198 | Type = OS_NPC; | 206 | //{ |
199 | 207 | // Type = AGENT; | |
200 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 208 | //} |
201 | INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); | 209 | //else |
202 | 210 | //{ | |
203 | if (npcData.SenseAsAgent) | 211 | // Type = OS_NPC; |
204 | { | 212 | |
205 | Type |= AGENT; | 213 | // INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
206 | } | 214 | // INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); |
207 | } | 215 | |
216 | // if (npcData.SenseAsAgent) | ||
217 | // { | ||
218 | // Type |= AGENT; | ||
219 | // } | ||
220 | //} | ||
208 | 221 | ||
209 | if (presence.Velocity != Vector3.Zero) | 222 | if (presence.Velocity != Vector3.Zero) |
210 | Type |= ACTIVE; | 223 | Type |= ACTIVE; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5793cc9..771db0c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Runtime.Remoting; | 35 | using System.Runtime.Remoting; |
35 | using System.Runtime.Remoting.Lifetime; | 36 | using System.Runtime.Remoting.Lifetime; |
@@ -219,13 +220,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
219 | 220 | ||
220 | if (part != null) | 221 | if (part != null) |
221 | { | 222 | { |
222 | lock (part.TaskInventory) | 223 | part.TaskInventory.LockItemsForRead(true); |
224 | if (part.TaskInventory.ContainsKey(ItemID)) | ||
223 | { | 225 | { |
224 | if (part.TaskInventory.ContainsKey(ItemID)) | 226 | ScriptTask = part.TaskInventory[ItemID]; |
225 | { | ||
226 | ScriptTask = part.TaskInventory[ItemID]; | ||
227 | } | ||
228 | } | 227 | } |
228 | part.TaskInventory.LockItemsForRead(false); | ||
229 | } | 229 | } |
230 | 230 | ||
231 | ApiManager am = new ApiManager(); | 231 | ApiManager am = new ApiManager(); |
@@ -417,14 +417,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
417 | { | 417 | { |
418 | int permsMask; | 418 | int permsMask; |
419 | UUID permsGranter; | 419 | UUID permsGranter; |
420 | lock (part.TaskInventory) | 420 | part.TaskInventory.LockItemsForRead(true); |
421 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
421 | { | 422 | { |
422 | if (!part.TaskInventory.ContainsKey(ItemID)) | 423 | part.TaskInventory.LockItemsForRead(false); |
423 | return; | 424 | return; |
424 | |||
425 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
426 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
427 | } | 425 | } |
426 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
427 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
428 | part.TaskInventory.LockItemsForRead(false); | ||
428 | 429 | ||
429 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 430 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
430 | { | 431 | { |
@@ -552,6 +553,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
552 | return true; | 553 | return true; |
553 | } | 554 | } |
554 | 555 | ||
556 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
555 | public void SetState(string state) | 557 | public void SetState(string state) |
556 | { | 558 | { |
557 | if (state == State) | 559 | if (state == State) |
@@ -563,7 +565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
563 | new DetectParams[0])); | 565 | new DetectParams[0])); |
564 | PostEvent(new EventParams("state_entry", new Object[0], | 566 | PostEvent(new EventParams("state_entry", new Object[0], |
565 | new DetectParams[0])); | 567 | new DetectParams[0])); |
566 | 568 | ||
567 | throw new EventAbortException(); | 569 | throw new EventAbortException(); |
568 | } | 570 | } |
569 | 571 | ||
@@ -653,45 +655,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
653 | /// <returns></returns> | 655 | /// <returns></returns> |
654 | public object EventProcessor() | 656 | public object EventProcessor() |
655 | { | 657 | { |
658 | EventParams data = null; | ||
656 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 659 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
657 | if (!Running) | 660 | if (!Running) |
658 | return 0; | 661 | return 0; |
659 | 662 | ||
660 | lock (m_Script) | ||
661 | { | ||
662 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 663 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
663 | 664 | ||
664 | if (Suspended) | 665 | if (Suspended) |
665 | return 0; | 666 | return 0; |
666 | |||
667 | EventParams data = null; | ||
668 | 667 | ||
669 | lock (EventQueue) | 668 | lock (EventQueue) |
669 | { | ||
670 | data = (EventParams) EventQueue.Dequeue(); | ||
671 | if (data == null) // Shouldn't happen | ||
670 | { | 672 | { |
671 | data = (EventParams)EventQueue.Dequeue(); | 673 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
672 | if (data == null) // Shouldn't happen | ||
673 | { | 674 | { |
674 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 675 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
675 | { | ||
676 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | ||
677 | } | ||
678 | else | ||
679 | { | ||
680 | m_CurrentWorkItem = null; | ||
681 | } | ||
682 | return 0; | ||
683 | } | 676 | } |
684 | 677 | else | |
685 | if (data.EventName == "timer") | ||
686 | m_TimerQueued = false; | ||
687 | if (data.EventName == "control") | ||
688 | { | 678 | { |
689 | if (m_ControlEventsInQueue > 0) | 679 | m_CurrentWorkItem = null; |
690 | m_ControlEventsInQueue--; | ||
691 | } | 680 | } |
692 | if (data.EventName == "collision") | 681 | return 0; |
693 | m_CollisionInQueue = false; | ||
694 | } | 682 | } |
683 | |||
684 | if (data.EventName == "timer") | ||
685 | m_TimerQueued = false; | ||
686 | if (data.EventName == "control") | ||
687 | { | ||
688 | if (m_ControlEventsInQueue > 0) | ||
689 | m_ControlEventsInQueue--; | ||
690 | } | ||
691 | if (data.EventName == "collision") | ||
692 | m_CollisionInQueue = false; | ||
693 | } | ||
694 | |||
695 | lock(m_Script) | ||
696 | { | ||
695 | 697 | ||
696 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 698 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
697 | 699 | ||
@@ -846,6 +848,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
846 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 848 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
847 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 849 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
848 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 850 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
851 | part.CollisionSound = UUID.Zero; | ||
849 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 852 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
850 | EventQueue.Clear(); | 853 | EventQueue.Clear(); |
851 | m_Script.ResetVars(); | 854 | m_Script.ResetVars(); |
@@ -860,6 +863,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
860 | new Object[0], new DetectParams[0])); | 863 | new Object[0], new DetectParams[0])); |
861 | } | 864 | } |
862 | 865 | ||
866 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
863 | public void ApiResetScript() | 867 | public void ApiResetScript() |
864 | { | 868 | { |
865 | // bool running = Running; | 869 | // bool running = Running; |
@@ -871,6 +875,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
871 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 875 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
872 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 876 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
873 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 877 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
878 | part.CollisionSound = UUID.Zero; | ||
874 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 879 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
875 | 880 | ||
876 | EventQueue.Clear(); | 881 | EventQueue.Clear(); |
@@ -891,10 +896,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
891 | 896 | ||
892 | public Dictionary<string, object> GetVars() | 897 | public Dictionary<string, object> GetVars() |
893 | { | 898 | { |
894 | if (m_Script != null) | 899 | return m_Script.GetVars(); |
895 | return m_Script.GetVars(); | ||
896 | else | ||
897 | return new Dictionary<string, object>(); | ||
898 | } | 900 | } |
899 | 901 | ||
900 | public void SetVars(Dictionary<string, object> vars) | 902 | public void SetVars(Dictionary<string, object> vars) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index d18efe0..4ab2f23 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -102,19 +102,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
102 | 102 | ||
103 | public override string ToString() | 103 | public override string ToString() |
104 | { | 104 | { |
105 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | 105 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); |
106 | return s; | 106 | return s; |
107 | } | 107 | } |
108 | 108 | ||
109 | public static explicit operator LSLString(Vector3 vec) | 109 | public static explicit operator LSLString(Vector3 vec) |
110 | { | 110 | { |
111 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 111 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
112 | return new LSLString(s); | 112 | return new LSLString(s); |
113 | } | 113 | } |
114 | 114 | ||
115 | public static explicit operator string(Vector3 vec) | 115 | public static explicit operator string(Vector3 vec) |
116 | { | 116 | { |
117 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 117 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); |
118 | return s; | 118 | return s; |
119 | } | 119 | } |
120 | 120 | ||
@@ -381,19 +381,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
381 | 381 | ||
382 | public override string ToString() | 382 | public override string ToString() |
383 | { | 383 | { |
384 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | 384 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); |
385 | return st; | 385 | return st; |
386 | } | 386 | } |
387 | 387 | ||
388 | public static explicit operator string(Quaternion r) | 388 | public static explicit operator string(Quaternion r) |
389 | { | 389 | { |
390 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 390 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
391 | return s; | 391 | return s; |
392 | } | 392 | } |
393 | 393 | ||
394 | public static explicit operator LSLString(Quaternion r) | 394 | public static explicit operator LSLString(Quaternion r) |
395 | { | 395 | { |
396 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 396 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
397 | return new LSLString(s); | 397 | return new LSLString(s); |
398 | } | 398 | } |
399 | 399 | ||
@@ -498,6 +498,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
498 | size += 64; | 498 | size += 64; |
499 | else if (o is int) | 499 | else if (o is int) |
500 | size += 4; | 500 | size += 4; |
501 | else if (o is uint) | ||
502 | size += 4; | ||
501 | else if (o is string) | 503 | else if (o is string) |
502 | size += ((string)o).Length; | 504 | size += ((string)o).Length; |
503 | else if (o is float) | 505 | else if (o is float) |
@@ -663,24 +665,16 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
663 | 665 | ||
664 | public static bool operator ==(list a, list b) | 666 | public static bool operator ==(list a, list b) |
665 | { | 667 | { |
666 | int la = -1; | 668 | int la = a.Length; |
667 | int lb = -1; | 669 | int lb = b.Length; |
668 | try { la = a.Length; } | ||
669 | catch (NullReferenceException) { } | ||
670 | try { lb = b.Length; } | ||
671 | catch (NullReferenceException) { } | ||
672 | 670 | ||
673 | return la == lb; | 671 | return la == lb; |
674 | } | 672 | } |
675 | 673 | ||
676 | public static bool operator !=(list a, list b) | 674 | public static bool operator !=(list a, list b) |
677 | { | 675 | { |
678 | int la = -1; | 676 | int la = a.Length; |
679 | int lb = -1; | 677 | int lb = b.Length; |
680 | try { la = a.Length; } | ||
681 | catch (NullReferenceException) { } | ||
682 | try {lb = b.Length;} | ||
683 | catch (NullReferenceException) { } | ||
684 | 678 | ||
685 | return la != lb; | 679 | return la != lb; |
686 | } | 680 | } |
@@ -914,7 +908,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
914 | ret = Math.Sign(Quaternion.Mag(l) - Quaternion.Mag(r)); | 908 | ret = Math.Sign(Quaternion.Mag(l) - Quaternion.Mag(r)); |
915 | } | 909 | } |
916 | 910 | ||
917 | if (ascending == 0) | 911 | if (ascending != 1) |
918 | { | 912 | { |
919 | ret = 0 - ret; | 913 | ret = 0 - ret; |
920 | } | 914 | } |
@@ -947,6 +941,9 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
947 | stride = 1; | 941 | stride = 1; |
948 | } | 942 | } |
949 | 943 | ||
944 | if ((Data.Length % stride) != 0) | ||
945 | return new list(ret); | ||
946 | |||
950 | // we can optimize here in the case where stride == 1 and the list | 947 | // we can optimize here in the case where stride == 1 and the list |
951 | // consists of homogeneous types | 948 | // consists of homogeneous types |
952 | 949 | ||
@@ -966,7 +963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
966 | if (homogeneous) | 963 | if (homogeneous) |
967 | { | 964 | { |
968 | Array.Sort(ret, new HomogeneousComparer()); | 965 | Array.Sort(ret, new HomogeneousComparer()); |
969 | if (ascending == 0) | 966 | if (ascending != 1) |
970 | { | 967 | { |
971 | Array.Reverse(ret); | 968 | Array.Reverse(ret); |
972 | } | 969 | } |
@@ -1114,7 +1111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1114 | { | 1111 | { |
1115 | list ret = new list(); | 1112 | list ret = new list(); |
1116 | double entry; | 1113 | double entry; |
1117 | for (int i = 0; i < src.Data.Length - 1; i++) | 1114 | for (int i = 0; i < src.Data.Length; i++) |
1118 | { | 1115 | { |
1119 | if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) | 1116 | if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) |
1120 | { | 1117 | { |